From 9f6a65e7f4b87b0e27e7d2949b4e42f40419b2ff Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期日, 20 九月 2026 09:19:53 +0800
Subject: [PATCH] chore: 桓海电子配置文件

---
 src/main/resources/mapper/quality/QualityTestStandardMapper.xml |   39 +++++++++++++++++++++++++++++----------
 1 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/src/main/resources/mapper/quality/QualityTestStandardMapper.xml b/src/main/resources/mapper/quality/QualityTestStandardMapper.xml
index b9ad8ed..b72b649 100644
--- a/src/main/resources/mapper/quality/QualityTestStandardMapper.xml
+++ b/src/main/resources/mapper/quality/QualityTestStandardMapper.xml
@@ -13,23 +13,42 @@
         <if test="c.standardName != null and c.standardName != '' ">
             AND standard_name like concat('%',#{c.standardName},'%')
         </if>
-        <if test="c.state != null and c.state != '' ">
+        <if test="c.state != null ">
             AND state =#{c.state}
         </if>
-        <if test="c.inspectType != null and c.inspectType != '' ">
+        <if test="c.inspectType != null ">
             AND inspect_type =#{c.inspectType}
         </if>
     </select>
-    <select id="getQualityTestStandardByProductId" resultType="com.ruoyi.quality.pojo.QualityTestStandard">
-        SELECT qts.*
+    <select id="getQualityTestStandardByProductId" resultType="com.ruoyi.quality.dto.QualityTestStandardDto">
+        SELECT DISTINCT qts.*, pm.model as product_model
         FROM quality_test_standard qts
                  left join quality_test_standard_binding qtsb on qtsb.test_standard_id = qts.id
-                 left join product_process pp on qts.process_id = pp.id
-        WHERE qtsb.product_id = #{productId}
-          AND qts.inspect_type = #{inspectType}
-        <if test="process!='' and process!=null">
-            and pp.name = #{process}
+                 left join technology_operation toper on qts.process_id = toper.id
+                 left join product_model pm on qtsb.product_model_id = pm.id
+        WHERE qts.inspect_type = #{inspectType}
+          AND (
+              qtsb.product_id = #{productId}
+              or qtsb.product_id in (
+                  WITH RECURSIVE product_parent AS (
+                      SELECT parent_id
+                      FROM product
+                      WHERE id = #{productId} AND parent_id IS NOT NULL
+                      UNION ALL
+                      SELECT p.parent_id
+                      FROM product p
+                      INNER JOIN product_parent pp ON p.id = pp.parent_id
+                      WHERE p.parent_id IS NOT NULL
+                  )
+                  SELECT parent_id FROM product_parent
+              )
+          )
+        <if test="productModelId != null">
+            and (qtsb.product_model_id is null or qtsb.product_model_id = #{productModelId})
         </if>
-        order by qts.id desc
+        <if test="process!='' and process!=null">
+            and toper.name = #{process}
+        </if>
+        order by qtsb.product_model_id is not null, qts.id desc
     </select>
 </mapper>

--
Gitblit v1.9.3