linwe
2024-07-08 7a1e4d9fe3fe2172d5c4fba524f17ffd73ffbb3e
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
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
<?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.springblade.modules.task.mapper.TaskMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="taskResultMap" type="org.springblade.modules.task.vo.TaskVO">
        <result column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="type" property="type"/>
        <result column="frequency" property="frequency"/>
        <result column="remark" property="remark"/>
        <result column="create_time" property="createTime"/>
        <result column="create_user" property="createUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="status" property="status"/>
        <result column="source" property="source"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="house_code" property="houseCode"/>
        <result column="report_type" property="reportType"/>
    </resultMap>
 
    <!--查询非取保候审任务列表(场所相关)-->
    <select id="selectTaskPage" resultMap="taskResultMap">
        SELECT
        jp.location AS address_name,
        br.district_code regionCode,
        br.village_code neiCode,
        br.town_code streetCode,
        jp.principal as realName,
        jp.principal_phone as phone,
        jp.nine_type,
        jp.front_type,
        jp.place_name,
        jt.id,
        jt.NAME,
        jt.type,
        jt.frequency,
        jt.remark,
        jt.create_time,
        jt.create_user,
        jt.update_time,
        jt.update_user,
        jt.STATUS,
        jt.source,
        jt.is_deleted,
        jt.house_code,
        jt.report_type
        FROM
        jczz_task jt
        LEFT JOIN jczz_place jp ON jt.house_code=jp.house_code and jp.is_deleted = 0
        LEFT JOIN blade_user bu on bu.id = jt.create_user and bu.is_deleted = 0
        LEFT JOIN jczz_grid jg on jg.grid_code = jp.grid_code and jg.is_deleted = 0
        LEFT JOIN blade_region br on br.code = jg.community_code
        LEFT JOIN jczz_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
        <where>
            <if test="isAdministrator==2">
                <choose>
                    <when test="task.roleName != null and task.roleName != ''">
                        <if test="task.roleName=='wgy'">
                            <choose>
                                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                    and jh.grid_code in
                                    <foreach collection="regionChildCodesList" item="code" open="(" close=")"
                                             separator=",">
                                        #{code}
                                    </foreach>
                                </when>
                                <otherwise>
                                    and jh.grid_code in ('')
                                </otherwise>
                            </choose>
                        </if>
                        <if test="task.roleName=='mj' and isAdministrator==2">
                            <choose>
                                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                    and br.village_code in
                                    <foreach collection="regionChildCodesList" item="code" open="(" close=")"
                                             separator=",">
                                        #{code}
                                    </foreach>
                                </when>
                                <otherwise>
                                    and br.village_code in ('')
                                </otherwise>
                            </choose>
                        </if>
                    </when>
                    <otherwise>
                        <choose>
                            <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                and
                                (
                                jg.grid_code in
                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                                or
                                br.village_code in
                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                                )
                            </when>
                            <otherwise>
                                and
                                (
                                jg.grid_code in ('') or br.village_code in ('')
                                )
                            </otherwise>
                        </choose>
                    </otherwise>
                </choose>
            </if>
            <if test="task.status != null and task.status != null">
                and jt.status = #{task.status}
            </if>
            <if test="task.neiCode != null and task.neiCode != null">
                and jg.community_code = #{task.neiCode}
            </if>
            <if test="task.communityCode != null and task.communityCode != null">
                and jg.community_code = #{task.communityCode}
            </if>
            <if test="task.communityName != null and task.communityName != null">
                and br.name like concat('%', #{task.communityName}, '%')
            </if>
            <if test="task.streetCode != null and task.streetCode != null">
                and br.town_code = #{task.streetCode}
            </if>
            <if test="task.realName != null and task.realName != null">
                and jp.principal like concat('%', #{task.realName}, '%')
            </if>
            <if test="task.phone != null and task.phone != null">
                and bu.phone like concat('%', #{task.phone}, '%')
            </if>
            <if test="task.frequency != null and task.frequency != ''">
                and jt.frequency = #{task.frequency}
            </if>
            <if test="task.name != null and task.name != ''">
                and jt.name like concat('%', #{task.name}, '%')
            </if>
            <if test="task.id != null ">and jt.id = #{task.id}</if>
            <if test="task.type != null ">and jt.type = #{task.type}</if>
            <if test="task.remark != null  and task.remark != ''">and jt.remark = #{task.remark}</if>
            <if test="task.createTime != null ">and jt.create_time = #{task.createTime}</if>
            <if test="task.createUser != null ">and jt.create_user = #{task.createUser}</if>
            <if test="task.updateTime != null ">and jt.update_time = #{task.updateTime}</if>
            <if test="task.updateUser != null ">and jt.update_user = #{task.updateUser}</if>
            <if test="task.isDeleted != null ">and jt.is_deleted = #{task.isDeleted}</if>
            <if test="task.houseCode != null  and task.houseCode != ''">and jt.house_code = #{task.houseCode}</if>
            <if test="task.startTime != null and task.startTime != '' and task.endTime != null and task.endTime != '' ">
                AND jt.create_time BETWEEN #{task.startTime} and #{task.endTime}
            </if>
            <!-- 场所店铺 -->
            <if test="task.reportType != null">
                and jt.report_type = #{task.reportType}
            </if>
            <if test="task.reportType == null">
                and jt.report_type in ( 5,8)
            </if>
            and jt.is_deleted = 0
            and jt.house_code is not null
            order by jt.create_time desc
        </where>
    </select>
 
    <!--查询取保候审任务列表(人房相关)-->
    <select id="selectTaskPageByPerson" resultType="org.springblade.modules.task.vo.TaskVO">
        SELECT
        jh.address AS address_name,
        jh.district_code AS aoiCode,
        br.district_code regionCode,
        br.village_code neiCode,
        br.town_code streetCode,
        jt.id,
        jt.NAME,
        jt.type,
        jt.frequency,
        jt.remark,
        jt.create_time,
        jt.create_user,
        jt.update_time,
        jt.update_user,
        jt.STATUS,
        jt.source,
        jt.is_deleted,
        jt.house_code,
        jt.report_type,
        jtbre.start_time startTimes,
        jtbre.reach_time,
        jtbre.return_time
        FROM
        jczz_task jt
        LEFT JOIN jczz_house jh ON jt.house_code=jh.house_code and jh.is_deleted = 0
        LEFT JOIN blade_user bu on bu.id = jt.create_user and bu.is_deleted = 0
        LEFT JOIN jczz_grid jg on jg.grid_code = jh.grid_code and jg.is_deleted = 0
        LEFT JOIN blade_region br on br.code = jg.community_code
        LEFT JOIN jczz_task_bail_reporting_event jtbre on jtbre.task_id = jt.id
        <where>
            <if test="isAdministrator==2">
                <choose>
                    <when test="task.roleName != null and task.roleName != ''">
                        <if test="task.roleName=='wgy'">
                            <choose>
                                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                    and jh.grid_code in
                                    <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                        #{code}
                                    </foreach>
                                </when>
                                <otherwise>
                                    and jh.grid_code in ('')
                                </otherwise>
                            </choose>
                        </if>
                        <if test="task.roleName=='mj' and isAdministrator==2">
                            <choose>
                                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                    and br.village_code in
                                    <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                        #{code}
                                    </foreach>
                                </when>
                                <otherwise>
                                    and br.village_code in ('')
                                </otherwise>
                            </choose>
                        </if>
                    </when>
                    <otherwise>
                        <choose>
                            <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                and
                                (
                                jg.grid_code in
                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                                or
                                br.village_code in
                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                                )
                            </when>
                            <otherwise>
                                and
                                (
                                jg.grid_code in ('') or br.village_code in ('')
                                )
                            </otherwise>
                        </choose>
                    </otherwise>
                </choose>
            </if>
            <if test="task.status != null and task.status != null">
                and jt.status = #{task.status}
            </if>
            <if test="task.aoiCode != null and task.aoiCode != null">
                and jh.district_code = #{task.aoiCode}
            </if>
            <if test="task.neiCode != null and task.neiCode != null">
                and jg.community_code = #{task.neiCode}
            </if>
            <if test="task.communityCode != null and task.communityCode != null">
                and jg.community_code = #{task.communityCode}
            </if>
            <if test="task.communityName != null and task.communityName != null">
                and br.name like concat('%', #{task.communityName}, '%')
            </if>
            <if test="task.streetCode != null and task.streetCode != null">
                and br.town_code = #{task.streetCode}
            </if>
            <if test="task.realName != null and task.realName != null">
                and bu.name like concat('%', #{task.realName}, '%')
            </if>
            <if test="task.phone != null and task.phone != null">
                and bu.phone like concat('%', #{task.phone}, '%')
            </if>
            <if test="task.districtName != null and task.districtName != null">
                and jh.district_name like concat('%', #{task.districtName}, '%')
            </if>
            <if test="task.frequency != null and task.frequency != ''">
                and jt.frequency = #{task.frequency}
            </if>
            <if test="task.name != null and task.name != ''">
                and jt.name like concat('%', #{task.name}, '%')
            </if>
            <if test="task.id != null ">and jt.id = #{task.id}</if>
            <if test="task.type != null ">and jt.type = #{task.type}</if>
            <if test="task.remark != null  and task.remark != ''">and jt.remark = #{task.remark}</if>
            <if test="task.createTime != null ">and jt.create_time = #{task.createTime}</if>
            <if test="task.createUser != null ">and jt.create_user = #{task.createUser}</if>
            <if test="task.updateTime != null ">and jt.update_time = #{task.updateTime}</if>
            <if test="task.updateUser != null ">and jt.update_user = #{task.updateUser}</if>
            <if test="task.isDeleted != null ">and jt.is_deleted = #{task.isDeleted}</if>
            <if test="task.houseCode != null  and task.houseCode != ''">and jt.house_code = #{task.houseCode}</if>
            <if test="task.startTime != null and task.startTime != '' and task.endTime != null and task.endTime != '' ">
                AND jt.create_time BETWEEN #{task.startTime} and #{task.endTime}
            </if>
            <!-- 取保候审 或 报事报修 -->
            <if test="task.reportType != null and task.reportType != 2 ">
                and jt.report_type = #{task.reportType}
            </if>
            and jt.is_deleted = 0
            order by jt.create_time desc
        </where>
    </select>
 
 
    <select id="selectTaskCount" resultType="int" parameterType="org.springblade.modules.task.vo.TaskVO">
        SELECT
        count(1)
        FROM
        jczz_task jt
        LEFT JOIN jczz_place jp ON jt.house_code=jp.house_code and jp.is_deleted = 0
        LEFT JOIN blade_user bu on bu.id = jt.create_user and bu.is_deleted = 0
        LEFT JOIN jczz_grid jg on jg.grid_code = jp.grid_code and jg.is_deleted = 0
        LEFT JOIN blade_region br on br.code = jg.community_code
        LEFT JOIN jczz_police_affairs_grid jpag on jp.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
        <where>
            <if test="task.roleName != null and task.roleName != ''">
                <if test="task.roleName=='wgy'">
                    <if test="isAdministrator==2">
                        <choose>
                            <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                and jp.grid_code in
                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                            </when>
                            <otherwise>
                                and jp.grid_code in ('')
                            </otherwise>
                        </choose>
                    </if>
                </if>
                <if test="task.roleName=='mj'">
                    <if test="isAdministrator==2">
                        <choose>
                            <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                and jpag.community_code in
                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                            </when>
                            <otherwise>
                                and jpag.community_code in ('')
                            </otherwise>
                        </choose>
                    </if>
                </if>
            </if>
            <if test="isAdministrator==2">
                <choose>
                    <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                        and
                        (
                        jg.grid_code in
                        <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                            #{code}
                        </foreach>
                        or
                        br.village_code in
                        <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                            #{code}
                        </foreach>
                        )
                    </when>
                    <otherwise>
                        and
                        (
                        jg.grid_code in ('') or br.village_code in ('')
                        )
                    </otherwise>
                </choose>
            </if>
            <if test="task.status != null and task.status != null">
                and jt.status = #{task.status}
            </if>
            <if test="task.neiCode != null and task.neiCode != null">
                and jg.community_code = #{task.neiCode}
            </if>
            <if test="task.communityCode != null and task.communityCode != null">
                and jg.community_code = #{task.communityCode}
            </if>
            <if test="task.communityName != null and task.communityName != null">
                and br.name like concat('%', #{task.communityName}, '%')
            </if>
            <if test="task.streetCode != null and task.streetCode != null">
                and br.town_code = #{task.streetCode}
            </if>
            <if test="task.realName != null and task.realName != null">
                and jp.principal like concat('%', #{task.realName}, '%')
            </if>
            <if test="task.phone != null and task.phone != null">
                and bu.phone like concat('%', #{task.phone}, '%')
            </if>
            <if test="task.frequency != null and task.frequency != ''">
                and jt.frequency = #{task.frequency}
            </if>
            <if test="task.name != null and task.name != ''">
                and jt.name like concat('%', #{task.name}, '%')
            </if>
            <if test="task.id != null ">and jt.id = #{task.id}</if>
            <if test="task.type != null ">and jt.type = #{task.type}</if>
            <if test="task.remark != null  and task.remark != ''">and jt.remark = #{task.remark}</if>
            <if test="task.createTime != null ">and jt.create_time = #{task.createTime}</if>
            <if test="task.createUser != null ">and jt.create_user = #{task.createUser}</if>
            <if test="task.updateTime != null ">and jt.update_time = #{task.updateTime}</if>
            <if test="task.updateUser != null ">and jt.update_user = #{task.updateUser}</if>
            <if test="task.isDeleted != null ">and jt.is_deleted = #{task.isDeleted}</if>
            <if test="task.houseCode != null  and task.houseCode != ''">and jt.house_code = #{task.houseCode}</if>
            <if test="task.startTime != null and task.startTime != '' and task.endTime != null and task.endTime != '' ">
                AND jt.create_time BETWEEN #{task.startTime} and #{task.endTime}
            </if>
            <!-- 场所店铺 -->
            <if test="task.reportType != null">
                and jt.report_type = #{task.reportType}
            </if>
            <if test="task.reportType == null">
                and jt.report_type in (5,8)
            </if>
            and jt.is_deleted = 0
        </where>
    </select>
 
 
    <select id="selectTaskPageBy" resultType="org.springblade.modules.task.vo.TaskVO">
        SELECT
        jt.* ,
        jda.address_name,
        jtbre.start_time startTimes,
        jtbre.reach_time,
        jtbre.return_time
        FROM
        jczz_task jt
        LEFT JOIN jczz_doorplate_address jda ON jt.house_code = jda.address_code
        LEFT JOIN jczz_community jc ON jc.CODE = jda.nei_code
        LEFT JOIN jczz_task_bail_reporting_event jtbre on jtbre.task_id = jt.id
        <where>
            <if test="task.reportType != null and task.reportType != '' and task.reportType == 1">
                AND jt.report_type = #{task.reportType}
            </if>
 
            <if test="task.startTime != null and task.startTime != '' and task.endTime != null and task.endTime != '' ">
                AND jt.create_time BETWEEN #{task.startTime} and #{task.endTime}
            </if>
 
            <if test="task.reportType == null or task.reportType == ''">
                AND jt.report_type in (2,3,6,7)
            </if>
            <if test="task.userId != null and task.userId != ''">
                AND jc.res_police_user_id like concat('%',#{task.userId},'%')
            </if>
            <if test="isAdministrator==2">
                <choose>
                    <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                        and jc.code in
                        <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                            #{code}
                        </foreach>
                    </when>
                    <otherwise>
                        and jc.code in ('')
                    </otherwise>
                </choose>
            </if>
        </where>
    </select>
 
    <!--取保候审人员查询-->
    <select id="getBailReportingPage" resultType="org.springblade.modules.task.vo.TaskVO">
        SELECT
        IFNULL( jda.address_name, jh.house_name ) AS address_name,
        jtbre.apply_name,
        jh.district_code aoiCode,
        jda.region_code,
        jg.community_code neiCode,
        jc.street_code streetCode,
        bu.real_name realName,
        ifnull(bu.phone,jtbre.check_telephone) as phone,
        jt.id,
        jt.NAME,
        jt.type,
        jt.frequency,
        jt.remark,
        jt.create_time,
        jt.create_user,
        jt.update_time,
        jt.update_user,
        jt.STATUS,
        jt.source,
        jt.is_deleted,
        jt.house_code,
        jt.report_type,
        jtbre.start_time startTimes,
        jtbre.reach_time,
        jtbre.return_time
        FROM
        jczz_task jt
        LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jt.house_code
        LEFT JOIN jczz_house jh ON jt.house_code = jh.house_code and jh.is_deleted = 0
        LEFT JOIN jczz_grid jg on jg.grid_code = jh.grid_code and jg.is_deleted = 0
        LEFT JOIN jczz_police_affairs_grid jpag on jh.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
        LEFT JOIN jczz_community jc on jc.`code`= jg.community_code and jc.is_deleted = 0
        LEFT JOIN jczz_task_bail_reporting_event jtbre on jtbre.task_id = jt.id and jtbre.is_deleted = 0
        LEFT JOIN blade_user bu on bu.id = jtbre.check_user_id and bu.is_deleted = 0
        <where>
            <if test="task.userId != null and task.userId != ''">
                AND jt.house_code IN (
                SELECT
                jgr.house_code
                FROM
                jczz_grid_range jgr
                LEFT JOIN jczz_grid jg ON jg.id = jgr.grid_id
                LEFT JOIN jczz_gridman jgm ON jg.id = jgm.grid_id
                WHERE
                jg.is_deleted = 0
                <if test="task.communityCode != null and task.communityCode != ''">
                    and jg.community_code = #{task.communityCode}
                </if>
                AND jgm.user_id = #{task.userId} )
            </if>
 
            <if test="task.status != null and task.status != null">
                and jt.status = #{task.status}
            </if>
 
            <if test="task.aoiCode != null and task.aoiCode != null">
                and jh.district_code = #{task.aoiCode}
            </if>
 
            <if test="task.neiCode != null and task.neiCode != null">
                and jg.community_code = #{task.neiCode}
            </if>
 
            <if test="task.streetCode != null and task.streetCode != null">
                and jc.street_code = #{task.streetCode}
            </if>
 
            <if test="task.realName != null and task.realName != null">
                and bu.name like concat('%', #{task.realName}, '%')
            </if>
 
            <if test="task.phone != null and task.phone != null">
                and bu.phone like concat('%', #{task.phone}, '%')
            </if>
 
            <if test="task.communityName != null and task.communityName != null">
                and jc.name like concat('%', #{task.communityName}, '%')
            </if>
 
            <if test="task.districtName != null and task.districtName != null">
                and jh.district_name like concat('%', #{task.districtName}, '%')
            </if>
 
            <if test="task.frequency != null and task.frequency != ''">
                and jt.frequency = #{task.frequency}
            </if>
            <if test="task.name != null and task.name != ''">
                and jt.name like concat('%', #{task.name}, '%')
            </if>
            <if test="task.id != null ">and jt.id = #{task.id}</if>
            <if test="task.type != null ">and jt.type = #{task.type}</if>
            <if test="task.remark != null  and task.remark != ''">and jt.remark = #{task.remark}</if>
            <if test="task.createTime != null ">and jt.create_time = #{task.createTime}</if>
            <if test="task.createUser != null ">and jt.create_user = #{task.createUser}</if>
            <if test="task.updateTime != null ">and jt.update_time = #{task.updateTime}</if>
            <if test="task.updateUser != null ">and jt.update_user = #{task.updateUser}</if>
            <if test="task.isDeleted != null ">and jt.is_deleted = #{task.isDeleted}</if>
            <if test="task.houseCode != null  and task.houseCode != ''">and jt.house_code = #{task.houseCode}</if>
            <if test="task.startTime != null and task.startTime != '' and task.endTime != null and task.endTime != '' ">
                AND jt.create_time BETWEEN #{task.startTime} and #{task.endTime}
            </if>
            <!-- 取保候审 或 报事报修 -->
            <if test="task.reportType != null and task.reportType != 2 ">
                and jt.report_type = #{task.reportType}
            </if>
            <if test="isAdministrator==2">
                <choose>
                    <when test="task.roleName != null and task.roleName != ''">
                        <if test="task.roleName=='wgy'">
                            <choose>
                                <when test="gridCodeList !=null and gridCodeList.size()>0">
                                    and jg.grid_code in
                                    <foreach collection="gridCodeList" item="code" open="(" close=")" separator=",">
                                        #{code}
                                    </foreach>
                                </when>
                                <otherwise>
                                    and jg.grid_code in ('')
                                </otherwise>
                            </choose>
                        </if>
                        <if test="task.roleName=='mj'">
                            <choose>
                                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                    and jpag.community_code in
                                    <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                        #{code}
                                    </foreach>
                                </when>
                                <otherwise>
                                    and jpag.community_code in ('')
                                </otherwise>
                            </choose>
                        </if>
                    </when>
                    <otherwise>
                        <choose>
                            <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                and
                                (
                                jg.grid_code in
                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                                or
                                jpag.community_code in
                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                                )
                            </when>
                            <otherwise>
                                and
                                (
                                jg.grid_code in ('') or jpag.community_code in ('')
                                )
                            </otherwise>
                        </choose>
                    </otherwise>
                </choose>
            </if>
            and jt.is_deleted = 0
            and jt.house_code is not null
            order by jt.create_time desc
        </where>
    </select>
 
 
</mapper>