From a325f9eda08af39cce45cba363e4247a1b7d5465 Mon Sep 17 00:00:00 2001
From: wu <731351411@qq.com>
Date: 星期五, 24 十月 2025 15:50:40 +0800
Subject: [PATCH] 切割排产,钢化排产的排序指定功能,排序规则重写

---
 hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml |  104 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 97 insertions(+), 7 deletions(-)

diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml
index b25a4f4..bb3e9b2 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 (
@@ -132,13 +155,12 @@
         </where>
     </update>
     <update id="updateDeviceIdBySlot">
-        update big_storage_cage_details t innser join big_storage_cage t1 on t.slot = t1.slot
+        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}
+            #{item}
         </foreach>
-        )
         )
     </update>
 
@@ -164,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 (
@@ -175,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
@@ -185,7 +207,7 @@
         )
         select *
         from result
-        order by engineer_id
+        order by engineer_id,tempering_layout_id
     </select>
 
     <select id="queryIsAllNeedDispatchVirtualSlot" resultMap="virtualSlotSequenceDTO">
@@ -201,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 (
@@ -267,4 +293,68 @@
         SELECT *
         FROM result
     </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)
+        group by bsc.device_id, bsc.slot
+        order by bsc.device_id, bsc.slot
+    </select>
+    <select id="queryTemperingGlassCountSummary" resultMap="temperingGlassCount">
+        with glass_info_temp as (
+        select engineer_id, tempering_layout_id, count(*) as total_count
+        from glass_info
+        group by engineer_id, tempering_layout_id
+        ),
+        big_details_temp as (
+        select engineer_id, tempering_layout_id, count(*) as real_count, films_id, thickness
+        from big_storage_cage_details
+        where state = 100
+        <if test="isTempering == 0">
+            and tempering_layout_id = 0
+        </if>
+        <if test="isTempering == 1">
+            and tempering_layout_id != 0
+        </if>
+
+        group by engineer_id, tempering_layout_id, films_id, thickness
+        ),
+        damage_temp as (
+        select engineer_id, tempering_layout_id, count(*) as damage_count
+        from damage
+        where type in(8,9) and STATUS = 1
+        group by engineer_id, tempering_layout_id
+        ),
+        result as (
+        select t.engineer_id,
+        t.tempering_layout_id,
+        t.films_id,
+        t.thickness,
+        total_count,
+        real_count,
+        ifnull(damage_count, 0) as damage_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
+        left join damage_temp t2
+        on t.engineer_id = t2.engineer_id and t.tempering_layout_id = t2.tempering_layout_id
+        ),
+        -- 浜屾姹囨�诲眰
+        secondary_summary as (
+        select
+        engineer_id,
+        films_id,
+        thickness,
+        count(distinct tempering_layout_id) as total_count, -- 璁$畻totalCount鐨勭疮璁℃暟锛堝幓閲嶈鏁帮級
+        sum(total_count) as real_count -- 璁$畻realCount鐨勬�诲拰
+        from result
+        group by engineer_id, films_id, thickness
+        )
+        select *
+        from secondary_summary
+        order by engineer_id, films_id, thickness
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0