zss
2025-02-18 bcc80a6833abe9f24abdb978f7c7f01b664a574f
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
<?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.yuanchu.mom.mapper.WarehouseMapper">
    <resultMap id="BaseResultMap" type="com.yuanchu.mom.pojo.Warehouse">
        <id property="id" column="id" jdbcType="INTEGER"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="createUser" column="create_user" jdbcType="INTEGER"/>
        <result property="updateUser" column="update_user" jdbcType="INTEGER"/>
    </resultMap>
 
    <resultMap id="Warehouse" type="com.yuanchu.mom.dto.WarehouseDto">
        <id property="id" column="id" jdbcType="INTEGER"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <collection property="warehouseShelfList" resultMap="shelf"/>
    </resultMap>
 
    <resultMap id="shelf" type="com.yuanchu.mom.pojo.WarehouseShelf">
        <id property="id" column="sId" jdbcType="INTEGER"/>
        <result property="name" column="sName" jdbcType="VARCHAR"/>
        <result property="row" column="row" jdbcType="INTEGER"/>
        <result property="col" column="col" jdbcType="INTEGER"/>
        <collection property="warehouseCellList" resultMap="cell"/>
    </resultMap>
 
    <resultMap id="cell" type="com.yuanchu.mom.pojo.WarehouseCell">
        <id property="id" column="cId" jdbcType="INTEGER"/>
        <result property="row" column="crow" jdbcType="INTEGER"/>
        <result property="col" column="ccol" jdbcType="INTEGER"/>
    </resultMap>
 
    <select id="selectWarehouseList" resultMap="Warehouse">
        select w.id,
               w.name,
               ws.id   sId,
               ws.name sName,
               ws.row,
               ws.col,
               wc.id   cId,
               wc.row  crow,
               wc.col  ccol
        from warehouse w
                 left join warehouse_shelf ws on w.id = ws.warehouse_id
                 left join warehouse_cell wc on shelf_id = ws.id
                 left join
                 (select cell_id, count(*) num from warehouse_history group by cell_id) a on cell_id = wc.id
        where num is null
           or num % 2 = 0
        order by id, sId, crow, ccol
    </select>
</mapper>