InventoryMapper.xml
11.6 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<?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.huaheng.pc.inventory.inventory.mapper.InventoryMapper">
<select id="getInventoryBySearchModel" resultType="com.huaheng.pc.inventory.inventory.domain.Inventory" >
select * from inventory
<where>
<if test="companyCode != null">
and code = #{companyCode}
</if>
<if test="materialCode != 0">
and materialCode = #{materialCode}
</if>
<if test="locationCode != 0">
and locationCode = #{locationCode}
</if>
<if test="beginTime != 0">
and created > #{beginTime}
</if>
<if test="endTime != 0">
and created < #{endTime}
</if>
</where>
</select>
<select id="getInventryMaterialCode" resultType="java.lang.String">
select distinct materialCode from inventory where materialCode like #{code}
</select>
<select id="selectListEntityByLikeLocationCode" resultType="com.huaheng.pc.inventory.inventory.domain.Inventory">
SELECT distinct warehouseCode, locationCode, materialCode, qty, taskQty, deleted
FROM inventory
<where>
<if test="warehouseCode != null and warehouseCode != ''">
<bind name="warehouseCodePattern" value="'%' + warehouseCode + '%'" />
AND warehouseCode like #{warehouseCodePattern}
</if>
<if test="locationCode != null and locationCode != ''">
<bind name="locationCodePattern" value="'%' + locationCode + '%'" />
AND locationCode like #{locationCodePattern}
</if>
<if test="materialCode != null and materialCode != ''">
<bind name="materialCodePattern" value="'%' + materialCode + '%'" />
AND materialCode like #{materialCodePattern}
</if>
<if test="qty != null ">
AND qty = #{qty}
</if>
<if test="taskQty != null ">
AND taskQty = #{taskQty}
</if>
<if test="deleted != null ">
AND deleted = #{deleted}
</if>
</where>
GROUP BY locationCode
</select>
<select id="selectListEntityByLikeMaterialCode" resultType="com.huaheng.pc.inventory.inventory.domain.Inventory">
SELECT distinct warehouseCode, locationCode, materialCode, qty, taskQty, deleted
FROM inventory
<where>
<if test="warehouseCode != null and warehouseCode != ''">
<bind name="warehouseCodePattern" value="'%' + warehouseCode + '%'" />
AND warehouseCode like #{warehouseCodePattern}
</if>
<if test="locationCode != null and locationCode != ''">
<bind name="locationCodePattern" value="'%' + locationCode + '%'" />
AND locationCode like #{locationCodePattern}
</if>
<if test="materialCode != null and materialCode != ''">
<bind name="materialCodePattern" value="'%' + materialCode + '%'" />
AND materialCode like #{materialCodePattern}
</if>
<if test="qty != null ">
AND qty = #{qty}
</if>
<if test="taskQty != null ">
AND taskQty = #{taskQty}
</if>
<if test="deleted != null ">
AND deleted = #{deleted}
</if>
</where>
GROUP BY materialCode
</select>
<select id="getUncompleteReceiptContainer" resultType="java.lang.Integer">
SELECT count(*) from receipt_container_header WHERE locationCode = #{locationCode} and `status`<40 and warehouseId = #{warehouseId}
</select>
<select id="getUncompleteShipmentContainer" resultType="java.lang.Integer">
SELECT count(*) from shipment_container_header t join location b ON t.warehouseId = b.warehouseId and t.shipmentContainerCode = b.containerCode
WHERE b.`code` = #{locationCode} AND t.`status`<20 and t.warehouseId = #{warehouseId}
</select>
<select id="searchInventoryByLike" resultType="com.huaheng.pc.inventory.inventory.domain.InventorySearch">
SELECT inv.*,ma.specification as 'materialSpec',ma.name as 'materialName', rh.supplierCode
FROM inventory inv
INNER JOIN material ma ON inv.materialCode=ma.`code`
INNER JOIN receipt_header rh ON inv.receiptId=rh.id
<where>
<if test="id != null ">
AND inv.id = #{id}
</if>
<if test="warehouseId != null ">
AND inv.warehouseId = #{warehouseId}
</if>
<if test="warehouseCode != null and warehouseCode != ''">
<bind name="warehouseCodePattern" value="'%' + warehouseCode + '%'" />
AND inv.warehouseCode like #{warehouseCodePattern}
</if>
<if test="locationId != null ">
AND inv.locationId = #{locationId}
</if>
<if test="locationCode != null and locationCode != ''">
<bind name="locationCodePattern" value="'%' + locationCode + '%'" />
AND inv.locationCode like #{locationCodePattern}
</if>
<if test="sourceCode != null and sourceCode != ''">
<bind name="sourceCodePattern" value="'%' + sourceCode + '%'" />
AND inv.sourceCode like #{sourceCodePattern}
</if>
<if test="sourceLine != null and sourceLine != ''">
<bind name="sourceLinePattern" value="'%' + sourceLine + '%'" />
AND inv.sourceLine like #{sourceLinePattern}
</if>
<if test="companyId != null ">
AND inv.companyId = #{companyId}
</if>
<if test="companyCode != null and companyCode != ''">
<bind name="companyCodePattern" value="'%' + companyCode + '%'" />
AND inv.companyCode like #{companyCodePattern}
</if>
<if test="materialId != null ">
AND inv.materialId = #{materialId}
</if>
<if test="materialCode != null and materialCode != ''">
<bind name="materialCodePattern" value="'%' + materialCode + '%'" />
AND inv.materialCode like #{materialCodePattern}
</if>
<if test="receiptId != null ">
AND inv.receiptId = #{receiptId}
</if>
<if test="receiptCode != null and receiptCode != ''">
<bind name="receiptCodePattern" value="'%' + receiptCode + '%'" />
AND inv.receiptCode like #{receiptCodePattern}
</if>
<if test="receiptDetailId != null ">
AND inv.receiptDetailId = #{receiptDetailId}
</if>
<if test="batch != null and batch != ''">
<bind name="batchPattern" value="'%' + batch + '%'" />
AND inv.batch like #{batchPattern}
</if>
<if test="lot != null and lot != ''">
<bind name="lotPattern" value="'%' + lot + '%'" />
AND inv.lot like #{lotPattern}
</if>
<if test="project != null and project != ''">
<bind name="projectPattern" value="'%' + project + '%'" />
AND inv.project like #{projectPattern}
</if>
<if test="params != null and params.manufactureDateBegin != null and params.manufactureDateBegin != ''">
AND inv.manufactureDate >= #{params.manufactureDateBegin}
</if>
<if test="params != null and params.manufactureDateEnd != null and params.manufactureDateEnd != ''">
AND inv.manufactureDate <= #{params.manufactureDateEnd}
</if>
<if test="params != null and params.expirationDateBegin != null and params.expirationDateBegin != ''">
AND inv.expirationDate >= #{params.expirationDateBegin}
</if>
<if test="params != null and params.expirationDateEnd != null and params.expirationDateEnd != ''">
AND inv.expirationDate <= #{params.expirationDateEnd}
</if>
<if test="status != null and status != ''">
<bind name="statusPattern" value="'%' + status + '%'" />
AND inv.status like #{statusPattern}
</if>
<if test="qty != null ">
AND inv.qty = #{qty}
</if>
<if test="taskQty != null ">
AND inv.taskQty = #{taskQty}
</if>
<if test="costPrice != null ">
AND inv.costPrice = #{costPrice}
</if>
<if test="listPrice != null ">
AND inv.listPrice = #{listPrice}
</if>
<if test="netPrice != null ">
AND inv.netPrice = #{netPrice}
</if>
<if test="params != null and params.createdBegin != null and params.createdBegin != ''">
AND inv.created >= #{params.createdBegin}
</if>
<if test="params != null and params.createdEnd != null and params.createdEnd != ''">
AND inv.created <= #{params.createdEnd}
</if>
<if test="createdBy != null and createdBy != ''">
<bind name="createdByPattern" value="'%' + createdBy + '%'" />
AND inv.createdBy like #{createdByPattern}
</if>
<if test="params != null and params.lastUpdatedBegin != null and params.lastUpdatedBegin != ''">
AND inv.lastUpdated >= #{params.lastUpdatedBegin}
</if>
<if test="params != null and params.lastUpdatedEnd != null and params.lastUpdatedEnd != ''">
AND inv.lastUpdated <= #{params.lastUpdatedEnd}
</if>
<if test="lastUpdatedBy != null and lastUpdatedBy != ''">
<bind name="lastUpdatedByPattern" value="'%' + lastUpdatedBy + '%'" />
AND inv.lastUpdatedBy like #{lastUpdatedByPattern}
</if>
<if test="userDef1 != null and userDef1 != ''">
<bind name="userDef1Pattern" value="'%' + userDef1 + '%'" />
AND inv.userDef1 like #{userDef1Pattern}
</if>
<if test="userDef2 != null and userDef2 != ''">
<bind name="userDef2Pattern" value="'%' + userDef2 + '%'" />
AND inv.userDef2 like #{userDef2Pattern}
</if>
<if test="userDef3 != null and userDef3 != ''">
<bind name="userDef3Pattern" value="'%' + userDef3 + '%'" />
AND inv.userDef3 like #{userDef3Pattern}
</if>
<if test="deleted != null ">
AND inv.deleted = #{deleted}
</if>
<if test="materialName != null and materialName != ''">
<bind name="materialNamePattern" value="'%' + materialName + '%'" />
AND ma.name like #{materialNamePattern}
</if>
<if test="materialSpec != null and materialSpec != ''">
<bind name="materialSpecPattern" value="'%' + materialSpec + '%'" />
AND ma.specification like #{materialSpecPattern}
</if>
<if test="supplierCode != null and supplierCode != ''">
<bind name="supplierCodePattern" value="'%' + supplierCode + '%'" />
AND rh.supplierCode like #{supplierCodePattern}
</if>
</where>
</select>
</mapper>