forked from gzzfw/backEnd/gz-dyh

liyj
2024-09-23 faf08d1b4dfdb3a79fadcc365b9597176ab117fb
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
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
<?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">
<!-- 
 * @title: 纠纷任务表
 * @description: 自定义sql,请自行实现业务逻辑
 * @company: hugeinfo
 * @author: liyj
 * @time:2024-09-09 22:10:33
 * @version 1.0.0
-->
<mapper namespace="cn.huge.module.cases.dao.mapper.CaseTaskMapper">
    <!-- 结果集 -->
    <resultMap id="dataResult" type="cn.huge.module.cases.domain.po.CaseTask">
            <result property="id" column="id"/>
            <result property="caseId" column="case_id"/>
            <result property="flowableId" column="flowable_id"/>
            <result property="processInstanceId" column="process_instance_id"/>
            <result property="processTaskId" column="process_task_id"/>
            <result property="taskType" column="task_type"/>
            <result property="nodeType" column="node_type"/>
            <result property="nodeId" column="node_id"/>
            <result property="nodeName" column="node_name"/>
            <result property="flowId" column="flow_id"/>
            <result property="nodeShowName" column="node_show_name"/>
            <result property="caseTaskType" column="case_task_type"/>
            <result property="candeType" column="cande_type"/>
            <result property="candeUnitId" column="cande_unit_id"/>
            <result property="candeUnitName" column="cande_unit_name"/>
            <result property="candeDeptId" column="cande_dept_id"/>
            <result property="candeDeptName" column="cande_dept_name"/>
            <result property="candeRoleCode" column="cande_role_code"/>
            <result property="candeRoleName" column="cande_role_name"/>
            <result property="candeUserId" column="cande_user_id"/>
            <result property="candeUserName" column="cande_user_name"/>
            <result property="signStatus" column="sign_status"/>
            <result property="signExpireTime" column="sign_expire_time"/>
            <result property="signTime" column="sign_time"/>
            <result property="signUserId" column="sign_user_id"/>
            <result property="signUserName" column="sign_user_name"/>
            <result property="expireTime" column="expire_time"/>
            <result property="status" column="status"/>
            <result property="handleUnitId" column="handle_unit_id"/>
            <result property="handleUnitName" column="handle_unit_name"/>
            <result property="handleUserId" column="handle_user_id"/>
            <result property="handleUserName" column="handle_user_name"/>
            <result property="handleResult" column="handle_result"/>
            <result property="handleContent" column="handle_content"/>
            <result property="handleIllust" column="handle_illust"/>
            <result property="handleTime" column="handle_time"/>
            <result property="deleteStatus" column="delete_status"/>
            <result property="custId" column="cust_id"/>
            <result property="createTime" column="create_time"/>
            <result property="updateTime" column="update_time"/>
    </resultMap>
    <!-- 表 -->
    <sql id='table-name'>dyh_case_task</sql>
    <!-- 字段 -->
    <sql id="column-part">
        id,
        case_id,
        flowable_id,
        process_instance_id,
        process_task_id,
        task_type,
        node_type,
        node_id,
        node_name,
        flow_id,
        node_show_name,
        case_task_type,
        cande_type,
        cande_unit_id,
        cande_unit_name,
        cande_dept_id,
        cande_dept_name,
        cande_role_code,
        cande_role_name,
        cande_user_id,
        cande_user_name,
        sign_status,
        sign_expire_time,
        sign_time,
        sign_user_id,
        sign_user_name,
        expire_time,
        status,
        handle_unit_id,
        handle_unit_name,
        handle_user_id,
        handle_user_name,
        handle_result,
        handle_content,
        handle_illust,
        handle_time,
        delete_status,
        cust_id,
        create_time,
        update_time
    </sql>
    <!-- 更新实体字段 -->
    <sql id="set-part">
            <if test="entity.caseId != null">case_id = #{entity.caseId},</if>
            <if test="entity.flowableId != null">flowable_id = #{entity.flowableId},</if>
            <if test="entity.processInstanceId != null">process_instance_id = #{entity.processInstanceId},</if>
            <if test="entity.processTaskId != null">process_task_id = #{entity.processTaskId},</if>
            <if test="entity.taskType != null">task_type = #{entity.taskType},</if>
            <if test="entity.nodeType != null">node_type = #{entity.nodeType},</if>
            <if test="entity.nodeId != null">node_id = #{entity.nodeId},</if>
            <if test="entity.nodeName != null">node_name = #{entity.nodeName},</if>
            <if test="entity.flowId != null">flow_id = #{entity.flowId},</if>
            <if test="entity.nodeShowName != null">node_show_name = #{entity.nodeShowName},</if>
            <if test="entity.caseTaskType != null">case_task_type = #{entity.caseTaskType},</if>
            <if test="entity.candeType != null">cande_type = #{entity.candeType},</if>
            <if test="entity.candeUnitId != null">cande_unit_id = #{entity.candeUnitId},</if>
            <if test="entity.candeUnitName != null">cande_unit_name = #{entity.candeUnitName},</if>
            <if test="entity.candeDeptId != null">cande_dept_id = #{entity.candeDeptId},</if>
            <if test="entity.candeDeptName != null">cande_dept_name = #{entity.candeDeptName},</if>
            <if test="entity.candeRoleCode != null">cande_role_code = #{entity.candeRoleCode},</if>
            <if test="entity.candeRoleName != null">cande_role_name = #{entity.candeRoleName},</if>
            <if test="entity.candeUserId != null">cande_user_id = #{entity.candeUserId},</if>
            <if test="entity.candeUserName != null">cande_user_name = #{entity.candeUserName},</if>
            <if test="entity.signStatus != null">sign_status = #{entity.signStatus},</if>
            <if test="entity.signExpireTime != null">sign_expire_time = #{entity.signExpireTime},</if>
            <if test="entity.signTime != null">sign_time = #{entity.signTime},</if>
            <if test="entity.signUserId != null">sign_user_id = #{entity.signUserId},</if>
            <if test="entity.signUserName != null">sign_user_name = #{entity.signUserName},</if>
            <if test="entity.expireTime != null">expire_time = #{entity.expireTime},</if>
            <if test="entity.status != null">status = #{entity.status},</if>
            <if test="entity.handleUnitId != null">handle_unit_id = #{entity.handleUnitId},</if>
            <if test="entity.handleUnitName != null">handle_unit_name = #{entity.handleUnitName},</if>
            <if test="entity.handleUserId != null">handle_user_id = #{entity.handleUserId},</if>
            <if test="entity.handleUserName != null">handle_user_name = #{entity.handleUserName},</if>
            <if test="entity.handleResult != null">handle_result = #{entity.handleResult},</if>
            <if test="entity.handleContent != null">handle_content = #{entity.handleContent},</if>
            <if test="entity.handleIllust != null">handle_illust = #{entity.handleIllust},</if>
            <if test="entity.handleTime != null">handle_time = #{entity.handleTime},</if>
            <if test="entity.deleteStatus != null">delete_status = #{entity.deleteStatus},</if>
            <if test="entity.custId != null">cust_id = #{entity.custId},</if>
            <if test="entity.createTime != null">create_time = #{entity.createTime},</if>
            <if test="entity.updateTime != null">update_time = #{entity.updateTime}</if>
    </sql>
    <!-- 条件 -->
    <sql id="where-part">
        <if test="terms != null">
            <where>
                <if test="terms.id != null and terms.id !=''">
                    and id = #{terms.id}
                </if>
                <if test="terms.caseId != null and terms.caseId !=''">
                    and case_id = #{terms.caseId}
                </if>
                <if test="terms.flowableId != null and terms.flowableId !=''">
                    and flowable_id = #{terms.flowableId}
                </if>
                <if test="terms.processInstanceId != null and terms.processInstanceId !=''">
                    and process_instance_id = #{terms.processInstanceId}
                </if>
                <if test="terms.processTaskId != null and terms.processTaskId !=''">
                    and process_task_id = #{terms.processTaskId}
                </if>
                <if test="terms.taskType != null and terms.taskType !=''">
                    and task_type = #{terms.taskType}
                </if>
                <if test="terms.nodeType != null and terms.nodeType !=''">
                    and node_type = #{terms.nodeType}
                </if>
                <if test="terms.nodeId != null and terms.nodeId !=''">
                    and node_id = #{terms.nodeId}
                </if>
                <if test="terms.nodeName != null and terms.nodeName !=''">
                    and node_name = #{terms.nodeName}
                </if>
                <if test="terms.flowId != null and terms.flowId !=''">
                    and flow_id = #{terms.flowId}
                </if>
                <if test="terms.nodeShowName != null and terms.nodeShowName !=''">
                    and node_show_name = #{terms.nodeShowName}
                </if>
                <if test="terms.caseTaskType != null and terms.caseTaskType !=''">
                    and case_task_type = #{terms.caseTaskType}
                </if>
                <if test="terms.candeType != null and terms.candeType !=''">
                    and cande_type = #{terms.candeType}
                </if>
                <if test="terms.candeUnitId != null and terms.candeUnitId !=''">
                    and cande_unit_id = #{terms.candeUnitId}
                </if>
                <if test="terms.candeUnitName != null and terms.candeUnitName !=''">
                    and cande_unit_name = #{terms.candeUnitName}
                </if>
                <if test="terms.candeDeptId != null and terms.candeDeptId !=''">
                    and cande_dept_id = #{terms.candeDeptId}
                </if>
                <if test="terms.candeDeptName != null and terms.candeDeptName !=''">
                    and cande_dept_name = #{terms.candeDeptName}
                </if>
                <if test="terms.candeRoleCode != null and terms.candeRoleCode !=''">
                    and cande_role_code = #{terms.candeRoleCode}
                </if>
                <if test="terms.candeRoleName != null and terms.candeRoleName !=''">
                    and cande_role_name = #{terms.candeRoleName}
                </if>
                <if test="terms.candeUserId != null and terms.candeUserId !=''">
                    and cande_user_id = #{terms.candeUserId}
                </if>
                <if test="terms.candeUserName != null and terms.candeUserName !=''">
                    and cande_user_name = #{terms.candeUserName}
                </if>
                <if test="terms.signStatus != null and terms.signStatus !=''">
                    and sign_status = #{terms.signStatus}
                </if>
                <if test="terms.signExpireTime != null and terms.signExpireTime !=''">
                    and sign_expire_time = #{terms.signExpireTime}
                </if>
                <if test="terms.signTime != null and terms.signTime !=''">
                    and sign_time = #{terms.signTime}
                </if>
                <if test="terms.signUserId != null and terms.signUserId !=''">
                    and sign_user_id = #{terms.signUserId}
                </if>
                <if test="terms.signUserName != null and terms.signUserName !=''">
                    and sign_user_name = #{terms.signUserName}
                </if>
                <if test="terms.expireTime != null and terms.expireTime !=''">
                    and expire_time = #{terms.expireTime}
                </if>
                <if test="terms.status != null and terms.status !=''">
                    and status = #{terms.status}
                </if>
                <if test="terms.handleUnitId != null and terms.handleUnitId !=''">
                    and handle_unit_id = #{terms.handleUnitId}
                </if>
                <if test="terms.handleUnitName != null and terms.handleUnitName !=''">
                    and handle_unit_name = #{terms.handleUnitName}
                </if>
                <if test="terms.handleUserId != null and terms.handleUserId !=''">
                    and handle_user_id = #{terms.handleUserId}
                </if>
                <if test="terms.handleUserName != null and terms.handleUserName !=''">
                    and handle_user_name = #{terms.handleUserName}
                </if>
                <if test="terms.handleResult != null and terms.handleResult !=''">
                    and handle_result = #{terms.handleResult}
                </if>
                <if test="terms.handleContent != null and terms.handleContent !=''">
                    and handle_content = #{terms.handleContent}
                </if>
                <if test="terms.handleIllust != null and terms.handleIllust !=''">
                    and handle_illust = #{terms.handleIllust}
                </if>
                <if test="terms.handleTime != null and terms.handleTime !=''">
                    and handle_time = #{terms.handleTime}
                </if>
                <if test="terms.deleteStatus = null and terms.deleteStatus =''">
                    and delete_status = 0
                </if>
                <if test="terms.deleteStatus != null and terms.deleteStatus !=''">
                    and delete_status = #{terms.deleteStatus}
                </if>
                <if test="terms.custId != null and terms.custId !=''">
                    and cust_id = #{terms.custId}
                </if>
                <if test="terms.createTime != null and terms.createTime !=''">
                    and DATE_FORMAT(create_time,'%Y-%m-%d') = #{terms.createTime}
                </if>
                <if test="terms.createStart != null and terms.createStart !='' and terms.createEnd != null and terms.createEnd !=''">
                    and (DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.createStart}
                        and DATE_FORMAT(create_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.createEnd})
                </if>
                <if test="terms.updateTime != null and terms.updateTime !=''">
                    and DATE_FORMAT(update_time,'%Y-%m-%d') = #{terms.updateTime}
                </if>
                <if test="terms.updateStart != null and terms.updateStart !='' and terms.updateEnd != null and terms.updateEnd !=''">
                    and (DATE_FORMAT(update_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.updateStart}
                        and DATE_FORMAT(update_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.updateEnd})
                </if>
            </where>
        </if>
    </sql>
    <!-- 更新对象 -->
    <update id="updateCaseTask">
        update
        <include refid="table-name"/>
        <set>
            <include refid="set-part"/>
        </set>
        <where>
            id = #{entity.id}
        </where>
    </update>
 
    <!-- 批量对象 -->
    <update id="updateCaseTaskList">
        update
        <include refid="table-name"/>
        <set>
            <include refid="set-part"/>
        </set>
        <where>
            id IN
            <foreach item="id" collection="taskIdList" open="(" separator="," close=")">
                #{id}
            </foreach>
        </where>
    </update>
 
    <!-- 条件更新对象 -->
    <update id="updateCaseTaskTerms">
        update
        <include refid="table-name"/>
        <set>
            <include refid="set-part"/>
        </set>
        <include refid="where-part"/>
    </update>
    <!--  根据编号物理删除  -->
    <delete id="deleteCaseTask">
        delete from
        <include refid="table-name" />
        where id = #{id}
    </delete>
    <!--  根据条件查询  -->
    <select id="listTerms" resultMap="dataResult">
        select
        <include refid="column-part"/>
        from
        <include refid="table-name" />
        <include refid="where-part"/>
    </select>
    <!--  根据条件统计  -->
    <select id="countTerms" resultType="java.lang.Long">
        select
        COUNT(1)
        from
        <include refid="table-name" />
        <include refid="where-part"/>
    </select>
    <!--  根据条件分页查询  -->
    <select id="pageTerms" resultMap="dataResult">
        SELECT
        <include refid="column-part"/>
        FROM
        <include refid="table-name" />
        <include refid="where-part"/>
        <if test="page.sort != null">
            <foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
                isnull(${s.property}), ${s.property} ${s.direction}
            </foreach>
        </if>
        <if test="page.sort == null">
            order by isnull(create_time), create_time desc
        </if>
        limit #{page.offset}, #{page.size}
    </select>
 
    <!--  结果集-->
    <resultMap id="FrontPageCountResult" type="cn.huge.module.cases.domain.dto.FrontPageCountDTO">
        <result property="waitDisp" column="waitDisp"/>
        <result property="waitSign" column="waitSign"/>
        <result property="waitAccept" column="waitAccept"/>
        <result property="waitAccept" column="waitAccept"/>
    </resultMap>
    <!--  查询任务数量  -->
    <select id="countTaskList" resultMap="FrontPageCountResult">
        select
        count(case when (node_id = 'ZJ_DFP' or  node_id = 'QJ_DFP' or  node_id = 'SJ_DFP' or  node_id = 'DFP') and sign_status != 1 then id end) as waitDisp,
        count(case when sign_status = 1 then id end) as waitSign,
        count(case when (node_id = 'ZJ_DSL' or  node_id = 'QJ_DSL' or  node_id = 'SJ_DSL' or  node_id = 'DSL') and sign_status != 1 and (handle_result != 3 or handle_result is null) then id end) as waitAccept,
        count(case when node_id = 'BLFK' then id end) as Processing
        from
        <include refid="table-name" />
        where
        cande_unit_id = #{terms.candeUnitId}
        and delete_status = 0
        and status = 1
    </select>
 
 
    <!-- 工作台-待/已分派条件查询-条件 -->
    <sql id="myTaskFp-where-part">
        <if test="terms != null">
            <if test="terms.candeUnitId != null and terms.candeUnitId !=''">
                and t1.cande_unit_id = #{terms.candeUnitId}
            </if>
            <if test="terms.handleUnitId != null and terms.handleUnitId !=''">
                and t1.handle_unit_id = #{terms.handleUnitId}
            </if>
            <if test="terms.createTimeStart != null and terms.createTimeStart !='' and terms.createTimeEnd != null and terms.createTimeEnd !=''">
                and (DATE_FORMAT(t1.create_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.createTimeStart}
                and DATE_FORMAT(t1.create_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.createTimeEnd})
            </if>
            <if test="terms.handleTimeStart != null and terms.handleTimeStart !='' and terms.handleTimeEnd != null and terms.handleTimeEnd !=''">
                and (DATE_FORMAT(t1.handle_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.handleTimeStart}
                and DATE_FORMAT(t1.handle_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.handleTimeEnd})
            </if>
            <if test="terms.partyName != null and terms.partyName !=''">
                and concat(t2.plaintiffs, t2.pagents, t2.defendants, t2.dagents) like concat('%', #{terms.partyName}, '%')
            </if>
        </if>
    </sql>
    <!--  工作台-待/已分派条件统计  -->
    <select id="countMyTaskFp" resultType="java.lang.Long">
        select
        COUNT(t1.id)
        from
        dyh_case_task t1 left join dyh_case_info t2 on t1.case_id = t2.id
        where
        (t1.node_id = 'ZJ_DFP' or  t1.node_id = 'QJ_DFP' or  t1.node_id = 'SJ_DFP' or  t1.node_id = 'DFP')
        and t1.sign_status != 1
        and t2.delete_status = 0
        and t1.status = #{terms.status}
        <include refid="myTaskFp-where-part"/>
    </select>
    <!--  工作台-待分派分页查询  -->
    <select id="pageMyTaskFp" resultType="cn.huge.module.cases.domain.dto.FrontPageListFPDTO">
        SELECT t1.id as ownerId, t1.case_id as caseId,
        t1.create_time as turnaroundTime, t1.expire_time as timeLimit, t1.handle_time as taskHandleTime,
        t2.case_level as caseGrade, t2.canal_name as caseSource, concat(t2.case_type_first_name, '/' ,t2.case_type_name) as caseType,
        concat(t2.que_area_name, t2.que_road_name) as queAddress,
        concat(t2.plaintiffs, t2.pagents) as plaintiffs, concat(t2.defendants, t2.dagents) as defendants,
        (select count(1) from dyh_case_supervise where case_id = t1.case_id) as superviseCount
        FROM
        dyh_case_task t1 left join dyh_case_info t2 on t1.case_id = t2.id
        where
        (t1.node_id = 'ZJ_DFP' or  t1.node_id = 'QJ_DFP' or  t1.node_id = 'SJ_DFP' or  t1.node_id = 'DFP')
        and t1.sign_status != 1
        and t2.delete_status = 0
        and t1.status = #{terms.status}
        <include refid="myTaskFp-where-part"/>
        <if test="page.sort != null">
            <foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
                isnull(${s.property}), ${s.property} ${s.direction}
            </foreach>
        </if>
        <if test="page.sort == null">
            order by isnull(t1.create_time), t1.create_time desc
        </if>
        limit #{page.offset}, #{page.size}
    </select>
 
 
    <!-- 工作台-待/已签收条件查询-条件 -->
    <sql id="myTaskQs-where-part">
        <if test="terms != null">
            <if test="terms.candeUnitId != null and terms.candeUnitId !=''">
                and t1.cande_unit_id = #{terms.candeUnitId}
            </if>
            <if test="terms.handleUnitId != null and terms.handleUnitId !=''">
                and t1.handle_unit_id = #{terms.handleUnitId}
            </if>
            <if test="terms.createTimeStart != null and terms.createTimeStart !='' and terms.createTimeEnd != null and terms.createTimeEnd !=''">
                and (DATE_FORMAT(t1.create_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.createTimeStart}
                and DATE_FORMAT(t1.create_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.createTimeEnd})
            </if>
            <if test="terms.signTimeStart != null and terms.signTimeStart !='' and terms.signTimeEnd != null and terms.signTimeEnd !=''">
                and (DATE_FORMAT(t1.sign_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.signTimeStart}
                and DATE_FORMAT(t1.sign_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.signTimeEnd})
            </if>
            <if test="terms.partyName != null and terms.partyName !=''">
                and concat(t2.plaintiffs, t2.pagents, t2.defendants, t2.dagents) like concat('%', #{terms.partyName}, '%')
            </if>
        </if>
    </sql>
    <!--  首页-待/已签收条件统计  -->
    <select id="countMyTaskQs" resultType="java.lang.Long">
        select
        COUNT(t1.id)
        from
        dyh_case_task t1 left join dyh_case_info t2 on t1.case_id = t2.id
        where
        t2.delete_status = 0
        and t1.status = '1'
        and t1.sign_status = #{terms.signStatus}
        <include refid="myTaskQs-where-part"/>
    </select>
    <!--  首页-待/已签收分页查询  -->
    <select id="pageMyTaskQs" resultType="cn.huge.module.cases.domain.dto.FrontPageListQSDTO">
        SELECT t1.id as ownerId, t1.case_id as caseId,
        t1.create_time as turnaroundTime, t1.sign_expire_time as timeLimit, t1.sign_time as taskHandleTime,
        t2.case_level as caseGrade, t2.canal_name as caseSource, concat(t2.case_type_first_name, '/' ,t2.case_type_name) as caseType,
        concat(t2.plaintiffs, t2.pagents) as plaintiffs, concat(t2.defendants, t2.dagents) as defendants,
        (select count(1) from dyh_case_supervise where case_id = t1.case_id) as superviseCount
        FROM
        dyh_case_task t1 left join dyh_case_info t2 on t1.case_id = t2.id
        where
        t2.delete_status = 0
        and t1.status = '1'
        and t1.sign_status = #{terms.signStatus}
        <include refid="myTaskQs-where-part"/>
        <if test="page.sort != null">
            <foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
                isnull(${s.property}), ${s.property} ${s.direction}
            </foreach>
        </if>
        <if test="page.sort == null">
            order by isnull(t1.create_time), t1.create_time desc
        </if>
        limit #{page.offset}, #{page.size}
    </select>
 
    <!--  全部签收-查询未签收所有Id  -->
    <select id="listIdByTerms" resultType="cn.huge.module.cases.domain.dto.SignTaskDTO">
        SELECT t1.id as caseTaskId, t1.case_id as caseId
        FROM
        dyh_case_task t1 left join dyh_case_info t2 on t1.case_id = t2.id
        where
        t2.delete_status = 0
        and t1.status = '1'
        <include refid="myTaskQs-where-part"/>
    </select>
 
 
    <!-- 工作台-待/已受理条件查询-条件 -->
    <sql id="myTaskSl-where-part">
        <if test="terms != null">
            <if test="terms.candeUnitId != null and terms.candeUnitId !=''">
                and t1.cande_unit_id = #{terms.candeUnitId}
            </if>
            <if test="terms.handleUnitId != null and terms.handleUnitId !=''">
                and t1.handle_unit_id = #{terms.handleUnitId}
            </if>
            <if test="terms.caseTaskType != null and terms.caseTaskType !=''">
                and t1.case_task_type = #{terms.caseTaskType}
            </if>
            <if test="terms.createTimeStart != null and terms.createTimeStart !='' and terms.createTimeEnd != null and terms.createTimeEnd !=''">
                and (DATE_FORMAT(t1.create_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.createTimeStart}
                and DATE_FORMAT(t1.create_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.createTimeEnd})
            </if>
            <if test="terms.handleTimeStart != null and terms.handleTimeStart !='' and terms.handleTimeEnd != null and terms.handleTimeEnd !=''">
                and (DATE_FORMAT(t1.handle_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.handleTimeStart}
                and DATE_FORMAT(t1.handle_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.handleTimeEnd})
            </if>
            <if test="terms.partyName != null and terms.partyName !=''">
                and concat(t2.plaintiffs, t2.pagents, t2.defendants, t2.dagents) like concat('%', #{terms.partyName}, '%')
            </if>
        </if>
    </sql>
    <!--  首页-待/已受理条件统计  -->
    <select id="countMyTaskSl" resultType="java.lang.Long">
        select
        COUNT(t1.id)
        from
        dyh_case_task t1 left join dyh_case_info t2 on t1.case_id = t2.id
        where
        (t1.node_id = 'ZJ_DSL' or  t1.node_id = 'QJ_DSL' or  t1.node_id = 'SJ_DSL' or  t1.node_id = 'DSL')
        and t2.delete_status = 0
        and t1.sign_status != 1
        and (t1.handle_result != 3 or t1.handle_result is null)
        and t1.status = #{terms.status}
        <include refid="myTaskSl-where-part"/>
    </select>
    <!--  首页-待/已受理分页查询  -->
    <select id="pageMyTaskSl" resultType="cn.huge.module.cases.domain.dto.FrontPageListSLDTO">
        SELECT t1.id as ownerId, t1.case_id as caseId,
        t1.create_time as turnaroundTime, t1.sign_expire_time as timeLimit, t1.handle_time as taskHandleTime,
        t2.case_level as caseGrade, t2.canal_name as caseSource, concat(t2.case_type_first_name, '/' ,t2.case_type_name) as caseType,
        concat(t2.plaintiffs, t2.pagents) as plaintiffs, concat(t2.defendants, t2.dagents) as defendants,
        (select count(1) from dyh_case_supervise where case_id = t1.case_id) as superviseCount
        FROM
        dyh_case_task t1 left join dyh_case_info t2 on t1.case_id = t2.id
        where
        (t1.node_id = 'ZJ_DSL' or t1.node_id = 'QJ_DSL' or t1.node_id = 'SJ_DSL' or t1.node_id = 'DSL')
        and t2.delete_status = 0
        and t1.sign_status != 1
        and (t1.handle_result != 3 or t1.handle_result is null)
        and t1.status = #{terms.status}
        <include refid="myTaskSl-where-part"/>
        <if test="page.sort != null">
            <foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
                isnull(${s.property}), ${s.property} ${s.direction}
            </foreach>
        </if>
        <if test="page.sort == null">
            order by isnull(t1.create_time), t1.create_time desc
        </if>
        limit #{page.offset}, #{page.size}
    </select>
 
 
    <!-- 工作台-办理中条件查询-条件 -->
    <sql id="myTaskBlz-where-part">
        <if test="terms != null">
            <if test="terms.candeUnitId != null and terms.candeUnitId !=''">
                and t1.cande_unit_id = #{terms.candeUnitId}
            </if>
            <if test="terms.status != null and terms.status !=''">
                and t1.status = #{terms.status}
            </if>
            <if test="terms.caseTaskType != null and terms.caseTaskType !=''">
                and t1.case_task_type = #{terms.caseTaskType}
            </if>
            <if test="terms.createTimeStart != null and terms.createTimeStart !='' and terms.createTimeEnd != null and terms.createTimeEnd !=''">
                and (DATE_FORMAT(t1.create_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.createTimeStart}
                and DATE_FORMAT(t1.create_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.createTimeEnd})
            </if>
            <if test="terms.partyName != null and terms.partyName !=''">
                and concat(t2.plaintiffs, t2.pagents, t2.defendants, t2.dagents) like concat('%', #{terms.partyName}, '%')
            </if>
        </if>
    </sql>
    <!--  首页-办理中条件统计  -->
    <select id="countMyTaskBlz" resultType="java.lang.Long">
        select
        COUNT(t1.id)
        from
        dyh_case_task t1 left join dyh_case_info t2 on t1.case_id = t2.id
        left join dyh_case_info_unfold t3 on t1.case_id = t3.id
        where
        t1.node_id = 'BLFK'
        and t1.status = 1
        and t2.delete_status = 0
        <include refid="myTaskBlz-where-part"/>
    </select>
    <!--  首页-办理中分页查询  -->
    <select id="pageMyTaskBlz" resultType="cn.huge.module.cases.domain.dto.FrontPageListBLZDTO">
        SELECT
        t1.id as ownerId, t1.case_id as caseId, t1.create_time as turnaroundTime, t2.case_level as caseGrade,
        t2.canal_name as caseSource, concat(t2.case_type_first_name, '/' ,t2.case_type_name) as caseType, t3.mediator as mediator,
        t3.assist_unit_name as cooperatingUnit, t3.mediate_unit_name as organizingUnit,
        concat(t2.plaintiffs, t2.pagents) as plaintiffs, concat(t2.defendants, t2.dagents) as defendants,
        (select count(1) from dyh_case_supervise where case_id = t1.case_id) as superviseCount
        FROM
        dyh_case_task t1 left join dyh_case_info t2 on t1.case_id = t2.id
        left join dyh_case_info_unfold t3 on t1.case_id = t3.id
        where
        t1.node_id = 'BLFK'
        and t1.status = 1
        and t2.delete_status = 0
        <include refid="myTaskBlz-where-part"/>
        <if test="page.sort != null">
            <foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
                isnull(${s.property}), ${s.property} ${s.direction}
            </foreach>
        </if>
        <if test="page.sort == null">
            order by isnull(t1.create_time), t1.create_time desc
        </if>
        limit #{page.offset}, #{page.size}
    </select>
 
    <!--  首页-待审核-我申请的条件统计  -->
    <select id="countMyTaskShWSQD" resultType="java.lang.Long">
        select sum(t1.count)
        from
        (
        SELECT count(1) as count, case_id as caseId
        FROM dyh_case_return
        WHERE return_unit_id = #{terms.applyUnitId}
        union all
        SELECT count(1) as count, case_id as caseId
        FROM dyh_case_windup_apply
        WHERE apply_unit_id = #{terms.applyUnitId}
        union all
        SELECT count(1) as count, case_id as caseId
        FROM dyh_case_appear
        WHERE appear_unit_id = #{terms.applyUnitId}
        union all
        SELECT count(1) as count, case_id as caseId
        FROM dyh_case_assist_apply
        WHERE apply_unit_id = #{terms.applyUnitId}
        )t1 left join dyh_case_info t2 on t1.caseId = t2.id
        <where>
            <if test="terms.applyType != null and terms.applyType !=''">
                and t1.applyType = #{terms.applyType}
            </if>
            <if test="terms.auditStatus != null and terms.auditStatus !=''">
                and t1.audit_result = #{terms.auditResult}
            </if>
            <if test="terms.timeStart != null and terms.timeStart !='' and terms.timeEnd != null and terms.timeEnd !=''">
                and (DATE_FORMAT(t1.turnaroundTime,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.timeStart}
                and DATE_FORMAT(t1.turnaroundTime,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.timeEnd})
            </if>
            <if test="terms.partyName != null and terms.partyName !=''">
                and concat(t2.plaintiffs, t2.pagents, t2.defendants, t2.dagents) like concat('%', #{terms.partyName}, '%')
            </if>
        </where>
    </select>
    <!--  首页-待审核-我申请的分页查询  -->
    <select id="pageMyTaskShWSQD" resultType="cn.huge.module.cases.domain.dto.FrontPageListWSQDDTO">
        select t1.*,t2.case_level as caseGrade, t2.canal_name as caseSource, concat(t2.case_type_first_name, '/' ,t2.case_type_name) as caseType,
        concat(t2.plaintiffs, t2.pagents) as plaintiffs, concat(t2.defendants, t2.dagents) as defendants
            from
            (
            SELECT case_id as caseId, id as ownerId, return_time as turnaroundTime, '回退' as applyType,
            audit_unit_name as auditUnit, return_status as auditStatus, audit_result_name as auditResult,
            audit_time as auditTime, create_time, audit_result
            FROM dyh_case_return
            WHERE return_unit_id = #{terms.applyUnitId}
            union all
            SELECT case_id as caseId, id as ownerId, apply_time as turnaroundTime, '结案' as applyType,
            audit_unit_name as auditUnit, apply_status as auditStatus, audit_result_name as auditResult,
            audit_time as auditTime, create_time, audit_result
            FROM dyh_case_windup_apply
            WHERE apply_unit_id = #{terms.applyUnitId}
            union all
            SELECT case_id as caseId, id as ownerId, appear_time as turnaroundTime, '上报' as applyType,
            audit_unit_name as auditUnit, apply_status as auditStatus, audit_result_name as auditResult,
            audit_time as auditTime, create_time, audit_result
            FROM dyh_case_appear
            WHERE appear_unit_id = #{terms.applyUnitId}
            union all
            SELECT case_id as caseId, id as ownerId, apply_time as turnaroundTime, '联合处置' as applyType,
            audit_unit_name as auditUnit, apply_status as auditStatus, audit_result_name as auditStatus,
            audit_time as auditTime, create_time, audit_result
            FROM dyh_case_assist_apply
            WHERE apply_unit_id = #{terms.applyUnitId}
            )t1 left join dyh_case_info t2 on t1.caseId = t2.id
        <where>
        <if test="terms.applyType != null and terms.applyType !=''">
            and t1.applyType = #{terms.applyType}
        </if>
        <if test="terms.auditStatus != null and terms.auditStatus !=''">
            and t1.audit_result = #{terms.auditResult}
        </if>
        <if test="terms.timeStart != null and terms.timeStart !='' and terms.timeEnd != null and terms.timeEnd !=''">
            and (DATE_FORMAT(t1.turnaroundTime,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.timeStart}
            and DATE_FORMAT(t1.turnaroundTime,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.timeEnd})
        </if>
        <if test="terms.partyName != null and terms.partyName !=''">
            and concat(t2.plaintiffs, t2.pagents, t2.defendants, t2.dagents) like concat('%', #{terms.partyName}, '%')
        </if>
        </where>
        <if test="page.sort != null">
            <foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
                isnull(${s.property}), ${s.property} ${s.direction}
            </foreach>
        </if>
        <if test="page.sort == null">
            order by isnull(t1.create_time), t1.create_time desc
        </if>
        limit #{page.offset}, #{page.size}
    </select>
 
 
    <!-- web端-工作台-已办事项条件查询-条件 -->
    <sql id="myTaskYb-where-part">
        <if test="terms != null">
            <if test="terms.createTimeStart != null and terms.createTimeStart !='' and terms.createTimeEnd != null and terms.createTimeEnd !=''">
                and (DATE_FORMAT(t1.create_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.createTimeStart}
                and DATE_FORMAT(t1.create_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.createTimeEnd})
            </if>
            <if test="terms.handleTimeStart != null and terms.handleTimeStart !='' and terms.handleTimeEnd != null and terms.handleTimeEnd !=''">
                and (DATE_FORMAT(t1.handle_time,'%Y-%m-%d') <![CDATA[ >= ]]> #{terms.handleTimeStart}
                and DATE_FORMAT(t1.handle_time,'%Y-%m-%d') <![CDATA[ <= ]]> #{terms.handleTimeEnd})
            </if>
            <if test="terms.mediator != null and terms.mediator !=''">
                and t3.mediator like concat('%', #{terms.mediator}, '%')
            </if>
            <if test="terms.canal != null and terms.canal !=''">
                and t1.canal = #{terms.canal}
            </if>
            <if test="terms.mediResult != null and terms.mediResult !=''">
                and t1.medi_result = #{terms.mediResult}
            </if>
            <if test="terms.caseLevel != null and terms.caseLevel !=''">
                and t1.case_level = #{terms.caseLevel}
            </if>
            <if test="terms.caseType != null and terms.caseType !=''">
                and t1.case_type = #{terms.caseType}
            </if>
            <if test="terms.status != null and terms.status !=''">
                and t2.status = #{terms.status}
            </if>
        </if>
    </sql>
    <!--  web端-工作台-已办事项条件统计  -->
    <select id="countMyTaskYb" resultType="java.lang.Long">
        SELECT count(DISTINCT t2.id)
        FROM dyh_case_task t1
        left join dyh_case_info t2 on t1.case_id = t2.id
        left join dyh_case_info_unfold t3 on t1.case_id = t3.id
        where t1.status = 2
        and t1.node_id = 'BLFK'
        and t1.handle_unit_id = #{terms.handleUnitId}
        and t2.delete_status = 0
        <include refid="myTaskYb-where-part"/>
    </select>
    <!--  web端-工作台-已办事项分页查询  -->
    <select id="pageMyTaskYb" resultType="cn.huge.module.cases.domain.dto.FrontPageListYBDTO">
        SELECT t1.id as caseTaskId, t2.id as caseId, t1.create_time as createTime, t2.status_name as statusName,
        t3.medi_result as mediResult, t3.medi_result_name as mediResultName, t3.mediator as mediator,
        t1.handle_time as handleTime, t2.case_level as caseLevel, t2.canal_name as canalName,
        concat(t2.case_type_first_name, '/' ,t2.case_type_name) as caseType,
        (select count(1) from dyh_case_supervise where case_id = t1.case_id) as superviseCount
        FROM dyh_case_task t1
        left join dyh_case_info t2 on t1.case_id = t2.id
        left join dyh_case_info_unfold t3 on t1.case_id = t3.id
        where t1.status = 2
        and t1.node_id = 'BLFK'
        and t1.handle_unit_id = #{terms.handleUnitId}
        and t2.delete_status = 0
        <include refid="myTaskYb-where-part"/>
        group by t2.id
        <if test="page.sort != null">
            <foreach collection="page.sort" item="s" index="index" separator="," open="order by ">
                isnull(${s.property}), ${s.property} ${s.direction}
            </foreach>
        </if>
        <if test="page.sort == null">
            order by isnull(t1.create_time), t1.create_time desc
        </if>
        limit #{page.offset}, #{page.size}
    </select>
 
</mapper>