From 49e1bc66ebaf696ebd3fc3ed33d65c8795fd3cde Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期二, 01 七月 2025 18:05:12 +0800
Subject: [PATCH] 1.巡检定时任务 2.设备管理 3.文档查询
---
main-business/src/main/java/com/ruoyi/business/service/impl/InputInventoryRecordServiceImpl.java | 66 ++++++++++++++++++--------------
1 files changed, 37 insertions(+), 29 deletions(-)
diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/InputInventoryRecordServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/InputInventoryRecordServiceImpl.java
index 7370557..1ddb4c2 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/impl/InputInventoryRecordServiceImpl.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/impl/InputInventoryRecordServiceImpl.java
@@ -11,6 +11,7 @@
import com.ruoyi.business.mapper.InventorySummaryMapper;
import com.ruoyi.business.service.InputInventoryRecordService;
import com.ruoyi.business.service.InventorySummaryService;
+import com.ruoyi.business.utils.InventoryUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -19,6 +20,7 @@
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
+import java.util.stream.Collectors;
import static com.ruoyi.business.constant.InventoryRecordConstant.OFFICIAL_INVENTORY;
import static com.ruoyi.business.constant.InventoryRecordConstant.PENDING_INVENTORY;
@@ -37,6 +39,7 @@
private final InputInventoryRecordMapper inputInventoryRecordMapper;
private final InventorySummaryService inventorySummaryService;
private final InventorySummaryMapper inventorySummaryMapper;
+ private final InventoryUtils inventoryUtils;
@Override
public int insertInputInventoryRecord(PendingInventoryDto pendingInventoryDto, OfficialInventoryDto officialInventoryDto, BigDecimal quantity) {
@@ -62,36 +65,41 @@
@Override
public int deleteInputInventoryRecord(List<Long> ids) {
- if (CollectionUtils.isNotEmpty(ids)) {
- List<InputInventoryRecord> inputInventoryRecords = inputInventoryRecordMapper.selectBatchIds(ids);
- // 鏍规嵁id杩涜闄嶅簭鎺掑簭
- List<InputInventoryRecord> inputInventoryRecordList = inputInventoryRecords.stream()
- .sorted(Comparator.comparing(InputInventoryRecord::getId).reversed())
- .toList();
-
- String InventoryType = inputInventoryRecords.get(0).getInventoryType();
- List<Long> inventoryIds = inputInventoryRecords.stream().map(InputInventoryRecord::getInventoryId).toList();
- List<InventorySummary> inventorySummaries = inventorySummaryMapper.selectList(new LambdaQueryWrapper<InventorySummary>()
- .eq(InventorySummary::getInventoryType, InventoryType)
- .in(InventorySummary::getInventoryId, inventoryIds));
- if (CollectionUtils.isNotEmpty(inventorySummaries)) {
- List<InventorySummary> updates = new ArrayList<>();
- for (InventorySummary inventorySummary : inventorySummaries) {
- for (InputInventoryRecord inputInventoryRecord : inputInventoryRecords) {
- // 濡傛灉鑺傜偣涓婄殑鍏ュ簱璁板綍id澶т簬鍙樻洿鐨刬d锛岃鏄庢id鍓嶆墍鏈夊叆搴撹褰曢兘瑕侀噸鏂拌绠�
- if (Objects.equals(inventorySummary.getInventoryId(), inputInventoryRecord.getInventoryId()) && inventorySummary.getInputEndRecordId() > inputInventoryRecord.getId()) {
- inventorySummary.setInputEndRecordId(inputInventoryRecord.getId());
- updates.add(inventorySummary);
- }
- }
-
- }
- // 閲嶇疆浠栦滑鐨勮妭鐐规渶缁坕d
- inventorySummaryMapper.updateById(updates);
- }
+ if (CollectionUtils.isEmpty(ids)) {
+ throw new RuntimeException("璇蜂紶鍏ヨ鍒犻櫎鐨刬d璁板綍");
}
- // todo 閲嶆柊璁$畻鑺傜偣搴撳瓨
- // todo 鏇存柊搴撳瓨瀹炴柦鏁版嵁
+ List<InputInventoryRecord> inputInventoryRecords = inputInventoryRecordMapper.selectBatchIds(ids);
+ // 鏍规嵁id杩涜闄嶅簭鎺掑簭
+ List<InputInventoryRecord> inputInventoryRecordList = inputInventoryRecords.stream()
+ .sorted(Comparator.comparing(InputInventoryRecord::getId).reversed())
+ .toList();
+
+ String InventoryType = inputInventoryRecords.get(0).getInventoryType();
+ List<Long> inventoryIds = inputInventoryRecords.stream().map(InputInventoryRecord::getInventoryId).toList().stream().distinct().collect(Collectors.toList());
+ List<InventorySummary> inventorySummaries = inventorySummaryMapper.selectList(new LambdaQueryWrapper<InventorySummary>()
+ .eq(InventorySummary::getInventoryType, InventoryType)
+ .in(InventorySummary::getInventoryId, inventoryIds));
+ if (CollectionUtils.isNotEmpty(inventorySummaries)) {
+ List<InventorySummary> updates = new ArrayList<>();
+ for (InventorySummary inventorySummary : inventorySummaries) {
+ for (InputInventoryRecord inputInventoryRecord : inputInventoryRecordList) {
+ // 濡傛灉鑺傜偣涓婄殑鍏ュ簱璁板綍id澶т簬鍙樻洿鐨刬d锛岃鏄庢id鍓嶆墍鏈夊叆搴撹褰曢兘瑕侀噸鏂拌绠�
+ if (Objects.equals(inventorySummary.getInventoryId(), inputInventoryRecord.getInventoryId()) && inventorySummary.getInputEndRecordId() > inputInventoryRecord.getId()) {
+ inventorySummary.setInputEndRecordId(inputInventoryRecord.getId());
+ updates.add(inventorySummary);
+ }
+ }
+
+ }
+ // 閲嶇疆鑺傜偣鏈�缁坕d
+ inventorySummaryMapper.updateById(updates);
+ }
+
+ // 閲嶆柊璁$畻鑺傜偣搴撳瓨
+ inventorySummaryService.updateInventorySummary(ids);
+
+ // 鏇存柊搴撳瓨瀹炴椂鏁版嵁
+ inventoryUtils.updateInventoryByIds(inventoryIds, inputInventoryRecords.get(0).getInventoryType());
// 鍒犻櫎鍏ュ簱璁板綍
--
Gitblit v1.9.3