From 13afb7eafeffac6ecccc7c66d36974c54c5172d4 Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期四, 28 五月 2026 15:13:37 +0800
Subject: [PATCH] 库存管理增加库存类型,并返回相关数据显示

---
 src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java b/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
index c19df49..7facfcf 100644
--- a/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
+++ b/src/main/java/com/ruoyi/stock/service/impl/StockInRecordServiceImpl.java
@@ -30,6 +30,7 @@
 import com.ruoyi.stock.service.StockInRecordService;
 import jakarta.servlet.http.HttpServletResponse;
 import lombok.AllArgsConstructor;
+import org.jspecify.annotations.NonNull;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
@@ -235,12 +236,7 @@
                 if ("0".equals(stockInRecord.getType())) {
                     // 鍚堟牸鍏ュ簱 -> 鍏堟煡搴撳瓨锛屽瓨鍦ㄥ垯鏇存柊锛屼笉瀛樺湪鍒欐柊澧�
                     StockInventory stockInventory = getStockInventory(stockInRecord.getProductModelId(), stockInRecord.getBatchNo());
-                    StockInventoryDto stockInventoryDto = new StockInventoryDto();
-                    stockInventoryDto.setProductModelId(stockInRecord.getProductModelId());
-                    stockInventoryDto.setBatchNo(stockInRecord.getBatchNo());
-                    stockInventoryDto.setQualitity(stockInRecord.getStockInNum());
-                    stockInventoryDto.setRemark(stockInRecord.getRemark());
-                    stockInventoryDto.setManufacturerId(stockInRecord.getManufacturerId());
+                    StockInventoryDto stockInventoryDto = getStockInventoryDto(stockInRecord);
                     if (stockInventory == null) {
                         stockInventoryMapper.insert(new StockInventory() {{
                             setProductModelId(stockInRecord.getProductModelId());
@@ -249,6 +245,7 @@
                             setRemark(stockInRecord.getRemark());
                             setWarnNum(stockInRecord.getWarnNum());
                             setManufacturerId(stockInRecord.getManufacturerId());
+                            setSource(stockInRecord.getSource());
                             setVersion(1);
                         }});
                     } else {
@@ -263,6 +260,7 @@
                     stockUninventoryDto.setQualitity(stockInRecord.getStockInNum());
                     stockUninventoryDto.setRemark(stockInRecord.getRemark());
                     stockUninventoryDto.setManufacturerId(stockInRecord.getManufacturerId());
+                    stockUninventoryDto.setSource(stockInRecord.getSource());
                     if (stockUninventory == null) {
                         stockUninventoryMapper.insert(new StockUninventory() {{
                             setProductModelId(stockInRecord.getProductModelId());
@@ -270,6 +268,7 @@
                             setBatchNo(stockInRecord.getBatchNo());
                             setRemark(stockInRecord.getRemark());
                             setManufacturerId(stockInRecord.getManufacturerId());
+                            setSource(stockInRecord.getSource());
                             setVersion(1);
                         }});
                     } else {
@@ -281,6 +280,17 @@
         return ids.size();
     }
 
+    private static @NonNull StockInventoryDto getStockInventoryDto(StockInRecord stockInRecord) {
+        StockInventoryDto stockInventoryDto = new StockInventoryDto();
+        stockInventoryDto.setProductModelId(stockInRecord.getProductModelId());
+        stockInventoryDto.setBatchNo(stockInRecord.getBatchNo());
+        stockInventoryDto.setQualitity(stockInRecord.getStockInNum());
+        stockInventoryDto.setRemark(stockInRecord.getRemark());
+        stockInventoryDto.setManufacturerId(stockInRecord.getManufacturerId());
+        stockInventoryDto.setSource(stockInRecord.getSource());
+        return stockInventoryDto;
+    }
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public int batchReAudit(List<Long> ids) {

--
Gitblit v1.9.3