From 2e378480e4920042ce57cc853ed33b35bcd580aa Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 24 九月 2026 17:50:00 +0800
Subject: [PATCH] fix(report): 解决Word报告生成中PNG图片压缩率问题

---
 cnas-process/src/main/resources/mapper/InspectionOrderMapper.xml |   50 +++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 41 insertions(+), 9 deletions(-)

diff --git a/cnas-process/src/main/resources/mapper/InspectionOrderMapper.xml b/cnas-process/src/main/resources/mapper/InspectionOrderMapper.xml
index ba0c03f..2074ad2 100644
--- a/cnas-process/src/main/resources/mapper/InspectionOrderMapper.xml
+++ b/cnas-process/src/main/resources/mapper/InspectionOrderMapper.xml
@@ -5,21 +5,53 @@
     <!--妫�楠屽鎵樺崟鍒嗛〉鏌ヨ-->
     <select id="pageInspectionOrder" resultType="com.ruoyi.process.dto.InspectionOrderDto">
         select *
-        from (select *
-        from cnas_inspection_order
-        order by create_time desc) a
+        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
+            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
+            order by cio.create_time desc
+        ) a
         <if test="ew.customSqlSegment != null and ew.customSqlSegment != ''">
             ${ew.customSqlSegment}
         </if>
     </select>
 
-    <!--濮旀墭鍗曟煡璇㈡垚鍝佽鍗�-->
-    <select id="getInsOrderOnInspection" resultType="com.ruoyi.inspect.pojo.InsOrder">
+    <!--鎴愬搧涓嬪崟閫夋嫨灏氭湭缁戝畾鐨勬楠屽鎵樺崟-->
+    <select id="pageUnboundInspectionOrder" resultType="com.ruoyi.process.pojo.InspectionOrder">
         select *
-        from (select *
-        from ins_order
-        where state = 4 and ifs_inventory_id is null
-        order by entrust_code desc) a
+        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 != ''">
             ${ew.customSqlSegment}
         </if>

--
Gitblit v1.9.3