chen.lin
6 天以前 024504a3933e8f2f86e80383e61fa574524a0d28
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
@@ -2477,6 +2477,44 @@
            throw new CoolException("组拖状态修改失败!!");
        }
        // 组托入库完成后累加订单及明细的已收数量,用于后续判断整单是否可置为已完成
        Map<Long, Double> orderIdToAdd = new HashMap<>();
        Map<Long, Double> itemIdToAdd = new HashMap<>();
        for (WaitPakinItem p : pakinItems) {
            if (StringUtils.isBlank(p.getAsnCode())) {
                continue;
            }
            WkOrder order = asnOrderService.getOne(new LambdaQueryWrapper<WkOrder>().eq(WkOrder::getCode, p.getAsnCode()));
            if (order == null) {
                continue;
            }
            double addQty = (p.getAnfme() != null ? p.getAnfme() : 0.0);
            orderIdToAdd.merge(order.getId(), addQty, Double::sum);
            if (p.getAsnItemId() != null) {
                itemIdToAdd.merge(p.getAsnItemId(), addQty, Double::sum);
            }
        }
        for (Map.Entry<Long, Double> e : orderIdToAdd.entrySet()) {
            WkOrder o = asnOrderService.getById(e.getKey());
            if (o != null) {
                Double newQty = QuantityUtils.roundToScale(QuantityUtils.add(o.getQty() != null ? o.getQty() : 0.0, e.getValue()));
                o.setQty(newQty);
                if (!asnOrderService.updateById(o)) {
                    throw new CoolException("入库单完成数量更新失败!!");
                }
            }
        }
        for (Map.Entry<Long, Double> e : itemIdToAdd.entrySet()) {
            WkOrderItem oi = asnOrderItemService.getById(e.getKey());
            if (oi != null) {
                Double newQty = QuantityUtils.roundToScale(QuantityUtils.add(oi.getQty() != null ? oi.getQty() : 0.0, e.getValue()));
                oi.setQty(newQty);
                if (!asnOrderItemService.updateById(oi)) {
                    throw new CoolException("入库单明细完成数量更新失败!!");
                }
            }
        }
        /**修改库位状态为F.在库*/
        if (!locService.update(new LambdaUpdateWrapper<Loc>().set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type).eq(Loc::getCode, task.getTargLoc()))) {
            throw new CoolException("库位状态修改失败!!");