| | |
| | | return Collections.emptyList(); |
| | | } |
| | | List<ProductionOrderPickVo> detailList = baseMapper.listPickedDetailByOrderId(productionOrderId); |
| | | fillStockQuantity(detailList); |
| | | fillBatchNoList(detailList); |
| | | fillSelectableBatchNoList(detailList); |
| | | return detailList; |
| | |
| | | updatePick.setId(oldPick.getId()); |
| | | updatePick.setReturnQty(totalReturnQty); |
| | | updatePick.setActualQty(actualQty); |
| | | updatePick.setReturned(totalReturnQty.compareTo(BigDecimal.ZERO) > 0); |
| | | // 实际用量归零时才标记退料完成,否则允许继续退料。 |
| | | updatePick.setReturned(actualQty.compareTo(BigDecimal.ZERO) == 0); |
| | | int affected = baseMapper.updateById(updatePick); |
| | | if (affected <= 0) { |
| | | throw new ServiceException("第" + rowNo + "行退料失败:更新领料主记录失败"); |
| | |
| | | } |
| | | } |
| | | |
| | | private void fillStockQuantity(List<ProductionOrderPickVo> detailList) { |
| | | if (detailList == null || detailList.isEmpty()) { |
| | | return; |
| | | } |
| | | Set<Long> productModelIdSet = detailList.stream() |
| | | .map(ProductionOrderPickVo::getProductModelId) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.toSet()); |
| | | if (productModelIdSet.isEmpty()) { |
| | | return; |
| | | } |
| | | List<StockInventory> stockList = stockInventoryMapper.selectList( |
| | | Wrappers.<StockInventory>lambdaQuery() |
| | | .in(StockInventory::getProductModelId, productModelIdSet)); |
| | | Map<Long, BigDecimal> stockQuantityMap = new HashMap<>(); |
| | | for (StockInventory stockInventory : stockList) { |
| | | if (stockInventory == null || stockInventory.getProductModelId() == null) { |
| | | continue; |
| | | } |
| | | stockQuantityMap.merge(stockInventory.getProductModelId(), |
| | | defaultDecimal(stockInventory.getQualitity()), |
| | | BigDecimal::add); |
| | | } |
| | | for (ProductionOrderPickVo detail : detailList) { |
| | | detail.setStockQuantity(stockQuantityMap.getOrDefault(detail.getProductModelId(), BigDecimal.ZERO)); |
| | | } |
| | | } |
| | | |
| | | private String buildBatchNoGroupKey(ProductionOrderPickVo detail) { |
| | | // 构建批次聚合分组键。 |
| | | return detail.getProductionOrderId() + "|" |