chen.lin
11 小时以前 82065a03737fa1370eb9f4f01ab5332933baf08a
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/MobileServiceImpl.java
@@ -14,6 +14,7 @@
import com.vincent.rsf.server.common.security.JwtSubject;
import com.vincent.rsf.server.common.utils.FieldsUtils;
import com.vincent.rsf.server.common.utils.JwtUtil;
import com.vincent.rsf.server.common.utils.QuantityUtils;
import com.vincent.rsf.server.manager.controller.params.GenerateTaskParams;
import com.vincent.rsf.server.manager.controller.params.IsptItemsParams;
import com.vincent.rsf.server.manager.controller.params.WaitPakinParam;
@@ -29,6 +30,7 @@
import com.vincent.rsf.server.system.entity.*;
import com.vincent.rsf.server.system.mapper.FieldsMapper;
import com.vincent.rsf.server.system.mapper.TenantMapper;
import com.vincent.rsf.server.system.entity.Config;
import com.vincent.rsf.server.system.service.ConfigService;
import com.vincent.rsf.server.system.service.FieldsItemService;
import com.vincent.rsf.server.system.service.UserLoginService;
@@ -258,8 +260,11 @@
            throw new CoolException("数据错误:主单不存在!!");
        }
        //TODO /**收货数量累加,1. 会出超收情况 2. 会有收货不足情况*/
        Double rcptedQty = Math.round((wkOrder.getQty() + receiptQty) * 1000000) / 1000000.0;
        wkOrder.setQty(rcptedQty).setExceStatus(AsnExceStatus.ASN_EXCE_STATUS_EXCE_ING.val);
        Double rcptedQty = QuantityUtils.add(wkOrder.getQty(), receiptQty);
        wkOrder.setQty(rcptedQty);
        if (AsnExceStatus.ASN_EXCE_STATUS_UN_EXCE.val.equals(wkOrder.getExceStatus())) {
            wkOrder.setExceStatus(AsnExceStatus.ASN_EXCE_STATUS_EXCE_ING.val);
        }
        if (!asnOrderMapper.updateById(wkOrder)) {
            throw new CoolException("已收货数量修改失败!!");
        }
@@ -306,14 +311,14 @@
                throw new CoolException("请输入正确的时间格式!!");
            }
            Double itemRcptQty = Math.round((dto.getReceiptQty() + orderItem.getQty()) * 1000000) / 1000000.0;
            Double itemRcptQty = QuantityUtils.add(dto.getReceiptQty(), orderItem.getQty());
            Boolean allowOver = false;
            if (!Objects.isNull(config)) {
                if (Boolean.parseBoolean(config.getVal())) {
                    allowOver = true;
                }
            }
            if (itemRcptQty.compareTo(orderItem.getAnfme()) > 0 && !allowOver) {
            if (QuantityUtils.compare(itemRcptQty, orderItem.getAnfme()) > 0 && !allowOver) {
                throw new CoolException("收货数量不能大于计划数量!!");
            }
@@ -350,13 +355,16 @@
            if (asnOrderItemMapper.updateById(orderItem) < 1) {
                throw new CoolException("通知单明细数量修改失败!!");
            }
            /**保存明细至收货区**/
            extracted(loginUserId, dto, areasItem, orderItem, wkOrder, matnr);
            // DirectWaitPakin 启用时保存至收货区,形成闭环;未启用时不写收货区
            Config directPakinConfig = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.DIRECT_WAIT_PAKIN));
            if (directPakinConfig != null && Boolean.parseBoolean(directPakinConfig.getVal())) {
                extracted(loginUserId, dto, areasItem, orderItem, wkOrder, matnr);
            }
        }
        // 已收数量 >= 计划数量时置为收货完成(2)
        WkOrder order = asnOrderMapper.getOne(new LambdaQueryWrapper<WkOrder>().eq(WkOrder::getCode, asnCode));
        if (order.getQty().compareTo(order.getAnfme()) >= 0.00) {
        if (order != null && order.getAnfme() != null && QuantityUtils.compare(order.getQty(), order.getAnfme()) >= 0) {
            order.setExceStatus(AsnExceStatus.ASN_EXCE_STATUS_RECEIPT_DONE.val).setRleStatus(Short.valueOf("1"));
            if (!asnOrderMapper.updateById(order)) {
                throw new CoolException("订单状态修改失败!!");
@@ -390,7 +398,7 @@
                .setUnit(orderItem.getStockUnit())
                .setStockUnit(orderItem.getStockUnit())
                .setBatch(StringUtils.isBlank(orderItem.getBatch()) ? SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_RECEIPT_BATCH, dto) : orderItem.getBatch())
                .setAnfme(dto.getReceiptQty())
                .setAnfme(QuantityUtils.roundToScale(dto.getReceiptQty()))
                .setSplrBatch(dto.getSplrBatch())
                .setMatnrCode(matnr.getCode())
                .setUpdateBy(loginUserId)
@@ -419,8 +427,7 @@
        if (!Objects.isNull(serviceOne)) {
            item.setId(serviceOne.getId());
            Double anfme = Math.round((item.getAnfme() + serviceOne.getAnfme()) * 1000000) / 1000000.0;
            item.setAnfme(anfme);
            item.setAnfme(QuantityUtils.add(item.getAnfme(), serviceOne.getAnfme()));
        }
        //未质检
@@ -511,8 +518,13 @@
     * @description 获取收货区
     * @time 2025/3/11 10:12
     */
    /** DirectWaitPakin 启用时返回收货区列表,未启用时返回空列表(不影响组托与云仓入库流程) */
    @Override
    public R getReceiptAreas() {
        Config directPakinConfig = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.DIRECT_WAIT_PAKIN));
        if (directPakinConfig == null || !Boolean.parseBoolean(directPakinConfig.getVal())) {
            return R.ok(Collections.emptyList());
        }
        List<WarehouseAreas> areas = warehouseAreasService.list(new LambdaQueryWrapper<WarehouseAreas>()
                .eq(WarehouseAreas::getType, WarehouseAreaType.WAREHOUSE_AREA_RECEIPT.type));
        return R.ok(areas);
@@ -552,7 +564,7 @@
//            throw new CoolException("票号不能为空!!");
//        }
//        if (Objects.isNull(code)) {
//            throw new CoolException("容器号不能为空!!");
//            throw new CoolException("料箱码不能为空!!");
//        }
//        BasContainer container = basContainerService.getOne(new LambdaQueryWrapper<BasContainer>().eq(BasContainer::getCode, barcode));
//        if (Objects.isNull(container)) {
@@ -579,7 +591,7 @@
                || !Objects.isNull(fieldIndex) || !Cools.isEmpty(matnrCode) || !Cools.isEmpty(asnCode);
        
        if (!hasValidCondition) {
            throw new CoolException("请至少输入一个查询条件:物料编码、ASN单号、跟踪码、批次或票号");
            throw new CoolException("请至少输入一个查询条件:物料编码、WMS单号、批号");/*、跟踪码、批次或票号*/
        }
        
        // 如果扫描物料编码且ASN单号为空,直接从物料信息表获取,不查询收货区
@@ -620,60 +632,138 @@
            return R.ok(resultList);
        }
        
        //TODO 后续需根据策略配置,获取组拖数据。如:混装,按批次混装等
        LambdaQueryWrapper<WarehouseAreasItem> queryWrapper = new LambdaQueryWrapper<>();
        // 构建OR查询条件组
        // 统计有效条件数量
        int conditionCount = 0;
        if (!Cools.isEmpty(code)) conditionCount++;
        if (!Cools.isEmpty(batch)) conditionCount++;
        if (!Objects.isNull(fieldIndex)) conditionCount++;
        if (!Cools.isEmpty(matnrCode)) conditionCount++;
        if (!Cools.isEmpty(asnCode)) conditionCount++;
        // 如果只有一个条件,直接使用eq;如果有多个条件,使用and包裹or条件组
        if (conditionCount == 1) {
            // 单个条件,直接查询
            if (!Cools.isEmpty(code)) {
                queryWrapper.eq(WarehouseAreasItem::getTrackCode, code);
            } else if (!Cools.isEmpty(batch)) {
                queryWrapper.eq(WarehouseAreasItem::getSplrBatch, batch);
            } else if (!Objects.isNull(fieldIndex)) {
                queryWrapper.eq(WarehouseAreasItem::getFieldsIndex, fieldIndex);
            } else if (!Cools.isEmpty(matnrCode)) {
                queryWrapper.eq(WarehouseAreasItem::getMatnrCode, matnrCode);
            } else if (!Cools.isEmpty(asnCode)) {
                queryWrapper.eq(WarehouseAreasItem::getAsnCode, asnCode);
        // 有ASN单号时:DirectWaitPakin 启用则从收货区查可组托物料,未启用则从订单明细查(可组盘数量 = 计划 - 已组托 - 已上架)
        if (!Cools.isEmpty(asnCode)) {
            Config directPakinConfig = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.DIRECT_WAIT_PAKIN));
            if (directPakinConfig != null && Boolean.parseBoolean(directPakinConfig.getVal())) {
                LambdaQueryWrapper<WarehouseAreasItem> receiptWrapper = new LambdaQueryWrapper<WarehouseAreasItem>().eq(WarehouseAreasItem::getAsnCode, asnCode);
                if (!Cools.isEmpty(matnrCode)) receiptWrapper.eq(WarehouseAreasItem::getMatnrCode, matnrCode);
                if (!Cools.isEmpty(batch)) receiptWrapper.eq(WarehouseAreasItem::getSplrBatch, batch);
                if (!Objects.isNull(fieldIndex)) receiptWrapper.eq(WarehouseAreasItem::getFieldsIndex, fieldIndex);
                if (!Cools.isEmpty(code)) receiptWrapper.eq(WarehouseAreasItem::getTrackCode, code);
                List<WarehouseAreasItem> receiptList = warehouseAreasItemService.list(receiptWrapper);
                // 组托通知档(WaitPakinItem)的已组托数量也要扣减:收货区 workQty 仅反映从收货区组托的部分,从订单直接组托的在此汇总
                Map<Long, Double> waitPakinSumByItemId = new java.util.HashMap<>();
                if (!receiptList.isEmpty() && receiptList.stream().anyMatch(e -> e.getAsnId() != null && e.getAsnItemId() != null)) {
                    List<Long> asnItemIds = receiptList.stream().map(WarehouseAreasItem::getAsnItemId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
                    Long asnId = receiptList.get(0).getAsnId();
                    if (asnId != null && !asnItemIds.isEmpty()) {
                        List<WaitPakinItem> wpItems = waitPakinItemService.list(
                                new LambdaQueryWrapper<WaitPakinItem>().eq(WaitPakinItem::getAsnId, asnId).in(WaitPakinItem::getAsnItemId, asnItemIds).eq(WaitPakinItem::getDeleted, 0));
                        wpItems.forEach(w -> waitPakinSumByItemId.merge(w.getAsnItemId(), w.getAnfme() != null ? w.getAnfme() : 0.0, (a, b) -> (a != null ? a : 0.0) + (b != null ? b : 0.0)));
                        waitPakinSumByItemId.replaceAll((k, v) -> QuantityUtils.roundToScale(v));
                    }
                }
                // 可组托 = 计划(anfme) - 已组托(waitPakinSumByItemId),不叠加 areaWorkQty 避免与组托档汇总重复计算
                receiptList.removeIf(e -> {
                    Double anfme = e.getAnfme() != null ? e.getAnfme() : 0.0;
                    Double qty = e.getQty() != null ? e.getQty() : 0.0;
                    Double alreadyInWaitPakin = e.getAsnItemId() != null ? waitPakinSumByItemId.getOrDefault(e.getAsnItemId(), 0.0) : 0.0;
                    Double totalAlready = QuantityUtils.roundToScale(alreadyInWaitPakin);
                    Double available = QuantityUtils.roundToScale(QuantityUtils.subtract(QuantityUtils.subtract(anfme, totalAlready), qty));
                    e.setWorkQty(totalAlready);
                    e.setAvailablePalletQty(available);
                    return QuantityUtils.compare(available, 0.0) <= 0;
                });
                logger.info("=== 从收货区查询可组托物料(DirectWaitPakin)asnCode: {} 返回 {} 条", asnCode, receiptList.size());
                return R.ok(receiptList);
            }
        } else {
            // 多个条件,使用OR连接
            queryWrapper.and(wrapper -> {
                boolean first = true;
            WkOrder order = asnOrderMapper.getOne(new LambdaQueryWrapper<WkOrder>().eq(WkOrder::getCode, asnCode));
            if (order == null) {
                logger.info("未找到ASN单号: {}", asnCode);
                return R.ok(Collections.emptyList());
            }
            List<WaitPakinItem> pakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().eq(WaitPakinItem::getAsnId, order.getId()).eq(WaitPakinItem::getDeleted, 0));
            Map<Long, Double> palletizedByItemId = pakinItems.stream()
                    .collect(Collectors.groupingBy(WaitPakinItem::getAsnItemId, Collectors.summingDouble(w -> w.getAnfme() != null ? w.getAnfme() : 0.0)));
            palletizedByItemId.replaceAll((k, v) -> QuantityUtils.roundToScale(v));
            LambdaQueryWrapper<WkOrderItem> itemWrapper = new LambdaQueryWrapper<WkOrderItem>().eq(WkOrderItem::getOrderId, order.getId());
            if (!Cools.isEmpty(matnrCode)) itemWrapper.eq(WkOrderItem::getMatnrCode, matnrCode);
            if (!Cools.isEmpty(batch)) itemWrapper.eq(WkOrderItem::getSplrBatch, batch);
            if (!Objects.isNull(fieldIndex)) itemWrapper.eq(WkOrderItem::getFieldsIndex, fieldIndex);
            if (!Cools.isEmpty(code)) itemWrapper.eq(WkOrderItem::getTrackCode, code);
            List<WkOrderItem> orderItems = asnOrderItemMapper.selectList(itemWrapper);
            List<WarehouseAreasItem> list = new ArrayList<>();
            for (WkOrderItem oi : orderItems) {
                Double anfme = QuantityUtils.roundToScale(oi.getAnfme() != null ? oi.getAnfme() : 0.0);
                Double qty = QuantityUtils.roundToScale(oi.getQty() != null ? oi.getQty() : 0.0);
                Double workQty = palletizedByItemId.getOrDefault(oi.getId(), 0.0);
                // 可组盘数量 = 计划 - 已组托(不扣减明细完成数量 qty,避免云仓同步完成数量=计划后导致可组托被算成 0)
                Double availablePalletQty = QuantityUtils.roundToScale(QuantityUtils.subtract(anfme, workQty));
                if (QuantityUtils.compare(availablePalletQty, 0.0) <= 0) continue;
                WarehouseAreasItem v = new WarehouseAreasItem();
                v.setId(oi.getId());
                v.setAsnItemId(oi.getId());
                v.setAsnId(order.getId());
                v.setAsnCode(order.getCode());
                v.setAnfme(anfme);
                v.setQty(qty);
                v.setWorkQty(QuantityUtils.roundToScale(workQty));
                v.setAvailablePalletQty(availablePalletQty);
                v.setMatnrCode(oi.getMatnrCode());
                v.setMaktx(oi.getMaktx());
                v.setSplrBatch(oi.getSplrBatch());
                v.setPlatItemId(oi.getPlatItemId());
                v.setStockUnit(oi.getStockUnit());
                v.setUnit(oi.getStockUnit());
                v.setMatnrId(oi.getMatnrId());
                v.setFieldsIndex(oi.getFieldsIndex());
                v.setTrackCode(oi.getTrackCode());
                if (oi.getFieldsIndex() != null) {
                    v.setExtendFields(FieldsUtils.getFields(oi.getFieldsIndex()));
                }
                list.add(v);
            }
            logger.info("=== 从订单明细查询可组托物料 asnCode: {} 返回 {} 条", asnCode, list.size());
            return R.ok(list);
        }
        // 无ASN单号时按其他条件查(收货区已停用,此处仅保留兼容,通常无数据)
        LambdaQueryWrapper<WarehouseAreasItem> queryWrapper = new LambdaQueryWrapper<>();
        {
            // 没有ASN单号时,可以扫描任意物料组托,使用OR连接多个条件
            // 统计有效条件数量
            int conditionCount = 0;
            if (!Cools.isEmpty(code)) conditionCount++;
            if (!Cools.isEmpty(batch)) conditionCount++;
            if (!Objects.isNull(fieldIndex)) conditionCount++;
            if (!Cools.isEmpty(matnrCode)) conditionCount++;
            // 如果只有一个条件,直接使用eq
            if (conditionCount == 1) {
                if (!Cools.isEmpty(code)) {
                    wrapper.eq(WarehouseAreasItem::getTrackCode, code);
                    first = false;
                    queryWrapper.eq(WarehouseAreasItem::getTrackCode, code);
                } else if (!Cools.isEmpty(batch)) {
                    queryWrapper.eq(WarehouseAreasItem::getSplrBatch, batch);
                } else if (!Objects.isNull(fieldIndex)) {
                    queryWrapper.eq(WarehouseAreasItem::getFieldsIndex, fieldIndex);
                } else if (!Cools.isEmpty(matnrCode)) {
                    queryWrapper.eq(WarehouseAreasItem::getMatnrCode, matnrCode);
                }
                if (!Cools.isEmpty(batch)) {
                    if (!first) wrapper.or();
                    wrapper.eq(WarehouseAreasItem::getSplrBatch, batch);
                    first = false;
                }
                if (!Objects.isNull(fieldIndex)) {
                    if (!first) wrapper.or();
                    wrapper.eq(WarehouseAreasItem::getFieldsIndex, fieldIndex);
                    first = false;
                }
                if (!Cools.isEmpty(matnrCode)) {
                    if (!first) wrapper.or();
                    wrapper.eq(WarehouseAreasItem::getMatnrCode, matnrCode);
                    first = false;
                }
                if (!Cools.isEmpty(asnCode)) {
                    if (!first) wrapper.or();
                    wrapper.eq(WarehouseAreasItem::getAsnCode, asnCode);
                }
            });
            } else if (conditionCount > 1) {
                // 多个条件,使用OR连接
                queryWrapper.and(wrapper -> {
                    boolean first = true;
                    if (!Cools.isEmpty(code)) {
                        wrapper.eq(WarehouseAreasItem::getTrackCode, code);
                        first = false;
                    }
                    if (!Cools.isEmpty(batch)) {
                        if (!first) wrapper.or();
                        wrapper.eq(WarehouseAreasItem::getSplrBatch, batch);
                        first = false;
                    }
                    if (!Objects.isNull(fieldIndex)) {
                        if (!first) wrapper.or();
                        wrapper.eq(WarehouseAreasItem::getFieldsIndex, fieldIndex);
                        first = false;
                    }
                    if (!Cools.isEmpty(matnrCode)) {
                        if (!first) wrapper.or();
                        wrapper.eq(WarehouseAreasItem::getMatnrCode, matnrCode);
                    }
                });
            }
        }
        
        // 打印查询参数到控制台
@@ -945,7 +1035,7 @@
    @Override
    public R operateToStock(OpStockParams params) {
        if (org.apache.commons.lang3.StringUtils.isBlank(params.getBarcode())) {
            throw new CoolException("托盘码不能为空!!");
            throw new CoolException("料箱码不能为空!!");
        }
        WaitPakin waitPakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>()
                .eq(WaitPakin::getBarcode, params.getBarcode())
@@ -1000,7 +1090,7 @@
            throw new CoolException("当前业务:" + SerialRuleCode.SYS_STOCK_CODE + ",编码规则不存在!!");
        }
        List<WkOrderItem> itemList = params.getItemList();
        double sum = itemList.stream().mapToDouble(WkOrderItem::getAnfme).sum();
        Double sum = QuantityUtils.roundToScale(itemList.stream().mapToDouble(WkOrderItem::getAnfme).sum());
        stock.setAnfme(sum)
                .setSourceId(order.getId())
                .setType(order.getType())
@@ -1154,15 +1244,15 @@
                .eq(WaitPakin::getFlagDefect, flagDefect)
                .in(WaitPakin::getIoStatus, asList));
//        if (!Cools.isEmpty(waitPakin)) {
//            throw new CoolException("托盘不可用,在组托中已存在");
//            throw new CoolException("料箱不可用,在组托中已存在");
//        }
        List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().eq(Task::getBarcode, params.get("barcode").toString()));
        if (!tasks.isEmpty()) {
            throw new CoolException("托盘码已在任务档执行!!");
            throw new CoolException("料箱码已在任务档执行!!");
        }
        List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getBarcode, params.get("barcode").toString()));
        if (!Cools.isEmpty(locs)) {
            throw new CoolException("托盘不可用,在库位中已存在");
            throw new CoolException("料箱不可用,在库位中已存在");
        }
//        List<WaitPakinItem> items = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>().eq(WaitPakinItem::getPakinId, waitPakin.getId()));
//        items.forEach(item -> {
@@ -1185,14 +1275,14 @@
    @Override
    public R getUnItemByContainer(Map<String, Object> params) {
        if (Cools.isEmpty(params.get("barcode")) && Cools.isEmpty(params.get("code"))) {
            throw new CoolException("容器号与组托档编码不能全为空");
            throw new CoolException("料箱码与组托档编码不能全为空");
        }
        WaitPakin waitPakin = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>()
                .eq(!Cools.isEmpty(params.get("barcode")), WaitPakin::getBarcode, params.get("barcode"))
                .eq(!Cools.isEmpty(params.get("code")), WaitPakin::getCode, params.get("code"))
                .eq(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_DONE.val));
        if (Objects.isNull(waitPakin)) {
            return R.error("未找到该容器码的组托明细,请检查组托状态");
            return R.error("未找到该料箱码的组托明细,请检查组托状态");
        }
        List<WaitPakinItem> pakinItems = waitPakinItemService.list(new LambdaQueryWrapper<WaitPakinItem>()
                .eq(WaitPakinItem::getPakinId, waitPakin.getId()));
@@ -1252,10 +1342,14 @@
     */
    @Override
    public R getDeviceSites() {
        List<DeviceSite> sites = deviceSiteMapper.selectList(new LambdaQueryWrapper<DeviceSite>()
        // 先查全部再按 site 去重,避免 GROUP BY 与 only_full_group_by 冲突
        List<DeviceSite> all = deviceSiteMapper.selectList(new LambdaQueryWrapper<DeviceSite>()
                .select(DeviceSite::getId, DeviceSite::getSite, DeviceSite::getName)
                .eq(DeviceSite::getStatus, 1)
                .groupBy(DeviceSite::getSite, DeviceSite::getId, DeviceSite::getName));
                .eq(DeviceSite::getStatus, 1));
        List<DeviceSite> sites = all.stream()
                .collect(Collectors.toMap(DeviceSite::getSite, d -> d, (a, b) -> a))
                .values().stream()
                .collect(Collectors.toList());
        return R.ok(sites);
    }
@@ -1304,11 +1398,11 @@
                    .setMaktx(asnOrderItem.getMaktx())
                    .setFieldsIndex(asnOrderItem.getFieldsIndex())
                    .setBarcode(asnOrderItem.getTrackCode())
                    .setQty(asnOrderItem.getQty())
                    .setQty(QuantityUtils.roundToScale(asnOrderItem.getQty()))
                    .setStockUnit(asnOrderItem.getStockUnit())
                    .setPurUnit(asnOrderItem.getPurUnit())
                    .setPoCode(asnOrderItem.getPoCode())
                    .setAnfme(asnOrderItem.getAnfme())
                    .setAnfme(QuantityUtils.roundToScale(asnOrderItem.getAnfme()))
                    .setPurQty(asnOrderItem.getPurQty())
                    .setSplrBatch(asnOrderItem.getSplrBatch())
                    .setExtendFields(asnOrderItem.getExtendFields())
@@ -1339,7 +1433,7 @@
            if (Objects.isNull(stockItem)) {
                detlsDto.setStockQty(0.0);
            } else {
                Double anfme = Math.round((stockItem.getAnfme() + stockItem.getWorkQty()) * 1000000) / 1000000.0;
                Double anfme = QuantityUtils.add(stockItem.getAnfme(), stockItem.getWorkQty());
                detlsDto.setStockQty(anfme);
            }