李林
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?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.warehouse.mapper.EscortDetailMapper">
 
    <resultMap id="escortDetailDtoMap" type="com.chinaztt.mes.warehouse.dto.EscortDetailDTO">
        <id property="id" column="id"/>
        <result property="escortId" column="escort_id"/>
        <result property="stockOrderId" column="stock_order_id"/>
        <result property="customerOrderId" column="customer_order_id"/>
        <result property="customerOrderNo" column="customer_order_no"/>
        <result property="customerName" column="customer_name"/>
        <result property="partNo" column="part_no"/>
        <result property="partName" column="part_name"/>
        <result property="partBatchNo" column="part_batch_no"/>
        <result property="reservedQuantity" column="reserved_quantity"/>
        <result property="deliveredQuantity" column="delivered_quantity"/>
        <result property="stockId" column="stock_id"/>
        <result property="status" column="status"/>
        <result property="sendBackQuantity" column="send_back_quantity"/>
        <result property="escortInAutoId" column="escort_in_auto_id"/>
        <result property="escortOutAutoId" column="escort_out_auto_id"/>
    </resultMap>
 
    <update id="activeById">
        update warehouse_escort_detail set active=true where id=#{id}
    </update>
 
    <select id="getEscortDetailList" resultMap="escortDetailDtoMap">
        select
            temp.*
        from (
                 SELECT
                     wed.*,
                     we.customer_order_id,
                     pco.customer_order_no,
                     pco.customer_name,
                     bp.part_no,
                     bp.part_name,
                     ws.part_batch_no,
                     wed.stock_id,
                     we.escort_no,
                     we.status
                 FROM
                     warehouse_escort_detail wed
                         LEFT JOIN warehouse_stock ws ON ws."id" = wed.stock_id
                         LEFT JOIN warehouse_escort we ON wed.escort_id = we."id"
                         LEFT JOIN basic_part bp ON bp."id" = ws.part_id
                         LEFT JOIN plan_customer_order pco ON pco."id" = we.customer_order_id
                 WHERE
                     wed.active = TRUE
             ) temp
        <if test="ew.emptyOfWhere == false">
            ${ew.customSqlSegment}
        </if>
    </select>
 
    <select id="getEscortDetailListComplete" resultMap="escortDetailDtoMap">
        select
            temp.*
        from (
                 select wed.*,
                        wjso.customer_order_id,
                        pco.customer_order_no,
                        pco.customer_name,
                        wjso.part_no,
                        wjso.part_name,
                        wjso.part_batch_no,
                        wjso.reserved_quantity,
                        wjso.part_unit,
                        wjso.delivery_quantity             delivered_quantity,
                        wjso.stock_id,
                        we.escort_no,
                        we.status,
                        ws.system_no,
                        ws.location_id,
                        (SELECT sum(wsb.send_back_quantity)
                         FROM warehouse_send_back wsb
                         WHERE
                             wsb.escort_detail_id = wed."id"
                           AND wsb.status = '02completed') send_back_quantity
                 from warehouse_escort_detail wed
                          left join warehouse_join_stock_order wjso on wjso."id" = wed.stock_order_id
                          left join warehouse_stock ws on ws."id" = wjso.stock_id
                          left join plan_customer_order pco on pco."id" = wjso.customer_order_id
                          left join warehouse_escort we on we."id" = wed.escort_id
                 where wed.active = true
             ) temp
        <if test="ew.emptyOfWhere == false">
            ${ew.customSqlSegment}
        </if>
    </select>
 
    <select id="exportList" resultMap="escortDetailDtoMap">
        select
            temp.*
        from (
                 select wed.*,
                        wjso.customer_order_id,
                        pco.customer_order_no,
                        pco.customer_name,
                        wjso.part_no,
                        wjso.part_name,
                        wjso.part_batch_no,
                        wjso.reserved_quantity,
                        wjso.delivery_quantity delivered_quantity,
                        wjso.stock_id,
                        we.escort_no,
                        we.status
                 from warehouse_escort_detail wed
                          left join warehouse_join_stock_order wjso on wjso."id" = wed.stock_order_id
                          left join plan_customer_order pco on pco."id" = wjso.customer_order_id
                          left join warehouse_escort we on we."id" = wed.escort_id
                 where wed.active = true
             ) temp
        <if test="ew.emptyOfWhere == false">
            ${ew.customSqlSegment}
        </if>
    </select>
</mapper>