| | |
| | | if(CollectionUtils.isEmpty( collect)){ |
| | | return procurementPageDtoCopyIPage; |
| | | } |
| | | // LambdaQueryWrapper<ProcurementRecordOut> procurementRecordLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | // procurementRecordLambdaQueryWrapper.in(ProcurementRecordOut::getProcurementRecordStorageId, collect); |
| | | // procurementRecordLambdaQueryWrapper.eq(ProcurementRecordOut::getType, 2); |
| | | // List<ProcurementRecordOut> procurementRecords = procurementRecordOutMapper.selectList(procurementRecordLambdaQueryWrapper); |
| | | // if(CollectionUtils.isEmpty(procurementRecords)){ |
| | | // return procurementPageDtoCopyIPage; |
| | | // } |
| | | // for (ProcurementPageDtoCopy dto : procurementPageDtoCopyList) { |
| | | // // 根据采购台账ID筛选对应的出库记录 |
| | | // List<ProcurementRecordOut> collect1 = procurementRecords.stream() |
| | | // .filter(ProcurementRecordOut -> ProcurementRecordOut.getProcurementRecordStorageId().equals(dto.getId())) |
| | | // .collect(Collectors.toList()); |
| | | // |
| | | // // 如果没有相关的出库记录,跳过该条数据 |
| | | // if(CollectionUtils.isEmpty(collect1)){ |
| | | // dto.setInboundNum0(dto.getInboundNum()); |
| | | // dto.setTotalInboundNum(BigDecimal.ZERO); |
| | | // continue; |
| | | // } |
| | | // |
| | | // // 计算已出库数量总和,并设置待出库数量 |
| | | // BigDecimal totalInboundNum = collect1.stream() |
| | | // .map(ProcurementRecordOut::getInboundNum) |
| | | // .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // // 出库数量 = 总数量 - 待出库数量 |
| | | // dto.setTotalInboundNum(totalInboundNum); |
| | | // // 待出库数量 = 总数量 - 已出库数量 |
| | | // dto.setInboundNum0(dto.getInboundNum().subtract(totalInboundNum)); |
| | | // // 库存价值 |
| | | // if(dto.getUnitPrice() != null){ |
| | | // dto.setTotalPrice(dto.getTotalInboundNum().multiply(dto.getUnitPrice())); |
| | | // } |
| | | // } |
| | | // 1. 查询采购记录已入库的出库记录(按storageId分组) |
| | | LambdaQueryWrapper<ProcurementRecordOut> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.in(ProcurementRecordOut::getProcurementRecordStorageId, collect); |
| | |
| | | Integer salesLedgerProductId = Integer.valueOf(Math.toIntExact(dto.getSalesLedgerProductId())); |
| | | // 获取当前salesLedgerProductId对应的已出库总数(默认0) |
| | | BigDecimal totalInboundNum = storageIdToTotalOutNumMap.getOrDefault(salesLedgerProductId, BigDecimal.ZERO); |
| | | |
| | | // 已出库数量 |
| | | dto.setTotalInboundNum(totalInboundNum); |
| | | // 待出库数量 = 总数量 - 已出库数量(总数量空值则默认0) |
| | | // BigDecimal totalNum = dto.getInboundNum() == null ? BigDecimal.ZERO : dto.getInboundNum(); |
| | | BigDecimal totalNum = storageIdToTotalintNumMap.getOrDefault(salesLedgerProductId, BigDecimal.ZERO); |
| | | dto.setInboundNum(totalNum); |
| | | dto.setInboundNum0(totalNum.subtract(totalInboundNum)); |
| | | // 已出库数量 |
| | | dto.setTotalInboundNum(totalInboundNum); |
| | | |
| | | // 库存价值 = 已出库数量 * 单价(单价空值则默认0) |
| | | BigDecimal unitPrice = dto.getUnitPrice() == null ? BigDecimal.ZERO : dto.getUnitPrice(); |
| | | dto.setTotalPrice(totalInboundNum.multiply(unitPrice)); |