ContainerMapper.xml
7.86 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
<?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.container.mapper.ContainerMapper">
<resultMap id="BaseResultMap" type="com.huaheng.pc.config.container.domain.Container">
<!--@mbg.generated-->
<id column="id" jdbcType="INTEGER" property="id" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="code" jdbcType="VARCHAR" property="code" />
<result column="warehouseCode" jdbcType="VARCHAR" property="warehouseCode" />
<result column="companyCode" jdbcType="VARCHAR" property="companyCode" />
<result column="containerType" jdbcType="VARCHAR" property="containerType" />
<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="status" jdbcType="VARCHAR" property="status" />
<result column="enable" jdbcType="INTEGER" property="enable" />
<result column="printNum" jdbcType="INTEGER" property="printNum" />
<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="processStamp" jdbcType="VARCHAR" property="processStamp" />
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, `name`, code, warehouseCode, companyCode, containerType, created, createdBy,
lastUpdated, lastUpdatedBy, `status`, `enable`, printNum, version, userDef1, userDef2,
userDef3, userDef4, userDef5, userDef6, userDef7, userDef8, processStamp
</sql>
<select id="getEmptyContainerInLocation" resultType="com.huaheng.pc.config.location.domain.Location">
SELECT *
FROM location t
<where>
AND t.warehouseCode = #{warehouseCode}
AND t.status='empty'
AND t.containerCode !=''
AND t.containerCode is not NULL
AND t.containerCode NOT in (SELECT h.containerCode from task_header h WHERE status < 100 AND warehouseCode=#{warehouseCode})
AND t.containerCode in (SELECT d.`code` from container d WHERE d.locationCode is not null AND d.locationCode !='' AND d.status = 'empty' AND d.warehouseCode=#{warehouseCode})
AND t.`code` NOT in (SELECT b.locationCode FROM inventory_detail b WHERE b.warehouseCode = #{warehouseCode} )
<if test="zoneCode != null and zoneCode !=''">
and t.zoneCode = #{zoneCode}
</if>
<if test="locationType != null and locationType !=''">
and t.locationType = #{locationType}
</if>
<if test="containerCode != null and containerCode !=''">
and t.containerCode = #{containerCode}
</if>
<if test="locationCode != null and locationCode !=''">
and t.`code` = #{locationCode}
</if>
</where>
</select>
<select id="getEmptyManyContainerInLocation" resultType="com.huaheng.pc.config.location.domain.Location">
SELECT *
FROM location t
<where>
AND t.warehouseCode = #{warehouseCode}
AND t.status='empty'
AND t.containerCode !=''
AND t.containerCode is not NULL
AND t.containerCode NOT in (SELECT h.containerCode from task_header h WHERE status < 100 AND warehouseCode=#{warehouseCode})
AND t.containerCode in (SELECT d.`code` from container d WHERE d.locationCode is not null AND d.locationCode !='' AND d.status = 'many' AND d.warehouseCode=#{warehouseCode})
AND t.`code` NOT in (SELECT b.locationCode FROM inventory_detail b WHERE b.warehouseCode = #{warehouseCode} )
<if test="zoneCode != null and zoneCode !=''">
and t.zoneCode = #{zoneCode}
</if>
<if test="locationType != null and locationType !=''">
and t.locationType = #{locationType}
</if>
<if test="containerCode != null and containerCode !=''">
and t.containerCode = #{containerCode}
</if>
<if test="locationCode != null and locationCode !=''">
and t.`code` = #{locationCode}
</if>
</where>
</select>
<!-- <select id="getEmptyContainerInLocation" resultType="com.huaheng.pc.config.location.domain.Location">
SELECT t.id, t.code, t.warehouseCode, t.zoneCode, t.locationType, t.containerCode, t.iRow, t.iColumn, t.iLayer,
t.iGrid, t.roadway, t.status, t.`name`, t.lastCycleCountDate, t.created, t.createdBy, t.lastUpdated, t.lastUpdatedBy,
t.version, t.userDef1, t.userDef2, t.userDef3, t.userDef4, t.userDef5, t.userDef6, t.userDef7, t.userDef8,
t.systemCreated
FROM location t
INNER JOIN ( SELECT locationCode,containerCode FROM inventory_header WHERE containerStatus = 'empty' ) i
on i.containerCode = t.containerCode
AND i.locationCode = t.code
<where>
t.locationType = 'LK'
AND t.warehouseCode = #{warehouseCode}
AND t.status='empty'
AND t.containerCode !=''
AND t.containerCode is not NULL
<if test="containerCode != null and containerCode !=''">
and t.containerCode = #{containerCode}
</if>
<if test="locationCode != null and locationCode !=''">
and t.`code` = #{locationCode}
</if>
</where>
</select>-->
<update id="updateLocationCodeAndStatus">
UPDATE container set `status`=#{status}, locationCode=#{locationCode} WHERE warehouseCode=#{warehouseCode} AND `code`=#{containerCode}
</update>
<select id="findAllByCode" resultMap="BaseResultMap" parameterType="java.lang.String">
SELECT * FROM container WHERE code = #{code,jdbcType=VARCHAR} AND warehouseCode=#{warehouseCode}
</select>
<insert id="addList" parameterType="com.huaheng.pc.config.container.domain.Container" keyProperty="id" useGeneratedKeys="true" >
INSERT INTO container(
code,
warehouseCode,
companyCode,
containerType,
createdBy,
status,
enable
)values
<foreach collection="containers" item="item" index="index" separator=",">
(
#{item.code},
#{item.warehouseCode},
#{item.companyCode},
#{item.containerType},
#{item.createdBy},
#{item.status},
#{item.enable}
)
</foreach>
</insert>
<select id="selectListShelf" resultType="com.huaheng.pc.config.container.domain.Container">
SELECT
g.goodsShelfNo
FROM
( SELECT DISTINCT ( goodsShelfNo ) goodsShelfNo, COUNT( * ) cunt FROM container WHERE `status` = 'empty' AND type = 'A' GROUP BY goodsShelfNo ) g
INNER JOIN ( SELECT DISTINCT ( goodsShelfNo ) goodsShelfNo, COUNT( * ) cunt FROM container WHERE type = 'A' GROUP BY goodsShelfNo ) s ON g.goodsShelfNo = s.goodsShelfNo
AND g.cunt = s.cunt
</select>
<select id="emptyContainer" resultMap="BaseResultMap">
select * from container where `status` = "empty" and (locationCode IS NOT NULL OR locationCode = "") ORDER BY id DESC limit 1
</select>
</mapper>