李林
2023-10-07 658d4927d468c47208fd012d9128b09249c07eff
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
<?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.chinaztt.mes.production.mapper.FeedingMapper">
 
    <resultMap id="feedingMap" type="com.chinaztt.mes.production.dto.FeedingDTO">
        <id property="id" column="id"/>
        <result property="workstationId" column="workstation_id"/>
        <result property="suppliedQuantity" column="supplied_quantity"/>
        <result property="residualQuantity" column="residual_quantity"/>
        <result property="partBatchNo" column="part_batch_no"/>
        <result property="systemNo" column="system_no"/>
        <result property="stockId" column="stock_id"/>
        <result property="createTime" column="create_time"/>
        <result property="createUser" column="create_user"/>
        <result property="partId" column="part_id"/>
        <result property="partNo" column="part_no"/>
        <result property="partName" column="part_name"/>
        <result property="workstationNo" column="workstation_no"/>
        <result property="workstationName" column="workstation_name"/>
        <result property="specs" column="specs"/>
        <result property="unit" column="unit"/>
        <result property="locName" column="loc_name"/>
        <result property="locNo" column="loc_no"/>
        <result property="ifsBatchNo" column="ifs_batch_no"/>
    </resultMap>
 
    <select id="getFeedingByParam" resultMap="feedingMap">
        select *
        from (
                 SELECT
                     f.workstation_id,
                     f."id",
                     f.supplied_quantity,
                     f.residual_quantity,
                     f.part_id,
                     f.part_batch_no,
                     f.ifs_batch_no,
                     f.system_no,
                     f.stock_id,
                     f.create_time,
                     coalesce(bs.staff_name, f.create_user) create_user,
                     bp.part_no,
                     bp.part_name,
                     bp.specs,
                     bp.description                         part_description,
                     bp.specs,
                     bp.unit
                 FROM
                     production_feeding f
                         LEFT JOIN basic_part bp ON bp."id" = f.part_id
                         left join basic_staff bs on bs.staff_no = f.create_user
                 where f.residual_quantity > 0) tempA
        <if test="ew.emptyOfWhere == false">
            ${ew.customSqlSegment}
        </if>
        order by create_time
    </select>
 
    <select id="pdaList" resultType="com.alibaba.fastjson.JSONObject">
        select workstation_no    "workstationNo",
               workstation_name  "workstationName",
               part_no           "partNo",
               part_name         "partName",
               part_batch_no     "partBatchNo",
               system_no         "systemNo",
               supplied_quantity "suppliedQuantity",
               residual_quantity "residualQuantity",
               create_time       "createTime",
               loc_name          "locName",
               loc_no            "locNo"
        from (
                 select bw.workstation_no,
                        bw."name" workstation_name,
                        bp.part_no,
                        bp.part_name,
                        pf.part_batch_no,
                        pf.system_no,
                        pf.supplied_quantity,
                        pf.residual_quantity,
                        pf.create_time,
                        bl.loc_name,
                        bl.loc_no
                 from production_feeding pf
                          left join basic_workstation bw on bw."id" = pf.workstation_id
                          left join basic_part bp on bp."id" = pf.part_id
                          left join warehouse_stock ws on ws."id" = pf.stock_id
                          left join basic_location bl on bl."id" = ws.location_id
             ) tempA
        <if test="ew.emptyOfWhere == false">
            <where>
                ${ew.SqlSegment}
            </where>
        </if>
        order by create_time desc
    </select>
 
</mapper>