From 9ccc8bd3a53160a40cf60f14e5867f6ce9f6c58f Mon Sep 17 00:00:00 2001
From: guoyujie <guoyujie@ng.com>
Date: 星期五, 26 十二月 2025 16:49:15 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10101/r/ERP_override

---
 north-glass-erp/src/main/resources/mapper/sd/BomDataMapper.xml |   76 +++++++++++++++++++++++++++++++++++--
 1 files changed, 71 insertions(+), 5 deletions(-)

diff --git a/north-glass-erp/src/main/resources/mapper/sd/BomDataMapper.xml b/north-glass-erp/src/main/resources/mapper/sd/BomDataMapper.xml
index b50e245..abfe0af 100644
--- a/north-glass-erp/src/main/resources/mapper/sd/BomDataMapper.xml
+++ b/north-glass-erp/src/main/resources/mapper/sd/BomDataMapper.xml
@@ -6,9 +6,9 @@
 
     <insert id="saveMaterialBomDataMp">
         insert into sd.bom_base
-            (material_id, material, status, type, consume, price,create_time)
+            (material_id, material, status, type, consume, price,unit,create_time)
         values
-            (#{id}, #{name}, 0, #{type}, #{consume},#{price}, now())
+            (#{id}, #{name}, 0, #{type}, #{consume},#{price}, #{unit},now())
     </insert>
 
     <select id="getMaterialId">
@@ -17,7 +17,7 @@
 
     <update id="updateMaterialBomDataMp">
         update sd.bom_base
-        set type=#{type},consume=#{consume},price=#{price},create_time=now()
+        set type=#{type},consume=#{consume},price=#{price},unit=#{unit},create_time=now()
         where material_id = #{id}
     </update>
 
@@ -28,10 +28,76 @@
     </insert>
 
     <select id="getOrderBomDataMp">
-        SELECT DISTINCT product_id,product_name from sd.order_detail where order_id=#{orderId}
+        SELECT  product_id,product_name,SUM(quantity) as quantity,
+            SUM(gross_area) as area,SUM(perimeter) as perimeter,order_id from sd.order_detail where order_id=#{orderId}
+            GROUP BY product_id
     </select>
 
     <select id="getBOMDetails">
-        
+        select  bp.*,bb.*,(consume*price) as materialPric,od.quantity,pdd.detail_type,
+            IFNULL(JSON_UNQUOTE(JSON_EXTRACT(pdd.separation, '$.GlueDepth')),0) as glueDepth,
+            CAST(SUBSTRING_INDEX(IFNULL(JSON_UNQUOTE(JSON_EXTRACT(pdd.separation, '$.thickness')), '0mm'), 'mm', 1) AS DECIMAL(10, 2)) AS thickness
+               from sd.bom_product as bp
+            left join sd.bom_base as bb on bb.id=bp.base_id
+            left join ( select order_id,product_id,SUM(quantity) as quantity from sd.order_detail GROUP BY  order_id,product_id
+        ) as od on od.product_id = bp.product_id
+            left join sd.product_detail as pdd on pdd.prod_id = bp.product_id and pdd.sort_num = bp.product_layer
+        where bp.product_id = #{productId} and od.order_id = #{orderId} ORDER BY product_layer
+    </select>
+
+    <select id="getOrderBomSumDataMp">
+        SELECT  product_id,product_name,SUM(quantity) as quantity,SUM(gross_area) as area,SUM(perimeter) as perimeter
+        from sd.order_detail where order_id=#{orderId}
+    </select>
+
+    <select id="getOrderBomsumDataDatilsMp">
+        SELECT
+            od.order_id,
+            bp.product_id,
+            bb.material_id,
+            bb.material,
+            bb.`status`,
+            bb.type,
+            sum(bb.consume) as consume,
+            sum(bb.price) as price,
+            sum(bb.consume * bb.price) AS materialPrice,
+            od.quantity,
+            pdd.detail_type,
+            IFNULL( JSON_UNQUOTE( JSON_EXTRACT( pdd.separation, '$.GlueDepth' )), 0 ) AS glueDepth,
+            CAST(
+                    SUBSTRING_INDEX( IFNULL( JSON_UNQUOTE( JSON_EXTRACT( pdd.separation, '$.thickness' )), '0mm' ), 'mm', 1 ) AS DECIMAL ( 10, 2 )) AS thickness
+        FROM
+            sd.bom_product AS bp
+                LEFT JOIN sd.bom_base AS bb ON bb.id = bp.base_id
+                LEFT JOIN (
+                select order_id,product_id,SUM(quantity) as quantity from sd.order_detail GROUP BY  order_id,product_id
+            ) as od on od.product_id = bp.product_id
+                LEFT JOIN sd.product_detail AS pdd ON pdd.prod_id = bp.product_id  AND pdd.sort_num = bp.product_layer
+        WHERE od.order_id=#{orderId}
+        GROUP BY bb.material_id
+        ORDER BY bp.product_layer
+    </select>
+
+    <select id="getEditProductBOMSv">
+        SELECT
+            bp.product_layer,
+            bb.material_id,
+            bb.material,
+            JSON_UNQUOTE(
+                    JSON_EXTRACT( ms.json, '$.thickness' )) AS thickness,
+            JSON_UNQUOTE(
+                    JSON_EXTRACT( ms.json, '$.width' )) AS width,
+            JSON_UNQUOTE(
+                    JSON_EXTRACT( ms.json, '$.height' )) AS height,
+            JSON_UNQUOTE(
+                    JSON_EXTRACT( ms.json, '$.unit' )) AS unit,
+            bb.consume,
+            bb.price
+        FROM
+            bom_product AS bp
+                LEFT JOIN bom_base AS bb ON bb.id = bp.base_id
+                LEFT JOIN mm.material_store AS ms ON ms.id = bb.material_id
+        WHERE
+            bp.product_id = #{produceId}
     </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0