zjj
2024-05-30 a83eeabe948a953290062e5dcedb0d33f01defef
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
132
133
134
135
136
137
138
139
<?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.OrderDetlMapper">
 
    <sql id="pakOutPageCondition">
        <if test="map.order_id!=null and map.order_id!='' ">
            and mod.order_id = #{map.order_id}
        </if>
        <if test="map.matnr!=null and map.matnr!='' ">
            and mod.matnr = #{map.matnr}
        </if>
        <if test="map.maktx!=null and map.maktx!='' ">
            and mod.maktx = #{map.maktx}
        </if>
        <if test="map.batch!=null and map.batch!='' ">
            and mod.batch = #{map.batch}
        </if>
    </sql>
 
    <select id="selectWorkingDetls" resultType="com.zy.asrs.common.wms.entity.OrderDetl">
        select * from wms_order_detl
        where 1=1
        and order_id = #{orderId}
        and qty &lt; anfme
    </select>
 
    <select id="selectItem" resultType="com.zy.asrs.common.wms.entity.OrderDetl">
        select * from wms_order_detl
        where 1=1
        and order_id = #{orderId}
        and matnr = #{matnr}
        and host_id = #{hostId}
        <choose>
            <when test="batch != null and batch != ''">
                and batch = #{batch}
            </when>
            <otherwise>
                and (batch IS NULL OR batch = '')
            </otherwise>
        </choose>
    </select>
 
    <select id="selectItem2" resultType="com.zy.asrs.common.wms.entity.OrderDetl">
        select * from wms_order_detl
        where 1=1
        and order_no = #{orderNo}
        and matnr = #{matnr}
        <choose>
            <when test="batch != null and batch != ''">
                and batch = #{batch}
            </when>
            <otherwise>
                and (batch IS NULL OR batch = '')
            </otherwise>
        </choose>
    </select>
 
    <select id="getPakoutPage" resultType="com.zy.asrs.common.wms.entity.OrderDetl">
        select
        mod.*
        from wms_order_detl mod
        inner join wms_order mo on mod.order_id = mo.id
        inner join wms_doc_type mdt on mo.doc_type = mdt.doc_id
        where 1=1
        and mo.settle &lt;= 2
        and mo.status = 1
        and mdt.pakout = 1
        <include refid="pakOutPageCondition"></include>
    </select>
 
    <update id="increase">
        update wms_order_detl
        set qty = qty + #{qty}
        where 1=1
        and order_id = #{orderId}
        and matnr = #{matnr}
        and host_id = #{hostId}
        <choose>
            <when test="batch != null and batch != ''">
                and batch = #{batch}
            </when>
            <otherwise>
                and (batch IS NULL OR batch = '')
            </otherwise>
        </choose>
    </update>
 
    <update id="decrease">
        update wms_order_detl
        set work_qty = work_qty - #{qty}
        where 1=1
        and order_no = #{orderNo}
        and matnr = #{matnr}
        and host_id = #{hostId}
        <choose>
            <when test="batch != null and batch != ''">
                and batch = #{batch}
            </when>
            <otherwise>
                and (batch IS NULL OR batch = '')
            </otherwise>
        </choose>
    </update>
 
    <update id="increaseQtyByOrderNo">
        update wms_order_detl
        set qty = qty + #{qty}
        where 1=1
        and order_no = #{orderNo}
        and matnr = #{matnr}
        and host_id = #{hostId}
        <choose>
            <when test="batch != null and batch != ''">
                and batch = #{batch}
            </when>
            <otherwise>
                and (batch IS NULL OR batch = '')
            </otherwise>
        </choose>
    </update>
 
    <update id="increaseWorkQtyByOrderNo">
        update wms_order_detl
        set work_qty = work_qty + #{qty}
        where 1=1
        and order_no = #{orderNo}
        and matnr = #{matnr}
        and host_id = #{hostId}
        <choose>
            <when test="batch != null and batch != ''">
                and batch = #{batch}
            </when>
            <otherwise>
                and (batch IS NULL OR batch = '')
            </otherwise>
        </choose>
    </update>
 
</mapper>