src/main/java/com/ruoyi/procurementrecord/dto/ProcurementPageDto.java
@@ -34,6 +34,8 @@ private String salesLedgerProductId; private Long productModelId; /** * 出入库数量 */ src/main/java/com/ruoyi/procurementrecord/pojo/ProcurementRecordStorage.java
@@ -86,4 +86,6 @@ */ @TableField(fill = FieldFill.INSERT) private Long tenantId; private Long productModelId; } src/main/java/com/ruoyi/procurementrecord/service/impl/ProcurementRecordServiceImpl.java
@@ -65,18 +65,18 @@ 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)); } src/main/java/com/ruoyi/sales/controller/SalesLedgerController.java
@@ -282,18 +282,16 @@ List<ProcurementPageDto> procurementPageDtoList = new ArrayList<>(); list.forEach(item -> { ProcurementPageDto procurementDto = new ProcurementPageDto(); procurementDto.setSalesLedgerProductId(String.valueOf(item.getId())); Page<ProcurementPageDto> page = new Page<>(1, 50); IPage<ProcurementPageDto> procurementPageDtoIPage = procurementRecordService.listPage(page, procurementDto); IPage<ProcurementPageDto> procurementPageDtoIPage = procurementRecordService.listPage(new Page<>(1, -1), procurementDto); procurementPageDtoList.addAll(procurementPageDtoIPage.getRecords()); }); if(!CollectionUtils.isEmpty(procurementPageDtoList)){ if(CollectionUtils.isEmpty(procurementPageDtoList)){ throw new RuntimeException("该产品库存不存在"); } AtomicInteger num = new AtomicInteger(); list.forEach(item -> { procurementPageDtoList.forEach(procurementPageDto -> { if(String.valueOf(item.getId().intValue()).equals(procurementPageDto.getSalesLedgerProductId())){ if(item.getProductModelId().equals(procurementPageDto.getProductModelId())){ if (item.getQuantity().compareTo(procurementPageDto.getInboundNum0()) <= 0) { num.getAndIncrement(); } src/main/resources/mapper/procurementrecord/ProcurementRecordMapper.xml
@@ -35,6 +35,7 @@ t2.product_category, t1.id, t1.sales_ledger_product_id, t1.product_model_id, t1.create_user, t2.specification_model, t2.unit, @@ -165,4 +166,4 @@ left join sales_ledger_product t2 on t2.id = t1.sales_ledger_product_id left join purchase_ledger t3 on t3.id = t2.sales_ledger_id </select> </mapper> </mapper>