| | |
| | | |
| | | List<WaitPakinItem> items = new ArrayList<>(); |
| | | if (directWaitPakin) { |
| | | // DirectWaitPakin 启用:组托来自收货区,param 中 id 为 WarehouseAreasItem.id |
| | | // DirectWaitPakin 启用:组托可来自收货区(有 id)或无订单组托(id 为 null,仅物料+数量) |
| | | for (PakinItem pakinItem1 : waitPakin.getItems()) { |
| | | if (pakinItem1.getId() == null) { |
| | | // 无订单组托:无收货区来源,按 matnrId + receiptQty 建组托明细 |
| | | if (pakinItem1.getMatnrId() == null) { |
| | | throw new CoolException("无订单组托时物料ID不能为空!!"); |
| | | } |
| | | Matnr matnr = matnrMapper.selectById(pakinItem1.getMatnrId()); |
| | | if (matnr == null) { |
| | | throw new CoolException("物料信息不存在,物料ID:" + pakinItem1.getMatnrId()); |
| | | } |
| | | if (pakinItem1.getReceiptQty() == null || pakinItem1.getReceiptQty().compareTo(0.0) <= 0) { |
| | | throw new CoolException("组托数量不能小于等于零!!"); |
| | | } |
| | | WaitPakinItem pakinItem = new WaitPakinItem(); |
| | | pakinItem.setPakinId(waitPakin1.getId()) |
| | | .setSource(null) |
| | | .setAsnId(null) |
| | | .setAsnCode(null) |
| | | .setAsnItemId(null) |
| | | .setIsptResult(null) |
| | | .setPlatItemId(null) |
| | | .setPlatOrderCode(null) |
| | | .setPlatWorkCode(null) |
| | | .setProjectCode(null) |
| | | .setBatch(null) |
| | | .setUnit(matnr.getStockUnit() != null ? matnr.getStockUnit() : "个") |
| | | .setFieldsIndex(matnr.getFieldsIndex()) |
| | | .setMatnrId(matnr.getId()) |
| | | .setMaktx(matnr.getName()) |
| | | .setUpdateBy(userId) |
| | | .setCreateBy(userId) |
| | | .setMatnrCode(matnr.getCode()) |
| | | .setAnfme(QuantityUtils.roundToScale(pakinItem1.getReceiptQty())) |
| | | .setTrackCode(pakinItem1.getTrackCode()); |
| | | items.add(pakinItem); |
| | | continue; |
| | | } |
| | | WarehouseAreasItem areaItem = warehouseAreasItemService.getById(pakinItem1.getId()); |
| | | if (areaItem == null) { |
| | | throw new CoolException("物料未送至收货区!!"); |
| | |
| | | throw new CoolException("组托明细保存失败!!"); |
| | | } |
| | | for (WaitPakinItem pakinItem : items) { |
| | | if (pakinItem.getSource() == null) { |
| | | continue; // 无订单组托无收货区来源,不更新收货区 |
| | | } |
| | | WarehouseAreasItem one = warehouseAreasItemService.getOne(new LambdaQueryWrapper<WarehouseAreasItem>().eq(WarehouseAreasItem::getId, pakinItem.getSource())); |
| | | if (one == null) { |
| | | throw new CoolException("收货区数据错误!!"); |