From d724176dbcf033a096d7dcbd864c05485f021fbb Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期三, 17 十二月 2025 08:30:56 +0800
Subject: [PATCH] 1、 钢化前钢化出片逻辑调整,避免卧转立信号对调度任务的影响 2、修改出片方式,当玻璃未在关系表时,默认出一片 3、中空新增进片线路校验,避免钢化重复报工

---
 hangzhoumesParent/common/servicebase/src/main/resources/mapper/OrderMapper.xml |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 50 insertions(+), 8 deletions(-)

diff --git a/hangzhoumesParent/common/servicebase/src/main/resources/mapper/OrderMapper.xml b/hangzhoumesParent/common/servicebase/src/main/resources/mapper/OrderMapper.xml
index ab29243..b2c0fdf 100644
--- a/hangzhoumesParent/common/servicebase/src/main/resources/mapper/OrderMapper.xml
+++ b/hangzhoumesParent/common/servicebase/src/main/resources/mapper/OrderMapper.xml
@@ -25,8 +25,7 @@
                a.area,
                a.quantity,
                a.create_time,
-               round(ifnull(d.finishNum, 0) / a.quantity * 100) as 'percent',
-                ifnull(d.finishNum, 0)
+               round(ifnull(d.finishNum, 0) / a.quantity * 100) as 'percent', ifnull(d.finishNum, 0)
         from sd.`order` as a
                  LEFT JOIN (
             SELECT sum(c.reporting_work_num) as 'finishNum',order_id
@@ -38,16 +37,15 @@
         ) as d
                            on a.order_id = d.order_id
         where a.warehousing != 2 and a.warehousing >= 0
-        ORDER BY  a.order_id desc
+        ORDER BY a.order_id desc
     </select>
     <select id="queryOrderByFlowCardId" resultType="com.mes.order.entity.HollowOrderDTO">
         select t1.*
         from pp.flow_card t
                  inner join sd.order t1 on t.order_id = t1.order_id
-        where t.process_id = #{flowCardId}
-            limit 1
+        where t.process_id = #{flowCardId} limit 1
     </select>
-    <select id="queryFlowCardIdMaxLayerGlassInfo"  resultMap="baseMapHollowDetail">
+    <select id="queryFlowCardIdMaxLayerGlassInfo" resultMap="baseMapHollowDetail">
         with temp_flow as (SELECT t.process_id,
                                   t.order_id,
                                   t.order_number,
@@ -137,7 +135,51 @@
             select min(order_id) as order_id, min(order_number) as order_number
             from pp.flow_card
             where process_id = #{flowCardId}
-        )
-            limit 1
+        ) limit 1
+    </select>
+    <select id="queryLackByERP" resultType="com.mes.order.entity.ProcessCardReport">
+        select a.*,
+               (b.quantity - b.termination_quantity) as 'quantity',
+                (b.quantity - b.termination_quantity - reporting_work_num) as 'lack_quantity'
+        from order_process_detail as a
+                 inner join pp.flow_card as b
+                            on a.order_id = b.order_id
+                                and a.process_id = b.process_id
+                                and a.order_number = b.order_number
+                                and a.technology_number = b.technology_number
+        where termination_status = 0
+          and a.process_id = #{flowCardId}
+          and a.process = "涓┖"
+          and (b.quantity - b.termination_quantity) > reporting_work_num
+    </select>
+
+
+    <select id="queryInterlayerByERP" resultType="com.mes.order.entity.dto.InterlayerDTO">
+        WITH flow_order AS (
+            SELECT ORDER_ID, ORDER_NUMBER
+            FROM pp.flow_card
+            WHERE process_id = #{flowCardId}
+            ORDER BY  ORDER_NUMBER /* 娣诲姞閫傚綋鐨勬帓搴忓瓧娈碉紝纭繚缁撴灉纭畾鎬� */
+            LIMIT 1
+        ),
+             product_ids AS (
+                 SELECT od.PRODUCT_ID
+                 FROM sd.order_detail od
+                          inner JOIN flow_order fo ON od.ORDER_id = fo.ORDER_ID AND od.ORDER_NUMBER = fo.ORDER_NUMBER
+             ),
+             ranked AS (
+                 SELECT
+                     detail_type,
+                     LAG(glass_sort) OVER (PARTITION BY prod_id ORDER BY sort_num) AS prev_sort,
+                     LEAD(glass_sort) OVER (PARTITION BY prod_id ORDER BY sort_num) AS next_sort
+                 FROM sd.product_detail
+                 WHERE prod_id IN (SELECT PRODUCT_ID FROM product_ids)
+
+             )
+        SELECT
+            prev_sort,
+            next_sort
+        FROM ranked
+        where detail_type = 'Interlayer'
     </select>
 </mapper>

--
Gitblit v1.8.0