From 173f44a1f9a59509996192e3446cbd26f2613b5e Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期五, 10 十月 2025 15:55:32 +0800
Subject: [PATCH] yys 新增关键煤种锁仓模块
---
main-business/src/main/java/com/ruoyi/business/service/impl/InventorySummaryServiceImpl.java | 40 +++++++++++++++++++++++++++++++---------
1 files changed, 31 insertions(+), 9 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 cb9c131..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
@@ -5,12 +5,8 @@
import com.ruoyi.business.dto.OfficialInventoryDto;
import com.ruoyi.business.dto.PendingInventoryDto;
import com.ruoyi.business.entity.*;
-import com.ruoyi.business.mapper.InventorySummaryMapper;
-import com.ruoyi.business.mapper.OfficialInventoryMapper;
-import com.ruoyi.business.mapper.PendingInventoryMapper;
-import com.ruoyi.business.service.InputInventoryRecordService;
+import com.ruoyi.business.mapper.*;
import com.ruoyi.business.service.InventorySummaryService;
-import com.ruoyi.business.service.OutputInventoryRecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -32,8 +28,9 @@
@RequiredArgsConstructor
public class InventorySummaryServiceImpl extends ServiceImpl<InventorySummaryMapper, InventorySummary> implements InventorySummaryService {
private final InventorySummaryMapper inventorySummaryMapper;
- private final InputInventoryRecordService inputInventoryRecordService;
- private final OutputInventoryRecordService outputInventoryRecordService;
+ private final InputInventoryRecordMapper inputInventoryRecordMapper;
+ private final OutputInventoryRecordMapper outputInventoryRecordMapper;
+
private final PendingInventoryMapper pendingInventoryMapper;
private final OfficialInventoryMapper officialInventoryMapper;
@@ -56,12 +53,12 @@
outputEndRecordId = inventorySummary.getOutputEndRecordId();
}
// 鏌ヨ鑺傜偣浠ュ悗鎵�鏈夊叆搴撹褰�
- List<InputInventoryRecord> inputInventoryRecords = inputInventoryRecordService.list(new LambdaQueryWrapper<InputInventoryRecord>()
+ List<InputInventoryRecord> inputInventoryRecords = inputInventoryRecordMapper.selectList(new LambdaQueryWrapper<InputInventoryRecord>()
.eq(InputInventoryRecord::getInventoryId, inventoryId)
.eq(InputInventoryRecord::getInventoryType, inventoryType)
.gt(InputInventoryRecord::getId, inputEndRecordId));
// 鏌ヨ鑺傜偣浠ュ悗鎵�鏈夊嚭搴撹褰�
- List<OutputInventoryRecord> outputInventoryRecords = outputInventoryRecordService.list(new LambdaQueryWrapper<OutputInventoryRecord>()
+ List<OutputInventoryRecord> outputInventoryRecords = outputInventoryRecordMapper.selectList(new LambdaQueryWrapper<OutputInventoryRecord>()
.eq(OutputInventoryRecord::getInventoryId, inventoryId)
.eq(OutputInventoryRecord::getInventoryType, inventoryType)
.gt(OutputInventoryRecord::getId, outputEndRecordId));
@@ -90,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