From fd2ec4214c6f8456b957c3545e7d67bcdbbb9985 Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期二, 02 十二月 2025 15:26:33 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10105/r/ERP_override

---
 north-glass-erp/src/main/resources/mapper/sd/BomDataMapper.xml |   91 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 91 insertions(+), 0 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
new file mode 100644
index 0000000..1085e96
--- /dev/null
+++ b/north-glass-erp/src/main/resources/mapper/sd/BomDataMapper.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.example.erp.mapper.sd.BomDataMapper">
+
+    <insert id="saveMaterialBomDataMp">
+        insert into sd.bom_base
+            (material_id, material, status, type, consume, price,unit,create_time)
+        values
+            (#{id}, #{name}, 0, #{type}, #{consume},#{price}, #{unit},now())
+    </insert>
+
+    <select id="getMaterialId">
+        select count(*) from sd.bom_base where material_id= #{id}
+    </select>
+
+    <update id="updateMaterialBomDataMp">
+        update sd.bom_base
+        set type=#{type},consume=#{consume},price=#{price},unit=#{unit},create_time=now()
+        where material_id = #{id}
+    </update>
+
+    <insert id="saveProductBOMMp">
+        insert into sd.bom_product
+                (product_id,base_id,product_layer)
+        values (#{produceId},#{tabId},#{layer})
+    </insert>
+
+    <select id="getOrderBomDataMp">
+        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}
+            GROUP BY product_id
+    </select>
+
+    <select id="getBOMDetails">
+        select *,(consume*price) as materialPric from sd.bom_product as bp left join sd.bom_base as bb on bb.id=bp.base_id
+            where bp.product_id = #{productId} 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
+        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 from sd.order_detail GROUP BY product_id
+            ) as od on od.product_id = bp.product_id
+
+        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