From 23ec64ed997fc206fba9f0d6a84975f7b36c47be Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期日, 11 十月 2026 16:09:26 +0800
Subject: [PATCH] 天津-奇缘恒艺 录数据需求修改

---
 src/main/java/com/ruoyi/sales/service/impl/SalesLedgerProductServiceImpl.java |   17 +++++++++++++++++
 1 files changed, 17 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..66285d4 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,18 @@
     @Transactional(rollbackFor = Exception.class)
     public int addOrUpdateSalesLedgerProduct(SalesLedgerProduct salesLedgerProduct) {
 
+        // 閿�鍞彴璐�(type=1)鎵嬪伐褰曞叆浜у搧澶х被/瑙勬牸鍨嬪彿鏃讹紝鑷姩娉ㄥ唽鍒颁骇鍝佺淮鎶わ紙缁熶竴鎸傘�屾垚鍝併�嶅ぇ绫讳笅锛�
+        if (Integer.valueOf(1).equals(salesLedgerProduct.getType())) {
+            ProductModel productModel = productService.ensureProductHierarchy(
+                    salesLedgerProduct.getProductCategory(),
+                    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