zhanghua
2023-11-29 5b545fd1006fb28dbe3928c666db2d8a0622fcf2
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?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.caseHandler.DisposeRecordMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ycl.entity.caseHandler.DisposeRecord">
        <id column="id" property="id"/>
        <result column="base_case_id" property="baseCaseId"/>
        <result column="workflow_config_step_id" property="workflowConfigStepId"/>
        <result column="step_name" property="stepName"/>
        <result column="start_time" property="startTime"/>
        <result column="handler_role_id" property="handlerRoleId"/>
        <result column="end_time" property="endTime"/>
        <result column="state" property="state"/>
        <result column="handler_id" property="handlerId"/>
        <result column="create_user" property="createUser"/>
        <result column="create_time" property="createTime"/>
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id
        , base_case_id, step_name, start_time, handler_role_id, end_time, state, handler_id, create_user, create_time
    </sql>
 
    <resultMap id="blacklogVoMap" type="com.ycl.vo.MyBacklogVO">
        <result column="event_source" property="eventSource"/>
        <result column="source" property="source"/>
        <result column="category" property="category"/>
        <result column="code" property="code"/>
        <result column="step_name" property="stepName"/>
        <result column="caseId" property="caseId"/>
        <result column="create_time" property="createTime"/>
        <result column="limit_time" property="limitTime"/>
        <collection property="pictureList" ofType="com.ycl.entity.resources.ImageResources">
            <result column="url" property="url"/>
        </collection>
    </resultMap>
 
    <select id="selectMyBackList" resultMap="blacklogVoMap">
        SELECT nt.*, t4.url
        from (select distinct * from (
        SELECT
        t3.event_source,
        t5.region_name source,
        t3.category,
        t2.step_name,
        t3.`id` caseId,
        t3.`code`,
        t2.create_time,
        t2.limit_time
        FROM
        ums_admin_role_relation t1
        left JOIN ums_dispose_record t2 ON t1.role_id = t2.handler_role_id
        left JOIN ums_base_case t3 ON t2.base_case_id=t3.id
        inner join ums_sccg_region t5 on t5.id = t3.community_id
        <where>
            t1.admin_id = #{id} and t3.`code` is not null
            AND t2.state = 0
            <if test="code!='' and code!=null">
                and t3.`code` LIKE CONCAT('%',#{code},'%')
            </if>
            <if test="alarmTimeStart!=null and alarmTimeEnd!=null">
                and t3.alarm_time <![CDATA[ <= ]]> #{alarmTimeEnd} and t3.alarm_time >= #{alarmTimeStart}
            </if>
            <if test="type !=null">
                and t3.category = #{type}
            </if>
            <if test="source !=null">
                and t5.parent_id = #{source}
            </if>
        </where>
        union all
        SELECT
        t3.event_source,
        t5.region_name source,
        t3.category,
        t2.step_name,
        t3.`id` caseId,
        t3.`code`,
        t2.create_time,
        t2.limit_time
        FROM
        ums_dispose_record t2
        LEFT JOIN ums_base_case t3 ON t2.base_case_id = t3.id
        inner join ums_sccg_region t5 on t5.id = t3.community_id
        <where>
            t2.handler_id = #{id}
            AND t2.state = 0
            <if test="code!='' and code!=null">
                and t3.`code` LIKE CONCAT('%',#{code},'%')
            </if>
            <if test="alarmTimeStart!=null and alarmTimeEnd!=null">
                and t3.alarm_time <![CDATA[ <= ]]> #{alarmTimeEnd} and t3.alarm_time >= #{alarmTimeStart}
            </if>
            <if test="type !=null">
                and t3.category = #{type}
            </if>
            <if test="source !=null">
                and t5.parent_id = #{source}
            </if>
        </where>
        ) as t
        order by create_time desc
        LIMIT #{pageIndex},#{pageSize}) nt
 
        left JOIN ums_image_resources t4 ON nt.caseId=t4.belong_to_id
    </select>
    <select id="selectMyBackListTotal" resultType="java.lang.Long">
        select count( distinct id) from (
        SELECT
        t3.id
        FROM
        ums_admin_role_relation t1
        left JOIN ums_dispose_record t2 ON t1.role_id = t2.handler_role_id
        left JOIN ums_base_case t3 ON t2.base_case_id=t3.id
        inner join ums_sccg_region t5 on t5.id = t3.community_id
        <where>
            t1.admin_id = #{id} and t3.`code` is not null
            AND t2.state = 0
            <if test="code!='' and code!=null">
                and t3.`code` LIKE CONCAT('%',#{code},'%')
            </if>
            <if test="alarmTimeStart!=null and alarmTimeEnd!=null">
                and t3.alarm_time <![CDATA[ <= ]]> #{alarmTimeEnd} and t3.alarm_time >= #{alarmTimeStart}
            </if>
            <if test="type !=null">
                and t3.category = #{type}
            </if>
            <if test="source !=null">
                and t5.parent_id = #{source}
            </if>
        </where>
        union all
        SELECT
        t3.id
        FROM
        ums_dispose_record t2
        LEFT JOIN ums_base_case t3 ON t2.base_case_id = t3.id
        inner join ums_sccg_region t5 on t5.id = t3.community_id
        <where>
            t2.handler_id = #{id}
            AND t2.state = 0
            <if test="code!='' and code!=null">
                and t3.`code` LIKE CONCAT('%',#{code},'%')
            </if>
            <if test="alarmTimeStart!=null and alarmTimeEnd!=null">
                and t3.alarm_time <![CDATA[ <= ]]> #{alarmTimeEnd} and t3.alarm_time >= #{alarmTimeStart}
            </if>
            <if test="type !=null">
                and t3.category = #{type}
            </if>
            <if test="source !=null">
                and t5.parent_id = #{source}
            </if>
        </where>
        ) as t
    </select>
</mapper>