From 94ec4e9e9214cb5dc28aef4a7f38be462cfda728 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期五, 22 五月 2026 16:50:09 +0800
Subject: [PATCH] fix(product): 产品型号复制功能的进行勾选复制

---
 src/main/resources/mapper/stock/StockOutRecordMapper.xml |   70 ++++++++++++++++++++++++++++++++++
 1 files changed, 69 insertions(+), 1 deletions(-)

diff --git a/src/main/resources/mapper/stock/StockOutRecordMapper.xml b/src/main/resources/mapper/stock/StockOutRecordMapper.xml
index 28e61e4..782f525 100644
--- a/src/main/resources/mapper/stock/StockOutRecordMapper.xml
+++ b/src/main/resources/mapper/stock/StockOutRecordMapper.xml
@@ -18,16 +18,32 @@
     </resultMap>
 
     <select id="listPage" resultType="com.ruoyi.stock.dto.StockOutRecordDto">
+        WITH RECURSIVE product_tree AS (
+        SELECT id
+        FROM product
+        WHERE id = #{params.topParentProductId}
+
+        UNION ALL
+
+        SELECT p.id
+        FROM product p
+        INNER JOIN product_tree pt ON p.parent_id = pt.id
+        )
         SELECT
         sor.*,
         p.product_name as productName,
         pm.model,
         pm.unit,
-        u.nick_name as createBy
+        pm.material_code as materialCode,
+        u.nick_name as createBy,
+        pp.name as processName
         FROM stock_out_record as sor
         LEFT JOIN product_model as pm on sor.product_model_id = pm.id
         LEFT JOIN product as p on pm.product_id = p.id
         LEFT JOIN sys_user as u on sor.create_user = u.user_id
+        LEFT JOIN production_product_main as ppm on sor.record_type = '3' and ppm.id = sor.record_id
+        LEFT JOIN product_process_route_item as ppri on ppri.id = ppm.product_process_route_item_id
+        LEFT JOIN product_process as pp on pp.id = ppri.process_id
         <where>
             <if test="params.timeStr != null and params.timeStr != ''">
                 and sor.create_time like concat('%',#{params.timeStr},'%')
@@ -38,6 +54,58 @@
             <if test="params.type != null and params.type != ''">
                 and sor.type = #{params.type}
             </if>
+            <if test="params.recordType != null and params.recordType != ''">
+                and sor.record_type = #{params.recordType}
+            </if>
+            <if test="params.topParentProductId != null and params.topParentProductId > 0">
+                and p.id in (select id from product_tree)
+            </if>
+        </where>
+        order by sor.id desc
+    </select>
+    <select id="listStockOutRecordExportData" resultType="com.ruoyi.stock.execl.StockOutRecordExportData">
+        WITH RECURSIVE product_tree AS (
+        SELECT id
+        FROM product
+        WHERE id = #{params.topParentProductId}
+
+        UNION ALL
+
+        SELECT p.id
+        FROM product p
+        INNER JOIN product_tree pt ON p.parent_id = pt.id
+        )
+        SELECT
+        sor.*,
+        p.product_name as productName,
+        pm.model,
+        pm.unit,
+        pm.material_code as materialCode,
+        u.nick_name as createBy,
+        pp.name as processName
+        FROM stock_out_record as sor
+        LEFT JOIN product_model as pm on sor.product_model_id = pm.id
+        LEFT JOIN product as p on pm.product_id = p.id
+        LEFT JOIN sys_user as u on sor.create_user = u.user_id
+        LEFT JOIN production_product_main as ppm on sor.record_type = '3' and ppm.id = sor.record_id
+        LEFT JOIN product_process_route_item as ppri on ppri.id = ppm.product_process_route_item_id
+        LEFT JOIN product_process as pp on pp.id = ppri.process_id
+        <where>
+            <if test="params.timeStr != null and params.timeStr != ''">
+                and sor.create_time like concat('%',#{params.timeStr},'%')
+            </if>
+            <if test="params.productName != null and params.productName != ''">
+                and p.product_name like concat('%',#{params.productName},'%')
+            </if>
+            <if test="params.type != null and params.type != ''">
+                and sor.type = #{params.type}
+            </if>
+            <if test="params.recordType != null and params.recordType != ''">
+                and sor.record_type = #{params.recordType}
+            </if>
+            <if test="params.topParentProductId != null and params.topParentProductId > 0">
+                and p.id in (select id from product_tree)
+            </if>
         </where>
         order by sor.id desc
     </select>

--
Gitblit v1.9.3