From 261698358e2b756a61e992bc1651e01b3f45290b Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期四, 23 十月 2025 16:50:27 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml |   77 ++++++++++++++++++++++++++++++++------
 1 files changed, 65 insertions(+), 12 deletions(-)

diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml
index 94b161b..63159c1 100644
--- a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml
+++ b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml
@@ -59,6 +59,29 @@
         <result column="is_damage" property="isDamage"/>
     </resultMap>
 
+    <select id="temperingIsAllByTemperingLayoutId" resultMap="temperingLayoutDTO">
+        SELECT T.*
+        FROM (
+                 SELECT ENGINEER_ID, TEMPERING_LAYOUT_ID, COUNT(distinct TEMPERING_FEED_SEQUENCE) AS COUNT
+                 FROM BIG_STORAGE_CAGE_DETAILS
+                 WHERE STATE = 100
+                   and ENGINEER_ID = #{engineerId}
+                   AND TEMPERING_LAYOUT_ID = #{temperingLayoutId}
+                 GROUP BY ENGINEER_ID, TEMPERING_LAYOUT_ID
+             ) T
+                 INNER JOIN (SELECT ENGINEER_ID,
+                                    TEMPERING_LAYOUT_ID,
+                                    COUNT(distinct TEMPERING_FEED_SEQUENCE) AS COUNT
+                             FROM GLASS_INFO
+                             WHERE ENGINEER_ID = #{engineerId}
+                               AND TEMPERING_LAYOUT_ID = #{temperingLayoutId}
+                             GROUP BY ENGINEER_ID,
+                                      TEMPERING_LAYOUT_ID) T1
+                            ON T.ENGINEER_ID = T1.ENGINEER_ID
+                                AND T.TEMPERING_LAYOUT_ID = T1.TEMPERING_LAYOUT_ID
+                                AND T.COUNT = T1.COUNT
+    </select>
+
     <select id="temperingIsAll" resultMap="temperingLayoutDTO">
         SELECT T2.*
         FROM (
@@ -66,14 +89,14 @@
                         T.TEMPERING_LAYOUT_ID,
                         COUNT(T.TEMPERING_FEED_SEQUENCE) AS COUNT
                  FROM GLASS_INFO T
-                     LEFT JOIN DAMAGE T1
-                 ON T.ENGINEER_ID = T1.ENGINEER_ID
-                     AND T.GLASS_ID = T1.GLASS_ID
-                     AND (T1.TYPE = 8
-                     OR T1.TYPE = 9)
+                          LEFT JOIN DAMAGE T1
+                                    ON T.ENGINEER_ID = T1.ENGINEER_ID
+                                        AND T.GLASS_ID = T1.GLASS_ID
+                                        AND (T1.TYPE = 8
+                                            OR T1.TYPE = 9)
                  WHERE T1.GLASS_ID IS NULL
                  GROUP BY T.ENGINEER_ID,
-                     T.TEMPERING_LAYOUT_ID
+                          T.TEMPERING_LAYOUT_ID
              ) T2
                  INNER JOIN (SELECT ENGINEER_ID, TEMPERING_LAYOUT_ID, COUNT(TEMPERING_FEED_SEQUENCE) AS COUNT
                              FROM BIG_STORAGE_CAGE_DETAILS
@@ -163,7 +186,7 @@
         damage_temp as (
         select engineer_id, tempering_layout_id, count(*) as damage_count
         from damage
-        where type in(8,9)
+        where type in(8,9) and STATUS = 1
         group by engineer_id, tempering_layout_id
         ),
         result as (
@@ -174,8 +197,8 @@
         total_count,
         real_count,
         ifnull(damage_count, 0) as damage_count,
-        total_count - real_count - ifnull(damage_count, 0) as lack_count
-
+        case when total_count - real_count - ifnull(damage_count, 0) &lt; 0 then 0 else
+        total_count - real_count - ifnull(damage_count, 0) end as lack_count
         from big_details_temp t
         inner join glass_info_temp t1 on t.engineer_id = t1.engineer_id and
         t.tempering_layout_id = t1.tempering_layout_id
@@ -184,7 +207,7 @@
         )
         select *
         from result
-        order by engineer_id
+        order by engineer_id,tempering_layout_id
     </select>
 
     <select id="queryIsAllNeedDispatchVirtualSlot" resultMap="virtualSlotSequenceDTO">
@@ -200,6 +223,10 @@
                          t.engineer_id = t1.engineer_id and t.tempering_layout_id = t1.tempering_layout_id and
                          t.tempering_feed_sequence = t1.tempering_feed_sequence
                  where t1.state = 100
+        AND T1.DEVICE_ID IN
+        <foreach collection="deviceIdList" item="item" open='(' close=')' separator=','>
+            #{item}
+        </foreach>
                  group by t.engineer_id, t.tempering_layout_id, t.virtual_slot
              ),
              result_one as (
@@ -268,9 +295,35 @@
     </select>
     <select id="querybigStorageCageDetail" resultType="com.mes.base.entity.vo.BigStorageVO">
         select bsc.device_id, bsc.slot, count(bscd.glass_id) as count
-        from big_storage_cage bsc left join big_storage_cage_details bscd
-        on bsc.slot=bscd.slot and bscd.state in (100, 102, 103, 104)
+        from big_storage_cage bsc
+                 left join big_storage_cage_details bscd
+                           on bsc.slot = bscd.slot and bscd.state in (100, 102, 103, 104)
         group by bsc.device_id, bsc.slot
         order by bsc.device_id, bsc.slot
     </select>
+    <select id="queryNeedDispatch" resultType="com.mes.bigstorage.entity.BigStorageCageDetails">
+        SELECT * FROM big_storage_cage_details WHERE STATE = 100 AND SLOT = (SELECT SLOT FROM big_storage_cage_details WHERE STATE = 100 AND sequence = 1 order by slot desc LIMIT 1) ORDER BY tempering_feed_sequence
+    </select>
+
+    <select id="queryNeedDispatchSlotBySequence" resultType="com.mes.bigstorage.entity.dto.BigStorageSlotDTO">
+        with glass_temp as (
+        select t.* ,t1.virtual_slot,t1.slot_sequence from big_storage_cage_details t inner join
+        big_storage_glass_relation_info t1 on t.engineer_id = t1.engineer_id
+        and t.tempering_layout_id = t1.tempering_layout_id
+        and t.tempering_feed_sequence = t1.tempering_feed_sequence where t.state = 100
+        ),slot_max_temp as (
+        select ROW_NUMBER()over(PARTITION by engineer_id, tempering_layout_id, virtual_slot order by slot_sequence desc)
+        as rn,t.* from glass_temp t where t.device_id in (5,6)
+        ) ,slot_max_message as (select * from slot_max_temp where rn =1)
+        ,slot_min_temp as (
+        select ROW_NUMBER()over(PARTITION by engineer_id, tempering_layout_id, virtual_slot order by slot_sequence) as
+        rn,t.* from glass_temp t where t.device_id in (5,6)
+        ) ,slot_min_message as (select * from slot_min_temp where rn =1)
+        ,result as (
+        select t.slot as target_slot ,t1.slot as start_slot from slot_max_message t inner join slot_min_message t1 on
+        t.engineer_id = t1.engineer_id and t.tempering_layout_id = t1.tempering_layout_id and t.virtual_slot =
+        t1.virtual_slot and t.tempering_layout_id = t1.tempering_layout_id and t.tempering_feed_sequence =
+        t1.tempering_feed_sequence -1
+        )select * from result limit 1
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0