From 46e131d4388bab568e3078b7beb046c57ba67375 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期四, 05 十二月 2024 13:59:25 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 hangzhoumesParent/moduleService/howllowGlassModule/src/main/resources/mapper/HollowBigStorageCageDetailsMapper.xml |  146 ++++++++++++++++++++++++++++--------------------
 1 files changed, 84 insertions(+), 62 deletions(-)

diff --git a/hangzhoumesParent/moduleService/howllowGlassModule/src/main/resources/mapper/HollowBigStorageCageDetailsMapper.xml b/hangzhoumesParent/moduleService/howllowGlassModule/src/main/resources/mapper/HollowBigStorageCageDetailsMapper.xml
index c8d05a5..33b44fd 100644
--- a/hangzhoumesParent/moduleService/howllowGlassModule/src/main/resources/mapper/HollowBigStorageCageDetailsMapper.xml
+++ b/hangzhoumesParent/moduleService/howllowGlassModule/src/main/resources/mapper/HollowBigStorageCageDetailsMapper.xml
@@ -14,6 +14,7 @@
     </resultMap>
     <resultMap id="virtualSlotSequenceDTO" type="com.mes.hollow.entity.dto.FlowCardVirtualSlotDTO">
         <result column="flow_card_id" property="flowCardId"/>
+        <result column="layer" property="layer"/>
         <result column="virtual_slot" property="virtualSlot"/>
     </resultMap>
     <resultMap id="baseSlotSequenceDTO" type="com.mes.hollow.entity.dto.BigStorageSequenceDTO">
@@ -38,52 +39,25 @@
     </update>
 
     <select id="hollowIsAll" resultMap="baseMap">
-        WITH sum_flow_layer_count AS (
-        SELECT
-        flow_card_id,
-        layer,
-        min( films_id ) AS films_id,
-        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
-        FROM
-        hollow_glass_relation_info
-        WHERE
-        tempering_layout_id IS NOT NULL
-        AND tempering_feed_sequence IS NOT NULL
-        GROUP BY
-        flow_card_id,
-        layer
-        ),
-        damage_flow_layer_count AS ( SELECT process_id AS flow_card_id, technology_number AS layer, count(*)
-        damage_count FROM damage GROUP BY process_id, technology_number ),
+        WITH sum_flow_layer_count AS ( SELECT flow_card_id, layer, min( films_id ) AS films_id, 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 FROM hollow_glass_relation_info WHERE tempering_layout_id IS NOT NULL AND tempering_feed_sequence IS NOT NULL 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 GROUP BY process_id, technology_number )
+        ,
         lack_flow_layer_count AS (
         SELECT
         t.flow_card_id,
         t.layer,
-        ( sum_count - real_count - damage_count ) AS lack_count
+        ifnull((sum_count - real_count - ifnull(damage_count,0)),0) AS lack_count
         FROM
         sum_flow_layer_count t
-        INNER JOIN real_flow_layer_count t1 ON t.flow_card_id = t1.flow_card_id
+        left JOIN real_flow_layer_count t1 ON t.flow_card_id = t1.flow_card_id
         AND t.layer = t1.layer
-        INNER JOIN damage_flow_layer_count t2 ON t1.flow_card_id = t2.flow_card_id
+        left JOIN damage_flow_layer_count t2 ON t1.flow_card_id = t2.flow_card_id
         AND t1.layer = t2.layer
         ),
-        layer_one AS ( SELECT * FROM hollow_glass_relation_info WHERE layer = 1 AND tempering_layout_id IS NOT NULL AND
-        tempering_feed_sequence IS NOT NULL ),
-        layer_two AS ( SELECT * FROM hollow_glass_relation_info WHERE layer = 2 AND tempering_layout_id IS NOT NULL AND
-        tempering_feed_sequence IS NOT NULL ),
-        layer_three AS ( SELECT * FROM hollow_glass_relation_info WHERE layer = 3 AND tempering_layout_id IS NOT NULL
-        AND tempering_feed_sequence IS NOT NULL )
+        layer_one AS ( SELECT * FROM hollow_glass_relation_info WHERE layer = 1 AND tempering_layout_id IS NOT NULL AND tempering_feed_sequence IS NOT NULL ),
+        layer_two AS ( SELECT * FROM hollow_glass_relation_info WHERE layer = 2 AND tempering_layout_id IS NOT NULL AND tempering_feed_sequence IS NOT NULL ),
+        layer_three AS ( SELECT * FROM hollow_glass_relation_info WHERE layer = 3 AND tempering_layout_id IS NOT NULL AND tempering_feed_sequence IS NOT NULL )
         ,
         pair_flow_layer_count AS (
         SELECT
@@ -101,25 +75,25 @@
         </if>
         GROUP BY
         t.flow_card_id
-        )
-        ,result_flow_layer_count AS (
+        ),
+        result_flow_layer_count AS (
         SELECT
         t.flow_card_id,
         t.layer,
         t.films_id,
         sum_count,
-        t3.pair_count,
-        IFNULL(real_count,0) as real_count,
-        IFNULL(damage_count,0) as damage_count,
-        IFNULL(lack_count,0) as lack_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
         FROM
         sum_flow_layer_count t
-        left JOIN real_flow_layer_count t1 ON t.flow_card_id = t1.flow_card_id
+        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
+        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
+        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
         *
@@ -135,40 +109,88 @@
 
     <select id="queryIsAllNeedDispatchVirtualSlot" resultMap="virtualSlotSequenceDTO">
         with relation_temp as (
-            select flow_card_id, virtual_slot, count(1) as slot_count
+            select flow_card_id, layer, virtual_slot, count(1) as slot_count
             from hollow_glass_relation_info
-            group by flow_card_id, virtual_slot
+            group by flow_card_id, layer, virtual_slot
         ),
              details_temp as (
-                 select flow_card_id, virtual_slot, count(1) as slot_count
+                 select flow_card_id, layer, virtual_slot, count(1) as slot_count
                  from hollow_big_storage_cage_details
                  where state = 100
-                 group by flow_card_id, virtual_slot
+                 group by flow_card_id, layer, virtual_slot
              ),
              result_one as (
                  select t.*, t1.slot_count as tslot_count
                  from relation_temp t
                           INNER JOIN details_temp t1 on t.flow_card_id = t1.flow_card_id and
+                                                        t.layer = t1.layer and
                                                         t.virtual_slot = t1.virtual_slot
                  where t.slot_count = t1.slot_count
              )
-        select flow_card_id, virtual_slot
+        select flow_card_id, layer, virtual_slot
         from result_one
-        order by flow_card_id, virtual_slot
+        order by flow_card_id, layer, virtual_slot
     </select>
 
     <select id="queryNeedDispatchSlot" resultMap="baseSlotSequenceDTO">
-        with glass_id_temp as (
-            select glass_id
-            from big_storage_glass_relation_info
-            where (flow_card_id, virtual_slot) =
-                  (#{flowCardId}, #{virtualSlot})
-        )
         select slot, max(sequence) as max_sequence, min(sequence) as min_sequence
-        from big_storage_cage_details
-        where glass_id in (select * from glass_id_temp)
-          and state = 100
+        from hollow_big_storage_cage_details
+        where (flow_card_id, layer, virtual_slot) = (#{flowCardId}, #{layer}, #{virtualSlot})
         group by slot
         order by max_sequence
     </select>
+    <select id="queryOutGlassList" resultType="com.mes.hollow.entity.HollowBigStorageCageDetails">
+        with flow_card_id_layer as (
+        select flow_card_id, max(total_layer) as total_layer
+        FROM hollow_big_storage_cage_details
+        group by flow_card_id
+        ),
+        details_sequence_count_temp as (
+        SELECT flow_card_id, hollow_sequence, count(1) as max_count
+        FROM hollow_big_storage_cage_details
+        where state = 100
+        group by flow_card_id, hollow_sequence
+        ),
+        glass_out_temp as (
+        select t1.*, case when t.total_layer = t1.max_count then 1 else 0 end is_pair
+        from flow_card_id_layer t
+        inner join details_sequence_count_temp t1 on t.flow_card_id = t1.flow_card_id
+        ),
+        result_detail as (
+        select t.id,
+        t.device_id,
+        t.virtual_slot,
+        t.slot,
+        t.glass_id,
+        t.sequence,
+        t.flow_card_id,
+        t.glass_type,
+        t.width,
+        t.height,
+        t.thickness,
+        t.tempering_layout_id,
+        t.tempering_feed_sequence,
+        t.state,
+        t.gap,
+        t.engineer_id,
+        t.total_layer,
+        t.layer,
+        t.create_time,
+        t.update_time,
+        t.hollow_sequence,
+        t.films_id,
+        t1.is_pair
+        from hollow_big_storage_cage_details t
+        INNER JOIN glass_out_temp t1
+        on t.flow_card_id = t1.flow_card_id and t.hollow_sequence = t1.hollow_sequence
+        where t.state = 100
+        and t.flow_card_id = #{flowCardId}
+        )
+        select *
+        from result_detail
+        order by flow_card_id, hollow_sequence,layer
+        <if test="cell != 931">
+            desc
+        </if>
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0