#
Junjie
2024-01-05 1c47b33225c57a13b65fc3bc2e43a7822b23b6a3
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
<?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.zy.asrs.common.wms.mapper.WrkDetlMapper">
 
    <sql id="batchSeq">
        <choose>
            <when test="batch != null and batch != ''">
                and batch = #{batch}
            </when>
            <otherwise>
                and (batch IS NULL OR batch = '')
            </otherwise>
        </choose>
    </sql>
 
    <select id="selectAndLogByOrderNoGroupByMatnrOfSum" resultType="com.zy.asrs.common.wms.entity.WrkDetl">
        select awd.wrk_no, awd.io_time, awd.matnr, sum(awd.anfme) as anfme
        from wms_wrk_detl awd
                 left join wms_wrk_mast awm on awd.wrk_no = awm.wrk_no and awd.io_time = awm.io_time
        where order_no = #{orderNo}
        group by awd.wrk_no, awd.io_time, awd.matnr
        union
        select distinct awdl.wrk_no, awdl.io_time, awdl.matnr, sum(awdl.anfme) as anfme
        from wms_wrk_detl_log awdl
                 left join wms_wrk_mast_log awml on awdl.wrk_no = awml.wrk_no and awdl.io_time = awml.io_time
        where awdl.order_no = #{orderNo}
          and (awml.manu_type is null or awml.manu_type != '手动取消')
        group by awdl.wrk_no, awdl.io_time, awdl.matnr
    </select>
 
    <update id="updateOrderNo">
        update wms_wrk_detl
        set order_no = #{orderNo}
        , modi_time = getdate()
        where 1=1
        and wrk_no = #{wrkNo}
        and matnr = #{matnr}
        and host_id = #{hostId}
        <include refid="batchSeq"></include>
    </update>
 
    <select id="selectAndLogByOrderNo" resultType="com.zy.asrs.common.wms.entity.WrkDetl">
        select awd.*
        from wms_wrk_detl awd
                 left join wms_wrk_mast awm on awd.wrk_no = awm.wrk_no and awd.io_time = awm.io_time
        where order_no = #{orderNo}
        and host_id = #{hostId}
        union
        select distinct awdl.*
        from wms_wrk_detl_log awdl
                 left join wms_wrk_mast_log awml on awdl.wrk_no = awml.wrk_no and awdl.io_time = awml.io_time
        where awdl.order_no = #{orderNo}
          and host_id = #{hostId}
          and (awml.manu_type is null or awml.manu_type != '手动取消')
    </select>
 
    <select id="selectPakoutQuery" resultType="com.zy.asrs.common.wms.entity.WrkDetl">
        select
            awd.*
        from wms_wrk_detl awd
                 left join asr_wrk_mast awm on awd.wrk_no = awm.wrk_no
        where 1=1
          and awm.wrk_sts = 199
          and (awd.inspect is null or awd.inspect = 0)
          and awm.sta_no = #{staNo}
          and awd.matnr + '-' + awd.batch = #{matnr}
    </select>
 
    <update id="updateInspect">
        update wms_wrk_detl
        set inspect = 1
        where 1=1
        and wrk_no = #{wrkNo}
        and matnr = #{matnr}
        and host_id = #{hostId}
        <include refid="batchSeq"></include>
    </update>
 
    <delete id="deleteItem">
        delete from wms_wrk_detl
        where 1=1
        and wrk_no = #{wrkNo}
        and matnr = #{matnr}
        and host_id = #{hostId}
        <include refid="batchSeq"></include>
    </delete>
 
    <update id="updateAnfme">
        update wms_wrk_detl
        set anfme = #{anfme}
        , modi_time = getdate()
        where 1=1
        and wrk_no = #{wrkNo}
        and matnr = #{matnr}
        and host_id = #{hostId}
        <include refid="batchSeq"></include>
    </update>
 
</mapper>