| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.manager.controller.params.PakinItem; |
| | | import com.vincent.rsf.server.manager.controller.params.WaitPakinParam; |
| | |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public WaitPakin mergeItems(WaitPakinParam waitPakin, Long userId) { |
| | | public synchronized WaitPakin mergeItems(WaitPakinParam waitPakin, Long userId) { |
| | | if (Objects.isNull(waitPakin.getItems()) || waitPakin.getItems().isEmpty()) { |
| | | throw new CoolException("参数错误:物料跟踪码为空!"); |
| | | } |
| | |
| | | //状态修改为入库中 |
| | | .setIoStatus(Short.parseShort(PakinIOStatus.PAKIN_IO_STATUS_DONE.val)) |
| | | .setAnfme(sum) |
| | | .setUpdateBy(userId) |
| | | .setCreateBy(userId) |
| | | .setBarcode(waitPakin.getBarcode()); |
| | | if (!this.save(waitPakin1)) { |
| | | throw new CoolException("主单保存失败!!"); |
| | |
| | | } |
| | | } |
| | | List<WaitPakinItem> items = new ArrayList<>(); |
| | | //不良标签组托 |
| | | if (!Objects.isNull(waitPakin.getType()) && waitPakin.getType().equals("defective")) { |
| | | List<AsnOrderItem> orderItems = asnOrderItemService.list(new LambdaQueryWrapper<AsnOrderItem>().in(AsnOrderItem::getTrackCode, tracks)); |
| | | if (Objects.isNull(orderItems) || orderItems.isEmpty()) { |
| | |
| | | .setUpdateBy(userId) |
| | | .setCreateBy(userId) |
| | | .setMatnrCode(item.getMatnrCode()); |
| | | AsnOrder order = asnOrderService.getById(item.getAsnId()); |
| | | if (!Objects.isNull(order)) { |
| | | pakinItem.setType(null == order.getType() ? null :order.getType()) |
| | | .setWkType(null == order.getWkType() ? null : Short.parseShort(order.getWkType()) ); |
| | | } |
| | | for (PakinItem waitPakinItem : waitPakin.getItems()) { |
| | | if (waitPakinItem.getTrackCode().equals(item.getTrackCode())) { |
| | | if (waitPakinItem.getReceiptQty() > item.getAnfme() && waitPakinItem.getReceiptQty().compareTo(0.0) >= 0) { |
| | | if (waitPakinItem.getReceiptQty() > item.getAnfme() || waitPakinItem.getReceiptQty().compareTo(0.0) >= 0) { |
| | | throw new CoolException("组拖数量不能大于收货数量!!"); |
| | | } |
| | | pakinItem.setAnfme(waitPakinItem.getReceiptQty()).setTrackCode(waitPakinItem.getTrackCode()); |
| | |
| | | } |
| | | } else { |
| | | LambdaQueryWrapper<WarehouseAreasItem> queryWrapper = new QueryWrapper<WarehouseAreasItem>() |
| | | .select("SUM(anfme) as anfme, track_code, asn_code, id, splr_batch, ispt_result, plat_item_id, batch, qty, work_qty, matnr_code, matnr_id, maktx") |
| | | .select("SUM(anfme) as anfme, track_code, asn_code, id, splr_batch, ispt_result, plat_item_id, batch, qty, unit, stock_unit, work_qty, matnr_code, matnr_id, maktx") |
| | | .lambda() |
| | | .in(WarehouseAreasItem::getTrackCode, tracks) |
| | | .eq(StringUtils.isNotBlank(waitPakin.getBatch()), WarehouseAreasItem::getSplrBatch, waitPakin.getBatch()) |
| | | .groupBy(WarehouseAreasItem::getSplrBatch, |
| | | WarehouseAreasItem::getTrackCode); |
| | | List<WarehouseAreasItem> warehouseAreasItems = warehouseAreasItemService.list(queryWrapper); |
| | |
| | | .setUpdateBy(userId) |
| | | .setCreateBy(userId) |
| | | .setMatnrCode(item.getMatnrCode()); |
| | | AsnOrder order = asnOrderService.getById(item.getAsnId()); |
| | | if (!Objects.isNull(order)) { |
| | | pakinItem.setType(null == order.getType() ? null :order.getType()) |
| | | .setWkType(null == order.getWkType() ? null : Short.parseShort(order.getWkType()) ); |
| | | } |
| | | |
| | | for (PakinItem waitPakinItem : waitPakin.getItems()) { |
| | | if (waitPakinItem.getTrackCode().equals(item.getTrackCode())) { |
| | | if (waitPakinItem.getReceiptQty() > item.getAnfme() && waitPakinItem.getReceiptQty().compareTo(0.0) >= 0) { |
| | | if (waitPakinItem.getReceiptQty() > item.getAnfme() || waitPakinItem.getReceiptQty().compareTo(0.0) <= 0) { |
| | | throw new CoolException("组拖数量不能大于收货数量且不能小于零!!"); |
| | | } |
| | | pakinItem.setAnfme(waitPakinItem.getReceiptQty()).setTrackCode(waitPakinItem.getTrackCode()); |
| | |
| | | } |
| | | items.add(pakinItem); |
| | | } |
| | | |
| | | |
| | | } |
| | | double sum1 = items.stream().mapToDouble(WaitPakinItem::getAnfme).sum(); |
| | | |
| | | if (!waitPakinItemService.saveBatch(items)) { |
| | | throw new CoolException("组拖明细保存失败!!"); |
| | | } |
| | | |
| | | for (WaitPakinItem pakinItem : items) { |
| | | WarehouseAreasItem one = warehouseAreasItemService.getOne(new LambdaQueryWrapper<WarehouseAreasItem>() |
| | | .eq(WarehouseAreasItem::getTrackCode, pakinItem.getTrackCode()) |
| | | .eq(WarehouseAreasItem::getSplrBatch, pakinItem.getBatch())); |
| | | if (Objects.isNull(one)) { |
| | | throw new CoolException("收货区数据错误!!"); |
| | | } |
| | | one.setWorkQty(one.getWorkQty() + pakinItem.getAnfme() + one.getQty()) ; |
| | | if (one.getWorkQty() > one.getAnfme()) { |
| | | throw new CoolException("组托数量不能大于收货数量!!"); |
| | | } |
| | | if (!warehouseAreasItemService.saveOrUpdate(one)) { |
| | | throw new CoolException("收货区执行数量修改失败!!"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | waitPakin1.setAnfme(sum1); |
| | | if (!this.updateById(waitPakin1)) { |
| | | throw new CoolException("组拖数量修改失败!!"); |
| | | } |
| | | |
| | | //TODO 组拖完成后,扣减收货区库存 |
| | | |
| | | return pakin; |
| | | } |
| | | |
| | |
| | | * @time 2025/3/29 14:42 |
| | | */ |
| | | @Override |
| | | public WaitPakin unBind(WaitPakinParam param) { |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public synchronized WaitPakin unBind(WaitPakinParam param) { |
| | | String barcode = param.getBarcode(); |
| | | if (StringUtils.isNotBlank(barcode)) { |
| | | WaitPakin waitPakins = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, barcode), false); |