1
zhang
1 天以前 fd0dc8eec755272d9b5adfd58369195db55173c4
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
<?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.zy.acs.manager.manager.mapper.LocMapper">
 
    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM man_loc a
        <where>
            AND a.deleted = 0
            <if test="param.id != null">
                AND a.id = #{param.id}
            </if>
            <if test="param.locNo != null">
                AND a.loc_no = #{param.locNo}
            </if>
            <if test="param.row != null">
                AND a.row = #{param.row}
            </if>
            <if test="param.bay != null">
                AND a.bay = #{param.bay}
            </if>
            <if test="param.lev != null">
                AND a.lev = #{param.lev}
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </if>
            <if test="param.uuid != null">
                AND a.id = #{param.uuid}
            </if>
            <if test="param.locType != null">
                AND a.loc_type = #{param.locType}
            </if>
            <if test="param.locSts != null">
                AND a.loc_sts = #{param.locSts}
            </if>
            <if test="param.keywords != null">
                AND (
                a.memo LIKE CONCAT('%', #{param.keywords}, '%')
                OR a.memo LIKE CONCAT('%', #{param.keywords}, '%')
                )
            </if>
        </where>
    </sql>
 
    <select id="selectCountGroupByLocSts" resultType="java.util.Map">
        SELECT
            mls.uuid AS sts,
            mls.name AS name,
            COUNT(ml.loc_sts) AS count
        FROM man_loc_sts mls
        LEFT JOIN man_loc ml ON ml.loc_sts = mls.id
        GROUP BY mls.id, mls.uuid, mls.name
    </select>
 
    <select id="selectDigitalLocWhichNeedShow" resultType="java.util.Map">
        SELECT
        DISTINCT ml.loc_no AS locNo,
        ml.row,
        ml.bay,
        ml.lev,
        ml.loc_sts AS locSts
        FROM man_loc ml
        LEFT JOIN man_task mt ON mt.dest_loc = ml.id OR mt.ori_loc = ml.id
        LEFT JOIN man_action ma ON ma.task_id = mt.id
        WHERE
        (
            ml.loc_sts = (SELECT id FROM man_loc_sts WHERE UUID = 'STOCK')
        )
        OR
        (
            ml.loc_sts = (SELECT id FROM man_loc_sts WHERE UUID = 'PAKIN')
            AND mt.task_sts IN
            (
                (SELECT id FROM man_task_sts WHERE UUID = 'INIT'),
                (SELECT id FROM man_task_sts WHERE UUID = 'WAITING'),
                (SELECT id FROM man_task_sts WHERE UUID = 'ASSIGN'),
                (SELECT id FROM man_task_sts WHERE UUID = 'PROGRESS')
            )
            AND ma.action_type = (SELECT id FROM man_action_type WHERE UUID = 'ReadyReleaseToShelvesLoc')
            AND ma.action_sts = (SELECT id FROM man_action_sts WHERE UUID = 'FINISH')
        )
        OR
        (
            ml.loc_sts = (SELECT id FROM man_loc_sts WHERE UUID = 'PAKOUT')
            AND mt.task_sts IN (
                (SELECT id FROM man_task_sts WHERE UUID = 'INIT'),
                (SELECT id FROM man_task_sts WHERE UUID = 'WAITING'),
                (SELECT id FROM man_task_sts WHERE UUID = 'ASSIGN'),
                (SELECT id FROM man_task_sts WHERE UUID = 'PROGRESS')
            )
            AND ma.action_type = (SELECT id FROM man_action_type WHERE UUID = 'ReadyTakeFromShelvesLoc')
            AND ma.action_sts != (SELECT id FROM man_action_sts WHERE UUID = 'FINISH')
        )
    </select>
 
</mapper>