xiangpei
2025-03-26 cde5e6335dd02db4d2137ba6d5f330544e764b3d
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
<?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.ycl.mapper.ProcessLogMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ycl.domain.vo.ProcessLogVO">
        <result column="task_id" property="taskId" />
        <result column="task_name" property="taskName" />
        <result column="event_type" property="eventType" typeHandler="com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler"/>
        <result column="project_id" property="projectId" />
        <result column="process_ins_id" property="processInsId" />
        <result column="user_id" property="userId" />
        <result column="nick_name" property="nickName" />
        <result column="gmt_create" property="gmtCreate" />
        <result column="event_data_json" property="eventDataJson" />
    </resultMap>
 
 
 
 
 
 
 
    <select id="getById" resultMap="BaseResultMap">
        SELECT
            TFL.task_id,
            TFL.task_name,
            TFL.event_type,
            TFL.project_id,
            TFL.process_ins_id,
            TFL.user_id,
            TFL.event_data_json,
            TFL.id
        FROM
            t_process_log TFL
        WHERE
            TFL.id = #{id} AND TFL.deleted = 0
    </select>
 
 
    <select id="getPage" resultMap="BaseResultMap">
        SELECT
            TFL.task_id,
            TFL.task_name,
            TFL.event_type,
            TFL.project_id,
            TFL.process_ins_id,
            TFL.user_id,
            TFL.event_data_json,
            TFL.gmt_create,
            TFL.id
        FROM
            t_process_log TFL
        WHERE
            TFL.deleted = 0
    </select>
 
    <select id="projectProcessLogPage" resultMap="BaseResultMap">
        SELECT
            TFL.task_id,
            TFL.task_name,
            TFL.event_type,
            TFL.project_id,
            TFL.process_ins_id,
            TFL.user_id,
            CONCAT(SU.nick_name, '(',COALESCE(SD.dept_name, '无部门'), ')') as nick_name,
            TFL.event_data_json,
            TFL.gmt_create,
            TFL.id
        FROM
            t_process_log TFL
        LEFT JOIN sys_user SU ON SU.user_id = TFL.user_id
        LEFT JOIN sys_dept SD ON SU.dept_id = SD.dept_id
        <where>
            <if test="query.deleted != null">AND TFL.deleted = #{query.deleted}</if>
            <if test="query.userId != null">AND TFL.user_id = #{query.userId}</if>
            <if test="query.processInsId != null and query.processInsId != ''">AND TFL.process_ins_id = #{query.processInsId}</if>
            <if test="query.taskId != null and query.taskId != ''">AND TFL.task_id = #{query.taskId}</if>
            <if test="query.projectId != null and query.projectId != ''">AND TFL.project_id = #{query.projectId}</if>
            <if test="query.taskDefKey != null and query.taskDefKey != ''">AND TFL.task_def_key = #{query.taskDefKey}</if>
            <if test="query.eventTypeList != null and query.eventTypeList.size > 0">
                AND TFL.event_type IN <foreach collection="query.eventTypeList" open="(" separator="," close=")" item="eventType">#{eventType}</foreach>
            </if>
        </where>
        ORDER BY
        TFL.gmt_create DESC
    </select>
 
    <select id="projectProcessLogList" resultMap="BaseResultMap">
        SELECT
            TFL.task_id,
            TFL.task_name,
            TFL.event_type,
            TFL.project_id,
            TFL.process_ins_id,
            TFL.user_id,
            CONCAT(SU.nick_name, '(',COALESCE(SD.dept_name, '无部门'), ')') as nick_name,
            TFL.event_data_json,
            TFL.gmt_create,
            TFL.id
        FROM
            t_process_log TFL
                LEFT JOIN sys_user SU ON SU.user_id = TFL.user_id
                LEFT JOIN sys_dept SD ON SU.dept_id = SD.dept_id
        <where>
            <if test="query.deleted != null">AND TFL.deleted = #{query.deleted}</if>
            <if test="query.userId != null">AND TFL.user_id = #{query.userId}</if>
            <if test="query.processInsId != null and query.processInsId != ''">AND TFL.process_ins_id = #{query.processInsId}</if>
            <if test="query.taskId != null and query.taskId != ''">AND TFL.task_id = #{query.taskId}</if>
            <if test="query.projectId != null and query.projectId != ''">AND TFL.project_id = #{query.projectId}</if>
            <if test="query.taskDefKey != null and query.taskDefKey != ''">AND TFL.task_def_key = #{query.taskDefKey}</if>
            <if test="query.eventTypeList != null and query.eventTypeList.size > 0">
                AND TFL.event_type IN <foreach collection="query.eventTypeList" open="(" separator="," close=")" item="eventType">#{eventType}</foreach>
            </if>
        </where>
        ORDER BY
            TFL.gmt_create DESC
    </select>
 
    <select id="getAllHangup" resultType="java.lang.String">
        SELECT task_id
        FROM (
                 SELECT task_id,
                        COUNT(*) AS num
                 FROM t_process_log
                 WHERE task_id IS NOT NULL
                 GROUP BY task_id
                 HAVING MOD(num, 2) != 0
             ) AS t;
    </select>
</mapper>