From f350465db70d6f9db9494483ee0cec7793a9007b Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 19 八月 2026 17:47:57 +0800
Subject: [PATCH] feat(approve): 实现审批流程或签会签功能并优化数据库配置

---
 src/main/resources/mapper/quality/QualityInspectMapper.xml |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/main/resources/mapper/quality/QualityInspectMapper.xml b/src/main/resources/mapper/quality/QualityInspectMapper.xml
index a9ebc19..3e01e97 100644
--- a/src/main/resources/mapper/quality/QualityInspectMapper.xml
+++ b/src/main/resources/mapper/quality/QualityInspectMapper.xml
@@ -20,7 +20,7 @@
             </when>
             <otherwise>
                 LEFT JOIN production_product_main ppm ON qi.product_main_id = ppm.id
-                LEFT JOIN product_work_order pwo ON ppm.work_order_id = pwo.id
+                LEFT JOIN product_work_order pwo ON pwo.id = COALESCE(qi.work_order_id, ppm.work_order_id)
             </otherwise>
         </choose>
         WHERE
@@ -43,7 +43,11 @@
         <if test="qualityInspect.entryDateEnd != null and qualityInspect.entryDateEnd != '' ">
             AND qi.check_time &lt;= DATE_FORMAT(#{qualityInspect.entryDateEnd},'%Y-%m-%d')
         </if>
-        ORDER BY qi.check_time DESC
+        ORDER BY
+        CASE WHEN qi.check_result IS NULL OR qi.check_result = '' THEN 0 ELSE 1 END,
+        inspect_state,
+        qi.check_time DESC,
+        qi.id DESC
     </select>
 
     <select id="qualityInspectExport" resultType="com.ruoyi.quality.pojo.QualityInspect">
@@ -84,7 +88,7 @@
             </when>
             <otherwise>
                 LEFT JOIN production_product_main ppm ON qi.product_main_id = ppm.id
-                LEFT JOIN product_work_order pwo ON ppm.work_order_id = pwo.id
+                LEFT JOIN product_work_order pwo ON pwo.id = COALESCE(qi.work_order_id, ppm.work_order_id)
             </otherwise>
         </choose>
         WHERE qi.inspect_type=#{qualityInspect.inspectType}

--
Gitblit v1.9.3