LocationMapper.xml
13.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
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
<?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.config.location.mapper.LocationMapper">
<resultMap id="BaseResultMap" type="com.huaheng.pc.config.location.domain.Location">
<!--@mbg.generated-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="code" jdbcType="VARCHAR" property="code" />
<result column="warehouseCode" jdbcType="VARCHAR" property="warehouseCode" />
<result column="zoneCode" jdbcType="VARCHAR" property="zoneCode" />
<result column="locationType" jdbcType="VARCHAR" property="locationType" />
<result column="containerCode" jdbcType="VARCHAR" property="containerCode" />
<result column="iRow" jdbcType="INTEGER" property="iRow" />
<result column="iColumn" jdbcType="INTEGER" property="iColumn" />
<result column="iLayer" jdbcType="INTEGER" property="iLayer" />
<result column="iGrid" jdbcType="INTEGER" property="iGrid" />
<result column="roadway" jdbcType="VARCHAR" property="roadway" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="lastCycleCountDate" jdbcType="TIMESTAMP" property="lastCycleCountDate" />
<result column="created" jdbcType="TIMESTAMP" property="created" />
<result column="createdBy" jdbcType="VARCHAR" property="createdBy" />
<result column="lastUpdated" jdbcType="TIMESTAMP" property="lastUpdated" />
<result column="lastUpdatedBy" jdbcType="VARCHAR" property="lastUpdatedBy" />
<result column="version" jdbcType="INTEGER" property="version" />
<result column="userDef1" jdbcType="VARCHAR" property="userDef1" />
<result column="userDef2" jdbcType="VARCHAR" property="userDef2" />
<result column="userDef3" jdbcType="VARCHAR" property="userDef3" />
<result column="userDef4" jdbcType="VARCHAR" property="userDef4" />
<result column="userDef5" jdbcType="VARCHAR" property="userDef5" />
<result column="userDef6" jdbcType="VARCHAR" property="userDef6" />
<result column="userDef7" jdbcType="VARCHAR" property="userDef7" />
<result column="userDef8" jdbcType="VARCHAR" property="userDef8" />
<result column="systemCreated" jdbcType="INTEGER" property="systemCreated" />
<result column="deleted" jdbcType="BIT" property="deleted" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, code, warehouseCode, zoneCode, locationType, containerCode, iRow, iColumn, iLayer,
iGrid, roadway, status, `name`, lastCycleCountDate, created, createdBy, lastUpdated, lastUpdatedBy,
version, userDef1, userDef2, userDef3, userDef4, userDef5, userDef6, userDef7, userDef8,
systemCreated,deleted
</sql>
<update id="updateStatus">
UPDATE location set `status`=#{status} WHERE warehouseCode=#{warehouseCode} AND `code`=#{code}
</update>
<select id="position" resultMap="BaseResultMap">
select code from location where #{locatingRule}
</select>
<insert id="addList" parameterType="com.huaheng.pc.config.location.domain.Location" keyProperty="id" useGeneratedKeys="true" >
INSERT INTO location(
code,
warehouseCode,
zoneCode,
locationType,
iRow,
iColumn,
iLayer,
iGrid,
roadway,
area,
createdBy,
lastUpdatedBy,
status,
high
)values
<foreach collection="locations" item="item" index="index" separator=",">
(
#{item.code},
#{item.warehouseCode},
#{item.zoneCode},
#{item.locationType},
#{item.iRow},
#{item.iColumn},
#{item.iLayer},
#{item.iGrid},
#{item.roadway},
#{item.area},
#{item.createdBy},
#{item.lastUpdatedBy},
#{item.status},
#{item.high}
)
</foreach>
</insert>
<update id="updateList" parameterType="com.huaheng.pc.config.location.domain.Location" keyProperty="id" useGeneratedKeys="true" >
replace INTO location(
code,
warehouseCode,
zoneCode,
locationType,
iRow,
iColumn,
iLayer,
iGrid,
rowFlag,
roadway,
area,
createdBy,
lastUpdatedBy,
status
)values
<foreach collection="locations" item="item" index="index" separator=",">
(
#{item.code},
#{item.warehouseCode},
#{item.zoneCode},
#{item.locationType},
#{item.iRow},
#{item.iColumn},
#{item.iLayer},
#{item.iGrid},
#{item.rowFlag},
#{item.roadway},
#{item.area},
#{item.createdBy},
#{item.lastUpdatedBy},
#{item.status}
)
</foreach>
</update>
<select id="getAllLocation" resultType="com.huaheng.pc.config.location.domain.Location">
select max(iRow) as iRow,max(iColumn) as iColumn,max(iLayer) as iLayer,max(iGrid) as iGrid from location l where l.warehouseCode=#{warehouseCode} AND l.zoneCode=#{type}
</select>
<select id="getLocationProp" resultType="java.util.LinkedHashMap">
SELECT w.name warehouseName,ifnull(convert(a.num1/(b.num2+a.num1),decimal(15,2)),0) '有货',ifnull(convert(b.num2/(b.num2+a.num1),decimal(15,2)),0) '无货' from warehouse w
left join
(SELECT count(1) num1,warehouseCode FROM location WHERE containerCode!='' GROUP BY warehouseCode) a on a.warehouseCode=w.code
LEFT JOIN
(SELECT count(1) num2,warehouseCode FROM location WHERE containerCode ='' GROUP BY warehouseCode) b on b.warehouseCode=w.code
</select>
<select id="pickLocation" resultType="com.huaheng.pc.config.location.domain.Location">
select * from location
where containerCode != '' and status = 'empty'
</select>
<select id="selectLocationByContainerEmpty" resultType="com.huaheng.pc.config.location.domain.Location">
SELECT id, code, warehouseCode, zoneCode, locationType, containerCode, iRow, iColumn, iLayer,
iGrid, roadway, `name`, lastCycleCountDate, created, createdBy, lastUpdated, lastUpdatedBy,
version, userDef1, userDef2, userDef3, userDef4, userDef5, userDef6, userDef7, userDef8,
systemCreated
FROM location t
<where>
t.warehouseCode = #{warehouseCode}
<if test="zoneCode != null">
AND zoneCode = #{zoneCode}
</if>
<if test="roadWay != null">
AND roadWay = #{roadWay}
</if>
AND t.status='empty'
AND t.containerCode =''
AND t.`code` NOT in
(SELECT b.locationCode FROM inventory_detail b WHERE b.warehouseCode = #{warehouseCode}
<if test="zoneCode != null">
AND zoneCode = #{zoneCode}
</if>
)
ORDER BY t.lastUpdated ASC
</where>
</select>
<select id="selectContainerEmpty" resultType="com.huaheng.pc.config.location.domain.Location">
SELECT id, code, warehouseCode, zoneCode, locationType, containerCode, iRow, iColumn, iLayer,
iGrid, roadway, `name`, lastCycleCountDate, created, createdBy, lastUpdated, lastUpdatedBy,
version, userDef1, userDef2, userDef3, userDef4, userDef5, userDef6, userDef7, userDef8,
systemCreated
FROM location t
<where>
t.warehouseCode = #{warehouseCode}
AND t.status='empty'
AND t.containerCode !=''
AND t.containerCode is not NULL
AND t.`code` NOT in
(SELECT b.locationCode FROM inventory_detail b WHERE b.warehouseCode = #{warehouseCode})
ORDER BY t.lastUpdated ASC
</where>
</select>
<select id="getFirstRowOfZone" resultType="java.lang.Integer">
select min(iRow) from location where warehouseCode=#{warehouseCode} and zoneCode = #{locationType}
</select>
<select id="getLastRowOfZone" resultType="java.lang.Integer">
select max(iRow) from location where warehouseCode=#{warehouseCode} and zoneCode = #{locationType}
</select>
<select id="selectAddress" resultType="com.huaheng.pc.config.location.domain.Location">
SELECT max(row) AS row,max(line) AS line FROM location where type='A' and warehouseCode=#{warehouseCode}
</select>
<select id="selectEmptyAddress" resultType="com.huaheng.pc.config.location.domain.Location">
SELECT DISTINCT l.row,l.line from location l
inner join location_position i on i.warehouseCode=l.warehouseCode and l.code=i.locationCode
inner join points p on i.warehouseCode=p.warehouseCode and i.intX=p.intX and i.intY=p.intY and p.isLocked=#{isLocked} and p.warehouseCode=#{warehouseCode}
</select>
<select id="selectlistEmpty" resultType="java.lang.String">
SELECT a.code from (SELECT * from location where iRow=3 and containerCode='' and zoneCode='LK' and warehouseCode=#{warehouseCode}) a
INNER JOIN (SELECT * from location where iRow=2 and containerCode!='' and zoneCode='LK' and warehouseCode=#{warehouseCode}) b on a.iColumn=b.iColumn and a.iLayer=b.iLayer and a.iGrid=b.iGrid
</select>
<select id="selectCode" resultType="com.huaheng.pc.config.location.domain.Location">
select l.* from location l inner join task_header t on t.status<=10 and l.zoneCode='LK' and (t.fromLocation = l.code or t.toLocation =l.code) and l.containerCode !='' and l.warehouseCode=#{warehouseCode}
</select>
<select id="selectByPrefix" resultType="com.huaheng.pc.config.location.domain.Location">
select * from location
<where> warehouseCode=#{warehouseCode} and locationType=#{type} and containerCode ='' and status='empty'
<if test="roadway != null">
AND roadway = #{roadway}
</if>
</where>
order by iColumn desc,FIND_IN_SET(iRow,'3,1,2'),iGrid desc,iLayer asc limit 1
</select>
<select id="selectModelByOld" resultType="com.huaheng.pc.config.location.domain.Location">
select * from location
<where> warehouseCode=#{warehouseCode} and locationType=#{locationType} and containerCode ='' and status='empty' and code !=#{code}
<if test="roadway != null">
AND roadway = #{roadway}
</if>
</where>
order by iColumn desc,FIND_IN_SET(iRow,'3,1,2'),iGrid desc,iLayer asc limit 1
</select>
<select id="selectModelByOlds" resultType="com.huaheng.pc.config.location.domain.Location">
select * from location
where warehouseCode=#{location.warehouseCode} and locationType=#{location.locationType} and containerCode ='' and status='empty' and code not in
<foreach item="item" index="index" collection="codes" open="(" separator="," close=")">
#{item}
</foreach>
order by iColumn desc,FIND_IN_SET(iRow,'3,1,2'),iGrid desc,iLayer asc limit 1
</select>
<select id="getLocationAajacentIsNull" resultType="com.huaheng.pc.config.location.domain.Location">
select * from location where zoneCode='LK' and status='empty' and roadWay=2
<choose>
<when test="flag==true">
and length(containerCode)>1
</when>
<otherwise>
and (containerCode is null or containerCode ='')
</otherwise>
</choose>
and iLayer=#{layer}
<choose>
<when test="line==23">
and iColumn < 23 ORDER BY iColumn desc
</when>
<when test="line==1">
and iColumn > 1 ORDER BY iColumn asc
</when>
<otherwise>
and iColumn >=#{line} ORDER BY iColumn asc
</otherwise>
</choose>
limit 2
</select>
<select id="getLocationRoadWay" resultType="com.huaheng.pc.config.location.domain.Location">
select * from location where roadway = #{roadway} and zoneCode ="LK" and length(containerCode) > 1 and status="empty" and iLayer=ceiling(rand()*8) limit 1
</select>
<select id="getLocationAdjacent" resultType="com.huaheng.pc.config.location.domain.Location">
select * from location where zoneCode='LK' and status='empty' and roadWay=2
<choose>
<when test="flag==true">
and length(containerCode)>1
</when>
<otherwise>
and (containerCode is null or containerCode ='')
</otherwise>
</choose>
and (iColumn between #{line}-2 and #{line}+2) and (iLayer between #{layer}-3 and #{layer}+3) and iColumn >1
</select>
<select id="getLocationOfRule" resultType="com.huaheng.pc.config.location.domain.Location">
select * from location where zoneCode='XC' and status = 'empty'
AND (containerCode IS NULL OR containerCode = '') ORDER BY iColumn asc,iRow asc LIMIT 1
</select>
<select id="selectListInventory" resultType="com.huaheng.pc.config.location.domain.Location">
SELECT l.code from location l inner join container c on
l.warehouseCode=c.warehouseCode and l.status='empty' and l.zoneCode=#{zoneCode}
and l.containerCode =c.code and c.status!='empty' ORDER BY code asc limit 2
</select>
<update id="updateStatusNew">
UPDATE location
SET `status`= #{status}
WHERE warehouseCode = #{warehouseCode}
AND `code`= #{code}
AND `status` = #{oldStatus}
</update>
<select id="getLkLocationList" resultType="com.huaheng.pc.config.location.domain.LocationAge">
select locationCode code, datediff(NOW(),created) age,companyCode,uWarehouseCode from inventory_header where zoneCode='LK'
</select>
</mapper>