From 0debf5b7bb0246eaef1397975cdb16f4adb9e8d9 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 29 十月 2026 14:36:31 +0800
Subject: [PATCH] refactor(inspection-order): 1.检验委托单绑定机制支持多次下单 2.合格率统计口径调整 3.外购铜导体推送入库MES增加米重 4.报告英文字段调整

---
 cnas-process/src/main/resources/mapper/InspectionOrderMapper.xml |   45 +++++++++++++++------------------------------
 1 files changed, 15 insertions(+), 30 deletions(-)

diff --git a/cnas-process/src/main/resources/mapper/InspectionOrderMapper.xml b/cnas-process/src/main/resources/mapper/InspectionOrderMapper.xml
index 2074ad2..b54745f 100644
--- a/cnas-process/src/main/resources/mapper/InspectionOrderMapper.xml
+++ b/cnas-process/src/main/resources/mapper/InspectionOrderMapper.xml
@@ -2,40 +2,26 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.process.mapper.InspectionOrderMapper">
 
+    <select id="selectByIdForUpdate" resultType="com.ruoyi.process.pojo.InspectionOrder">
+        select *
+        from cnas_inspection_order
+        where inspection_order_id = #{inspectionOrderId}
+        for update
+    </select>
+
     <!--妫�楠屽鎵樺崟鍒嗛〉鏌ヨ-->
     <select id="pageInspectionOrder" resultType="com.ruoyi.process.dto.InspectionOrderDto">
         select *
         from (
             select cio.*,
-                   case when cio.ins_order_id is null then 0 else 1 end as binding_status,
-                   io.state as order_state,
-                   io.ins_result as ins_result,
-                   case
-                       when cio.ins_order_id is null then null
-                       when total_product_counts.total_count is null or total_product_counts.total_count = 0 then '0%'
-                       else concat(round(ifnull(approved_product_counts.approved_count, 0) / total_product_counts.total_count * 100, 2), '%')
-                   end as ins_progress,
-                   case
-                       when cio.file_url is not null and trim(cio.file_url) != '' then 2
-                       when approved_report.id is not null then 1
-                       else 0
-                   end as report_status
+                   ifnull(binding_counts.binding_count, 0) as binding_count,
+                   case when ifnull(binding_counts.binding_count, 0) = 0 then 0 else 1 end as binding_status
             from cnas_inspection_order cio
-                     left join ins_order io on cio.ins_order_id = io.id
-                     left join (select max(id) as id, ins_order_id
-                                from ins_report
-                                where is_ratify = 1
-                                group by ins_order_id) approved_report on approved_report.ins_order_id = io.id
-                     left join (select ins_sample.ins_order_id, count(*) as total_count
-                                from ins_product
-                                         join ins_sample on ins_product.ins_sample_id = ins_sample.id
-                                where ins_product.state = 1
-                                group by ins_sample.ins_order_id) total_product_counts on total_product_counts.ins_order_id = io.id
-                     left join (select ins_sample.ins_order_id, count(*) as approved_count
-                                from ins_product
-                                         join ins_sample on ins_product.ins_sample_id = ins_sample.id
-                                where ins_product.state = 1 and ins_product.ins_result is not null
-                                group by ins_sample.ins_order_id) approved_product_counts on approved_product_counts.ins_order_id = io.id
+                     left join (select inspection_order_id, count(*) as binding_count
+                                from cnas_inspection_order_binding
+                                where order_deleted = 0
+                                group by inspection_order_id) binding_counts
+                               on binding_counts.inspection_order_id = cio.inspection_order_id
             order by cio.create_time desc
         ) a
         <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
@@ -43,13 +29,12 @@
         </if>
     </select>
 
-    <!--鎴愬搧涓嬪崟閫夋嫨灏氭湭缁戝畾鐨勬楠屽鎵樺崟-->
+    <!--鍏煎鍘熸帴鍙e悕锛氬娆$粦瀹氬悗锛屾墍鏈夊鎵樺崟鍧囧彲渚涙垚鍝佷笅鍗曢�夋嫨銆�-->
     <select id="pageUnboundInspectionOrder" resultType="com.ruoyi.process.pojo.InspectionOrder">
         select *
         from (
             select *
             from cnas_inspection_order
-            where ins_order_id is null
             order by create_time desc
         ) a
         <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">

--
Gitblit v1.9.3