From 8097a2a4383a3785e11990170d61c59ae6b48888 Mon Sep 17 00:00:00 2001 From: chenhj <1263187585@qq.com> Date: 星期五, 20 六月 2025 18:02:53 +0800 Subject: [PATCH] 库存明细数据处理 --- main-business/src/main/java/com/ruoyi/business/service/impl/InventorySummaryServiceImpl.java | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-) diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/InventorySummaryServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/InventorySummaryServiceImpl.java index 9892611..2669ab6 100644 --- a/main-business/src/main/java/com/ruoyi/business/service/impl/InventorySummaryServiceImpl.java +++ b/main-business/src/main/java/com/ruoyi/business/service/impl/InventorySummaryServiceImpl.java @@ -87,4 +87,29 @@ return officialInventoryMapper.updateById(officialInventory); } } + + @Override + public int updateInventorySummary(List<Long> ids) { + List<InventorySummary> inventorySummaries = inventorySummaryMapper.selectBatchIds(ids); + for (InventorySummary inventorySummary : inventorySummaries) { + // 鏌ヨ鑺傜偣涔嬪墠鎵�鏈夊叆搴撹褰� + List<InputInventoryRecord> inputInventoryRecords = inputInventoryRecordMapper.selectList(new LambdaQueryWrapper<InputInventoryRecord>() + .eq(InputInventoryRecord::getInventoryId, inventorySummary.getInventoryId()) + .eq(InputInventoryRecord::getInventoryType, inventorySummary.getInventoryType()) + .lt(InputInventoryRecord::getId, inventorySummary.getInputEndRecordId())); + + // 鏌ヨ鑺傜偣涔嬪墠鎵�鏈夊嚭搴撹褰� + List<OutputInventoryRecord> outputInventoryRecords = outputInventoryRecordMapper.selectList(new LambdaQueryWrapper<OutputInventoryRecord>() + .eq(OutputInventoryRecord::getInventoryId, inventorySummary.getInventoryId()) + .eq(OutputInventoryRecord::getInventoryType, inventorySummary.getInventoryType()) + .lt(OutputInventoryRecord::getId, inventorySummary.getOutputEndRecordId())); + + // 璁$畻搴撳瓨鏁伴噺 + BigDecimal inputQuantity = inputInventoryRecords.stream().map(InputInventoryRecord::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal outputQuantity = outputInventoryRecords.stream().map(OutputInventoryRecord::getQuantity).reduce(BigDecimal.ZERO, BigDecimal::add); + inventorySummary.setInventoryQuantity(inputQuantity.subtract(outputQuantity)); + } + + return inventorySummaryMapper.updateById(inventorySummaries).size(); + } } -- Gitblit v1.9.3