gongchunyi
7 小时以前 ec7d3b867e7b7f5073dda1684a8720424b9da5ad
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?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.ruoyi.production.mapper.ProductMaterialMapper">
 
    <resultMap id="ProductMaterialResultMap" type="com.ruoyi.production.pojo.ProductMaterial">
        <id property="id" column="id"/>
        <result property="tenantId" column="tenant_id"/>
        <result property="materialTypeId" column="material_type_id"/>
        <result property="inventoryCategoryId" column="inventory_category_id"/>
        <result property="productName" column="product_name"/>
        <result property="unit" column="unit"/>
        <result property="remark" column="remark"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>
 
    <select id="selectProductByModelId" resultType="com.ruoyi.production.dto.ProductMaterialSkuDto"
            parameterType="java.lang.Long">
        select pm.product_name as productName,
        pm.unit,
        pms.material_code as materialCode,
        pms.model
        from product_material pm
        left join product_material_sku pms on pms.product_id = pm.id
        <where>
            <choose>
                <when test="productModelId != null">
                    pms.id = #{productModelId}
                </when>
                <otherwise>
                    1 = 0
                </otherwise>
            </choose>
        </where>
    </select>
 
    <select id="selectProductByProductMainId" resultType="com.ruoyi.production.dto.ProductMaterialSkuDto"
            parameterType="java.lang.Long">
        select
        pm.product_name as productName,
        pm.unit,
        pms.material_code as materialCode,
        pms.model
        from product_order po
        left join product_order_plan pop on po.id = pop.product_order_id
        left join production_plan pp on pp.id = pop.production_plan_id
        left join product_material_sku pms on pms.id = pop.production_plan_id
        left join product_material pm on pm.id = pms.product_id
        <where>
            <choose>
                <when test="productOrderId != null">
                    po.id = #{productOrderId}
                </when>
                <otherwise>
                    1 = 0
                </otherwise>
            </choose>
        </where>
    </select>
 
 
</mapper>