From 5640d1300795c002438962386049bb65fb4f2216 Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期二, 22 九月 2026 18:05:34 +0800
Subject: [PATCH] feat: 采购台账产品层级自动注册与材质字段、大类删除限制、审批模板启用后仅可修改状态

---
 src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
index 171f5ae..b2c002f 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java
@@ -4,6 +4,8 @@
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.basic.pojo.ProductModel;
+import com.ruoyi.basic.service.IProductService;
 import com.ruoyi.framework.web.domain.R;
 import com.ruoyi.procurementrecord.utils.StockUtils;
 import com.ruoyi.production.mapper.*;
@@ -26,6 +28,7 @@
 import com.ruoyi.technology.mapper.TechnologyRoutingMapper;
 import com.ruoyi.technology.pojo.TechnologyRouting;
 import org.apache.commons.lang3.BooleanUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -86,6 +89,8 @@
     private StockUtils stockUtils;
     @Autowired
     private StockInventoryMapper stockInventoryMapper;
+    @Autowired
+    private IProductService productService;
 
     @Override
     public SalesLedgerProduct selectSalesLedgerProductById(Long id) {
@@ -178,6 +183,20 @@
     @Transactional(rollbackFor = Exception.class)
     public int addOrUpdateSalesLedgerProduct(SalesLedgerProduct salesLedgerProduct) {
 
+        // 閲囪喘鍙拌处(type=2)鎵嬪伐褰曞叆鍝佸悕/鏉愯川/瑙勬牸鍨嬪彿鏃讹紝鑷姩娉ㄥ唽鍒颁骇鍝佺淮鎶�
+        if (Integer.valueOf(2).equals(salesLedgerProduct.getType())
+                && StringUtils.isNotBlank(salesLedgerProduct.getMaterial())) {
+            ProductModel productModel = productService.ensureProductHierarchy(
+                    salesLedgerProduct.getProductCategory(),
+                    salesLedgerProduct.getMaterial(),
+                    salesLedgerProduct.getSpecificationModel(),
+                    salesLedgerProduct.getUnit());
+            if (productModel != null) {
+                salesLedgerProduct.setProductId(productModel.getProductId());
+                salesLedgerProduct.setProductModelId(productModel.getId());
+            }
+        }
+
         int result;
         Long salesLedgerId = salesLedgerProduct.getSalesLedgerId();
         if (salesLedgerProduct.getId() == null) {

--
Gitblit v1.9.3