From 689e17c797bf3844f7b6b6f7c086df9bd8f72a0c Mon Sep 17 00:00:00 2001
From: wyu <kknd09321@nate.com>
Date: 화, 28 12월 2021 19:45:34 +0900
Subject: [PATCH] Merge branch 'master' of http://192.168.0.25:9001/r/owl-kisa

---
 src/main/resources/mybatis/query-template/widget-template.xml |  332 +++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 236 insertions(+), 96 deletions(-)

diff --git a/src/main/resources/mybatis/query-template/widget-template.xml b/src/main/resources/mybatis/query-template/widget-template.xml
index 02b923b..1f57277 100644
--- a/src/main/resources/mybatis/query-template/widget-template.xml
+++ b/src/main/resources/mybatis/query-template/widget-template.xml
@@ -15,9 +15,9 @@
         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">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -29,13 +29,13 @@
         SELECT
         COUNT(i.id) FROM issue i
         INNER JOIN issue_department isd ON isd.issue_id = i.id
-        INNER JOIN department d ON d.id = isd.department_id
+        INNER JOIN user_department ud ON ud.department_id = isd.department_id
         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">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -47,6 +47,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
     </select>
 
@@ -57,9 +60,9 @@
         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">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -73,12 +76,12 @@
         SELECT
         COUNT(i.id) FROM issue i
         INNER JOIN issue_department isd ON isd.issue_id = i.id
-        INNER JOIN department d ON d.id = isd.department_id
+        INNER JOIN user_department ud ON ud.department_id = isd.department_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">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -90,6 +93,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         AND i.complete_date IS NOT NULL
         AND i.complete_date <![CDATA[ < ]]> #{completeDate}
@@ -139,9 +145,9 @@
         </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">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -153,7 +159,7 @@
         SELECT
         COUNT(i.id) FROM issue i
         INNER JOIN issue_department isd ON isd.issue_id = i.id
-        INNER JOIN department d ON d.id = isd.department_id
+        INNER JOIN user_department ud ON ud.department_id = isd.department_id
         WHERE EXISTS(SELECT 1 FROM issue_department isd WHERE isd.issue_id = i.id
         <choose>
             <when test="myDepartmentIds.size != 0">
@@ -168,9 +174,9 @@
         </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">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -184,9 +190,9 @@
         count(i.id) as todayCount from issue i where
         i.register_id = #{loginUserId}
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -199,13 +205,13 @@
         select
         count(i.id) as todayCount from issue i
         INNER JOIN issue_department isd ON isd.issue_id = i.id
-        INNER JOIN department d ON d.id = isd.department_id
+        INNER JOIN user_department ud ON ud.department_id = isd.department_id
         where
         i.register_id = #{loginUserId}
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -217,6 +223,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         AND i.register_date BETWEEN (CURDATE()) AND (CURDATE() + INTERVAL 1 DAY)
     </select>
@@ -230,9 +239,9 @@
         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">
+            <when test="projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -249,9 +258,9 @@
         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">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -259,7 +268,7 @@
         AND isd.id IS NULL
     </select>
 
-    <select id="countNoAssigneeIssueByDepartment" resultType="java.lang.Long"
+    <!--<select id="countNoAssigneeIssueByDepartment" resultType="java.lang.Long"
             parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
         SELECT
         COUNT(DISTINCT i.id) FROM issue i
@@ -267,9 +276,9 @@
         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">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -283,7 +292,7 @@
             </when>
         </choose>
         AND isd.id IS NULL
-    </select>
+    </select>-->
 
     <!--    �셿猷뚮맂 �씠�뒋 媛쒖닔   -->
     <select id="countCompleteIssue" resultType="java.lang.Long"
@@ -293,9 +302,9 @@
         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">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -308,12 +317,12 @@
         count(*) as issueCount from issue i
         inner join issue_status iss on iss.id = i.issue_status_id
         INNER JOIN issue_department isd ON isd.issue_id = i.id
-        INNER JOIN department d ON d.id = isd.department_id
+        INNER JOIN user_department ud ON ud.department_id = isd.department_id
         where iss.issue_status_type = 'CLOSE'
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -325,6 +334,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
     </select>
 
@@ -341,9 +353,9 @@
         where iss.issue_status_type = 'CLOSE'
         and i.modify_date between #{searchStartDate} and #{searchEndDate}
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -358,9 +370,9 @@
         inner join issue_status iss on iss.id = i.issue_status_id
         where 1=1
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -438,9 +450,9 @@
         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">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND p.id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -535,21 +547,26 @@
             parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
         select
         count(i.id) as todayCount from issue i where
-        exists(select 1 from issue_department isd where isd.issue_id = i.id
+        exists(select 1 from issue_department isd
+        INNER JOIN user_department ud ON ud.department_id = isd.department_id
+        where isd.issue_id = i.id
         <choose>
-            <when test="myDepartmentIds.size != 0">
+            <when test="myDepartmentIds != null and myDepartmentIds.size != 0">
                 AND isd.department_id IN
                 <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         and isd.register_date
         BETWEEN (CURDATE()) AND (CURDATE() + INTERVAL 1 DAY))
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -587,9 +604,9 @@
         inner join issue_status iss on iss.id = i.issue_status_id
         WHERE 1=1
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -601,6 +618,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         And iss.issue_status_type != 'CLOSE'
     </select>
@@ -656,9 +676,9 @@
         inner join project p on p.id = i.project_id
         WHERE 1=1
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND p.id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -675,6 +695,7 @@
         select
         distinct i.id as id,
         i.title as title,
+        i.issue_type_id as issueTypeId,
         p.name as projectName,
         CONCAT(p.project_key, '-', i.issue_number) AS issueKey,
         p.project_key as projectKey,
@@ -684,24 +705,28 @@
         replace(SUBSTRING(i.register_date, 1, 10), "-", ".") as registerDate
         from issue i
         inner join issue_department isd on isd.issue_id = i.id
+        INNER JOIN user_department ud ON ud.department_id = isd.department_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">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND p.id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
         </choose>
         <choose>
-            <when test="myDepartmentIds.size != 0">
+            <when test="myDepartmentIds != null and myDepartmentIds.size != 0">
                 AND isd.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
@@ -745,9 +770,9 @@
         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">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -791,16 +816,17 @@
         CONCAT(p.project_key, '-', i.issue_number) AS issueKey,
         i.issue_number as issueNumber,
         p.project_key as projectKey,
-        p.name as projectName
+        p.name as projectName,
+        i.issue_type_id as issueTypeId
         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">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND p.id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -821,9 +847,9 @@
         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">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -850,6 +876,7 @@
             , i.issue_number as issueNumber
             , p.project_key as projectKey
             , CONCAT(p.project_key, '-', i.issue_number) AS issueKey
+            , i.issue_type_id as issueTypeId
         </if>
         FROM issue i
         <if test="page != null and !page.equals('')">
@@ -859,9 +886,9 @@
         WHERE 1=1
         AND i.register_id = #{loginUserId}
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -890,9 +917,9 @@
             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">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -919,18 +946,28 @@
             , iss.name as issueStatusName
             , i.issue_number as issueNumber
             , p.project_key as projectKey
+            , i.issue_type_id as issueTypeId
             , 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
+            LEFT OUTER join issue_department isd on isd.issue_id = i.id
         </if>
         WHERE 1=1
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </when>
+        </choose>
+        <choose>
+            <when test="myDepartmentIds != null and myDepartmentIds.size != 0">
+                AND isd.department_id IN
+                <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -949,14 +986,23 @@
         SELECT
         COUNT(DISTINCT i.id) FROM issue i
         INNER JOIN project p ON p.id = i.project_id
+        LEFT OUTER join issue_department isd on isd.issue_id = i.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">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </when>
+        </choose>
+        <choose>
+            <when test="myDepartmentIds != null and myDepartmentIds.size != 0">
+                AND isd.department_id IN
+                <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -985,18 +1031,60 @@
             </when>
         </choose>
         ,p.id,
-        p.name as projectName
+        p.name as projectName,
+        i.issue_type_id as issueTypeId
         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">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
+        </choose>
+        group by p.id
+    </select>
+
+    <select id="findByStandIssueStatusOfDepartment" 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,
+        i.issue_type_id as issueTypeId
+        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
+        INNER JOIN issue_department isd ON isd.issue_id = i.id
+        INNER JOIN user_department ud ON ud.department_id = isd.department_id
+        where 1=1
+        <choose>
+            <when test="projectIds != null and 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="myDepartmentIds != null and myDepartmentIds.size != 0">
+                AND isd.department_id IN
+                <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         group by p.id
     </select>
@@ -1055,9 +1143,9 @@
         inner join project p on p.id = pr.project_id
         WHERE
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 p.id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -1085,13 +1173,14 @@
         from
         department d
         inner join project_role_department prd on prd.department_id = d.id
+        INNER JOIN user_department ud ON ud.department_id = prd.department_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">
+            <when test="projectIds != null and projectIds.size != 0">
                 p.id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -1103,6 +1192,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         and p.status = '02';
     </select>
@@ -1121,9 +1213,9 @@
         'CLOSE') AND
         i.register_id = #{loginUserId}
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -1139,9 +1231,9 @@
         'CLOSE')
         AND i.register_id = #{loginUserId}
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -1180,12 +1272,15 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         and iss.issue_status_type = 'CLOSE'
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -1225,11 +1320,14 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -1243,9 +1341,38 @@
 
     <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
+        SELECT issue_type.name as name, COUNT(issue.id) as issueCount FROM issue
+        INNER JOIN issue_type ON issue.issue_type_id = issue_type.id
+        WHERE 1=1
+        <choose>
+            <when test="projectIds != null and projectIds.size != 0">
+                AND issue.project_id IN
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </when>
+        </choose>
+        GROUP BY issue_type.name
+    </select>
+
+    <select id="findByStandIssueTypeOfDepartment" resultType="java.util.HashMap"
+            parameterType="kr.wisestone.owl.web.condition.WidgetCondition">
+        SELECT issue_type.name as name, COUNT(issue.id) as issueCount FROM issue
+        INNER JOIN issue_type ON issue.issue_type_id = issue_type.id
+        INNER JOIN issue_department isd ON isd.issue_id = issue.id
+        INNER JOIN user_department ud ON ud.department_id = isd.department_id
         WHERE issue.project_id = #{projectId}
+        <choose>
+            <when test="myDepartmentIds != null and myDepartmentIds.size != 0">
+                AND isd.department_id IN
+                <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")">
+                    #{item}
+                </foreach>
+            </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
+        </choose>
         GROUP BY issue_type.name
     </select>
 
@@ -1267,9 +1394,9 @@
         WHERE w.id = #{workspaceId}
         AND iss.issue_status_type != 'CLOSE'
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -1289,12 +1416,13 @@
         INNER JOIN severity s ON s.id = i.severity_id
         INNER JOIN issue_status iss ON iss.id = i.issue_status_id
         INNER JOIN issue_department isd on isd.issue_id = i.id
+        INNER JOIN user_department ud ON ud.department_id = isd.department_id
         WHERE w.id = #{workspaceId}
         AND iss.issue_status_type != 'CLOSE'
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -1306,6 +1434,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
     </select>
 
@@ -1322,7 +1453,8 @@
         p.project_key AS projectKey,
         p.name AS projectName,
         iss.name AS issueStatusName,
-        CONCAT(p.project_key, '-', i.issue_number) AS issueKey
+        CONCAT(p.project_key, '-', i.issue_number) AS issueKey,
+        i.issue_type_id as issueTypeId
         FROM issue i
         INNER JOIN project p ON p.id = i.project_id
         INNER JOIN workspace w ON w.id = p.workspace_id
@@ -1332,9 +1464,9 @@
         AND s.id = #{severityId}
         AND iss.issue_status_type != 'CLOSE'
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -1356,20 +1488,22 @@
         p.project_key AS projectKey,
         p.name AS projectName,
         iss.name AS issueStatusName,
-        CONCAT(p.project_key, '-', i.issue_number) AS issueKey
+        CONCAT(p.project_key, '-', i.issue_number) AS issueKey,
+        i.issue_type_id as issueTypeId
         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
         INNER JOIN issue_department isd on isd.issue_id = i.id
+        INNER JOIN user_department ud ON ud.department_id = isd.department_id
         WHERE w.id = #{workspaceId}
         AND s.id = #{severityId}
         AND iss.issue_status_type != 'CLOSE'
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -1381,6 +1515,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
         <if test="page != null and !page.equals('')">
             limit #{pageSize} offset #{page};
@@ -1400,9 +1537,9 @@
         AND s.id = #{severityId}
         AND iss.issue_status_type != 'CLOSE'
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -1422,9 +1559,9 @@
         AND s.id = #{severityId}
         AND iss.issue_status_type != 'CLOSE'
         <choose>
-            <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0">
+            <when test="projectIds != null and projectIds.size != 0">
                 AND i.project_id IN
-                <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")">
+                <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")">
                     #{item}
                 </foreach>
             </when>
@@ -1436,6 +1573,9 @@
                     #{item}
                 </foreach>
             </when>
+            <otherwise>
+                AND 1 != 1
+            </otherwise>
         </choose>
     </select>
 

--
Gitblit v1.8.0