From 4d3286b758594acab704d92159b4e4df3deaf7bb Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期五, 17 一月 2025 11:32:14 +0800
Subject: [PATCH] 增加暂停的工程号到选择工程的数据列里,更变engineering表的实现层到公共里

---
 hangzhoumesParent/moduleService/howllowGlassModule/src/main/resources/mapper/HollowBigStorageCageDetailsMapper.xml |  127 +++++++++++++++++++++++++----------------
 1 files changed, 77 insertions(+), 50 deletions(-)

diff --git a/hangzhoumesParent/moduleService/howllowGlassModule/src/main/resources/mapper/HollowBigStorageCageDetailsMapper.xml b/hangzhoumesParent/moduleService/howllowGlassModule/src/main/resources/mapper/HollowBigStorageCageDetailsMapper.xml
index 800ad1e..38803e6 100644
--- a/hangzhoumesParent/moduleService/howllowGlassModule/src/main/resources/mapper/HollowBigStorageCageDetailsMapper.xml
+++ b/hangzhoumesParent/moduleService/howllowGlassModule/src/main/resources/mapper/HollowBigStorageCageDetailsMapper.xml
@@ -6,6 +6,8 @@
         <result column="engineer_id" property="engineerId"/>
         <result column="flow_card_id" property="flowCardId"/>
         <result column="layer" property="layer"/>
+        <result column="films_id" property="filmsId"/>
+        <result column="thickness" property="thickness"/>
         <result column="sum_count" property="sumCount"/>
         <result column="pair_count" property="pairCount"/>
         <result column="real_count" property="realCount"/>
@@ -37,54 +39,38 @@
             and state !=101
         </where>
     </update>
+    <update id="updateDeviceIdBySlot">
+        update big_storage_cage_details t inner join big_storage_cage t1 on t.slot = t1.slot
+        set t.device_id = t1.device_id
+        where t.slot in (
+        <foreach collection="list" item="item" separator=",">
+            #{item}
+        </foreach>
+        )
+    </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, 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 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 (
         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_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 (
         SELECT
@@ -94,33 +80,34 @@
         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.slot_sequence = t1.slot_sequence
+        AND t.sequence = t1.sequence
         <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.slot_sequence = t2.slot_sequence
+            t.virtual_slot = t2.virtual_slot and t.sequence = t2.sequence
         </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,
+        t.thickness,
         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
         *
@@ -132,7 +119,6 @@
             and sum_count = pair_count
         </if>
     </select>
-
 
     <select id="queryIsAllNeedDispatchVirtualSlot" resultMap="virtualSlotSequenceDTO">
         with relation_temp as (
@@ -220,4 +206,45 @@
             desc
         </if>
     </select>
+    <select id="queryHollowbigStorageCageDetail" resultType="com.mes.base.entity.vo.BigStorageVO">
+        SELECT SLOT, COUNT(1) AS COUNT
+        FROM HOLLOW_BIG_STORAGE_CAGE_DETAILS
+        where state in (100, 102, 103, 104)
+        group by SLOT
+        ORDER BY SLOT
+    </select>
+    <select id="querySlotMaxSequence" resultType="com.mes.hollow.entity.HollowBigStorageCageDetails">
+        select max(sequence) as sequence, device_id, slot
+        from hollow_big_storage_cage_details
+        where (flow_card_id, total_layer, layer, virtual_slot) =
+              (#{flowCardId}, #{totalLayer}, #{layer}, #{virtualSlot})
+          and state in (0, 100, 102, 103, 104)
+        group by device_id, slot
+        order by sequence
+    </select>
+    <select id="queryPairGlassList" resultType="com.mes.hollow.entity.HollowBigStorageCageDetails">
+        with hollow_sequence_temp as (
+        SELECT hollow_sequence, count(distinct layer) as count
+        FROM hollow_big_storage_cage_details
+        WHERE flow_card_id = #{flowCardId}
+        <if test="isOut == 0">
+            AND STATE = 100
+        </if>
+
+        GROUP BY hollow_sequence
+        having count = #{totalLayer}
+        limit #{totalPairQuantity}
+        ),
+        hollow_details as (select *
+        from hollow_big_storage_cage_details
+        WHERE flow_card_id = #{flowCardId}
+        <if test="isOut == 0">
+            AND STATE = 100
+        </if>
+        )
+        select *
+        from hollow_details t
+        inner join hollow_sequence_temp t1 on t.hollow_sequence = t1.hollow_sequence
+        ORDER BY t.hollow_sequence
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0