skyouc
2025-04-30 6f4f866484c956cfbe3de3d4d60a723d4f2ba6c7
rsf-server/src/main/java/com/vincent/rsf/server/manager/service/impl/TaskServiceImpl.java
@@ -61,6 +61,9 @@
    @Autowired
    private WarehouseAreasService warehouseAreasService;
    @Autowired
    private WarehouseAreasItemService warehouseAreasItemService;
    /**
     * @param
@@ -168,6 +171,13 @@
            if (!taskItemService.saveBatch(taskItems)) {
                throw new CoolException("任务明细保存失败!!");
            }
            waitPakinItems.forEach(item -> {
               if (! waitPakinItemService.update(new LambdaUpdateWrapper<WaitPakinItem>()
                       .set(WaitPakinItem::getWorkQty, item.getAnfme())
                       .eq(WaitPakinItem::getId, item.getId()))) {
                   throw new CoolException("组托明细修执行数量修改失败!!");
               }
            });
        });
        if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
@@ -223,6 +233,8 @@
            //保存库存明细
            try {
                saveStockItems(items, pakinItem);
                //移出收货区库存
                removeReceiptStock(pakinItem);
            } catch (Exception e) {
                throw new CoolException("库存管理保存更新失败!!");
            }
@@ -238,6 +250,42 @@
    /**
     * @author Ryan
     * @description 移除收货区库存
     * @param
     * @return
     * @time 2025/4/30 16:32
     */
    @Transactional(rollbackFor = Exception.class)
    private void removeReceiptStock(WaitPakinItem pakinItem) {
        WarehouseAreasItem itemServiceOne = warehouseAreasItemService.getOne(new LambdaQueryWrapper<WarehouseAreasItem>()
                .eq(WarehouseAreasItem::getTrackCode, pakinItem.getTrackCode())
                .eq(WarehouseAreasItem::getSplrBatch, pakinItem.getBatch()));
        if (Objects.isNull(itemServiceOne)) {
            throw new CoolException("数据错误,请查看请货区库存是否存在!!");
        }
        Double workQty = itemServiceOne.getWorkQty() - pakinItem.getAnfme();
        Double qty = itemServiceOne.getQty() + pakinItem.getAnfme();
        itemServiceOne.setWorkQty(workQty).setQty(qty);
        if (!waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>()
                .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_DONE.val)
                .eq(WaitPakin::getId, pakinItem.getPakinId()))) {
            throw new CoolException("组拖状态修改失败!!");
        }
        if (qty.compareTo(itemServiceOne.getAnfme()) == 0.00) {
            if (!warehouseAreasItemService.removeById(itemServiceOne.getId())) {
                throw new CoolException("收货区物料删除失败!!");
            }
        } else {
            if (!warehouseAreasItemService.updateById(itemServiceOne)) {
                throw new CoolException("收货区库完成数量修改失败!!");
            }
        }
    }
    /**
     * @author Ryan
     * @description 更新库位明细
     * @param
     * @return