张天森
2022-10-12 3c884ccd7b51edf3b36840bf99de5edaa41a38a7
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
<?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.panzhihua.service_community.dao.ComEventMapper">
     <resultMap id="baseResult" type="com.panzhihua.service_community.entity.ComEvent">
            <id property="id" column="id" />
            <result property="orderSn" column="order_sn" />
            <result property="requestUserId" column="request_user_id" />
            <result property="userEventStatus" column="user_event_status" />
            <result property="requestUserEventDes" column="request_user_event_des" />
            <result property="requestUserName" column="request_user_name" />
            <result property="requestUserTel" column="request_user_tel" />
            <result property="eventCategory" column="event_category" />
            <result property="type" column="type" />
            <result property="submitDate" column="submit_date" />
            <result property="appointmentTime" column="appointment_time" />
            <result property="requestUserCommunity" column="request_user_community" />
            <result property="centerId" column="center_id" />
            <result property="centerTel" column="center_tel" />
            <result property="specialistOrg" column="specialist_org" />
            <result property="specialistLevel" column="specialist_level" />
            <result property="specialistId" column="specialist_id" />
            <result property="specialistName" column="specialist_name" />
            <result property="specialistTel" column="specialist_tel" />
            <result property="specialistAcceptTime" column="specialist_accept_time" />
            <result property="revokeType" column="revoke_type" />
            <result property="eventProcessStatus" column="event_process_status" />
            <result property="currentProcessType" column="current_process_type" />
            <result property="currentOrgId" column="current_org_id" />
            <result property="currentOrgName" column="current_org_name" />
            <result property="currentProcessUserId" column="current_process_user_id" />
            <result property="currentProcessUserName" column="current_process_user_name" />
            <result property="revokeDes" column="revoke_des" />
            <result property="eventResult" column="event_result" />
            <result property="eventSucceed" column="event_succeed" />
            <result property="currentEventProcessResult" column="current_event_process_result" />
            <result property="reportSuperior" column="report_superior" />
            <result property="result" column="result" />
            <result property="resultDate" column="result_date" />
            <result property="urgent" column="urgent" />
            <result property="difficult" column="difficult" />
            <result property="urgentDell" column="urgent_dell" />
            <result property="invalid" column="invalid" />
            <result property="major" column="major" />
            <result property="requestUserResponse" column="request_user_response" />
            <result property="createBy" column="create_by" />
            <result property="createAt" column="create_at" />
            <result property="updateBy" column="update_by" />
            <result property="updateAt" column="update_at" />
 
    </resultMap>
    <sql id="columns">
        id,order_sn,request_user_id,user_event_status,request_user_event_des,event_succeed,current_event_process_result,request_user_name,request_user_tel,event_category,type,submit_date,appointment_time,request_user_community,center_id,center_tel,specialist_org,specialist_level,specialist_id,specialist_name,specialist_tel,specialist_accept_time,revoke_type,event_process_status,current_process_type,current_org_id,current_org_name,current_process_user_id,current_process_user_name,revoke_des,event_result,report_superior,result,result_date,urgent,difficult,urgent_dell,invalid,major,request_user_response,create_by,create_at,update_by,update_at
    </sql>
 
    <select id="pageByComEvent" resultType="com.panzhihua.service_community.entity.ComEvent">
        SELECT <include refid="columns" />
        FROM com_sanshuo_event_info
        <where>
            event_process_status !=9
            <if test="comEvent.keyword != null and comEvent.keyword!=''" >
                AND    ( order_sn = #{comEvent.keyword} or request_user_tel =#{comEvent.keyword} or current_org_name=#{comEvent.keyword})
            </if>
            <if test="comEvent.createBy != null and comEvent.createBy!=''" >
                AND create_by = #{comEvent.createBy}
            </if>
            <if test="comEvent.eventCategory != null">
                AND event_category = #{comEvent.eventCategory}
            </if>
            <if test="comEvent.eventProcessStatus != null">
                AND event_process_status = #{comEvent.eventProcessStatus}
            </if>
            <if test="comEvent.orderSn != null">
                AND order_sn = #{comEvent.orderSn}
            </if>
            <if test="comEvent.requestUserTel != null">
                AND request_user_tel = #{comEvent.requestUserTel}
            </if>
            <if test="comEvent.currentOrgName != null">
                AND current_org_name = #{comEvent.currentOrgName}
            </if>
            <if test="comEvent.userType == 1">
                AND request_user_id=#{comEvent.requestUserId}
            </if>
            <if test="comEvent.userType == 2">
                AND specialist_id=#{comEvent.specialistId}
            </if>
            <if test="comEvent.userType == 3">
                AND center_id=#{comEvent.centerId}
            </if>
            <if test="comEvent.userType == 4">
                AND request_user_community=#{comEvent.communityId}
            </if>
        </where>
        order by create_at desc
    </select>
    <select id="pageByComEventExpert" resultType="com.panzhihua.service_community.entity.ComEvent">
        SELECT <include refid="columns" />
        FROM com_sanshuo_event_info
        <where>
            event_process_status !=9
            <if test="eventIds != null">
                AND id in 
                <foreach collection="eventIds" item="id" separator="," open="(" close=")">
                    #{id}
                </foreach>
            </if>
            <if test="comEvent.keyword != null and comEvent.keyword!=''" >
                AND    ( order_sn = #{comEvent.keyword} or request_user_tel =#{comEvent.keyword} or current_org_name=#{comEvent.keyword})
            </if>
            <if test="comEvent.createBy != null and comEvent.createBy!=''" >
                AND create_by = #{comEvent.createBy}
            </if>
            <if test="comEvent.eventCategory != null">
                AND event_category = #{comEvent.eventCategory}
            </if>
            <if test="comEvent.eventProcessStatus != null">
                AND event_process_status = #{comEvent.eventProcessStatus}
            </if>
            <if test="comEvent.orderSn != null">
                AND order_sn = #{comEvent.orderSn}
            </if>
            <if test="comEvent.requestUserTel != null">
                AND request_user_tel = #{comEvent.requestUserTel}
            </if>
            <if test="comEvent.currentOrgName != null">
                AND current_org_name = #{comEvent.currentOrgName}
            </if>
            <!--<if test="comEvent.userType == 1">-->
                <!--AND request_user_id=#{comEvent.requestUserId}-->
            <!--</if>-->
            <!--<if test="comEvent.userType == 2">-->
                <!--AND specialist_id=#{comEvent.specialistId}-->
            <!--</if>-->
            <!--<if test="comEvent.userType == 3">-->
                <!--AND center_id=#{comEvent.centerId}-->
            <!--</if>-->
            <!--<if test="comEvent.userType == 4">-->
                <!--AND request_user_community=#{comEvent.communityId}-->
            <!--</if>-->
        </where>
        order by create_at desc
    </select>
    <select id="listEventIds" resultType="java.lang.Long">
        select event_id from com_sanshuo_expert_event where expert_id=#{expertId}
    </select>
    <select id="listByComEvent" resultType="com.panzhihua.service_community.entity.ComEvent">
        SELECT <include refid="columns" />
        FROM com_sanshuo_event_info
        <if test="requestUserId != null and requestUserId != ''">
            where request_user_id=#{requestUserId}
        </if>
    </select>
 
    <select id="calculate" resultType="com.panzhihua.common.model.vos.sanshuo.ComEventCalculateVO">
        select event_process_status as status ,count(1) as  sum
        from com_sanshuo_event_info
        group by event_process_status
        having event_process_status not in (9)
    </select>
    <select id="dateAnalysis" resultType="com.panzhihua.common.model.vos.sanshuo.IndexDateVO">
        SELECT
        (SELECT count(id) FROM com_sanshuo_event_info
        where event_process_status  in (3,5,6)
        AND user_event_status not in(3,4)
        <if test="dto.type == 2">
            AND type=1
            <if test="dto.id != null">
                AND center_id=#{dto.id}
            </if>
        </if>
        <if test="dto.type == 3">
            AND type=2
            <if test="dto.id != null">
                AND request_user_community in (select com_act.community_id from com_act where street_id=#{dto.id})
            </if>
        </if>
        <if test="dto.type == 4">
            AND type=3
            <if test="dto.id != null">
                AND request_user_community=#{dto.id}
            </if>
        </if>
        <if test="dto.type == 1">
            AND type=4
        </if>
        ) as accept,
        (SELECT count(id) FROM com_sanshuo_event_info
        where event_process_status = 5
        AND user_event_status not in(3,4)
        <if test="dto.type == 1">
            AND type=4
        </if>
        <if test="dto.type == 2">
            AND type=1
            <if test="dto.id != null">
                AND center_id=#{dto.id}
            </if>
        </if>
        <if test="dto.type == 3">
            AND type=2
            <if test="dto.id != null">
                AND request_user_community in (select com_act.community_id from com_act where street_id=#{dto.id})
            </if>
        </if>
        <if test="dto.type == 4">
            AND type=3
            <if test="dto.id != null">
                AND request_user_community=#{dto.id}
            </if>
        </if>) as accepting,
        (SELECT count(id) FROM com_sanshuo_event_info
        where event_process_status = 6
        AND user_event_status not in(3)
        <if test="dto.type == 1">
            AND type=4
        </if>
        <if test="dto.type == 2">
            AND type=1
            <if test="dto.id != null">
                AND center_id=#{dto.id}
            </if>
        </if>
        <if test="dto.type == 3">
            AND type=2
            <if test="dto.id != null">
                 AND request_user_community in (select com_act.community_id from com_act where street_id=#{dto.id})
            </if>
        </if>
        <if test="dto.type == 4">
            AND type=3
            <if test="dto.id != null">
                AND request_user_community=#{dto.id}
            </if>
        </if>) as accepted,
        (SELECT count(id) FROM com_sanshuo_event_info
        where event_process_status in (6,7)
        AND user_event_status not in(3,4)
        <if test="dto.type == 1">
            AND type=4
        </if>
        <if test="dto.type == 2">
            AND type=1
            <if test="dto.id != null">
                AND center_id=#{dto.id}
            </if>
        </if>
        <if test="dto.type == 3">
            AND type=2
            <if test="dto.id != null">
                AND request_user_community in (select com_act.community_id from com_act where street_id=#{dto.id})
            </if>
        </if>
        <if test="dto.type == 4">
            AND type=3
            <if test="dto.id != null">
                AND request_user_community=#{dto.id}
            </if>
        </if>) as expirences,
        (select count(id) FROM com_sanshuo_event_info
        where event_result=1
        AND user_event_status not in(3,4)
        <if test="dto.type == 1">
            AND type=4
        </if>
        <if test="dto.type == 2">
            AND type=1
            <if test="dto.id != null">
                AND center_id=#{dto.id}
            </if>
        </if>
        <if test="dto.type == 3">
            AND type=2
            <if test="dto.id != null">
                AND request_user_community in (select com_act.community_id from com_act where street_id=#{dto.id})
            </if>
        </if>
        <if test="dto.type == 4">
            AND type=3
            <if test="dto.id != null">
                AND request_user_community=#{dto.id}
            </if>
        </if>) as success,
        (select count(id) FROM com_sanshuo_event_info
        where event_result=2
        AND user_event_status not in(3,4)
        <if test="dto.type == 1">
            AND type=4
        </if>
        <if test="dto.type == 2">
            AND type=1
            <if test="dto.id != null">
                AND center_id=#{dto.id}
            </if>
        </if>
        <if test="dto.type == 3">
            AND type=2
            <if test="dto.id != null">
                AND request_user_community in (select com_act.community_id from com_act where street_id=#{dto.id})
            </if>
        </if>
        <if test="dto.type == 4">
            AND type=3
            <if test="dto.id != null">
                AND request_user_community=#{dto.id}
            </if>
        </if>) as fail,
        (select count(id) from com_sanshuo_expert where `status`=1 and del_flag=1
        AND user_event_status not in(3,4)
        <if test="dto.type == 1">
            AND type=4
        </if>
        <if test="dto.type == 2">
            AND type=1
            <if test="dto.id != null">
                AND center_id=#{dto.id}
            </if>
        </if>
        <if test="dto.type == 3">
            AND type=2
            <if test="dto.id != null">
                AND request_user_community in (select com_act.community_id from com_act where street_id=#{dto.id})
            </if>
        </if>
        <if test="dto.type == 4">
            AND type=3
            <if test="dto.id != null">
                AND request_user_community=#{dto.id}
            </if>
        </if>) as expert,
        (select count(id) from com_sanshuo_event_info WHERE
        create_at BETWEEN DATE_FORMAT(#{beginDate}, '%Y-%m-%d 00:00:00') AND DATE_FORMAT(#{endDate}, '%Y-%m-%d 23:59:59')
        AND event_process_status not in (8)
        <if test="dto.type == 1">
            AND type=4
        </if>
        <if test="dto.type == 2">
            AND type=1
            <if test="dto.id != null">
                AND center_id=#{dto.id}
            </if>
        </if>
        <if test="dto.type == 3">
            AND type=2
            <if test="dto.id != null">
                AND request_user_community in (select com_act.community_id from com_act where street_id=#{dto.id})
            </if>
        </if>
        <if test="dto.type == 4">
            AND type=3
            <if test="dto.id != null">
                AND request_user_community=#{dto.id}
            </if>
        </if>) as monthIncrease,
        (select count(id) from com_sanshuo_event_info WHERE
        create_at BETWEEN DATE_FORMAT(#{beginDate}, '%Y-%m-%d 00:00:00') AND DATE_FORMAT(#{endDate}, '%Y-%m-%d 23:59:59')
        AND event_process_status not in (8)
        AND event_process_status = 6
        <if test="dto.type == 1">
            AND type=4
        </if>
        <if test="dto.type == 2">
            AND type=1
            <if test="dto.id != null">
                AND center_id=#{dto.id}
            </if>
        </if>
        <if test="dto.type == 3">
            AND type=2
            <if test="dto.id != null">
                AND request_user_community in (select com_act.community_id from com_act where street_id=#{dto.id})
            </if>
        </if>
        <if test="dto.type == 4">
            AND type=3
            <if test="dto.id != null">
                AND request_user_community=#{dto.id}
            </if>
        </if>) as monthFinish
        FROM com_sanshuo_event_info limit 1
    </select>
    <select id="dateAnalysisY" resultType="java.lang.Integer">
        SELECT COUNT(id) FROM com_sanshuo_event_info
        WHERE create_at BETWEEN DATE_FORMAT(#{beginDate}, '%Y-%m-%d 00:00:00') AND DATE_FORMAT(#{endDate}, '%Y-%m-%d 23:59:59')
        <if test="dto.type != null">
            <if test="dto.type == 1">
                AND type=4
            </if>
            <if test="dto.type==2">
                 AND type=1
                <if test="dto.id != null">
                    AND center_id=#{dto.id}
                </if>
            </if>
            <if test="dto.type == 3">
                AND type=2
                <if test="dto.id != null">
                    AND request_user_community in (select com_act.community_id from com_act where street_id=#{dto.id})
                </if>
            </if>
            <if test="dto.type == 4">
                AND type=3
                <if test="dto.id != null">
                    AND request_user_community=#{dto.id}
                </if>
            </if>
        </if>
    </select>
    <select id="dateAnalysisYTwo" resultType="java.lang.Integer">
        SELECT COUNT(id) FROM com_sanshuo_event_info
        WHERE create_at BETWEEN DATE_FORMAT(#{beginDate}, '%Y-%m-%d 00:00:00') AND DATE_FORMAT(#{endDate}, '%Y-%m-%d 23:59:59')
        AND event_process_status=6
        <if test="dto.type != null">
            <if test="dto.type == 1">
                AND type=4
            </if>
        <if test="dto.type==2">
            AND type=1
            <if test="dto.id != null">
                AND center_id=#{dto.id}
            </if>
        </if>
        <if test="dto.type == 3">
            AND type=2
            <if test="dto.id != null">
                AND request_user_community in (select com_act.community_id from com_act where street_id=#{dto.id})
            </if>
        </if>
        <if test="dto.type == 4">
            AND type=3
            <if test="dto.id != null">
                AND request_user_community=#{dto.id}
            </if>
        </if>
        </if>
    </select>
    <select id="eventRate" resultType="com.panzhihua.common.model.vos.sanshuo.EventRateVO">
        select count(id) as count,type from com_sanshuo_event_info
        where event_process_status not in(7.8)
        group by type
    </select>
    <select id="expertRate" resultType="com.panzhihua.common.model.vos.sanshuo.EventRateVO">
        select count(t.id) as count,t1.level as type  from com_sanshuo_event_info t
        left join com_sanshuo_expert t1 on t.specialist_id=t1.id
        where t.event_process_status not in(7.8)
        group by t1.level
        having type is not null
    </select>
    <select id="mediateTypeRate" resultType="com.panzhihua.common.model.vos.sanshuo.EventRateVO">
        select count(t.id) as count,t1.name from com_sanshuo_event_info t
        left join com_mediate_type t1 on t.event_category=t1.id
        where t.event_process_status not in(7.8)
        group by t.event_category
    </select>
 
    <select id="getUserAvatar" resultType="String">
        select  image_url from sys_user where user_id = #{userId}
    </select>
    <select id="insertEventAndExpertRecord">
        insert into com_sanshuo_expert_event values(#{eventId},#{expertId},#{status})
    </select>
 
</mapper>