吉安感知网项目-后端
linwei
15 mins ago f7f44b007f6d75dc1b6446f083123e39d78a9806
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<?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="org.sxkj.gd.workorder.mapper.GdClueEventMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="gdClueEventResultMap" type="org.sxkj.gd.workorder.entity.GdClueEventEntity">
        <result column="id" property="id"/>
        <result column="result_id" property="resultId"/>
        <result column="work_order_id" property="workOrderId"/>
        <result column="dispose_user" property="disposeUser"/>
        <result column="dispose_dept" property="disposeDept"/>
        <result column="longitude" property="longitude"/>
        <result column="latitude" property="latitude"/>
        <result column="event_status" property="eventStatus"/>
        <result column="area_code" property="areaCode"/>
        <result column="event_num" property="eventNum"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>
 
    <resultMap id="gdClueEventVoResultMap" type="org.sxkj.gd.workorder.vo.GdClueEventVO">
        <result column="id" property="id"/>
        <result column="result_id" property="resultId"/>
        <result column="work_order_id" property="workOrderId"/>
        <result column="dispose_user" property="disposeUser"/>
        <result column="dispose_dept" property="disposeDept"/>
        <result column="dispose_user_name" property="disposeUserName"/>
        <result column="dispose_dept_name" property="disposeDeptName"/>
        <result column="longitude" property="longitude"/>
        <result column="latitude" property="latitude"/>
        <result column="event_status" property="eventStatus"/>
        <result column="area_code" property="areaCode"/>
        <result column="event_num" property="eventNum"/>
        <result column="event_location" property="eventLocation"/>
        <result column="shoot_time" property="shootTime"/>
        <result column="event_image_url" property="eventImageUrl"/>
        <result column="distribute_user_name" property="distributeUserName"/>
        <result column="distribute_dept_name" property="distributeDeptName"/>
        <result column="distribute_time" property="distributeTime"/>
        <result column="create_user" property="createUser"/>
        <result column="create_dept" property="createDept"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="geojson" property="geojson"/>
        <result column="attachment_type" property="attachmentType"/>
    </resultMap>
 
    <resultMap id="gdClueEventListVoResultMap" type="org.sxkj.gd.workorder.vo.GdClueEventListVO">
        <result column="id" property="id"/>
        <result column="event_image_url" property="eventImageUrl"/>
        <result column="create_time" property="createTime"/>
        <result column="geojson" property="geojson"/>
        <result column="attachment_type" property="attachmentType"/>
        <result column="event_name" property="eventName"/>
        <result column="shoot_time" property="shootTime"/>
        <result column="dispose_user_name" property="disposeUserName"/>
        <result column="dispose_dept_name" property="disposeDeptName"/>
        <result column="result_id" property="resultId"/>
        <result column="work_order_id" property="workOrderId"/>
        <result column="dispose_user" property="disposeUser"/>
        <result column="dispose_dept" property="disposeDept"/>
        <result column="longitude" property="longitude"/>
        <result column="latitude" property="latitude"/>
        <result column="event_status" property="eventStatus"/>
        <result column="area_code" property="areaCode"/>
        <result column="event_num" property="eventNum"/>
        <result column="attach_url" property="attachUrl"/>
    </resultMap>
 
    <resultMap id="gdClueEventCountVoResultMap" type="org.sxkj.gd.workorder.vo.GdClueEventCountVO">
        <result column="total_count" property="totalCount"/>
        <result column="my_count" property="myCount"/>
        <result column="disposing_count" property="disposingCount"/>
        <result column="disposed_count" property="disposedCount"/>
        <result column="completed_count" property="completedCount"/>
    </resultMap>
 
    <resultMap id="gdClueEventExcelResultMap" type="org.sxkj.gd.workorder.excel.GdClueEventExcel">
        <result column="result_id" property="resultId"/>
        <result column="work_order_id" property="workOrderId"/>
        <result column="dispose_user" property="disposeUser"/>
        <result column="dispose_dept" property="disposeDept"/>
        <result column="longitude" property="longitude"/>
        <result column="latitude" property="latitude"/>
        <result column="event_status" property="eventStatus"/>
        <result column="area_code" property="areaCode"/>
        <result column="event_num" property="eventNum"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>
 
    <select id="selectGdClueEventPage" resultMap="gdClueEventResultMap">
        select * from ja_gd_clue_event where is_deleted = 0
    </select>
 
    <select id="selectGdClueEventList" resultMap="gdClueEventVoResultMap">
        select ce.*,
               COALESCE(bu.real_name, bu.name) as dispose_user_name,
        bd.dept_name as dispose_dept_name
        from (select * from ja_gd_clue_event ${ew.customSqlSegment}) ce
        left join blade_user bu on bu.id::VARCHAR = ce.dispose_user::VARCHAR and bu.is_deleted = 0
        left join blade_dept bd on bd.id::VARCHAR = ce.dispose_dept::VARCHAR and bd.is_deleted = 0
    </select>
 
    <select id="selectGdClueEventSimpleList" resultMap="gdClueEventListVoResultMap">
        select
            ce.id as id,
            ce.event_name,
            COALESCE(tr.result_url, ce.attach_url) as event_image_url,
            COALESCE(tr.geojson, ce.geojson)  as geojson,
            COALESCE(tr.attachment_type, ce.attachment_type) as attachment_type,
            ce.create_time as create_time,
            tr.shoot_time as shoot_time,
            COALESCE(bu.real_name, bu.name) as dispose_user_name,
            bd.dept_name as dispose_dept_name,
            ce.result_id,
            ce.work_order_id,
            ce.dispose_user,
            ce.dispose_dept,
            ce.longitude,
            ce.latitude,
            ce.event_status,
            ce.area_code,
            ce.event_num,
            ce.attach_url
        from ja_gd_clue_event ce
        left join ja_gd_task_result tr on tr.id::VARCHAR = ce.result_id::VARCHAR and tr.is_deleted = 0
        left join blade_user bu on bu.id::VARCHAR = ce.dispose_user::VARCHAR and bu.is_deleted = 0
        left join blade_dept bd on bd.id::VARCHAR = ce.dispose_dept::VARCHAR and bd.is_deleted = 0
        where ce.is_deleted = 0
        <if test="deptId != null">
            and ce.dispose_dept = #{deptId}
        </if>
        <if test="statusList != null and statusList.size() > 0">
            and ce.event_status in
            <foreach collection="statusList" item="status" open="(" separator="," close=")">
                #{status}
            </foreach>
        </if>
        <if test="keyword != null and keyword != ''">
            and (ce.event_num::VARCHAR like concat('%', #{keyword}, '%')
                 or ce.event_name::VARCHAR like like concat('%', #{keyword}, '%'))
        </if>
        <if test="onlyMine != null and onlyMine == 1">
            and ce.dispose_user = #{userId}
        </if>
        <if test="startTime != null and startTime != ''">
            and tr.shoot_time &gt;= #{startTime}::timestamp
        </if>
        <if test="endTime != null and endTime != ''">
            and tr.shoot_time &lt;= #{endTime}::timestamp
        </if>
        order by ce.create_time desc
    </select>
 
    <select id="selectGdClueEventDetailById" resultMap="gdClueEventVoResultMap">
        select
        ce.id,
        ce.result_id,
        ce.work_order_id,
        ce.dispose_user,
        ce.dispose_dept,
        ce.longitude,
        ce.latitude,
        ce.event_status,
        ce.area_code,
        ce.event_num,
        ce.event_name,
        ce.create_user,
        ce.create_dept,
        ce.create_time,
        ce.update_user,
        ce.update_time,
        ce.status,
        ce.is_deleted,
        COALESCE(bu.real_name, bu.name) as dispose_user_name,
        bd.dept_name as dispose_dept_name,
        COALESCE(cu.real_name, cu.name) as distribute_user_name,
        cd.dept_name as distribute_dept_name,
        ce.create_time as distribute_time,
        concat(ce.longitude, ',', ce.latitude) as event_location,
        ce.event_num as event_num,
        COALESCE(tr.shoot_time, ce.shoot_time) as shoot_time,
        COALESCE(tr.result_url, ce.attach_url) as event_image_url,
        COALESCE(tr.geojson, ce.geojson)  as geojson,
        COALESCE(tr.attachment_type, ce.attachment_type) as attachment_type,
               tr.id as tr_id,
               tr.attachment_type as tr_attachment_type_raw
        from ja_gd_clue_event ce
        left join blade_user bu on bu.id::VARCHAR = ce.dispose_user::VARCHAR and bu.is_deleted = 0
        left join blade_dept bd on bd.id::VARCHAR = ce.dispose_dept::VARCHAR and bd.is_deleted = 0
        left join blade_user cu on cu.id::VARCHAR = ce.create_user::VARCHAR and cu.is_deleted = 0
        left join blade_dept cd on cd.id::VARCHAR = ce.create_dept::VARCHAR and cd.is_deleted = 0
        left join ja_gd_task_result tr on tr.id::VARCHAR = ce.result_id::VARCHAR and tr.is_deleted = 0
        where ce.is_deleted = 0
        <if test="deptId != null">
            and ce.dispose_dept = #{deptId}
        </if>
        and ce.id = #{id}
    </select>
 
    <select id="selectGdClueEventCount" resultMap="gdClueEventCountVoResultMap">
        select count(1) as total_count,
        COALESCE(sum(case when ce.dispose_user = #{userId} then 1 else 0 end), 0) as my_count,
        COALESCE(sum(case when ce.event_status = 1 then 1 else 0 end), 0) as disposing_count,
        COALESCE(sum(case when ce.event_status = 3 then 1 else 0 end), 0) as disposed_count,
        COALESCE(sum(case when ce.event_status = 4 then 1 else 0 end), 0) as completed_count
        from ja_gd_clue_event ce
        where ce.is_deleted = 0
        <if test="deptId != null">
            and ce.dispose_dept = #{deptId}
        </if>
        <if test="statusList != null and statusList.size() > 0">
            and ce.event_status in
            <foreach collection="statusList" item="status" open="(" separator="," close=")">
                #{status}
            </foreach>
        </if>
        <if test="keyword != null and keyword != ''">
            and (ce.event_num like concat('%', #{keyword}, '%')
                 or ce.event_name like concat('%', #{keyword}, '%'))
        </if>
    </select>
 
 
    <select id="exportGdClueEvent" resultMap="gdClueEventExcelResultMap">
        SELECT * FROM ja_gd_clue_event ${ew.customSqlSegment}
    </select>
 
</mapper>