InventoryMapper.xml
31.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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
<?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="companyIdList != null ">
AND companyId in
<foreach collection="companyIdList" item="companyIdItem" open="(" separator="," close=")">
#{companyIdItem}
</foreach>
</if>
<if test="companyId != null">
AND companyId = #{companyId}
</if>
<if test="companyCodeList != null ">
AND companyCode in
<foreach collection="companyCodeList" item="companyCodeItem" open="(" separator="," close=")">
#{companyCodeItem}
</foreach>
</if>
<if test="companyCode != null">
AND companyCode = #{companyCode}
</if>
<if test="materialCode != null">
and materialCode = #{materialCode}
</if>
<if test="locationCode != null">
and locationCode = #{locationCode}
</if>
<if test="containerCode != null">
and containerCode = #{containerCode}
</if>
<if test="beginTime != null">
and created > #{beginTime}
</if>
<if test="endTime != null">
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 != ''">
AND warehouseCode = #{warehouseCode}
</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>
<if test="companyIdList != null ">
AND companyId in
<foreach collection="companyIdList" item="companyIdItem" open="(" separator="," close=")">
#{companyIdItem}
</foreach>
</if>
<if test="companyId != null">
AND companyId = #{companyId}
</if>
<if test="companyCodeList != null ">
AND companyCode in
<foreach collection="companyCodeList" item="companyCodeItem" open="(" separator="," close=")">
#{companyCodeItem}
</foreach>
</if>
<if test="companyCode != null">
AND companyCode = #{companyCode}
</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 != ''">
AND warehouseCode = #{warehouseCode}
</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>
<if test="companyIdList != null ">
AND companyId in
<foreach collection="companyIdList" item="companyIdItem" open="(" separator="," close=")">
#{companyIdItem}
</foreach>
</if>
<if test="companyId != null">
AND companyId = #{companyId}
</if>
<if test="companyCodeList != null ">
AND companyCode in
<foreach collection="companyCodeList" item="companyCodeItem" open="(" separator="," close=")">
#{companyCodeItem}
</foreach>
</if>
<if test="companyCode != null">
AND companyCode = #{companyCode}
</if>
</where>
GROUP BY materialCode
</select>
<select id="getUncompleteReceiptContainer" resultType="java.lang.Integer">
SELECT count(*) from receipt_container_header WHERE locationCode = #{locationCode} and `status`<20 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, rh.supplierName, ma.userDef1 as 'materialOldCode'
FROM inventory inv
INNER JOIN material ma ON inv.materialCode=ma.`code` and inv.warehouseCode=ma.warehouseCode
LEFT JOIN receipt_header rh ON inv.receiptId=rh.id
<where>
<if test="id != null ">
AND inv.id = #{id}
</if>
<if test="uWarehouseCode != null and uWarehouseCode!=''">
AND inv.uWarehouseCode = #{uWarehouseCode}
</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 = #{locationCodePattern}
</if>
<if test="containerCode != null and containerCode != ''"> <!--//容器编号-->
<bind name="containerCodePattern" value="containerCode" />
AND inv.containerCode = #{containerCodePattern}
</if>
<if test="zoneCode != null and zoneCode != ''">
AND inv.zoneCode = #{zoneCode}
</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="companyIdList != null ">
AND inv.companyId in
<foreach collection="companyIdList" item="companyIdItem" open="(" separator="," close=")">
#{companyIdItem}
</foreach>
</if>
<if test="companyId != null">
AND inv.companyId = #{companyId}
</if>
<if test="companyCodeList != null ">
AND inv.companyCode in
<foreach collection="companyCodeList" item="companyCodeItem" open="(" separator="," close=")">
#{companyCodeItem}
</foreach>
</if>
<if test="companyCode != null">
AND inv.companyCode = #{companyCode}
</if>
<if test="materialId != null ">
AND inv.materialId = #{materialId}
</if>
<if test="materialCode != null and materialCode != ''">
<bind name="materialCodePattern" value="materialCode" />
AND inv.materialCode = #{materialCodePattern}
</if>
<if test="receiptId != null ">
AND inv.receiptId = #{receiptId}
</if>
<if test="receiptCode != null and receiptCode != ''">
AND inv.receiptCode = #{receiptCodePattern}
</if>
<if test="receiptDetailId != null ">
AND inv.receiptDetailId = #{receiptDetailId}
</if>
<if test="batch != null and batch != ''">
AND inv.batch = #{batchPattern}
</if>
<if test="lot != null and lot != ''">
AND inv.lot = #{lotPattern}
</if>
<if test="project != null and project != ''">
AND inv.project = #{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 != ''">
AND inv.status = #{status}
</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 != ''">
AND inv.userDef1 = #{userDef1}
</if>
<if test="userDef2 != null and userDef2 != ''">
AND inv.userDef2 = #{userDef2Pattern}
</if>
<if test="userDef3 != null and userDef3 != ''">
AND inv.userDef3 = #{userDef3Pattern}
</if>
<if test="deleted != null ">
AND inv.deleted = #{deleted}
</if>
<if test="materialOldCode != null and materialOldCode != ''">
<bind name="materialOldCodePattern" value="materialOldCode" />
AND ma.userDef1 = #{materialOldCodePattern}
</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 != ''">
AND rh.supplierCode = #{supplierCode}
</if>
AND ma.deleted = 0
</where>
</select>
<select id="selectFirstInvertory" resultType="com.huaheng.pc.inventory.inventory.domain.Inventory">
select i.materialCode,i.containerCode,i.locationCode,i.qty from inventory i
inner join container c on i.containerCode=c.code
where
i.containerCode<>#{condition.receiptContainerCode} and i.materialCode=#{condition.materialCode} and c.status='some' and i.containerCode like CONCAT('%',#{code},'%')
limit 1
</select>
<select id="selectList" resultType="com.huaheng.pc.inventory.inventory.domain.Inventory">
select i.materialCode,i.containerCode,i.locationCode,i.qty from inventory i
inner join container c on i.containerCode=c.code
where
c.goodsShelfNo<>#{code} and c.status='some' and i.materialCode=#{record.materialCode}
limit 1
</select>
<select id="getSumQtyByZoneId" resultType="java.math.BigDecimal">
SELECT SUM(b.qty) FROM `location` a RIGHT JOIN `inventory` b ON a.CODE = b.locationCode WHERE a.zoneId = #{zoneid} AND b.materialCode = #{materialCode} AND a.`enable` = TRUE AND b.deleted = FALSE
</select>
<update id="updateLocationCode">
update inventory i inner join container c on i.containerCode=c.code
and i.warehouseCode=#{warehouseCode} and c.warehouseCode=#{warehouseCode} and c.code like CONCAT(#{code},'%')
set i.locationCode=c.locationCode
</update>
<!--这条sql的意思是,如果id为1,则name的值为name1,title的值为New Title1;依此类推-->
<update id="updateBatch" parameterType="java.util.List">
update inventory
<trim prefix="set" suffixOverrides=",">
<trim prefix="warehouseId =case" suffix="end,">
<foreach collection="inventoryList" item="item" index="index">
<if test="item.warehouseId != null">
when id = #{item.id} then #{item.warehouseId}
</if>
</foreach>
</trim>
<trim prefix="warehouseCode =case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
<if test="item.warehouseCode != null and item.warehouseCode != '' ">
when id = #{item.id} then #{item.warehouseCode}
</if>
</foreach>
</trim>
<trim prefix="uWarehouseCode=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.uWarehouseCode}
</foreach>
</trim>
<trim prefix="zoneId=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.zoneId}
</foreach>
</trim>
<trim prefix="zoneCode=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.zoneCode}
</foreach>
</trim>
<trim prefix="weight=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.weight}
</foreach>
</trim>
<trim prefix="locationId=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.locationId}
</foreach>
</trim>
<trim prefix="locationCode=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.locationCode}
</foreach>
</trim>
<trim prefix="containerCode=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.containerCode}
</foreach>
</trim>
<trim prefix="sourceCode=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.sourceCode}
</foreach>
</trim>
<trim prefix="sourceLine=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.sourceLine}
</foreach>
</trim>
<trim prefix="companyId=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.companyId}
</foreach>
</trim>
<trim prefix="companyCode=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.companyCode}
</foreach>
</trim>
<trim prefix="materialId=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.materialId}
</foreach>
</trim>
<trim prefix="materialCode=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.materialCode}
</foreach>
</trim>
<trim prefix="receiptId=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.receiptId}
</foreach>
</trim>
<trim prefix="receiptCode=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.receiptCode}
</foreach>
</trim>
<trim prefix="receiptDetailId=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.receiptDetailId}
</foreach>
</trim>
<trim prefix="batch=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.batch}
</foreach>
</trim>
<trim prefix="lot=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.lot}
</foreach>
</trim>
<trim prefix="project=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.project}
</foreach>
</trim>
<trim prefix="manufactureDate=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.manufactureDate}
</foreach>
</trim>
<trim prefix="expirationDate=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.expirationDate}
</foreach>
</trim>
<trim prefix="status=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.status}
</foreach>
</trim>
<trim prefix="containerStatus=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.containerStatus}
</foreach>
</trim>
<trim prefix="qty=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.qty}
</foreach>
</trim>
<trim prefix="taskQty=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.taskQty}
</foreach>
</trim>
<trim prefix="costPrice=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.costPrice}
</foreach>
</trim>
<trim prefix="listPrice=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.listPrice}
</foreach>
</trim>
<trim prefix="netPrice=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.netPrice}
</foreach>
</trim>
<trim prefix="created=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.created}
</foreach>
</trim>
<trim prefix="createdBy=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.createdBy}
</foreach>
</trim>
<trim prefix="lastUpdated=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.lastUpdated}
</foreach>
</trim>
<trim prefix="lastUpdatedBy=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.lastUpdatedBy}
</foreach>
</trim>
<trim prefix="userDef1=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.userDef1}
</foreach>
</trim>
<trim prefix="userDef2=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.userDef2}
</foreach>
</trim>
<trim prefix="userDef3=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.userDef3}
</foreach>
</trim>
<trim prefix="deleted=case" suffix="end," >
<foreach collection="inventoryList" item="item" index="index">
when id = #{item.id} then #{item.deleted}
</foreach>
</trim>
</trim>
where id in
<foreach collection="inventoryList" separator="," item="item" index="index" open="(" close=")">
#{item.id,jdbcType=INTEGER}
</foreach>
</update>
<!--批量新增-->
<insert id="insertBatch" parameterType="com.huaheng.pc.inventory.inventory.domain.Inventory" keyProperty="id" useGeneratedKeys="true">
INSERT INTO inventory(
warehouseId,
warehouseCode,
uWarehouseCode,
zoneId,
zoneCode,
weight,
locationId,
locationCode,
containerCode,
sourceCode,
sourceLine,
companyId,
companyCode,
materialId,
materialCode,
receiptId,
receiptCode,
receiptDetailId,
batch,
lot,
project,
manufactureDate,
expirationDate,
status,
containerStatus,
qty,
taskQty,
costPrice,
listPrice,
netPrice,
created,
createdBy,
lastUpdated,
lastUpdatedBy,
userDef1,
userDef2,
userDef3,
deleted
)VALUES
<foreach collection="inventoryBatch" item="item" index="index" separator=",">
(
#{item.warehouseId, jdbcType=INTEGER},
#{item.warehouseCode, jdbcType=VARCHAR},
#{item.uWarehouseCode, jdbcType=VARCHAR},
#{item.zoneId, jdbcType=INTEGER},
#{item.zoneCode, jdbcType=VARCHAR},
#{item.weight, jdbcType=FLOAT},
#{item.locationId, jdbcType=INTEGER},
#{item.locationCode, jdbcType=VARCHAR},
#{item.containerCode, jdbcType=VARCHAR},
#{item.sourceCode, jdbcType=VARCHAR},
#{item.sourceLine, jdbcType=VARCHAR},
#{item.companyId, jdbcType=INTEGER},
#{item.companyCode, jdbcType=VARCHAR},
#{item.materialId, jdbcType=INTEGER},
#{item.materialCode, jdbcType=VARCHAR},
#{item.receiptId, jdbcType=INTEGER},
#{item.receiptCode, jdbcType=VARCHAR},
#{item.receiptDetailId, jdbcType=INTEGER},
#{item.batch, jdbcType=VARCHAR},
#{item.lot, jdbcType=VARCHAR},
#{item.project, jdbcType=VARCHAR},
#{item.manufactureDate, jdbcType=TIMESTAMP},
#{item.expirationDate, jdbcType=TIMESTAMP},
#{item.status, jdbcType=VARCHAR},
#{item.containerStatus, jdbcType=VARCHAR},
#{item.qty, jdbcType=DECIMAL},
#{item.taskQty, jdbcType=DECIMAL},
#{item.costPrice, jdbcType=DECIMAL},
#{item.listPrice, jdbcType=DECIMAL},
#{item.netPrice, jdbcType=DECIMAL},
#{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},
#{item.deleted, jdbcType=BIT}
)
</foreach>
</insert>
<select id="getSumQty" resultType="java.math.BigDecimal">
SELECT ifnull(sum(qty),0) qty from inventory where materialCode=#{materialCode} and warehouseCode=#{warehouseCode}
</select>
<select id="getWarehouseInventoryProp" resultType="java.util.LinkedHashMap">
-- SELECT w.name,a.name,ifnull(a.total,0) total from warehouse w
-- left join
-- (SELECT m.name name,sum(i.qty) total,i.warehouseCode warehouseCode from inventory i
-- inner join material m on i.materialCode = m.`code` and i.warehouseId = m.warehouseId
-- GROUP BY m.name,i.warehouseCode) a on w.code=a.warehouseCode ORDER BY total desc
SELECT m.name name,sum(i.qty) total from inventory i
inner join material m on i.materialCode = m.`code` and i.warehouseId = m.warehouseId and i.warehouseCode=#{warehouseCode}
GROUP BY m.code ORDER BY total desc limit 10
</select>
<select id="getCompanyInventoryProp" resultType="java.util.LinkedHashMap">
-- SELECT c.name,a.name,ifnull(a.total,0) total from company c
-- left join
-- (SELECT m.name name,sum(i.qty) total,i.companyId companyId from inventory i
-- inner join material m on i.materialCode = m.`code` and i.companyId = m.companyId
-- GROUP BY m.name,i.companyId) a on c.id=a.companyId ORDER BY total desc
SELECT m.name name,sum(i.qty) total from inventory i
inner join material m on i.materialCode = m.`code` and i.companyId = m.companyId and i.companyCode=#{companyCode}
GROUP BY m.code ORDER BY total desc limit 10
</select>
<select id="getWarehouseInventoryStatus" resultType="java.lang.String">
SELECT
ifnull(
CONVERT (
( SELECT count( 1 ) FROM inventory WHERE TIMESTAMPDIFF( MONTH, created, CURDATE( ) ) >= #{a}
and TIMESTAMPDIFF( MONTH, created, CURDATE( ) ) <#{b}
AND warehouseCode = #{warehouseCode} ) / ( SELECT count( 1 ) FROM inventory WHERE warehouseCode = #{warehouseCode} ),
DECIMAL ( 15, 2 )
),
0
) scale
FROM
DUAL
</select>
<select id="getWarehouseInventoryStatuss" resultType="java.lang.String">
SELECT
ifnull(
CONVERT (
( SELECT count( 1 ) FROM inventory WHERE TIMESTAMPDIFF( MONTH, created, CURDATE( ) ) >= #{a} AND warehouseCode = #{warehouseCode} ) / ( SELECT count( 1 ) FROM inventory WHERE warehouseCode = #{warehouseCode} ),
DECIMAL ( 15, 2 )
),
0
) scale
FROM
DUAL
</select>
<select id="getCompanyInventoryStatus" resultType="java.lang.String">
SELECT
ifnull(
CONVERT (
( SELECT count( 1 ) FROM inventory WHERE TIMESTAMPDIFF( MONTH, created, CURDATE( ) ) >= #{a}
and TIMESTAMPDIFF( MONTH, created, CURDATE( ) ) <#{b}
AND companyCode = #{companyCode} ) / ( SELECT count( 1 ) FROM inventory WHERE companyCode = #{companyCode} ),
DECIMAL ( 15, 2 )
),
0
) scale
FROM
DUAL
</select>
<select id="getCompanyInventoryStatuss" resultType="java.lang.String">
SELECT
ifnull(
CONVERT (
( SELECT count( 1 ) FROM inventory WHERE TIMESTAMPDIFF( MONTH, created, CURDATE( ) ) >= #{a}
AND companyCode = #{companyCode} ) / ( SELECT count( 1 ) FROM inventory WHERE companyCode = #{companyCode} ),
DECIMAL ( 15, 2 )
),
0
) scale
FROM
DUAL
</select>
</mapper>