#
vincentlu
2025-05-13 ebd2f4397a92c6a5096de1b86d59154363344720
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
<?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.ActionMapper">
 
    <!-- 关联查询sql -->
    <sql id="selectSql">
        SELECT a.*
        FROM man_action a
        <where>
            AND a.deleted = 0
            <if test="param.id != null">
                AND a.id = #{param.id}
            </if>
            <if test="param.seqNum != null">
                AND a.seq_num = #{param.seqNum}
            </if>
            <if test="param.taskId != null">
                AND a.task_id = #{param.taskId}
            </if>
            <if test="param.actionType != null">
                AND a.action_type = #{param.actionType}
            </if>
            <if test="param.actionSts != null">
                AND a.action_sts = #{param.actionSts}
            </if>
            <if test="param.status != null">
                AND a.status = #{param.status}
            </if>
            <if test="param.keywords != null">
                AND (
                a.memo LIKE CONCAT('%', #{param.keywords}, '%')
                OR a.memo LIKE CONCAT('%', #{param.keywords}, '%')
                )
            </if>
        </where>
        order by a.create_time desc
    </sql>
 
    <update id="updateStsByGroupId">
        update man_action set action_sts = #{actionSts} where group_id = #{groupId}
    </update>
 
    <select id="selectRecentForInout" resultType="java.util.Map">
        SELECT
        magv.uuid AS agvNo,
        mat.name
        FROM man_action ma
        LEFT JOIN man_action_type mat ON ma.action_type = mat.id
        LEFT JOIN man_agv magv ON ma.agv_id = magv.id
        WHERE 1=1
        AND mat.uuid IN ('ReadyTakeFromShelvesLoc', 'ReadyTakeFromAgvSite', 'ReadyReleaseToShelvesLoc', 'ReadyReleaseToAgvSite')
        ORDER BY ma.id DESC
        LIMIT 0, 10
    </select>
 
    <select id="selectCountGroupByType" resultType="java.util.Map">
        SELECT
        mat.uuid,
        mat.name,
        COUNT(ma.action_type) AS count
        FROM man_action_type mat
        LEFT JOIN man_action ma ON ma.`action_type` = mat.`id`
        WHERE 1=1
        GROUP BY mat.uuid, mat.name
        ORDER BY count DESC
    </select>
 
    <select id="selectGroupNo" resultType="java.lang.String">
        SELECT group_id
        FROM man_action
        WHERE 1=1
        AND action_sts = #{actionSts}
        AND group_id IS NOT NULL
        GROUP BY group_id
    </select>
 
    <select id="selectPrepareGroup" resultType="java.lang.String">
        SELECT ma.group_id
        FROM man_action ma
        JOIN man_action_sts mas ON ma.action_sts = mas.id
        WHERE mas.UUID = 'PREPARE'
        AND ma.group_id IS NOT NULL
        GROUP BY ma.group_id
    </select>
 
    <select id="selectTaskIdsByGroupId" resultType="java.lang.Long">
        SELECT
        DISTINCT task_id
        FROM man_action
        WHERE 1=1
        AND group_id = #{groupId}
        AND task_id IS NOT NULL
    </select>
 
    <select id="selectSortCodeByAgv" resultType="java.lang.String">
        SELECT
        ma.code
        FROM man_action ma
        WHERE 1=1
        AND ma.action_sts IN (
            SELECT id FROM man_action_sts WHERE UUID IN ('PREPARE', 'ISSUED')
        )
        AND ma.agv_id = #{agvId}
        ORDER BY ma.priority DESC
    </select>
 
    <select id="selectLatestOfGroup" resultType="com.zy.acs.manager.manager.entity.Action">
        SELECT *
        FROM man_action a
        JOIN (
            SELECT group_id, MAX(io_time) AS max_io_time
            FROM man_action
            WHERE agv_id = #{agvId} AND action_sts = #{actionSts}
            GROUP BY group_id
        ) b ON a.group_id = b.group_id AND a.io_time = b.max_io_time
        WHERE a.agv_id = #{agvId}
        AND a.action_sts = #{actionSts}
        ORDER BY a.priority DESC
    </select>
 
</mapper>