| | |
| | | return Collections.emptyList(); |
| | | } |
| | | List<ProductionOrderPickVo> detailList = baseMapper.listPickedDetailByOrderId(productionOrderId); |
| | | fillStockQuantity(detailList); |
| | | fillBatchNoList(detailList); |
| | | fillSelectableBatchNoList(detailList); |
| | | return detailList; |
| | |
| | | BigDecimal totalReturnQty = oldReturnQty.add(currentReturnQty); |
| | | if (currentReturnQty.compareTo(BigDecimal.ZERO) > 0) { |
| | | String returnBatchNo = resolveInventoryBatchNoFromStored(oldPick.getBatchNo()); |
| | | addInventory(oldPick.getId(), oldPick.getProductModelId(), returnBatchNo, currentReturnQty, FEED_RETURN_IN_RECORD_TYPE); |
| | | addInventoryRecordOnly(oldPick.getId(), oldPick.getProductModelId(), returnBatchNo, currentReturnQty, FEED_RETURN_IN_RECORD_TYPE); |
| | | } |
| | | |
| | | BigDecimal actualQty = defaultDecimal(oldPick.getQuantity()) |
| | |
| | | throw ex; |
| | | } catch (Exception ex) { |
| | | throw new ServiceException("回补库存失败:" + ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | | private void addInventoryRecordOnly(Long recordId, |
| | | Long productModelId, |
| | | String batchNo, |
| | | BigDecimal quantity, |
| | | String stockInRecordType) { |
| | | // 仅记录入库申请,不做审核通过。 |
| | | BigDecimal addQuantity = defaultDecimal(quantity); |
| | | if (addQuantity.compareTo(BigDecimal.ZERO) <= 0) { |
| | | return; |
| | | } |
| | | try { |
| | | StockInventoryDto stockInventoryDto = new StockInventoryDto(); |
| | | stockInventoryDto.setProductModelId(productModelId); |
| | | stockInventoryDto.setBatchNo(batchNo); |
| | | stockInventoryDto.setQualitity(addQuantity); |
| | | stockInventoryDto.setRecordType(stockInRecordType); |
| | | stockInventoryDto.setRecordId(recordId == null ? 0L : recordId); |
| | | stockInventoryService.addStockInRecordOnly(stockInventoryDto); |
| | | } catch (ServiceException ex) { |
| | | throw ex; |
| | | } catch (Exception ex) { |
| | | throw new ServiceException("退料入库记录保存失败:" + ex.getMessage()); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | 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() + "|" |