From d9b764868dbfa79aa79d79f676f60a28c4055b06 Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期六, 14 六月 2025 17:00:07 +0800
Subject: [PATCH] 库存明细数据处理
---
main-business/src/main/java/com/ruoyi/business/service/impl/InventorySummaryServiceImpl.java | 15 +++----
main-business/src/main/java/com/ruoyi/business/service/InputInventoryRecordService.java | 3 +
main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java | 8 ---
main-business/src/main/java/com/ruoyi/business/service/impl/InputInventoryRecordServiceImpl.java | 52 +++++++++++++++++++++++---
main-business/src/main/java/com/ruoyi/business/service/impl/OutputInventoryRecordServiceImpl.java | 7 ++-
5 files changed, 60 insertions(+), 25 deletions(-)
diff --git a/main-business/src/main/java/com/ruoyi/business/service/InputInventoryRecordService.java b/main-business/src/main/java/com/ruoyi/business/service/InputInventoryRecordService.java
index 074d7ec..f7f41c9 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/InputInventoryRecordService.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/InputInventoryRecordService.java
@@ -6,6 +6,7 @@
import com.ruoyi.business.entity.InputInventoryRecord;
import java.math.BigDecimal;
+import java.util.List;
/**
* <p>
@@ -21,5 +22,5 @@
int insertInputInventoryRecord(PendingInventoryDto pendingInventoryDto, OfficialInventoryDto officialInventoryDto, BigDecimal quantity);
// 鍒犻櫎鍏ュ簱璁板綍
- int deleteInputInventoryRecord(Long[] ids);
+ int deleteInputInventoryRecord(List<Long> ids);
}
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 d2a2112..7370557 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
@@ -1,15 +1,24 @@
package com.ruoyi.business.service.impl;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.business.dto.OfficialInventoryDto;
import com.ruoyi.business.dto.PendingInventoryDto;
import com.ruoyi.business.entity.InputInventoryRecord;
+import com.ruoyi.business.entity.InventorySummary;
import com.ruoyi.business.mapper.InputInventoryRecordMapper;
+import com.ruoyi.business.mapper.InventorySummaryMapper;
import com.ruoyi.business.service.InputInventoryRecordService;
+import com.ruoyi.business.service.InventorySummaryService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Objects;
import static com.ruoyi.business.constant.InventoryRecordConstant.OFFICIAL_INVENTORY;
import static com.ruoyi.business.constant.InventoryRecordConstant.PENDING_INVENTORY;
@@ -26,6 +35,8 @@
@RequiredArgsConstructor
public class InputInventoryRecordServiceImpl extends ServiceImpl<InputInventoryRecordMapper, InputInventoryRecord> implements InputInventoryRecordService {
private final InputInventoryRecordMapper inputInventoryRecordMapper;
+ private final InventorySummaryService inventorySummaryService;
+ private final InventorySummaryMapper inventorySummaryMapper;
@Override
public int insertInputInventoryRecord(PendingInventoryDto pendingInventoryDto, OfficialInventoryDto officialInventoryDto, BigDecimal quantity) {
@@ -43,18 +54,47 @@
}
inputInventoryRecord.setQuantity(quantity);
- return inputInventoryRecordMapper.insert(inputInventoryRecord);
+ inputInventoryRecordMapper.insert(inputInventoryRecord);
// 鏇存柊搴撳瓨
-// inventorySummaryService.updateInventory(pendingInventoryDto, officialInventoryDto);
+ return inventorySummaryService.updateInventory(pendingInventoryDto, officialInventoryDto);
}
@Override
- public int deleteInputInventoryRecord(Long[] ids) {
+ 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);
+ }
+ }
+ // todo 閲嶆柊璁$畻鑺傜偣搴撳瓨
+ // todo 鏇存柊搴撳瓨瀹炴柦鏁版嵁
-
-
- return 0;
+ // 鍒犻櫎鍏ュ簱璁板綍
+ return inputInventoryRecordMapper.deleteByIds(ids);
}
}
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..9892611 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));
diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/OutputInventoryRecordServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/OutputInventoryRecordServiceImpl.java
index 87888d3..a2544f1 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/impl/OutputInventoryRecordServiceImpl.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/impl/OutputInventoryRecordServiceImpl.java
@@ -5,6 +5,7 @@
import com.ruoyi.business.dto.PendingInventoryDto;
import com.ruoyi.business.entity.OutputInventoryRecord;
import com.ruoyi.business.mapper.OutputInventoryRecordMapper;
+import com.ruoyi.business.service.InventorySummaryService;
import com.ruoyi.business.service.OutputInventoryRecordService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
@@ -27,6 +28,8 @@
public class OutputInventoryRecordServiceImpl extends ServiceImpl<OutputInventoryRecordMapper, OutputInventoryRecord> implements OutputInventoryRecordService {
private final OutputInventoryRecordMapper outputInventoryRecordMapper;
+ private final InventorySummaryService inventorySummaryService;
+
@Override
public int insertOutputInventoryRecord(PendingInventoryDto pendingInventoryDto, OfficialInventoryDto officialInventoryDto, BigDecimal quantity) {
if ((pendingInventoryDto != null && officialInventoryDto != null) || (pendingInventoryDto == null && officialInventoryDto == null)) {
@@ -43,9 +46,9 @@
}
outputInventoryRecord.setQuantity(quantity);
- return outputInventoryRecordMapper.insert(outputInventoryRecord);
+ outputInventoryRecordMapper.insert(outputInventoryRecord);
// 鍙樻洿鍘熷簱瀛樹俊鎭�
-// return inventorySummaryService.updateInventory(pendingInventoryDto, officialInventoryDto);
+ return inventorySummaryService.updateInventory(pendingInventoryDto, officialInventoryDto);
}
}
diff --git a/main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java b/main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java
index bcf7e46..53182f3 100644
--- a/main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java
+++ b/main-business/src/main/java/com/ruoyi/business/service/impl/PendingInventoryServiceImpl.java
@@ -192,7 +192,7 @@
officialInventory.setPendingId(pendingInventoryDto.getPId());
officialInventory.setInventoryQuantity(quantity);
officialInventoryMapper.insert(officialInventory);
- }else {
+ } else {
OfficialInventory officialInventory = officialInventoryMapper.selectById(pendingInventoryDto.getOfficialId());
officialInventory.setInventoryQuantity(quantity.add(officialInventory.getInventoryQuantity()));
officialInventoryMapper.updateById(officialInventory);
@@ -200,10 +200,4 @@
}
return i;
}
-
- // 澶勭悊鏄庣粏鍜屽簱瀛樻暟閲�
- private int handeInventoryQuantity(PendingInventoryDto pendingInventoryDto) {
- inputInventoryRecordService.insertInputInventoryRecord(pendingInventoryDto, null, pendingInventoryDto.getInventoryQuantity());
- return inventorySummaryService.updateInventory(pendingInventoryDto, null);
- };
}
--
Gitblit v1.9.3