| | |
| | | List<ProcurementRecordStorage> collect1 = procurementRecordStorages.stream() |
| | | .filter(procurementRecordStorage -> procurementRecordStorage.getSalesLedgerProductId().equals(dto.getId())) |
| | | .collect(Collectors.toList()); |
| | | |
| | | |
| | | // 如果没有相关的入库记录,跳过该条数据 |
| | | if(CollectionUtils.isEmpty(collect1)){ |
| | | dto.setQuantity0(dto.getQuantity()); |
| | | continue; |
| | | } |
| | | |
| | | |
| | | // 计算已入库数量总和,并设置待入库数量 |
| | | BigDecimal totalInboundNum = collect1.stream() |
| | | .map(ProcurementRecordStorage::getInboundNum) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | |
| | | |
| | | // 待入库数量 = 总数量 - 已入库数量 |
| | | dto.setQuantity0(dto.getQuantity().subtract(totalInboundNum)); |
| | | } |
| | |
| | | List<ProcurementRecordOut> recordOutList = procurementRecordOutMapper.selectList(queryWrapper); |
| | | |
| | | // 2. 按SalesLedgerProductId分组,统计每个id对应的已出库数量总和-已出库数量 |
| | | Map<Integer, BigDecimal> storageIdToTotalOutNumMap = recordOutList.stream() |
| | | Map<Long, BigDecimal> storageIdToTotalOutNumMap = recordOutList.stream() |
| | | .collect(Collectors.groupingBy( |
| | | ProcurementRecordOut::getSalesLedgerProductId, |
| | | Collectors.reducing( |