zss
6 小时以前 7d45b1aa345be565648f9ae01cd200631eb008a2
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?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.productionPlan.mapper.ProductionPlanMapper">
 
    <resultMap id="ProductionPlanResultMap" type="com.ruoyi.productionPlan.pojo.ProductionPlan">
        <id property="id" column="id"/>
        <result property="formInstanceId" column="form_instance_id"/>
        <result property="serialNo" column="serial_no"/>
        <result property="applyNo" column="apply_no"/>
        <result property="customerName" column="customer_name"/>
        <result property="productMaterialSkuId" column="product_material_sku_id"/>
        <result property="length" column="length"/>
        <result property="width" column="width"/>
        <result property="height" column="height"/>
        <result property="quantity" column="quantity"/>
        <result property="volume" column="volume"/>
        <result property="strength" column="strength"/>
        <result property="startDate" column="start_date"/>
        <result property="endDate" column="end_date"/>
        <result property="submitter" column="submitter"/>
        <result property="submitOrg" column="submit_org"/>
        <result property="remarkOne" column="remark_one"/>
        <result property="remarkTwo" column="remark_two"/>
        <result property="creatorName" column="creator_name"/>
        <result property="modifierName" column="modifier_name"/>
        <result property="formCreatedTime" column="form_created_time"/>
        <result property="formModifiedTime" column="form_modified_time"/>
        <result property="dataSourceType" column="data_source_type"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
        <result property="totalCount" column="total_count"/>
    </resultMap>
 
    <select id="listPage" resultType="com.ruoyi.productionPlan.dto.ProductionPlanDto">
        SELECT
        pp.*,
        pms.material_code AS materialCode,
        pms.model,
        pms.product_id AS productMaterialId,
        pm.product_name AS productName,
        pm.unit
        FROM production_plan pp
        left join product_material_sku pms on pp.product_material_sku_id = pms.id
        left join product_material pm on pms.product_id = pm.id
        WHERE 1 = 1
        <if test="c.customerName != null and c.customerName != '' ">
            AND pp.customer_name LIKE CONCAT('%',#{c.customerName},'%')
        </if>
        <if test="c.productName != null and c.productName != '' ">
            AND pm.product_name LIKE CONCAT('%',#{c.productName},'%')
        </if>
        <if test="c.materialCode != null and c.materialCode != '' ">
            AND pms.material_code LIKE CONCAT('%',#{c.materialCode},'%')
        </if>
        <if test="c.model != null and c.model != '' ">
            AND pms.model LIKE CONCAT('%',#{c.model},'%')
        </if>
         <if test="c.status != null">
            AND pp.status =#{c.status}
        </if>
        <if test="c.applyNo != null and c.applyNo != '' ">
            AND pp.apply_no LIKE CONCAT('%',#{c.applyNo},'%')
        </if>
        <if test="c.startDate != null">
            AND pp.start_date &gt;= DATE_FORMAT(#{c.startDate},'%Y-%m-%d')
        </if>
        <if test="c.endDate != null">
            AND pp.end_date &lt;= DATE_FORMAT(#{c.endDate},'%Y-%m-%d')
        </if>
        ORDER BY COALESCE(pp.form_modified_time, pp.id) DESC
    </select>
 
    <select id="selectSummaryByProductType" resultType="com.ruoyi.productionPlan.dto.ProductionPlanSummaryDto">
        SELECT
        sku.material_code AS materialCode,
        pm.product_name AS productName,
        sku.model,
        pp.length,
        pp.width,
        pp.height,
        pm.unit AS unit,
        COALESCE(SUM(pp.quantity),0) AS quantity,
        COALESCE(SUM(pp.volume),0) AS volume
        FROM production_plan pp
        LEFT JOIN product_material_sku sku
        ON pp.product_material_sku_id = sku.id
        LEFT JOIN product_material pm
        ON sku.product_id = pm.id
        <where>
            <if test="materialCode != null and materialCode != ''">
                AND sku.material_code LIKE CONCAT('%', #{materialCode}, '%')
            </if>
 
            <if test="productName != null and productName != ''">
                AND pm.product_name LIKE CONCAT('%', #{productName}, '%')
            </if>
 
            <if test="model != null and model != ''">
                AND sku.model LIKE CONCAT('%', #{model}, '%')
            </if>
        </where>
        GROUP BY
        sku.material_code,
        pm.product_name,
        sku.model,
        pp.length,
        pp.width,
        pp.height,
        pm.unit
    </select>
 
    <select id="selectWithMaterialByIds" resultType="com.ruoyi.productionPlan.dto.ProductionPlanDto">
        SELECT
        pp.*,
        pms.material_code AS materialCode,
        pms.model,
        pm.product_name AS productName,
        pm.unit
        FROM production_plan pp
        LEFT JOIN product_material_sku pms ON pp.product_material_sku_id = pms.id
        LEFT JOIN product_material pm ON pms.product_id = pm.id
        WHERE pp.id IN
        <foreach collection="ids" item="id" open="(" separator="," close=")">
            #{id}
        </foreach>
        ORDER BY pp.id ASC
    </select>
</mapper>