From ac6db1c4fddcb89c9668e34a35f023817a59f838 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 01 四月 2026 17:54:44 +0800
Subject: [PATCH] yys 1.产品导入新增excel错误提示 2.bom导入新增excel错误提示 3.仓储物流增加库位字段 4.修改发货出库-新增库位 5.修改采购入库审核-新增库位 6.生产入库-新增库位,审核

---
 src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java |   57 ++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 34 insertions(+), 23 deletions(-)

diff --git a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
index f9a21d6..aa535a3 100644
--- a/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
+++ b/src/main/java/com/ruoyi/procurementrecord/utils/StockUtils.java
@@ -1,23 +1,30 @@
 package com.ruoyi.procurementrecord.utils;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.ruoyi.procurementrecord.mapper.ProcurementRecordMapper;
 import com.ruoyi.procurementrecord.mapper.ProcurementRecordOutMapper;
 import com.ruoyi.stock.dto.StockInRecordDto;
 import com.ruoyi.stock.dto.StockInventoryDto;
 import com.ruoyi.stock.dto.StockUninventoryDto;
 import com.ruoyi.stock.pojo.StockInRecord;
+import com.ruoyi.stock.pojo.StockOutRecord;
 import com.ruoyi.stock.service.StockInRecordService;
 import com.ruoyi.stock.service.StockInventoryService;
+import com.ruoyi.stock.service.StockOutRecordService;
 import com.ruoyi.stock.service.StockUninventoryService;
 import com.ruoyi.stock.service.impl.StockInRecordServiceImpl;
+import com.ruoyi.stock.service.impl.StockOutRecordServiceImpl;
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Component;
 
 import java.math.BigDecimal;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 @Component
 @RequiredArgsConstructor
@@ -27,21 +34,7 @@
     private final StockUninventoryService stockUninventoryService;
     private final StockInventoryService stockInventoryService;
     private final StockInRecordService stockInRecordService;
-
-    // 鑾峰彇鍟嗗搧鍏ュ簱鏁伴噺,鍑哄簱鏁伴噺,鍓╀綑搴撳瓨
-    public Map<String, BigDecimal> getStockQuantity(Long productModelId) {
-        // 鍏ュ簱鏁伴噺
-        BigDecimal sumQuantity = procurementRecordMapper.getSumQuantity(productModelId);
-        // 鍑哄簱鏁伴噺
-        BigDecimal outQuantity = procurementRecordOutMapper.getSumQuantity(productModelId);
-        // 鍓╀綑搴撳瓨
-        BigDecimal stockQuantity = outQuantity.compareTo(sumQuantity) > 0 ? BigDecimal.ZERO : sumQuantity.subtract(outQuantity);
-        Map<String, BigDecimal> stockMap = new HashMap<>();
-        stockMap.put("inboundNum", sumQuantity);
-        stockMap.put("outboundNum", outQuantity);
-        stockMap.put("stockQuantity", stockQuantity);
-        return stockMap;
-    }
+    private final StockOutRecordService stockOutRecordService;
 
     /**
      * 涓嶅悎鏍煎叆搴�
@@ -50,12 +43,13 @@
      * @param recordType
      * @param recordId
      */
-    public void addUnStock(Long productModelId, BigDecimal quantity, Integer recordType,Long recordId) {
+    public void addUnStock(Long productModelId, BigDecimal quantity, String recordType,Long recordId) {
         StockUninventoryDto stockUninventoryDto = new StockUninventoryDto();
         stockUninventoryDto.setRecordId(recordId);
         stockUninventoryDto.setRecordType(String.valueOf(recordType));
         stockUninventoryDto.setQualitity(quantity);
         stockUninventoryDto.setProductModelId(productModelId);
+        stockUninventoryDto.setStockLocation("涓嶅悎鏍煎簱浣�");
         stockUninventoryService.addStockUninventory(stockUninventoryDto);
     }
 
@@ -72,6 +66,7 @@
         stockUninventoryDto.setRecordType(String.valueOf(recordType));
         stockUninventoryDto.setQualitity(quantity);
         stockUninventoryDto.setProductModelId(productModelId);
+        stockUninventoryDto.setStockLocation("涓嶅悎鏍煎簱浣�");
         stockUninventoryService.subtractStockUninventory(stockUninventoryDto);
     }
 
@@ -82,13 +77,19 @@
      * @param recordType
      * @param recordId
      */
-    public void addStock(Long productModelId, BigDecimal quantity, Integer recordType,Long recordId) {
+    public void addStock(Long productModelId,
+                         BigDecimal quantity,
+                         String recordType,
+                         Long recordId,
+                         String stockLocation,
+                         Integer isProduction) {
         StockInventoryDto stockInventoryDto = new StockInventoryDto();
         stockInventoryDto.setRecordId(recordId);
         stockInventoryDto.setRecordType(String.valueOf(recordType));
         stockInventoryDto.setQualitity(quantity);
         stockInventoryDto.setProductModelId(productModelId);
-        stockInventoryService.addstockInventory(stockInventoryDto);
+        stockInventoryDto.setStockLocation(stockLocation);
+        stockInventoryService.addstockInventory(stockInventoryDto,isProduction);
     }
 
     /**
@@ -98,21 +99,31 @@
      * @param recordType
      * @param recordId
      */
-    public void substractStock(Long productModelId, BigDecimal quantity, Integer recordType,Long recordId) {
+    public void substractStock(Long productModelId, BigDecimal quantity, String recordType,Long recordId,String stockLocation) {
         StockInventoryDto stockInventoryDto = new StockInventoryDto();
         stockInventoryDto.setRecordId(recordId);
         stockInventoryDto.setRecordType(String.valueOf(recordType));
         stockInventoryDto.setQualitity(quantity);
         stockInventoryDto.setProductModelId(productModelId);
+        stockInventoryDto.setStockLocation(stockLocation);
         stockInventoryService.subtractStockInventory(stockInventoryDto);
     }
 
     //涓嶅悎鏍煎簱瀛樺垹闄�
-    public void deleteStockRecord(Long recordId, Integer recordType) {
-        StockInRecord one = stockInRecordService.getOne(new QueryWrapper<StockInRecord>()
+    public void deleteStockInRecord(Long recordId, String recordType) {
+        List<StockInRecord> one = stockInRecordService.getBaseMapper().selectList(new QueryWrapper<StockInRecord>()
                 .lambda().eq(StockInRecord::getRecordId, recordId)
                 .eq(StockInRecord::getRecordType, recordType));
-
-        stockInRecordService.batchDelete(Collections.singletonList(one.getId()));
+        if (CollectionUtils.isNotEmpty(one)) {
+            stockInRecordService.batchDelete(one.stream().map(StockInRecord::getId).collect(Collectors.toList()));
+        }
+    }
+    public void deleteStockOutRecord(Long recordId, String recordType) {
+        List<StockOutRecord> one = stockOutRecordService.getBaseMapper().selectList(new QueryWrapper<StockOutRecord>()
+                .lambda().eq(StockOutRecord::getRecordId, recordId)
+                .eq(StockOutRecord::getRecordType, recordType));
+        if (CollectionUtils.isNotEmpty(one)) {
+            stockOutRecordService.batchDelete(one.stream().map(StockOutRecord::getId).collect(Collectors.toList()));
+        }
     }
 }

--
Gitblit v1.9.3