廖井涛
2025-09-24 4ecafe1bbc2f5da577f1f5dff307983f9fd71bde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?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,create_time)
        values
            (#{id}, #{name}, 0, #{type}, #{consume},#{price}, 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},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>
</mapper>