ShipmentDetailMapper.xml
6.64 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
<?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>
<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>
</mapper>