ShipmentDetailMapper.xml
16.8 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
<?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.shipment.shipmentDetail.mapper.ShipmentDetailMapper">
<select id="SelectFirstStatus" resultType="java.util.Map">
SELECT h.id, h.firstStatus
FROM shipment_header h
INNER JOIN shipment_detail d ON h.id = d.shipmentId AND d.id IN (#{ids})
GROUP BY h.id,firstStatus
</select>
<select id="selectListDetail" resultType="com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail">
SELECT d.id, d.warehouseId, d.warehouseCode, d.companyId, d.companyCode, d.sourceCode, d.sourceLine, d.shipmentId, d.shipmentCode, d.materialId, d.materialCode, d.batch, d.lot, d.project, d.manufactureDate, d.expirationDate, d.agingDate, d.inventoryStatus, d.qty, d.qtyCompleted, d.price, d.status, d.created, d.createdBy, d.lastUpdated, d.lastUpdatedBy, d.deleted, d.userDef1, d.userDef2, d.userDef3,
d.zoneCode
FROM shipment_detail d
where d.shipmentCode=#{shipmentCode} and d.warehouseId=#{warehouseId} and (d.zoneCode<>'QG' or d.zoneCode is null)
</select>
<select id="selectListAgvDetail" resultType="com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail">
SELECT d.id, d.warehouseId, d.warehouseCode, d.companyId, d.companyCode, d.sourceCode, d.sourceLine, d.shipmentId, d.shipmentCode, d.materialId, d.materialCode, d.batch, d.lot, d.project, d.manufactureDate, d.expirationDate, d.agingDate, d.inventoryStatus, d.qty, d.qtyCompleted, d.price, d.status, d.created, d.createdBy, d.lastUpdated, d.lastUpdatedBy, d.deleted, d.userDef1, d.userDef2, d.userDef3
FROM shipment_detail d
where d.shipmentCode=#{shipmentCode} and d.warehouseId=#{warehouseId} and d.zoneCode="AGV"
</select>
<select id="selectEntity" resultType="java.util.Map">
SELECT d.id, d.warehouseId, d.warehouseCode, d.companyId, d.companyCode, d.sourceCode, d.sourceLine, d.shipmentId, d.shipmentCode, d.materialId, d.materialCode, d.batch, d.lot, d.project, d.manufactureDate, d.expirationDate, d.agingDate, d.inventoryStatus, d.qty, d.qtyCompleted, d.price, d.status, d.created, d.createdBy, d.lastUpdated, d.lastUpdatedBy, d.deleted, d.userDef1, d.userDef2, d.userDef3,
m.name as materialName,m.specification, '个' unit
FROM shipment_detail d
INNER join material m on m.code=d.materialCode
where d.shipmentCode=#{shipmentCode} and d.id=#{id} and d.warehouseId=#{warehouseId} and d.warehouseId=m.warehouseId and (d.zoneCode<>"AGV" and d.zoneCode<>"QG" or d.zoneCode is null)
</select>
<select id="selectListEntity" resultType="java.util.Map">
SELECT d.id, d.warehouseId, d.warehouseCode, d.companyId, d.companyCode, d.sourceCode, d.sourceLine, d.shipmentId, d.shipmentCode, d.materialId, d.materialCode, d.batch, d.lot, d.project, d.manufactureDate, d.expirationDate, d.agingDate, d.inventoryStatus, d.qty, d.qtyCompleted, d.price, d.status, d.created, d.createdBy, d.lastUpdated, d.lastUpdatedBy, d.deleted, d.userDef1, d.userDef2, d.userDef3,
m.name as materialName,m.specification, m.masterUnit unit
FROM shipment_detail d
INNER join material m on m.code=d.materialCode
where d.shipmentCode=#{shipmentCode} and d.warehouseId=#{warehouseId} and d.warehouseId=m.warehouseId and (d.zoneCode<>"AGV" and d.zoneCode<>"QG" or d.zoneCode is null) and m.deleted = 0
</select>
<select id="getAvgShipping" resultType="java.util.Map">
SELECT d.id, d.warehouseId, d.warehouseCode, d.companyId, d.companyCode, d.sourceCode, d.sourceLine, d.shipmentId, d.shipmentCode, d.materialId, d.materialCode, d.batch, d.lot, d.project, d.manufactureDate, d.expirationDate, d.agingDate, d.inventoryStatus, d.qty, d.qtyCompleted, d.price, d.status, d.created, d.createdBy, d.lastUpdated, d.lastUpdatedBy, d.deleted, d.userDef1, d.userDef2, d.userDef3,
m.name as materialName,m.specification, m.masterUnit unit
FROM shipment_detail d
INNER join material m on m.code=d.materialCode
where d.shipmentCode=#{shipmentCode} and d.id=#{id} and d.warehouseId=#{warehouseId} and d.warehouseId=m.warehouseId and d.zoneCode="AGV"
</select>
<select id="getAvgShippings" resultType="java.util.Map">
SELECT d.id, d.warehouseId, d.warehouseCode, d.companyId, d.companyCode, d.sourceCode, d.sourceLine, d.shipmentId, d.shipmentCode, d.materialId, d.materialCode, d.batch, d.lot, d.project, d.manufactureDate, d.expirationDate, d.agingDate, d.inventoryStatus, d.qty, d.qtyCompleted, d.price, d.status, d.created, d.createdBy, d.lastUpdated, d.lastUpdatedBy, d.deleted, d.userDef1, d.userDef2, d.userDef3,
m.name as materialName,m.specification, m.masterUnit unit
FROM shipment_detail d
INNER join material m on m.code=d.materialCode
where d.shipmentCode=#{shipmentCode} and d.warehouseId=#{warehouseId} and d.warehouseId=m.warehouseId and d.zoneCode="AGV"
</select>
<select id="selectLists" resultType="java.util.Map">
SELECT d.id, d.materialCode, d.inventoryStatus,i.containerCode,i.locationCode,i.qty,
m.name as materialName,m.specification
FROM shipment_detail d
INNER join inventory i on d.materialCode=i.materialCode and d.warehouseCode=i.warehouseCode
INNER join material m on m.code=d.materialCode and d.warehouseCode=m.warehouseCode
where d.shipmentCode=#{code} and d.warehouseCode=#{warehouseCode} and d.zoneCode="AGV" and i.zoneCode="AGV" and i.containerCode like CONCAT(#{shelfNo},'%') group by d.id
</select>
<delete id="batchDelete">
DELETE FROM shipment_detail WHERE id IN
<foreach item="idItem" collection="array" open="(" separator="," close=")">
#{idItem}
</foreach>
</delete>
<select id="countUnCompleted" resultType="java.lang.Integer">
SELECT COUNT(*) FROM shipment_detail WHERE shipmentId=#{shipmentId} AND qty>qtyCompleted
</select>
<select id="getShipmentDetailListByLike" resultType="com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail">
SELECT d.id,d.warehouseId,d.warehouseCode,d.companyId,d.companyCode,d.sourceCode,d.sourceLine,d.shipmentId,d.shipmentCode,
d.materialId,d.materialCode,d.batch,d.lot,d.project,d.manufactureDate,d.expirationDate,d.agingDate,d.inventoryStatus,d.qty,d.qtyCompleted,
d.price,d.status,d.created,d.createdBy,d.lastUpdated,d.lastUpdatedBy,d.deleted,d.userDef1,d.userDef2,d.userDef3,
m.name as materialName, m.specification
FROM shipment_detail d
INNER JOIN material m
ON d.materialCode = m.code AND d.warehouseId = m.warehouseId AND d.deleted = FALSE AND m.deleted = FALSE
<if test="id != null ">
AND d.id = #{id}
</if>
<if test="warehouseId != null ">
AND d.warehouseId = #{warehouseId}
</if>
<if test="warehouseCode != null and warehouseCode != ''">
<bind name="warehouseCodePattern" value="'%' + warehouseCode + '%'" />
AND d.warehouseCode like #{warehouseCodePattern}
</if>
<if test="sourceLine != null and sourceLine != ''">
<bind name="sourceLinePattern" value="'%' + sourceLine + '%'" />
AND d.sourceLine like #{sourceLinePattern}
</if>
<if test="shipmentId != null ">
AND d.shipmentId = #{shipmentId}
</if>
<if test="shipmentCode != null and shipmentCode != ''">
<bind name="shipmentCodePattern" value="'%' + shipmentCode + '%'" />
AND d.shipmentCode like #{shipmentCodePattern}
</if>
<if test="materialId != null ">
AND d.materialId = #{materialId}
</if>
<if test="materialCode != null and materialCode != ''">
<bind name="materialCodePattern" value="'%' + materialCode + '%'" />
AND d.materialCode like #{materialCodePattern}
</if>
<if test="batch != null and batch != ''">
<bind name="batchPattern" value="'%' + batch + '%'" />
AND d.batch like #{batchPattern}
</if>
<if test="lot != null and lot != ''">
<bind name="lotPattern" value="'%' + lot + '%'" />
AND d.lot like #{lotPattern}
</if>
<if test="project != null and project != ''">
<bind name="projectPattern" value="'%' + project + '%'" />
AND d.project like #{projectPattern}
</if>
<if test="params != null and params.manufactureDateBegin != null and params.manufactureDateBegin != ''">
AND d.manufactureDate >= #{params.manufactureDateBegin}
</if>
<if test="params != null and params.manufactureDateEnd != null and params.manufactureDateEnd != ''">
AND d.manufactureDate <= #{params.manufactureDateEnd}
</if>
<if test="params != null and params.expirationDateBegin != null and params.expirationDateBegin != ''">
AND d.expirationDate >= #{params.expirationDateBegin}
</if>
<if test="params != null and params.expirationDateEnd != null and params.expirationDateEnd != ''">
AND d.expirationDate <= #{params.expirationDateEnd}
</if>
<if test="inventoryStatus != null and inventoryStatus != ''">
<bind name="inventoryStatusPattern" value="'%' + inventoryStatus + '%'" />
AND d.inventoryStatus like #{inventoryStatusPattern}
</if>
<if test="qty != null ">
AND d.qty = #{qty}
</if>
<if test="qtyCompleted != null ">
AND d.qtyCompleted = #{qtyCompleted}
</if>
<if test="price != null ">
AND d.price = #{price}
</if>
<if test="status != null ">
AND d.status = #{status}
</if>
<if test="params != null and params.createdBegin != null and params.createdBegin != ''">
AND d.created >= #{params.createdBegin}
</if>
<if test="params != null and params.createdEnd != null and params.createdEnd != ''">
AND d.created <= #{params.createdEnd}
</if>
<if test="createdBy != null and createdBy != ''">
<bind name="createdByPattern" value="'%' + createdBy + '%'" />
AND d.createdBy like #{createdByPattern}
</if>
<if test="params != null and params.lastUpdatedBegin != null and params.lastUpdatedBegin != ''">
AND d.lastUpdated >= #{params.lastUpdatedBegin}
</if>
<if test="params != null and params.lastUpdatedEnd != null and params.lastUpdatedEnd != ''">
AND d.lastUpdated <= #{params.lastUpdatedEnd}
</if>
<if test="lastUpdatedBy != null and lastUpdatedBy != ''">
<bind name="lastUpdatedByPattern" value="'%' + lastUpdatedBy + '%'" />
AND d.lastUpdatedBy like #{lastUpdatedByPattern}
</if>
<if test="deleted != null ">
AND d.deleted = #{deleted}
</if>
<if test="userDef1 != null and userDef1 != ''">
<bind name="userDef1Pattern" value="'%' + userDef1 + '%'" />
AND d.userDef1 like #{userDef1Pattern}
</if>
<if test="userDef2 != null and userDef2 != ''">
<bind name="userDef2Pattern" value="'%' + userDef2 + '%'" />
AND d.userDef2 like #{userDef2Pattern}
</if>
<if test="userDef3 != null and userDef3 != ''">
<bind name="userDef3Pattern" value="'%' + userDef3 + '%'" />
AND d.userDef3 like #{userDef3Pattern}
</if>
</select>
<select id="StatisticalByReceiptId" resultType="java.util.Map">
SELECT count(*) as 'totalLines',sum(qty) as 'totalQty'
FROM shipment_detail
WHERE shipmentId=#{receiptId} and deleted=FALSE
</select>
<update id="updateDetails" >
update shipment_detail s inner join inventory i on s.shipmentCode=#{code} and s.materialCode=i.materialCode and s.warehouseCode=i.warehouseCode set s.zoneCode=i.zoneCode
</update>
<select id="getShipmentQtyLast7Days" resultType="com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail">
SELECT
a.click_date AS lastUpdated,
ifnull( b.taskQty, 0 ) AS qty
FROM
(
SELECT
curdate( ) AS click_date UNION ALL
SELECT
date_sub( curdate( ), INTERVAL 1 DAY ) AS click_date UNION ALL
SELECT
date_sub( curdate( ), INTERVAL 2 DAY ) AS click_date UNION ALL
SELECT
date_sub( curdate( ), INTERVAL 3 DAY ) AS click_date UNION ALL
SELECT
date_sub( curdate( ), INTERVAL 4 DAY ) AS click_date UNION ALL
SELECT
date_sub( curdate( ), INTERVAL 5 DAY ) AS click_date UNION ALL
SELECT
date_sub( curdate( ), INTERVAL 6 DAY ) AS click_date
) a
LEFT JOIN (
SELECT
DATE( r.lastUpdated ) AS date,
SUM( r.qtyCompleted ) AS taskQty
FROM
shipment_detail r
WHERE
r.lastUpdated >= DATE_SUB( CURDATE( ), INTERVAL 7 DAY )
AND r.status=300
GROUP BY
DATE(r.lastUpdated )
) b ON a.click_date = b.date
ORDER BY
a.click_date;
</select>
<select id="getWarehouseShipment" resultType="com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail">
SELECT ifnull(sum(r.qtyCompleted),0) as qty,w.name as warehouseName from warehouse w
left JOIN shipment_detail r on r.warehouseCode=w.code and r.status=300
and date(r.lastUpdated)=CURDATE() group by w.code
</select>
<select id="getCompanyShipment" resultType="com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail">
SELECT ifnull(sum(r.qtyCompleted),0) as qty,c.name as companyName from company c
left JOIN shipment_detail r on r.companyCode=c.code and r.status=300
and date(r.lastUpdated)=CURDATE() group by c.code
</select>
<select id="selectEntityByIdWithMaterialName"
resultType="com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail">
SELECT d.id, d.warehouseId, d.warehouseCode, d.zoneCode, d.companyId, d.companyCode, d.sourceCode, d.sourceLine, d.shipmentId, d.shipmentCode, d.materialId, d.materialCode, d.batch, d.lot, d.project, d.manufactureDate, d.expirationDate, d.agingDate, d.inventoryStatus, d.qty, d.qtyCompleted, d.unit, d.price, d.status, d.created, d.createdBy, d.lastUpdated, d.lastUpdatedBy, d.deleted, d.userDef1, d.userDef2, d.userDef3,
m.name as materialName, m.specification
FROM shipment_detail d
INNER JOIN material m
ON d.materialCode = m.code AND d.warehouseId = m.warehouseId AND d.deleted = FALSE AND m.deleted = FALSE AND d.shipmentId = #{shipmentId}
</select>
<insert id="insertBatch" parameterType="com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail" keyProperty="id" useGeneratedKeys="true" >
INSERT INTO shipment_detail
(
warehouseId,
warehouseCode,
zoneCode,
companyId,
companyCode,
sourceCode,
sourceLine,
shipmentId,
shipmentCode,
materialId,
materialCode,
batch,
lot,
project,
manufactureDate,
expirationDate,
agingDate,
inventoryStatus,
qty,
qtyCompleted,
unit,
price,
status,
created,
createdBy,
lastUpdated,
lastUpdatedBy,
userDef1,
userDef2,
userDef3
)VALUES
<foreach collection="shipmentDetailList" item="item" index="index" separator=",">
(
#{item.warehouseId, jdbcType=INTEGER},
#{item.warehouseCode, jdbcType=VARCHAR},
#{item.zoneCode, jdbcType=VARCHAR},
#{item.companyId, jdbcType=INTEGER},
#{item.companyCode, jdbcType=VARCHAR},
#{item.sourceCode, jdbcType=VARCHAR},
#{item.sourceLine, jdbcType=VARCHAR},
#{item.shipmentId, jdbcType=INTEGER},
#{item.shipmentCode, jdbcType=VARCHAR},
#{item.materialId, jdbcType=INTEGER},
#{item.materialCode, jdbcType=VARCHAR},
#{item.batch, jdbcType=VARCHAR},
#{item.lot, jdbcType=VARCHAR},
#{item.project, jdbcType=VARCHAR},
#{item.manufactureDate, jdbcType=TIMESTAMP},
#{item.expirationDate, jdbcType=TIMESTAMP},
#{item.agingDate, jdbcType=TIMESTAMP},
#{item.inventoryStatus, jdbcType=VARCHAR},
#{item.qty, jdbcType=DECIMAL},
#{item.qtyCompleted, jdbcType=DECIMAL},
#{item.unit, jdbcType=VARCHAR},
#{item.price, jdbcType=DECIMAL},
#{item.status, jdbcType=SMALLINT},
#{item.created, jdbcType=TIMESTAMP},
#{item.createdBy, jdbcType=VARCHAR},
#{item.lastUpdated, jdbcType=TIMESTAMP},
#{item.lastUpdatedBy, jdbcType=VARCHAR},
#{item.userDef1, jdbcType=VARCHAR},
#{item.userDef2, jdbcType=VARCHAR},
#{item.userDef3, jdbcType=VARCHAR}
)
</foreach>
</insert>
</mapper>