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/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml |  143 ++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 122 insertions(+), 21 deletions(-)

diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml
index 9611a10..aa85103 100644
--- a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml
+++ b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/resources/mapper/BigStorageCageDetailsMapper.xml
@@ -30,6 +30,35 @@
         <result column="min_sequence" property="minSequence"/>
     </resultMap>
 
+    <resultMap id="temperingGlassCount" type="com.mes.bigstorage.entity.dto.TemperingGlassCountDTO">
+        <result column="engineer_id" property="engineerId"/>
+        <result column="tempering_layout_id" property="temperingLayoutId"/>
+        <result column="films_id" property="filmsId"/>
+        <result column="thickness" property="thickness"/>
+        <result column="total_count" property="totalCount"/>
+        <result column="real_count" property="realCount"/>
+        <result column="damage_count" property="damageCount"/>
+        <result column="lack_count" property="lackCount"/>
+    </resultMap>
+
+    <resultMap id="glassInfoLackDTO" type="com.mes.bigstorage.entity.dto.GlassInfoLackDTO">
+        <result column="flow_card_id" property="flowCardId"/>
+        <result column="width" property="width"/>
+        <result column="height" property="height"/>
+        <result column="thickness" property="thickness"/>
+        <result column="filmsid" property="filmsid"/>
+        <result column="total_layer" property="totalLayer"/>
+        <result column="layer" property="layer"/>
+        <result column="tempering_layout_id" property="temperingLayoutId"/>
+        <result column="tempering_feed_sequence" property="temperingFeedSequence"/>
+        <result column="x_coordinate" property="xCoordinate"/>
+        <result column="y_coordinate" property="yCoordinate"/>
+        <result column="angle" property="angle"/>
+        <result column="engineer_id" property="engineerId"/>
+        <result column="glass_id" property="glassId"/>
+        <result column="is_damage" property="isDamage"/>
+    </resultMap>
+
     <select id="temperingIsAll" resultMap="temperingLayoutDTO">
         SELECT T2.*
         FROM (
@@ -102,28 +131,60 @@
             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="selectTemperingGlassCount" resultType="java.util.Map">
-        select a.engineer_id,
-               a.tempering_layout_id,
-               count2,
-               count1,
-               count2 - count1   as count3,
-               count(c.glass_id) as count4
-        from (select engineer_id, tempering_layout_id, count(*) as count1
-              from big_storage_cage_details
-              where state = 100
-              group by engineer_id, tempering_layout_id) as a
-                 left join
-             (select engineer_id, tempering_layout_id, count(*) as count2
-              from glass_info
-              group by engineer_id, tempering_layout_id) as b
-             on a.engineer_id = b.engineer_id and a.tempering_layout_id = b.tempering_layout_id
-                 left join damage as c
-                           on a.engineer_id = c.engineer_id and a.tempering_layout_id = c.tempering_layout_id and
-                              (type = 8 or type = 9)
-        group by a.engineer_id, a.tempering_layout_id
-        order by a.engineer_id, a.tempering_layout_id
+    <select id="selectTemperingGlassCount" 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)
+        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,
+        total_count - real_count - ifnull(damage_count, 0) 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
+        )
+        select *
+        from result
+        order by engineer_id
     </select>
 
     <select id="queryIsAllNeedDispatchVirtualSlot" resultMap="virtualSlotSequenceDTO">
@@ -172,4 +233,44 @@
         group by t.slot
         order by max_sequence desc
     </select>
+    <select id="queryLackGlassInfo" resultMap="glassInfoLackDTO">
+        WITH glass_info_temp AS (SELECT *
+                                 FROM glass_info
+                                 WHERE engineer_id = #{engineerId}
+                                   AND tempering_layout_id = #{temperingLayoutId}),
+             big_details_temp AS (SELECT *
+                                  FROM big_storage_cage_details
+                                  WHERE state = 100
+                                    AND engineer_id = #{engineerId}
+                                    AND tempering_layout_id = #{temperingLayoutId}),
+             damage_temp AS (SELECT *
+                             FROM damage
+                             WHERE type IN (8, 9)
+                               AND engineer_id = #{engineerId}
+                               AND tempering_layout_id = #{temperingLayoutId}),
+             result_lack AS (SELECT t.*
+                             FROM glass_info_temp t
+                                      LEFT JOIN big_details_temp t1 ON t.glass_id = t1.glass_id
+                             WHERE t1.glass_id IS NULL),
+             result AS (
+                 SELECT t.*,
+                        CASE
+
+                            WHEN t1.glass_id is null THEN
+                                0
+                            ELSE 1
+                            END AS is_damage
+                 FROM result_lack t
+                          LEFT JOIN damage_temp t1 ON t.glass_id = t1.glass_id
+             )
+        SELECT *
+        FROM result
+    </select>
+    <select id="querybigStorageCageDetail" resultType="com.mes.base.entity.vo.BigStorageVO">
+        SELECT SLOT, COUNT(1) AS COUNT
+        FROM BIG_STORAGE_CAGE_DETAILS
+        where state in (100, 102, 103, 104)
+        group by SLOT
+        ORDER BY SLOT
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0