Blame view

src/main/resources/mybatis/config/LocationMapper.xml 6.42 KB
1
2
<?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">
3
4
<mapper namespace="com.huaheng.pc.config.location.mapper.LocationMapper">
  <resultMap id="BaseResultMap" type="com.huaheng.pc.config.location.domain.Location">
5
6
7
8
9
10
11
12
13
14
15
    <!--@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" />
16
    <result column="roadway" jdbcType="VARCHAR" property="roadway" />
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
    <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" />
xqs authored
33
      <result column="deleted" jdbcType="BIT" property="deleted" />
34
35
36
37
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, code, warehouseCode, zoneCode, locationType, containerCode, iRow, iColumn, iLayer, 
xqs authored
38
    iGrid, roadway, status, `name`, lastCycleCountDate, created, createdBy, lastUpdated, lastUpdatedBy,
39
40
41
    version, userDef1, userDef2, userDef3, userDef4, userDef5, userDef6, userDef7, userDef8, 
    systemCreated
  </sql>
pengcheng authored
42
43
44
45

  <update id="updateStatus">
        UPDATE location set `status`=#{status} WHERE warehouseCode=#{warehouseCode} AND `code`=#{code}
    </update>
46
47
  <select id="position" resultMap="BaseResultMap">
    select code from location where #{locatingRule}
48
  </select>
xqs authored
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
  <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,
    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.roadway},
      #{item.createdBy},
      #{item.lastUpdatedBy},
      #{item.status}
      )
    </foreach>
  </insert>
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
    <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,
        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.createdBy},
            #{item.lastUpdatedBy},
            #{item.status}
            )
        </foreach>
    </update>
mahuandong authored
118
119
120
121
  <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.locationType=#{type}
  </select>
122
123
124
125
126
127
128
  <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>
游杰 authored
129
130

  <select id="pickLocation" resultType="com.huaheng.pc.config.location.domain.Location">
游杰 authored
131
        select * from location
xqs authored
132
        where containerCode != '' and status = 'empty'
游杰 authored
133
    </select>
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153

    <select id="selectContainerEmpty" resultType="com.huaheng.pc.config.location.domain.Location">
        SELECT id, code, warehouseCode, zoneCode, locationType, containerCode, iRow, iColumn, iLayer,
        iGrid, roadway, `name`, `enable`, 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 WHERE b.warehouseCode = #{warehouseCode})
            ORDER BY t.lastUpdated ASC
        </where>
    </select>
154
</mapper>