From b460ec7a380334516ec478544afe42df409f4c54 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期二, 25 十一月 2025 09:50:20 +0800
Subject: [PATCH] 1、中空夹胶线出片逻辑优化 2、钢化前卧转新增协议卧转立允许信号

---
 hangzhoumesParent/common/servicebase/src/main/resources/mapper/OptimizeProjectMapper.xml |  136 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 133 insertions(+), 3 deletions(-)

diff --git a/hangzhoumesParent/common/servicebase/src/main/resources/mapper/OptimizeProjectMapper.xml b/hangzhoumesParent/common/servicebase/src/main/resources/mapper/OptimizeProjectMapper.xml
index decf51f..6cc8288 100644
--- a/hangzhoumesParent/common/servicebase/src/main/resources/mapper/OptimizeProjectMapper.xml
+++ b/hangzhoumesParent/common/servicebase/src/main/resources/mapper/OptimizeProjectMapper.xml
@@ -10,15 +10,145 @@
         <result property="thickness" column="glass_thickness"/>
         <result property="layoutSequence" column="heat_layout_sort"/>
         <result property="state" column="state"/>
-
     </resultMap>
 
+    <resultMap id="resultMap" type="com.mes.pp.entity.OptimizeProject">
+        <result property="id" column="id"/>
+        <result property="projectNo" column="project_no"/>
+        <result property="projectName" column="project_name"/>
+        <result property="state" column="state"/>
+        <result property="type" column="type"/>
+        <result property="glassThickness" column="glass_thickness"/>
+        <result property="glassType" column="glass_type"/>
+        <result property="glassTotal" column="glass_total"/>
+        <result property="glassTotalArea" column="glass_total_area"/>
+    </resultMap>
+    <resultMap id="progressResultMap" type="com.mes.pp.entity.dto.ProgressDTO">
+        <!-- 鐜荤拑淇℃伅琛紙a锛夊瓧娈垫槧灏� -->
+        <result property="engineerId" column="engineer_id"/>    <!-- 鐜荤拑No 鈫� a.engineer_id -->
+        <result property="flowCardId" column="flow_card_id"/>     <!-- 娴佺▼鍗″彿 鈫� a.flow_card_id -->
+        <result property="layer" column="layer"/>     <!-- 灞傚彿 鈫� a.layer -->
+        <result property="glassType" column="glass_type"/>      <!-- 鐜荤拑鍚嶇О 鈫� a.glass_type -->
+        <result property="width" column="width"/>                <!-- 瀹� 鈫� a.width -->
+        <result property="height" column="height"/>              <!-- 楂� 鈫� a.height -->
+        <result property="glassIdCount" column="glassIdCount"/>      <!-- 璁㈠崟鏁伴噺 鈫� 缁熻鐨� glassIdCount -->
+        <result property="cuttingCount" column="cuttingCount"/>       <!-- 鍒囧壊鎶ュ伐鏁� 鈫� cuttingCount -->
+        <result property="edgingCount" column="edgingCount"/>   <!-- 纾ㄨ竟鎶ュ伐鏁� 鈫� edgingCount -->
+         <result property="temperingCount" column="temperingCount"/>
+         <result property="insulatingCount" column="insulatingCount"/>
+    </resultMap>
     <select id="saveProject" parameterType="com.mes.pp.entity.request.OptimizeRequest" resultMap="sequenceMap">
-        select a.project_no, b.glass_type, a.width, a.height, b.glass_thickness, a.heat_layout_sort, 0 as state
+        select a.project_no,
+               1                                            as glass_type,
+               a.width,
+               a.height,
+               REGEXP_REPLACE(b.glass_thickness, '\\D', '') as glass_thickness,
+               a.heat_layout_sort,
+               0                                            as state
         from optimize_detail a
                  left join optimize_project b on a.project_no = b.project_no
-        where a.project_no = #{projectNo,jdbcType=VARCHAR}
+        where a.project_no = #{projectNo}
     </select>
 
+    <select id="queryEngineer" parameterType="com.mes.pp.entity.OptimizeProject" resultMap="resultMap">
+        select p.project_no,
+               p.project_name,
+               p.glass_thickness,
+               p.glass_type,
+               p.glass_total,
+               p.glass_total_area
+        from pp.optimize_project p
+        where p.state = 100
+          and p.project_no not in (select es.project_no
+                                   from north_glass_mes.engineer_scheduling es
+                                   where es.project_no is not null)
+        order by p.id
+    </select>
 
+    <select id="engineerScheduling" parameterType="com.mes.pp.entity.request.OptimizeRequest" resultMap="resultMap">
+        select es.project_no,
+        es.project_name,
+        es.type,
+        p.glass_thickness,
+        p.glass_type,
+        p.glass_total,
+        p.glass_total_area,
+        IFNULL(e.state,0) as state
+        from north_glass_mes.engineer_scheduling es
+        left join pp.optimize_project p on es.project_no=p.project_no
+        left join north_glass_mes.engineering e on es.project_no=e.engineer_id
+        where es.state = 100
+        <if test="type != null and type != ''">
+            and es.type = #{type}
+        </if>
+        order by case when IFNULL(e.state, 0) = 1 then 0 else 1 end, es.id
+    </select>
+
+    <!-- 鏍规嵁绫诲瀷鍒犻櫎engineer_scheduling琛ㄤ腑鐨勬暟鎹� -->
+    <delete id="deleteByType">
+        DELETE
+        FROM north_glass_mes.engineer_scheduling
+        WHERE type = #{type}
+    </delete>
+    <delete id="deleteByScheduling">
+        DELETE
+        FROM north_glass_mes.engineer_scheduling
+        WHERE project_no = #{engineerId}
+        and type in (
+        <foreach collection="types" item="item" separator=",">
+            #{item}
+        </foreach>
+        )
+    </delete>
+
+    <!-- 鎵归噺鎻掑叆鏁版嵁鍒癳ngineer_scheduling琛� -->
+    <insert id="batchInsert">
+        INSERT INTO north_glass_mes.engineer_scheduling (
+        project_no,
+        project_name,
+        state,
+        type
+        ) VALUES
+        <foreach collection="list" item="item" separator=",">
+            (
+            #{item.projectNo},
+            #{item.projectName},
+            #{item.state},
+            #{item.type}
+            )
+        </foreach>
+    </insert>
+    <select id="selectProgress" parameterType="com.mes.glassinfo.entity.GlassInfo" resultMap="progressResultMap">
+        SELECT
+        a.engineer_id,
+        a.flow_card_id,
+        a.layer,
+        a.glass_type,
+        a.thickness,
+        a.filmsid,
+        a.width,
+        a.height,
+        COUNT(a.glass_id) as glassIdCount,
+        SUM(CASE WHEN d.working_procedure = '鍒囧壊' AND d.type = 1 THEN 1 ELSE 0 END) as cuttingCount,
+        SUM(CASE WHEN d.working_procedure = '纾ㄨ竟' AND d.type = 1 THEN 1 ELSE 0 END) as edgingCount,
+        SUM(CASE WHEN d.working_procedure = '閽㈠寲' AND d.type = 1 THEN 1 ELSE 0 END) as temperingCount,
+        SUM(CASE WHEN d.working_procedure = '涓┖' AND d.type = 1 THEN 1 ELSE 0 END) as insulatingCount
+        FROM
+        north_glass_mes.glass_info a
+        LEFT JOIN
+        north_glass_mes.damage d
+        ON a.glass_id = d.glass_id
+        AND a.engineer_id = d.engineer_id
+        WHERE
+        a.engineer_id = #{engineerId}
+        GROUP BY
+        a.engineer_id,
+        a.flow_card_id,
+        a.layer,
+        a.glass_type,
+        a.thickness,
+        a.filmsid,
+        a.width,
+        a.height
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0