LocationMapper.xml
7.85 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
<?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.general.location.mapper.LocationMapper">
<select id="getEmptyContainerInLocation" resultType="com.huaheng.pc.general.location.domain.Location">
SELECT * FROM location t
<where>
t.warehouseId = #{warehouseId} AND t.status='empty' AND t.containerCode !='' AND t.containerCode is not NULL
AND t.`code` NOT in (SELECT b.locationCode FROM inventory b WHERE b.warehouseId = #{warehouseId} )
<if test="containerCode != null and containerCode !=''">
<bind name="temp1" value="'%' + containerCode + '%'" />
and t.containerCode like #{temp1}
</if>
<if test="locationCode != null and locationCode !=''">
<bind name="temp2" value="'%' + locationCode + '%'" />
and t.`code` like #{temp2}
</if>
</where>
</select>
<update id="updateStatus">
UPDATE location set `status`=#{status} WHERE warehouseCode=#{warehouseCode} AND `code`=#{code}
</update>
<update id="updateContainerCodeAndStatus">
UPDATE location set `status`=#{status},containerCode=#{containerCode} WHERE warehouseCode=#{warehouseCode} AND `code`=#{locationCode}
</update>
<update id="updateContainerCode">
UPDATE location set containerCode=#{containerCode} WHERE warehouseCode=#{warehouseCode} AND `code`=#{locationCode}
</update>
<select id="getEmptyLocation" resultType="com.huaheng.pc.general.location.domain.Location">
select * from location l
<where>
l.containerCode = "" AND l.warehouseId = #{warehouseId} AND l.deleted = #{deleted} AND l.status = #{status}
<if test="locationCode != null and locationCode !=''">
<bind name="temp2" value="'%' + locationCode + '%'" />
and l.`code` like #{temp2}
</if>
</where>
</select>
<select id="getAllLocation" resultType="com.huaheng.pc.general.location.domain.Location">
select max(row) as row,max(line) as line,max(layer) as layer,max(grid) as grid from location l where l.warehouseCode= #{warehouseCode} AND l.type=#{type}
</select>
<select id="selectSSPLocation" resultType="com.huaheng.pc.general.location.domain.Location">
SELECT * FROM `location` WHERE zoneCode = 'QG' AND `status` = 'empty' ORDER BY `row` LIMIT 1
</select>
<select id="getAllLocationCode" resultType="java.lang.String">
SELECT code
FROM location
<where>
<if test="id != null">
AND id = #{id}
</if>
<if test="code != null">
AND code = #{code}
</if>
<if test="warehouseId != null">
AND warehouseId = #{warehouseId}
</if>
<if test="warehouseCode != null">
AND warehouseCode = #{warehouseCode}
</if>
<if test="row != null">
AND row = #{row}
</if>
<if test="line != null">
AND line = #{line}
</if>
<if test="layer != null">
AND layer = #{layer}
</if>
<if test="grid != null">
AND grid = #{grid}
</if>
<if test="rowIndex != null">
AND rowIndex = #{rowIndex}
</if>
<if test="roadway != null">
AND roadway = #{roadway}
</if>
<if test="type != null">
AND type = #{type}
</if>
<if test="containerId != null">
AND containerId = #{containerId}
</if>
<if test="containerCode != null">
AND containerCode = #{containerCode}
</if>
<if test="zoneId != null">
AND zoneId = #{zoneId}
</if>
<if test="zoneCode != null">
AND zoneCode = #{zoneCode}
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="lastCycleCountDate != null">
AND lastCycleCountDate = #{lastCycleCountDate}
</if>
<if test="created != null">
AND created = #{created}
</if>
<if test="createdBy != null">
AND createdBy = #{createdBy}
</if>
<if test="lastUpdated != null">
AND lastUpdated = #{lastUpdated}
</if>
<if test="lastUpdatedBy != null">
AND lastUpdatedBy = #{lastUpdatedBy}
</if>
<if test="enable != null">
AND enable = #{enable}
</if>
<if test="deleted != null">
AND deleted = #{deleted}
</if>
<if test="userDef1 != null">
AND userDef1 = #{userDef1}
</if>
<if test="userDef2 != null">
AND userDef2 = #{userDef2}
</if>
<if test="userDef3 != null">
AND userDef3 = #{userDef3}
</if>
<if test="userDef4 != null">
AND userDef4 = #{userDef4}
</if>
<if test="userDef5 != null">
AND userDef5 = #{userDef5}
</if>
</where>
</select>
<select id="selectAddress" resultType="com.huaheng.pc.general.location.domain.Location">
SELECT max(row) AS row,max(line) AS line FROM location where type='A' and warehouseCode=#{warehouseCode}
</select>
<!--<select id="selectIntY" resultType="java.util.HashMap">-->
<!--SELECT distinct(line) FROM location where type='A' group by line asc-->
<!--</select>-->
<select id="selectLocationPosition" resultType="com.huaheng.pc.general.location.domain.LocationPosition">
SELECT intX,intY FROM location_position where locationCode=#{locationCode} and warehouseCode=#{warehouseCode}
</select>
<!--<select id="selectList" resultType="com.huaheng.pc.general.location.domain.LocationPosition">-->
<!--SELECT locationCode FROM location_position where warehouseCode=#{warehouseCode} and intX=#{intX} and intY=#{intY}-->
<!--</select>-->
<update id="updateContainer">
UPDATE location l
inner join location_position p on l.code=p.locationCode
inner join container c on substr(c.code,5,1)=substr(p.locationCode,9,1) and substr(c.code,6,1)=substr(p.locationCode,12,1) and c.warehouseCode=p.warehouseCode
set l.containerCode=c.code where c.warehouseCode=#{container.warehouseCode} and c.type=#{container.type} and c.code like CONCAT(#{container.code},'%')
and p.warehouseCode=#{locationPosition.warehouseCode} and p.intX=#{locationPosition.intX} and p.intY=#{locationPosition.intY}
</update>
<select id="selectEmptyAddress" resultType="com.huaheng.pc.general.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="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>
</mapper>