From 5c891d8d2c206dfd2aa6daf59579eb2b6843dcc0 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期三, 01 四月 2026 18:00:37 +0800
Subject: [PATCH] fix:1.采购/销售入库去掉审批 2.返工下载附件内容变更 3.生产/库存入库生产日期添加 4.仓库导入导出字段优化

---
 src/main/resources/mapper/stock/StockInventoryMapper.xml |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/src/main/resources/mapper/stock/StockInventoryMapper.xml b/src/main/resources/mapper/stock/StockInventoryMapper.xml
index d592b11..f373f79 100644
--- a/src/main/resources/mapper/stock/StockInventoryMapper.xml
+++ b/src/main/resources/mapper/stock/StockInventoryMapper.xml
@@ -52,6 +52,21 @@
         where product_model_id = #{ew.productModelId} and qualitity >= #{ew.qualitity}
     </update>
     <select id="pagestockInventory" resultType="com.ruoyi.stock.dto.StockInventoryDto">
+        WITH RECURSIVE get_root AS (
+        SELECT
+        id,
+        parent_id,
+        id AS root_id
+        FROM product
+        WHERE parent_id IS NULL  -- 鏍硅妭鐐�
+        UNION ALL
+        SELECT
+        p.id,
+        p.parent_id,
+        gr.root_id
+        FROM product p
+        INNER JOIN get_root gr ON p.parent_id = gr.id
+        )
         SELECT
         si.id,
         si.qualitity,
@@ -68,12 +83,15 @@
         pm.uid_no AS uidNo,
         p.product_name,
         si.batch_no,
-        si.customer
+        si.customer,
+        rp.product_name AS root_product_name,
+        si.production_date
         FROM
         stock_inventory si
         LEFT JOIN product_model pm ON si.product_model_id = pm.id
         LEFT JOIN product p ON pm.product_id = p.id
-        LEFT JOIN product p1 ON p.parent_id = p1.id
+        LEFT JOIN get_root gr ON gr.id = p.id
+        LEFT JOIN product rp ON rp.id = gr.root_id
         <where>
             <if test="ew.productName != null and ew.productName != ''">
                 AND p.product_name LIKE CONCAT('%', #{ew.productName}, '%')
@@ -90,10 +108,10 @@
             <if test="ew.productScope != null and ew.productScope != ''">
                 <choose>
                     <when test="ew.productScope == '鎴愬搧'">
-                        AND p1.product_name = #{ew.productScope}
+                        AND rp.product_name = '鎴愬搧'
                     </when>
                     <otherwise>
-                        AND p1.product_name != '鎴愬搧'
+                        AND rp.product_name != '鎴愬搧'
                     </otherwise>
                 </choose>
             </if>
@@ -103,6 +121,10 @@
         select si.qualitity,
         pm.model,
         pm.unit,
+        si.batchNo,
+        pm.uid_no,
+        si.production_date,
+        si.customer,
         p.product_name,
         coalesce(si.warn_num, 0) as warn_num,
         coalesce(si.locked_quantity, 0) as locked_quantity,

--
Gitblit v1.9.3