From 266ca8c80300d479351eed50fee5a30751a22fda Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期四, 09 十月 2025 11:46:11 +0800
Subject: [PATCH] 1、中空领取任务界面查询慢解决 2、卧理新增日志记录

---
 hangzhoumesParent/moduleService/hollowGlassModule/src/main/resources/mapper/HollowBigStorageCageDetailsMapper.xml |  121 +++++++++++++++++++---------------------
 1 files changed, 58 insertions(+), 63 deletions(-)

diff --git a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/resources/mapper/HollowBigStorageCageDetailsMapper.xml b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/resources/mapper/HollowBigStorageCageDetailsMapper.xml
index d01fb36..dda21d7 100644
--- a/hangzhoumesParent/moduleService/hollowGlassModule/src/main/resources/mapper/HollowBigStorageCageDetailsMapper.xml
+++ b/hangzhoumesParent/moduleService/hollowGlassModule/src/main/resources/mapper/HollowBigStorageCageDetailsMapper.xml
@@ -50,77 +50,72 @@
     </update>
 
     <select id="hollowIsAll" resultMap="baseMap">
-        WITH sum_flow_layer_count AS ( SELECT flow_card_id, layer, min( films_id ) AS films_id, min(thickness) as
-        thickness,count(*) AS sum_count FROM hollow_glass_relation_info GROUP BY flow_card_id, layer ),
-        real_flow_layer_count AS ( SELECT flow_card_id, layer, count(*) AS real_count, count(distinct slot) as
-        slot_count FROM
-        hollow_big_storage_cage_details t WHERE state = 100 GROUP BY flow_card_id, layer ),
-        damage_flow_layer_count AS ( SELECT process_id AS flow_card_id, technology_number AS layer, count(*) as
-        damage_count FROM damage where type in(8,9) GROUP BY process_id, technology_number ),
-        lack_flow_layer_count AS (
+        WITH flow_layer_stats AS (
         SELECT
-        t.flow_card_id,
-        t.layer,
-        ifnull((sum_count - real_count - ifnull(damage_count,0)),0) AS lack_count
-        FROM
-        sum_flow_layer_count t
-        left JOIN real_flow_layer_count t1 ON t.flow_card_id = t1.flow_card_id
-        AND t.layer = t1.layer
-        left JOIN damage_flow_layer_count t2 ON t1.flow_card_id = t2.flow_card_id
-        AND t1.layer = t2.layer
+        h.flow_card_id,
+        h.layer,
+        MIN(r.films_id) AS films_id,
+        MIN(r.thickness) AS thickness,
+        COUNT(*) AS sum_count,
+        COUNT(DISTINCT h.slot) AS slot_count,
+        SUM(CASE WHEN h.state = 100 THEN 1 ELSE 0 END) AS real_count
+        FROM hollow_glass_relation_info r
+        LEFT JOIN hollow_big_storage_cage_details h
+        ON r.flow_card_id = h.flow_card_id AND r.layer = h.layer
+        WHERE r.flow_card_id = #{flowCardId}
+        GROUP BY h.flow_card_id, h.layer
         ),
-        layer_one AS ( SELECT * FROM hollow_big_storage_cage_details WHERE layer = 1 AND state = 100 ),
-        layer_two AS ( SELECT * FROM hollow_big_storage_cage_details WHERE layer = 2 AND state = 100),
-        layer_three AS ( SELECT * FROM hollow_big_storage_cage_details WHERE layer = 3 AND state = 100 )
-        ,
-        pair_flow_layer_count AS (
+        damage_stats AS (
         SELECT
-        t.flow_card_id,
-        count(*) AS pair_count
-        FROM
-        layer_one t
-        INNER JOIN layer_two t1 ON t.flow_card_id = t1.flow_card_id
-        AND t.virtual_slot = t1.virtual_slot
-        AND t.sequence = t1.sequence
+        process_id AS flow_card_id,
+        technology_number AS layer,
+        COUNT(*) AS damage_count
+        FROM damage
+        WHERE type IN (8,9) AND process_id = #{flowCardId}
+        GROUP BY process_id, technology_number
+        ),
+        pair_stats AS (
+        SELECT
+        t1.flow_card_id,
+        COUNT(*) AS pair_count
+        FROM hollow_big_storage_cage_details t1
+        INNER JOIN hollow_big_storage_cage_details t2
+        ON t1.flow_card_id = t2.flow_card_id
+        AND t1.virtual_slot = t2.virtual_slot
+        AND t1.sequence = t2.sequence
+        AND t1.layer = 1 AND t2.layer = 2
+        AND t1.state = 100 AND t2.state = 100
         <if test="totalLayer == 3">
-            inner join layer_three t2
-            on t.flow_card_id = t2.flow_card_id and
-            t.virtual_slot = t2.virtual_slot and t.sequence = t2.sequence
+            INNER JOIN hollow_big_storage_cage_details t3
+            ON t1.flow_card_id = t3.flow_card_id
+            AND t1.virtual_slot = t3.virtual_slot
+            AND t1.sequence = t3.sequence
+            AND t3.layer = 3 AND t3.state = 100
         </if>
-        GROUP BY
-        t.flow_card_id
-        ),
-        result_flow_layer_count AS (
+        WHERE t1.flow_card_id = #{flowCardId}
+        GROUP BY t1.flow_card_id
+        )
         SELECT
-        t.flow_card_id,
-        t.layer,
-        t.films_id,
-        t.thickness,
-        sum_count,
-        IFNULL( t3.pair_count, 0 ) AS pair_count,
-        IFNULL( real_count, 0 ) AS real_count,
-        IFNULL( damage_count, 0 ) AS damage_count,
-        IFNULL( lack_count, 0 ) AS lack_count,
-        IFNULL(slot_count,0) AS slot_count
-        FROM
-        sum_flow_layer_count t
-        LEFT JOIN real_flow_layer_count t1 ON t.flow_card_id = t1.flow_card_id
-        AND t.layer = t1.layer
-        LEFT JOIN lack_flow_layer_count t2 ON t.flow_card_id = t2.flow_card_id
-        AND t.layer = t2.layer
-        LEFT JOIN pair_flow_layer_count t3 ON t.flow_card_id = t3.flow_card_id
-        LEFT JOIN damage_flow_layer_count t4 ON t.flow_card_id = t4.flow_card_id
-        AND t.layer = t4.layer
-        ) SELECT
-        *
-        FROM
-        result_flow_layer_count
-        WHERE
-        flow_card_id = #{flowCardId}
+        f.flow_card_id,
+        f.layer,
+        f.films_id,
+        f.thickness,
+        f.sum_count,
+        COALESCE(p.pair_count, 0) AS pair_count,
+        COALESCE(f.real_count, 0) AS real_count,
+        COALESCE(d.damage_count, 0) AS damage_count,
+        (f.sum_count - COALESCE(f.real_count, 0) - COALESCE(d.damage_count, 0)) AS lack_count,
+        f.slot_count
+        FROM flow_layer_stats f
+        LEFT JOIN damage_stats d
+        ON f.flow_card_id = d.flow_card_id AND f.layer = d.layer
+        LEFT JOIN pair_stats p
+        ON f.flow_card_id = p.flow_card_id
+        WHERE 1=1
         <if test="flag == true">
-            and sum_count = pair_count
+            AND f.sum_count = COALESCE(p.pair_count, 0)
         </if>
-        order by layer
+        ORDER BY f.layer;
     </select>
 
     <select id="queryIsAllNeedDispatchVirtualSlot" resultMap="virtualSlotSequenceDTO">

--
Gitblit v1.8.0