From 743b74dfa59b05cb4bafe8678d8a6223a283ad03 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期一, 29 六月 2026 02:18:42 +0800
Subject: [PATCH] fix: 质检合格率有误

---
 src/main/resources/mapper/stock/StockInRecordMapper.xml |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/src/main/resources/mapper/stock/StockInRecordMapper.xml b/src/main/resources/mapper/stock/StockInRecordMapper.xml
index f9c2b44..5bf1b58 100644
--- a/src/main/resources/mapper/stock/StockInRecordMapper.xml
+++ b/src/main/resources/mapper/stock/StockInRecordMapper.xml
@@ -34,6 +34,16 @@
             <if test="params.productName != null and params.productName != ''">
                 and p.product_name like concat('%',#{params.productName},'%')
             </if>
+            <if test="params.topParentProductId != null and params.topParentProductId > 0">
+                and p.id in (
+                    WITH RECURSIVE product_tree AS (
+                        SELECT id FROM product WHERE id = #{params.topParentProductId}
+                        UNION ALL
+                        SELECT p2.id FROM product p2 INNER JOIN product_tree pt ON p2.parent_id = pt.id
+                    )
+                    SELECT id FROM product_tree
+                )
+            </if>
             <if test="params.salesContractNo != null and params.salesContractNo != ''">
                 and (
                     (sir.record_type IN ('6', '7', '18', '19', '20') and pl.purchase_contract_number like concat('%',#{params.salesContractNo},'%'))
@@ -48,13 +58,14 @@
                 and sir.record_type = #{params.recordType}
             </if>
         </where>
-        order by sir.id desc
+        order by sir.inbound_batches desc
     </select>
     <select id="listStockInRecordExportData" resultType="com.ruoyi.stock.execl.StockInRecordExportData">
         SELECT
         sir.*,
         p.product_name as product_name,
         pm.model,
+        pm.thickness,
         pm.unit,
         u.nick_name as createBy,
         CASE
@@ -81,6 +92,16 @@
             <if test="params.productName != null and params.productName != ''">
                 and p.product_name like concat('%',#{params.productName},'%')
             </if>
+            <if test="params.topParentProductId != null and params.topParentProductId > 0">
+                and p.id in (
+                    WITH RECURSIVE product_tree AS (
+                        SELECT id FROM product WHERE id = #{params.topParentProductId}
+                        UNION ALL
+                        SELECT p2.id FROM product p2 INNER JOIN product_tree pt ON p2.parent_id = pt.id
+                    )
+                    SELECT id FROM product_tree
+                )
+            </if>
             <if test="params.salesContractNo != null and params.salesContractNo != ''">
                 and (
                     (sir.record_type IN ('6', '7', '18', '19', '20') and pl.purchase_contract_number like concat('%',#{params.salesContractNo},'%'))

--
Gitblit v1.9.3