OWL ITS + 탐지시스템(인터넷 진흥원)
이민희
2021-12-01 eee313007ce5c4f0879d764d56d3a1ba93f6fb37
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
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
<mapper namespace="kr.wisestone.owl.mapper.WidgetMapper">
 
    <!-- 전체 위젯 -->
    <!--    1번 위젯 시작 -->
 
    <!--    잔여 이슈 개수 -->
    <select id="countRemainIssue" resultType="java.lang.Long"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        SELECT
        COUNT(i.id) FROM issue i
        WHERE EXISTS(SELECT 1 FROM issue_status iss WHERE iss.issue_status_type != 'CLOSE' AND i.issue_status_id =
        iss.id)
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
    </select>
 
    <!--    지연 이슈 개수   -->
    <select id="countTodayDelayIssue" resultType="java.lang.Long"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        SELECT
        COUNT(i.id) FROM issue i where
        exists(select 1 from issue_status iss where iss.id = i.issue_status_id and iss.issue_status_type != 'CLOSE')
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        AND i.complete_date IS NOT NULL
        AND i.complete_date <![CDATA[ < ]]> #{completeDate}
    </select>
 
    <!--    할당 이슈 개수 - 담당자 버전  -->
    <!--<select id="countAssigneeIssue" resultType="java.lang.Long"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        SELECT
        COUNT(i.id) FROM issue i
        WHERE EXISTS(SELECT 1 FROM issue_user iu WHERE iu.issue_id = i.id AND iu.user_id = #{loginUserId})
        AND EXISTS(SELECT 1 FROM issue_status iss WHERE iss.id = i.issue_status_id and iss.issue_status_type != 'CLOSE')
        <choose>
            <when test="projectIds.size != 0">
                AND i.project_id IN
                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        <choose>
            <when test="downProjectIds.size != 0">
                OR i.project_id IN
                <foreach collection="downProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
    </select>-->
 
    <!--    할당 이슈 개수 - 담당부서 버전  -->
    <select id="countAssigneeIssue" resultType="java.lang.Long"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        SELECT
        COUNT(i.id) FROM issue i
        WHERE EXISTS(SELECT 1 FROM issue_department id WHERE id.issue_id = i.id
        <choose>
            <when test="myDepartmentIds.size != 0">
                AND id.department_id IN
                <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
            <otherwise>
                AND 1 != 1
            </otherwise>
        </choose>
        ) AND EXISTS(SELECT 1 FROM issue_status iss WHERE iss.id = i.issue_status_id and iss.issue_status_type != 'CLOSE')
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
    </select>
 
    <!--    내가 오늘 등록한 이슈 개수 -->
    <select id="countTodayRegisterIssue" resultType="java.lang.Long"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        count(i.id) as todayCount from issue i where
        i.register_id = #{loginUserId}
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        AND i.register_date BETWEEN (CURDATE()) AND (CURDATE() + INTERVAL 1 DAY)
    </select>
 
    <!--    미할당 이슈 개수   -->
    <!--<select id="countNoAssigneeIssue" resultType="java.lang.Long"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        SELECT
        COUNT(DISTINCT i.id) FROM issue i
        LEFT OUTER JOIN issue_user iu ON iu.issue_id = i.id
        WHERE
        EXISTS(select 1 from issue_status iss where iss.id = i.issue_status_id and iss.issue_status_type != 'CLOSE')
        <choose>
            <when test="meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        AND iu.id IS NULL
    </select>-->
 
    <!--    미할당 이슈 개수 (담당부서 버전)  -->
    <select id="countNoAssigneeIssue" resultType="java.lang.Long"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        SELECT
        COUNT(DISTINCT i.id) FROM issue i
        LEFT OUTER JOIN issue_department id ON id.issue_id = i.id
        WHERE
        EXISTS(select 1 from issue_status iss where iss.id = i.issue_status_id and iss.issue_status_type != 'CLOSE')
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        AND id.id IS NULL
    </select>
 
    <!--    완료된 이슈 개수   -->
    <select id="countCompleteIssue" resultType="java.lang.Long"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        count(*) as issueCount from issue i
        inner join issue_status iss on iss.id = i.issue_status_id
        where iss.issue_status_type = 'CLOSE'
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
    </select>
 
    <!--    1번 위젯 끝 -->
 
    <!--    2번 위젯 시작  -->
 
    <!--    전체 이슈 처리현황   -->
    <select id="findIssueComplete" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select (DATE_FORMAT(i.modify_date, '%Y-%m-%d')) as modifyDate,
        count(*) as issueCount from issue i
        inner join issue_status iss on iss.id = i.issue_status_id
        where iss.issue_status_type = 'CLOSE'
        and i.modify_date between #{searchStartDate} and #{searchEndDate}
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        group by (DATE_FORMAT(i.modify_date, '%Y-%m-%d'))
    </select>
 
    <!--    전체 이슈 개수   -->
    <select id="countTotalIssue" resultType="java.lang.Long"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select count(distinct i.id) from issue i
        inner join issue_status iss on iss.id = i.issue_status_id
        where 1=1
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
    </select>
 
    <!--    2번 위젯 끝 -->
 
 
    <!--    3번 위젯 시작 -->
 
    <!--    진행중인 프로젝트 현황 (담당자 버전)   -->
    <!--<select id="findProjectProgress" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        p.id as id,
        p.name as name,
        replace(p.start_date, "-", ".") as startDate,
        replace(p.end_date, "-", ".") as endDate,
        count(case when iss.issue_status_type = 'CLOSE' THEN 1 END) as 'close',
        count(case when iss.issue_status_type != 'CLOSE' THEN 1 END) as 'remain',
        (select concat(u.name, "%", u.account, "%", u.profile) from user u
        inner join project_role_user pru on pru.user_id = u.id
        inner join project_role pr on pr.id = pru.project_role_id
        where pr.project_id = p.id and pr.role_type = '02'
        ) as managerInfo
        ,
        (
        select count(distinct(u.id)) from user u
        inner join project_role_user pru on pru.user_id = u.id
        inner join project_role pr on pr.id = pru.project_role_id
        where pr.project_id = p.id and pr.role_type = '01'
        ) as teamCount
        from
        project p
        left outer join issue i on p.id = i.project_id
        left outer join issue_status iss on iss.id = i.issue_status_id
        WHERE 1=1
        <choose>
            <when test="projectIds.size != 0">
                AND p.id IN
                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        GROUP by p.id
    </select>-->
 
    <!--    진행중인 프로젝트 현황 (담당부서 버전)   -->
    <select id="findProjectProgress" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        p.id as id,
        p.name as name,
        replace(p.start_date, "-", ".") as startDate,
        replace(p.end_date, "-", ".") as endDate,
        count(case when iss.issue_status_type = 'CLOSE' THEN 1 END) as 'close',
        count(case when iss.issue_status_type != 'CLOSE' THEN 1 END) as 'remain',
        (select concat(u.name, "%", u.account, "%", u.profile) from user u
        inner join project_role_user pru on pru.user_id = u.id
        inner join project_role pr on pr.id = pru.project_role_id
        where pr.project_id = p.id and pr.role_type = '02'
        ) as managerInfo
        ,
        (
        select count(distinct(d.id)) from department d
        inner join project_role_department prd on prd.department_id = d.id
        inner join project_role pr on pr.id = prd.project_role_id
        where pr.project_id = p.id and pr.role_type = '01'
        ) as teamCount
        from
        project p
        left outer join issue i on p.id = i.project_id
        left outer join issue_status iss on iss.id = i.issue_status_id
        WHERE 1=1
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND p.id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        GROUP by p.id
    </select>
 
    <!--    진행중인 프로젝트 현황(전체) (담당자 버전)   -->
    <!--<select id="findProjectProgressAll" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        p.id as id,
        p.name as name,
        replace(p.start_date, "-", ".") as startDate,
        replace(p.end_date, "-", ".") as endDate,
        count(case when iss.issue_status_type = 'CLOSE' THEN 1 END) as 'close',
        count(case when iss.issue_status_type != 'CLOSE' THEN 1 END) as 'remain',
        (select concat(u.name, "%", u.account, "%", u.profile) from user u
        inner join project_role_user pru on pru.user_id = u.id
        inner join project_role pr on pr.id = pru.project_role_id
        where pr.project_id = p.id and pr.role_type = '02'
        ) as managerInfo
        ,
        (
        select count(distinct(u.id)) from user u
        inner join project_role_user pru on pru.user_id = u.id
        inner join project_role pr on pr.id = pru.project_role_id
        where pr.project_id = p.id and pr.role_type = '01'
        ) as teamCount
        from
        project p
        left outer join issue i on p.id = i.project_id
        left outer join issue_status iss on iss.id = i.issue_status_id
        WHERE 1=1
        GROUP by p.id
    </select>-->
 
    <!--    진행중인 프로젝트 현황(전체) (담당부서 버전)   -->
    <select id="findProjectProgressAll" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        p.id as id,
        p.name as name,
        replace(p.start_date, "-", ".") as startDate,
        replace(p.end_date, "-", ".") as endDate,
        count(case when iss.issue_status_type = 'CLOSE' THEN 1 END) as 'close',
        count(case when iss.issue_status_type != 'CLOSE' THEN 1 END) as 'remain',
        (select concat(u.name, "%", u.account, "%", u.profile) from user u
        inner join project_role_user pru on pru.user_id = u.id
        inner join project_role pr on pr.id = pru.project_role_id
        where pr.project_id = p.id and pr.role_type = '02'
        ) as managerInfo
        ,
        (
        select count(distinct(d.id)) from department d
          inner join project_role_department prd on prd.department_id = d.id
          inner join project_role pr on pr.id = prd.project_role_id
        where pr.project_id = p.id and pr.role_type = '01'
        ) as teamCount
        from
        project p
        left outer join issue i on p.id = i.project_id
        left outer join issue_status iss on iss.id = i.issue_status_id
        WHERE 1=1
        GROUP by p.id
    </select>
 
    <!--    3번 위젯 끝 -->
 
 
    <!--    4번 위젯 시작 -->
 
    <!--내가 오늘 할당받은 이슈 개수 - 담당자 버전-->
    <!--<select id="countTodayMyAssigneeIssue" resultType="java.lang.Long"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        count(i.id) as todayCount from issue i where
        exists(select 1 from issue_user iu where iu.issue_id = i.id and iu.user_id = #{loginUserId} and iu.register_date
        BETWEEN (CURDATE()) AND (CURDATE() + INTERVAL 1 DAY))
        <choose>
            <when test="projectIds.size != 0">
                AND i.project_id IN
                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
    </select>-->
 
    <!--    내가 오늘 할당받은 이슈 개수 - 담당부서 버전 -->
    <select id="countTodayMyAssigneeIssue" resultType="java.lang.Long"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        count(i.id) as todayCount from issue i where
        exists(select 1 from issue_department id where id.issue_id = i.id
        <choose>
            <when test="myDepartmentIds.size != 0">
                AND id.department_id IN
                <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
            <otherwise>
                AND 1 != 1
            </otherwise>
        </choose>
        and id.register_date
        BETWEEN (CURDATE()) AND (CURDATE() + INTERVAL 1 DAY))
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
    </select>
 
    <!--    내가 담당하는 이슈 개수 - 담당자  -->
    <!--<select id="countMyAssigneeIssue" resultType="java.lang.Long"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        count(distinct i.id)
        from issue i
        inner join issue_user iu on iu.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        WHERE 1=1
        <choose>
            <when test="projectIds.size != 0">
                AND i.project_id IN
                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        and iu.user_id = #{loginUserId}
        and iss.issue_status_type != 'CLOSE'
    </select>-->
 
    <!--    내가 담당하는 이슈 개수 - 담당부서  -->
    <select id="countMyAssigneeIssue" resultType="java.lang.Long"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        count(distinct i.id)
        from issue i
        inner join issue_department id on id.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        WHERE 1=1
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        <choose>
            <when test="myDepartmentIds.size != 0">
                AND id.department_id IN
                <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
            <otherwise>
                AND 1 != 1
            </otherwise>
        </choose>
        And iss.issue_status_type != 'CLOSE'
    </select>
 
    <!--    내가 담당하는 이슈  -->
    <!--<select id="findMyAssigneeIssue" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        distinct i.id as id,
        i.title as title,
        CONCAT(p.project_key, '-', i.issue_number) AS issueKey,
        p.project_key as projectKey,
        i.issue_number as issueNumber,
        iss.name as issueStatusName,
        replace(i.complete_date, "-", ".") as completeDate,
        replace(SUBSTRING(i.register_date, 1, 10), "-", ".") as registerDate
        from issue i
        inner join issue_user iu on iu.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        inner join project p on p.id = i.project_id
        WHERE 1=1
        <choose>
            <when test="projectIds.size != 0">
                AND p.id IN
                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        and iu.user_id = #{loginUserId}
        and iss.issue_status_type != 'CLOSE'
        GROUP by i.id
        <if test="page != null and !page.equals('')">
            limit #{pageSize} offset #{page};
        </if>
    </select>-->
 
    <!--    내가 담당하는 이슈 - 담당부서  -->
    <select id="findMyAssigneeIssue" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        distinct i.id as id,
        i.title as title,
        p.name as projectName,
        CONCAT(p.project_key, '-', i.issue_number) AS issueKey,
        p.project_key as projectKey,
        i.issue_number as issueNumber,
        iss.name as issueStatusName,
        replace(i.complete_date, "-", ".") as completeDate,
        replace(SUBSTRING(i.register_date, 1, 10), "-", ".") as registerDate
        from issue i
        inner join issue_department id on id.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        inner join project p on p.id = i.project_id
        WHERE 1=1
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND p.id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        <choose>
            <when test="myDepartmentIds.size != 0">
                AND id.department_id IN
                <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
            <otherwise>
                AND 1 != 1
            </otherwise>
        </choose>
        and iss.issue_status_type != 'CLOSE'
        GROUP by i.id
        <if test="page != null and !page.equals('')">
            limit #{pageSize} offset #{page};
        </if>
    </select>
 
    <!--    4번 위젯 끝 -->
 
 
    <!--    5번 위젯 시작 -->
 
    <!--    번복되는 상태 변경 및 빈번한 담당자 변경 개수   -->
    <!--<select id="countChangeStatusAndAssigneeIssue" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        count(case when ir.change_assignee_count > 3 then 1 end) as changeAssigneeCount,
        count(case when ir.change_issue_status_count > 3 then 1 end) as changeIssueStatusCount
        from issue i
        inner join issue_risk ir on ir.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        where iss.issue_status_type != 'CLOSE'
        <choose>
            <when test="projectIds.size != 0">
                AND i.project_id IN
                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
    </select>-->
 
    <select id="countChangeStatusAndDepartmentIssue" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        count(case when ir.change_department_count > 3 then 1 end) as changeDepartmentCount,
        count(case when ir.change_issue_status_count > 3 then 1 end) as changeIssueStatusCount
        from issue i
        inner join issue_risk ir on ir.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        where iss.issue_status_type != 'CLOSE'
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
    </select>
 
    <!--    위험 관리    -->
    <!--<select id="findRiskIssue" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        DISTINCT i.id, i.title, iss.name as issueStatusName,
        (case when ir.change_assignee_count > 3 then true else false end) as changeAssigneeType,
        (case when ir.change_issue_status_count > 3 then true else false end) as changeIssueStatusType,
        CONCAT(p.project_key, '-', i.issue_number) AS issueKey,
        i.issue_number as issueNumber,
        p.project_key as projectKey
        from issue i
        inner join issue_risk ir on ir.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        inner join project p on p.id = i.project_id
        where iss.issue_status_type != 'CLOSE'
        <choose>
            <when test="projectIds.size != 0">
                AND p.id IN
                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        and (ir.change_assignee_count > 3 || ir.change_issue_status_count > 3)
        <if test="page != null and !page.equals('')">
            limit #{pageSize} offset #{page};
        </if>
    </select>-->
    <select id="findRiskIssue" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        DISTINCT i.id, i.title, iss.name as issueStatusName,
        (case when ir.change_department_count > 3 then true else false end) as changeDepartmentType,
        (case when ir.change_issue_status_count > 3 then true else false end) as changeIssueStatusType,
        CONCAT(p.project_key, '-', i.issue_number) AS issueKey,
        i.issue_number as issueNumber,
        p.project_key as projectKey,
        p.name as projectName
        from issue i
        inner join issue_risk ir on ir.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        inner join project p on p.id = i.project_id
        where iss.issue_status_type != 'CLOSE'
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND p.id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        and (ir.change_department_count > 3 || ir.change_issue_status_count > 3)
        <if test="page != null and !page.equals('')">
            limit #{pageSize} offset #{page};
        </if>
    </select>
 
    <!--    위험 관리 개수    -->
    <select id="countRiskIssue" resultType="java.lang.Long"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        count(DISTINCT i.id)
        from issue i
        inner join issue_risk ir on ir.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        where iss.issue_status_type != 'CLOSE'
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        and (ir.change_department_count > 3 || ir.change_issue_status_count > 3)
    </select>
 
    <!--    5번 위젯 끝 -->
 
 
    <!--    6번 위젯 시작 -->
 
    <!--    내가 등록한 이슈 조회    -->
    <select id="findRegisterIssue" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        SELECT
        DISTINCT i.id
        <if test="page != null and !page.equals('')">
            , replace(i.start_date, "-", ".") as startDate
            , replace(i.complete_date, "-", ".") as completeDate
            , i.title as title
            , p.name as projectName
            , iss.name as issueStatusName
            , i.issue_number as issueNumber
            , p.project_key as projectKey
            , CONCAT(p.project_key, '-', i.issue_number) AS issueKey
        </if>
        FROM issue i
        <if test="page != null and !page.equals('')">
            INNER JOIN issue_status iss ON iss.id = i.issue_status_id
            INNER JOIN project p ON p.id = i.project_id
        </if>
        WHERE 1=1
        AND i.register_id = #{loginUserId}
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        <if test="page != null and !page.equals('')">
            AND iss.issue_status_type != 'CLOSE'
            limit #{pageSize} offset #{page};
        </if>
    </select>
 
    <!--    내가 등록한 이슈 카운트 구하기   -->
    <select id="countRegisterIssue" resultType="java.lang.Long"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        SELECT
        <choose>
            <when test="page != null and !page.equals('')">
                COUNT(i.id)
            </when>
            <otherwise>
                COUNT(DISTINCT i.id)
            </otherwise>
        </choose>
        FROM issue i
        WHERE i.register_id = #{loginUserId}
        <if test="page != null and !page.equals('')">
            AND EXISTS (SELECT 1 FROM issue_status iss WHERE iss.id = i.issue_status_id AND iss.issue_status_type != 'CLOSE')
        </if>
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
    </select>
 
    <!--    6번 위젯 끝 -->
 
 
    <!--    7번 위젯 끝 -->
 
    <!--    8번 위젯 시작 -->
 
    <!--    지연중인 이슈 조회 (오늘 날짜 기준)    -->
    <select id="findDelayIssue" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        SELECT
        DISTINCT i.id
        <if test="page != null and !page.equals('')">
            , replace(i.start_date, "-", ".") as startDate
            , replace(i.complete_date, "-", ".") as completeDate
            , i.title as title
            , p.name as projectName
            , iss.name as issueStatusName
            , i.issue_number as issueNumber
            , p.project_key as projectKey
            , CONCAT(p.project_key, '-', i.issue_number) AS issueKey
        </if>
        FROM issue i
        <if test="page != null and !page.equals('')">
            INNER JOIN issue_status iss ON iss.id = i.issue_status_id
            INNER JOIN project p ON p.id = i.project_id
        </if>
        WHERE 1=1
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        AND i.complete_date IS NOT NULL
        AND i.complete_date <![CDATA[ < ]]> #{completeDate}
        <if test="page != null and !page.equals('')">
            AND iss.issue_status_type != 'CLOSE'
            limit #{pageSize} offset #{page};
        </if>
    </select>
 
    <!--    지연중인 이슈 카운트 구하기   -->
    <select id="countDelayIssue" resultType="java.lang.Long"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        SELECT
        COUNT(DISTINCT i.id) FROM issue i
        INNER JOIN project p ON p.id = i.project_id
        <if test="page != null and !page.equals('')">
            INNER JOIN issue_status iss ON iss.id = i.issue_status_id
        </if>
        WHERE 1=1
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        AND i.complete_date IS NOT NULL
        AND i.complete_date <![CDATA[ < ]]> #{completeDate}
        <if test="page != null and !page.equals('')">
            AND iss.issue_status_type != 'CLOSE'
        </if>
    </select>
 
    <!--    8번 위젯 끝 -->
 
 
    <!--    9번 위젯 시작 -->
 
    <!--    프로젝트 별 상태별 이슈 현황 조회 -->
    <select id="findByStandIssueStatus" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        <choose>
            <when test="issueStatuses.size != 0">
                <foreach collection="issueStatuses" item="item" index="index" separator="," open="" close="">
                    count(case when i.issue_status_id = #{item.id} then 1 end) as #{item.name}
                </foreach>
            </when>
        </choose>
        ,p.id,
        p.name as projectName
        from issue i
        inner join project p on p.id = i.project_id
        inner join issue_status iss on iss.id = i.issue_status_id
        where 1=1
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        group by p.id
    </select>
 
    <!--    9번 위젯 끝 -->
 
    <!--    11번 위젯 시작 -->
 
    <!--    멤버별 진행률 -->
    <!--<select id="findProjectMemberIssue" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        u.name, u.profile, u.account,
        (select count(*) from issue i
        inner join issue_user iu on iu.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        where iu.user_id = u.id and i.project_id = p.id and iss.issue_status_type = 'CLOSE') as completeCount,
        (select count(*) from issue i
        inner join issue_user iu on iu.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        where iu.user_id = u.id and i.project_id = p.id and iss.issue_status_type != 'CLOSE') as remainCount,
        (select count(*) from issue i
        inner join issue_user iu on iu.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        where iu.user_id = u.id and i.project_id = p.id and iss.issue_status_type != 'CLOSE' and i.complete_date is not null and i.complete_date <![CDATA[ < ]]> now()) as delayCount
        from
        user u
        inner join project_role_user pru on pru.user_id = u.id
        inner join project_role pr on pr.id = pru.project_role_id
        inner join project p on p.id = pr.project_id
        where p.id = #{projectId} and p.status = '02'
    </select>-->
 
    <!--  담당부서별 진행률 -->
    <select id="findProjectMemberIssue" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select
        d.department_name as departmentName,
        p.name as projectName,
        (select count(*) from issue i
        inner join issue_department id on id.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        where id.department_id = d.id and i.project_id = p.id and iss.issue_status_type = 'CLOSE') as completeCount,
        (select count(*) from issue i
        inner join issue_department id on id.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        where id.department_id = d.id and i.project_id = p.id and iss.issue_status_type != 'CLOSE') as remainCount,
        (select count(*) from issue i
        inner join issue_department id on id.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        where id.department_id = d.id and i.project_id = p.id and iss.issue_status_type != 'CLOSE' and i.complete_date is not null and i.complete_date <![CDATA[ < ]]> now()) as delayCount
        from
        department d
        inner join project_role_department prd on prd.department_id = d.id
        inner join project_role pr on pr.id = prd.project_role_id
        inner join project p on p.id = pr.project_id
        WHERE
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                p.id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        and p.status = '02';
    </select>
 
 
    <!--    11번 위젯 끝 -->
 
 
    <!--    12번 위젯 시작 -->
 
    <!--    등록한 이슈 중 완료 갯수  -->
    <select id="findMyRegisterCompleteIssue" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select i.project_id as projectId, count(i.id) as issueCount from issue i
        where exists (select 1 from issue_status iss where iss.id = i.issue_status_id and iss.issue_status_type =
        'CLOSE') AND
        i.register_id = #{loginUserId}
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        group by i.project_id
    </select>
 
    <!--    등록한 이슈 중 진행 갯수  -->
    <select id="findMyRegisterRemainIssue" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select i.project_id as projectId, count(i.id) as issueCount from issue i
        where exists (select 1 from issue_status iss where iss.id = i.issue_status_id and iss.issue_status_type !=
        'CLOSE')
        AND i.register_id = #{loginUserId}
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        group by i.project_id
    </select>
 
    <!--    담당한 이슈 중 완료 갯수  -->
    <!--<select id="findMyAssigneeCompleteIssue" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select i.project_id as projectId, count(distinct i.id) as issueCount from issue i
        inner join issue_user iu on iu.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        where iu.user_id = #{loginUserId} and iss.issue_status_type = 'CLOSE'
        <choose>
            <when test="projectIds.size != 0">
                AND i.project_id IN
                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        group by i.project_id
    </select>-->
 
    <!--    담당한 이슈 중 완료 갯수  - 담당부서 -->
    <select id="findMyAssigneeCompleteIssue" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select i.project_id as projectId, count(distinct i.id) as issueCount from issue i
        inner join issue_department id on id.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        <choose>
            <when test="myDepartmentIds.size != 0">
                AND id.department_id IN
                <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
            <otherwise>
                AND 1 != 1
            </otherwise>
        </choose>
        and iss.issue_status_type = 'CLOSE'
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        group by i.project_id
    </select>
 
    <!--    담당한 이슈 중 진행 갯수  -->
    <!--<select id="findMyAssigneeRemainIssue" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select i.project_id as projectId, count(distinct i.id) as issueCount from issue i
        inner join issue_user iu on iu.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        where iu.user_id = #{loginUserId} and iss.issue_status_type != 'CLOSE'
        <choose>
            <when test="projectIds.size != 0">
                AND i.project_id IN
                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        group by i.project_id
    </select>-->
 
    <!--    담당한 이슈 중 진행 갯수  - 담당부서 -->
    <select id="findMyAssigneeRemainIssue" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        select i.project_id as projectId, count(distinct i.id) as issueCount from issue i
        inner join issue_department id on id.issue_id = i.id
        inner join issue_status iss on iss.id = i.issue_status_id
        where iss.issue_status_type != 'CLOSE'
        <choose>
            <when test="myDepartmentIds.size != 0">
                id.department_id IN
                <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
            <otherwise>
                AND 1 != 1
            </otherwise>
        </choose>
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        group by i.project_id
    </select>
 
    <!--    12번 위젯 끝 -->
 
    <!--    이슈 타입 별 이슈 현황   -->
 
    <select id="findByStandIssueType" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        SELECT issue_type.name as name, COUNT(issue.id) as issueCount FROM issue issue
        INNER JOIN issue_type issue_type ON issue.issue_type_id = issue_type.id
        WHERE issue.project_id = #{projectId}
        GROUP BY issue_type.name
    </select>
 
    <!-- 13번 위젯 시작 -->
 
    <!-- 중요도 별 이슈 갯수 -->
    <select id="countSeverityIssue" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        SELECT
        COUNT(case when s.id = 1 then 'CRITICAL' END) AS 'critical',
        COUNT(case when s.id = 2 then 'MAJOR' END) AS 'major',
        COUNT(case when s.id = 3 then 'MINOR' END) AS 'minor',
        COUNT(case when s.id = 4 then 'TRIVIAL' END) AS 'trivial'
        FROM issue i
        INNER JOIN project p ON p.id = i.project_id
        INNER JOIN workspace w ON w.id = p.workspace_id
        INNER JOIN severity s ON s.id = i.severity_id
        INNER JOIN issue_status iss ON iss.id = i.issue_status_id
        WHERE w.id = #{workspaceId}
        AND iss.issue_status_type != 'CLOSE'
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
    </select>
 
    <!-- 중요도 이슈 목록 -->
    <select id="findSeverityIssues" resultType="java.util.HashMap"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        SELECT i.title AS title,
        s.name AS severityName,
        p.name AS projectName,
        s.color AS severityColor,
        replace(i.start_date, "-", ".") AS startDate,
        replace(i.complete_date, "-", ".")  AS completeDate,
        i.issue_number AS issueNumber,
        p.project_key AS projectKey,
        p.name AS projectName,
        iss.name AS issueStatusName,
        CONCAT(p.project_key, '-', i.issue_number) AS issueKey
        FROM issue i
        INNER JOIN project p ON p.id = i.project_id
        INNER JOIN workspace w ON w.id = p.workspace_id
        INNER JOIN severity s ON s.id = i.severity_id
        INNER JOIN issue_status iss ON iss.id = i.issue_status_id
        WHERE w.id = #{workspaceId}
        AND s.id = #{severityId}
        AND iss.issue_status_type != 'CLOSE'
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
        <if test="page != null and !page.equals('')">
            limit #{pageSize} offset #{page};
        </if>
    </select>
 
    <!-- 중요도 항목 별 갯수 -->
    <select id="countSearchIssue" resultType="java.lang.Long"
            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
        SELECT COUNT(distinct i.id)
        FROM issue i
        INNER JOIN project p ON p.id = i.project_id
        INNER JOIN workspace w ON w.id = p.workspace_id
        INNER JOIN severity s ON s.id = i.severity_id
        INNER JOIN issue_status iss ON iss.id = i.issue_status_id
        WHERE w.id = #{workspaceId}
        AND s.id = #{severityId}
        AND iss.issue_status_type != 'CLOSE'
        <choose>
            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
                AND i.project_id IN
                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
                    #{item}
                </foreach>
            </when>
        </choose>
    </select>
 
    <!-- 13번 위젯 끝 -->
 
</mapper>