From 6665597fc7f2fa201d584d796cc628c14e46bb1e Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期六, 14 三月 2026 14:30:08 +0800
Subject: [PATCH] feat: 新增产品参数配置模块及CRUD接口

---
 src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java |   35 +++++++++++++++++++++++++++++------
 1 files changed, 29 insertions(+), 6 deletions(-)

diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
index 3a42fc7..fe3e20b 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -24,20 +24,18 @@
 import com.ruoyi.other.mapper.TempFileMapper;
 import com.ruoyi.other.pojo.TempFile;
 import com.ruoyi.production.mapper.*;
-import com.ruoyi.production.pojo.*;
 import com.ruoyi.production.service.ProductionProductMainService;
-import com.ruoyi.production.service.impl.ProductionProductMainServiceImpl;
 import com.ruoyi.project.system.domain.SysDept;
 import com.ruoyi.project.system.domain.SysUser;
 import com.ruoyi.project.system.mapper.SysDeptMapper;
 import com.ruoyi.project.system.mapper.SysUserMapper;
 import com.ruoyi.quality.mapper.QualityInspectMapper;
-import com.ruoyi.quality.pojo.QualityInspect;
 import com.ruoyi.sales.dto.*;
 import com.ruoyi.sales.mapper.*;
 import com.ruoyi.sales.pojo.*;
-import com.ruoyi.sales.service.ISalesLedgerProductService;
 import com.ruoyi.sales.service.ISalesLedgerService;
+import com.ruoyi.stock.dto.StockInventoryDto;
+import com.ruoyi.stock.mapper.StockInventoryMapper;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FilenameUtils;
@@ -129,6 +127,9 @@
     private final ProductionProductInputMapper productionProductInputMapper;
 
     private final QualityInspectMapper qualityInspectMapper;
+
+    private final StockInventoryMapper stockInventoryMapper;
+
 
     @Autowired
     private SysDeptMapper sysDeptMapper;
@@ -708,9 +709,26 @@
         List<SalesLedgerProduct> updateList = partitionedProducts.get(true);
         List<SalesLedgerProduct> insertList = partitionedProducts.get(false);
 
+        List<StockInventoryDto> stockInventoryDtos = stockInventoryMapper.selectProductList();
+
         // 鎵ц鏇存柊鎿嶄綔
         if (!updateList.isEmpty()) {
             for (SalesLedgerProduct product : updateList) {
+                // 鏌ヨ搴撳瓨鏁伴噺
+                SalesLedgerProduct oldProduct = salesLedgerProductMapper.selectById(product.getId());
+                BigDecimal quantityChange = product.getQuantity().subtract(oldProduct.getQuantity());
+
+                // 濡傛灉鏁伴噺澧炲姞浜嗭紝妫�鏌ュ簱瀛�
+                if (quantityChange.compareTo(BigDecimal.ZERO) > 0) {
+                    for (StockInventoryDto stockInventoryDto : stockInventoryDtos) {
+                        if (stockInventoryDto.getProductId().equals(product.getId())) {
+                            if (quantityChange.compareTo(stockInventoryDto.getQualitity()) > 0) {
+                                throw new RuntimeException("搴撳瓨涓嶈冻");
+                            }
+                            break;
+                        }
+                    }
+                }
                 product.setType(type);
                 salesLedgerProductMapper.updateById(product);
             }
@@ -718,13 +736,18 @@
         // 鎵ц鎻掑叆鎿嶄綔
         if (!insertList.isEmpty()) {
             for (SalesLedgerProduct salesLedgerProduct : insertList) {
+                for (StockInventoryDto stockInventoryDto : stockInventoryDtos) {
+                    if (stockInventoryDto.getProductId().equals(salesLedgerProduct.getId())) {
+                        if (salesLedgerProduct.getQuantity().compareTo(stockInventoryDto.getQualitity()) > 0) {
+                            throw new RuntimeException("搴撳瓨涓嶈冻");
+                        }
+                    }
+                }
                 salesLedgerProduct.setType(type);
                 salesLedgerProduct.setNoInvoiceNum(salesLedgerProduct.getQuantity());
                 salesLedgerProduct.setNoInvoiceAmount(salesLedgerProduct.getTaxInclusiveTotalPrice());
                 salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProduct.getTaxInclusiveTotalPrice());
                 salesLedgerProductMapper.insert(salesLedgerProduct);
-                // 娣诲姞鐢熶骇鏁版嵁
-                salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct);
             }
         }
     }

--
Gitblit v1.9.3