From fec9f42e00f2df68a2a20cbf132b17bdeed8e63a Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期一, 25 八月 2025 09:19:52 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 north-glass-erp/src/main/resources/mapper/sd/OrderGlassDetailMapper.xml |  151 +++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 135 insertions(+), 16 deletions(-)

diff --git a/north-glass-erp/src/main/resources/mapper/sd/OrderGlassDetailMapper.xml b/north-glass-erp/src/main/resources/mapper/sd/OrderGlassDetailMapper.xml
index b217e42..2af4985 100644
--- a/north-glass-erp/src/main/resources/mapper/sd/OrderGlassDetailMapper.xml
+++ b/north-glass-erp/src/main/resources/mapper/sd/OrderGlassDetailMapper.xml
@@ -13,25 +13,69 @@
             glass_child,
             child_width,
             child_height,
+            area,
+            total_area,
+
             process,
-            `group`)
+            `group`
+            ,arc)
         select
             od.order_id,
             od.order_number,
             pd.glass_sort,
             if(pd.glass_sort=1,'(澶�)',if(pd2.glass_sort=pd.glass_sort,'(鍐�)','')),
             pd.detail,
-            od.width,
+            if( od.bend_radius!='',
+                round(od.width*
+                      (od.bend_radius-round(
+                          sum(t.thicknessCount)-t1.thicknessCount/2
+                          ,2))
+                          /od.bend_radius
+                    ,1),
+                od.width
+              )
+               ,
+
             od.height,
+            od.area,
+            od.gross_area,
             pd.process,
-            pd.glass_group
+            pd.glass_group,
+            if( od.bend_radius!='',
+                round((od.width*(od.bend_radius-(sum(t.thicknessCount)-t1.thicknessCount)))/od.bend_radius,1)
+                ,null) as 'arc'
+
+
         from sd.product_detail as pd
         left join order_detail as od
             on od.product_id = pd.prod_id and pd.detail_type='glass'
         LEFT JOIN (SELECT max(id) as id ,max(glass_sort) as glass_sort  from product_detail GROUP BY prod_id)as pd2
             on pd2.id=pd.id
+        left join (
+            select
+                a.prod_id,
+                a.sort_num,
+                a.glass_sort,
+                left(detail,LOCATE('mm',detail)-1) as 'thicknessCount'
+
+            from product_detail as a
+            group  by prod_id,a.sort_num
+        ) as t
+        ON t.prod_id = od.product_id and t.sort_num &lt;=pd.sort_num
+        left join (
+            select
+                a.prod_id,
+                a.sort_num,
+                a.glass_sort,
+                left(detail,LOCATE('mm',detail)-1) as 'thicknessCount'
+
+            from product_detail as a
+            group  by prod_id,a.sort_num
+        ) as t1
+          ON t1.prod_id = od.product_id and t1.sort_num =pd.sort_num
 
         where od.order_id = #{orderId}
+        group by od.order_number,pd.glass_sort
         ORDER BY od.order_number
     </insert>
 
@@ -48,19 +92,22 @@
         <result column="glass_child" property="glassChild"/>
         <result column="child_width" property="childWidth"/>
         <result column="child_height" property="childHeight"/>
+        <result column="arc" property="arc"/>
+        <result column="arch_rise" property="archRise"/>
+        <result column="icon" property="icon"/>
         <result column="process" property="process"/>
+        <result column="area" property="area"/>
+        <result column="total_area" property="totalArea"/>
         <!--鎺ユ敹鍏朵粬澶栭敭瀹炰綋绫绘暟鎹�-->
         <association property="orderDetail" javaType="com.example.erp.entity.sd.OrderDetail">
 
             <result column="building_number" property="buildingNumber"/>
-
+            <result column="product_id" property="productId"/>
             <result column="product_name" property="productName"/>
             <result column="width" property="width"/>
             <result column="height" property="height"/>
             <result column="shape" property="shape"/>
-            <result column="gross_area" property="grossArea"/>
             <result column="edging_type" property="edgingType"/>
-            <result column="area" property="area"/>
             <result column="quantity" property="quantity"/>
             <result column="processing_note"  property="processingNote"/>
             <result column="beizhu"  property="remarks"/>
@@ -74,6 +121,7 @@
             a.order_id,
             a.order_number,
             b.building_number,
+            b.product_id,
             b.product_name,
             a.glass_address,
            a.technology_number,
@@ -81,11 +129,13 @@
            b.width,
            b.height,
            b.shape,
-           b.gross_area,
+           a.total_area,
            b.edging_type,
            a.child_width,
-           a.child_height,
-           b.area,
+           a.child_height,a.arc,
+           a.icon,
+           a.arch_rise,
+           a.area,
            b.quantity,
            a.process,
            b.remarks as 'beizhu',
@@ -99,16 +149,85 @@
     
     <update id="updateSizeAndProcess" parameterType="java.util.List">
         <foreach collection="orderGlassDetails"  item="item" index="index" open="" close="" separator=";">
-            update order_glass_detail
+            update order_glass_detail as a,
+                order_detail as b
             set
-                child_width = #{item.childWidth},
-                child_height = #{item.childHeight},
-                process = #{item.process}
+                a.child_width = #{item.childWidth},
+                a.child_height = #{item.childHeight},
+                a.area = #{item.area},
+                a.total_area = #{item.area}*b.quantity,
+                a.icon = #{item.icon},
+                a.process = #{item.process},
+                a.arc = #{item.arc},
+                a.arch_rise = #{item.archRise}
             where
-                order_id = #{item.orderId}
-                and order_number = #{item.orderNumber}
-                and technology_number = #{item.technologyNumber}
+                a.order_id = b.order_id
+                and a.order_id = #{item.orderId}
+                and a.order_number = #{item.orderNumber}
+                and a.technology_number = #{item.technologyNumber}
         </foreach>
 
     </update>
+
+    <select id="getDifferentSizeNumber">
+       select if(count(id)>0,1,0) from (select
+          a.id,a.child_width,b.width
+        from order_glass_detail as a
+        left join order_detail as b
+        on a.order_id = b.order_id and a.order_number = b.order_number
+        where a.order_id = #{orderId}
+          and a.order_number = #{orderNumber}
+          and(a.child_width != b.width or a.child_height != b.height)
+        ) as c
+    </select>
+
+    <select id="getOrderGlassDetailByProductIdGlassChild" >
+        select a.glass_child
+        from sd.order_glass_detail as a
+        where a.order_id = #{orderId}
+          and a.order_number = #{orderNumber}
+        group by a.glass_child
+    </select>
+
+    <select id="getOrderGlassDetailByProductId" >
+        select *
+        from sd.order_detail od
+                 LEFT join sd.order_glass_detail  ogd on ogd.order_id=od.order_id and ogd.order_number=od.order_number
+        where od.order_id = #{orderId} and od.product_id=#{productId}
+          and  ogd.glass_child=#{glassChild}
+    </select>
+
+    <select id="getMinIdByGroup" >
+        select min(id) from sd.order_glass_detail as a
+        where a.order_id = #{orderId}
+          and a.order_number = #{orderNumber}
+        and a.`group` = #{group}
+
+    </select>
+
+    <select id="getMaxIdByGroup" >
+        select max(id) from sd.order_glass_detail as a
+        where a.order_id = #{orderId}
+          and a.order_number = #{orderNumber}
+          and a.`group` = #{group}
+
+    </select>
+
+
+    <select id="getMinTechnologyNumberByGroup" >
+        select min(technology_number) from sd.order_glass_detail as a
+        where a.order_id = #{orderId}
+          and a.order_number = #{orderNumber}
+          and a.`group` = #{group}
+
+    </select>
+
+    <select id="getMaxTechnologyNumberByGroup" >
+        select max(technology_number) from sd.order_glass_detail as a
+        where a.order_id = #{orderId}
+          and a.order_number = #{orderNumber}
+          and a.`group` = #{group}
+
+    </select>
+
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0