From 3bdf2a1f2757de8ab6570508385d89124243943c Mon Sep 17 00:00:00 2001 From: 이민희 <mhlee@maprex.co.kr> Date: 금, 10 12월 2021 15:34:13 +0900 Subject: [PATCH] 일반회원 대시보드 오류 해결 --- src/main/resources/mybatis/query-template/widget-template.xml | 874 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 816 insertions(+), 58 deletions(-) diff --git a/src/main/resources/mybatis/query-template/widget-template.xml b/src/main/resources/mybatis/query-template/widget-template.xml index a460ac6..4b94ec0 100644 --- a/src/main/resources/mybatis/query-template/widget-template.xml +++ b/src/main/resources/mybatis/query-template/widget-template.xml @@ -15,12 +15,41 @@ WHERE EXISTS(SELECT 1 FROM issue_status iss WHERE iss.issue_status_type != 'CLOSE' AND i.issue_status_id = iss.id) <choose> - <when test="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </when> + </choose> + </select> + + <select id="countRemainIssueByDepartment" resultType="java.lang.Long" + parameterType="kr.wisestone.owl.web.condition.WidgetCondition"> + SELECT + COUNT(i.id) 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 + 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> + <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> </select> @@ -31,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="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </when> @@ -42,8 +71,38 @@ AND i.complete_date <![CDATA[ < ]]> #{completeDate} </select> - <!-- �븷�떦 �씠�뒋 媛쒖닔 --> - <select id="countAssigneeIssue" resultType="java.lang.Long" + <select id="countTodayDelayIssueByDepartment" resultType="java.lang.Long" + parameterType="kr.wisestone.owl.web.condition.WidgetCondition"> + SELECT + COUNT(i.id) 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 + 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> + <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> + 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 @@ -57,6 +116,71 @@ </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 isd WHERE isd.issue_id = i.id + <choose> + <when test="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 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="countAssigneeIssueByDepartment" resultType="java.lang.Long" + parameterType="kr.wisestone.owl.web.condition.WidgetCondition"> + SELECT + COUNT(i.id) 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 + WHERE EXISTS(SELECT 1 FROM issue_department isd WHERE isd.issue_id = i.id + <choose> + <when test="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 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> <!-- �궡媛� �삤�뒛 �벑濡앺븳 �씠�뒋 媛쒖닔 --> @@ -66,9 +190,9 @@ count(i.id) as todayCount from issue i where i.register_id = #{loginUserId} <choose> - <when test="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </when> @@ -76,8 +200,38 @@ AND i.register_date BETWEEN (CURDATE()) AND (CURDATE() + INTERVAL 1 DAY) </select> + <select id="countTodayRegisterIssueByDepartment" resultType="java.lang.Long" + parameterType="kr.wisestone.owl.web.condition.WidgetCondition"> + select + count(i.id) as todayCount 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 + 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> + <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> + AND i.register_date BETWEEN (CURDATE()) AND (CURDATE() + INTERVAL 1 DAY) + </select> + <!-- 誘명븷�떦 �씠�뒋 媛쒖닔 --> - <select id="countNoAssigneeIssue" resultType="java.lang.Long" + <!--<select id="countNoAssigneeIssue" resultType="java.lang.Long" parameterType="kr.wisestone.owl.web.condition.WidgetCondition"> SELECT COUNT(DISTINCT i.id) FROM issue i @@ -85,15 +239,61 @@ WHERE 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"> + <when test="meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <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 isd ON isd.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 isd.id IS NULL </select> + + <!--<select id="countNoAssigneeIssueByDepartment" resultType="java.lang.Long" + parameterType="kr.wisestone.owl.web.condition.WidgetCondition"> + SELECT + COUNT(DISTINCT i.id) FROM issue i + LEFT OUTER JOIN issue_department isd ON isd.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> + <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> + </choose> + AND isd.id IS NULL + </select>--> + <!-- �셿猷뚮맂 �씠�뒋 媛쒖닔 --> <select id="countCompleteIssue" resultType="java.lang.Long" parameterType="kr.wisestone.owl.web.condition.WidgetCondition"> @@ -102,12 +302,41 @@ inner join issue_status iss on iss.id = i.issue_status_id where iss.issue_status_type = 'CLOSE' <choose> - <when test="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </when> + </choose> + </select> + + <select id="countCompleteIssueByDepartment" 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 + INNER JOIN issue_department isd ON isd.issue_id = i.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"> + AND i.project_id IN + <foreach collection="meAndDownProjectIds" 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> </select> @@ -124,9 +353,9 @@ where iss.issue_status_type = 'CLOSE' and i.modify_date between #{searchStartDate} and #{searchEndDate} <choose> - <when test="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </when> @@ -141,9 +370,9 @@ inner join issue_status iss on iss.id = i.issue_status_id where 1=1 <choose> - <when test="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </when> @@ -155,8 +384,8 @@ <!-- 3踰� �쐞�젽 �떆�옉 --> - <!-- 吏꾪뻾以묒씤 �봽濡쒖젥�듃 �쁽�솴 --> - <select id="findProjectProgress" resultType="java.util.HashMap" + <!-- 吏꾪뻾以묒씤 �봽濡쒖젥�듃 �쁽�솴 (�떞�떦�옄 踰꾩쟾) --> + <!--<select id="findProjectProgress" resultType="java.util.HashMap" parameterType="kr.wisestone.owl.web.condition.WidgetCondition"> select p.id as id, @@ -191,10 +420,48 @@ </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" + <!-- 吏꾪뻾以묒씤 �봽濡쒖젥�듃 �쁽�솴(�쟾泥�) (�떞�떦�옄 踰꾩쟾) --> + <!--<select id="findProjectProgressAll" resultType="java.util.HashMap" parameterType="kr.wisestone.owl.web.condition.WidgetCondition"> select p.id as id, @@ -221,6 +488,36 @@ 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踰� �쐞�젽 �걹 --> @@ -228,8 +525,8 @@ <!-- 4踰� �쐞�젽 �떆�옉 --> - <!-- �궡媛� �삤�뒛 �븷�떦諛쏆� �씠�뒋 媛쒖닔 --> - <select id="countTodayMyAssigneeIssue" resultType="java.lang.Long" + <!--�궡媛� �삤�뒛 �븷�떦諛쏆� �씠�뒋 媛쒖닔 - �떞�떦�옄 踰꾩쟾--> + <!--<select id="countTodayMyAssigneeIssue" resultType="java.lang.Long" parameterType="kr.wisestone.owl.web.condition.WidgetCondition"> select count(i.id) as todayCount from issue i where @@ -243,10 +540,41 @@ </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 isd + INNER JOIN user_department ud ON ud.department_id = isd.department_id + where isd.issue_id = i.id + <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> + and isd.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" + <!-- �궡媛� �떞�떦�븯�뒗 �씠�뒋 媛쒖닔 - �떞�떦�옄 --> + <!--<select id="countMyAssigneeIssue" resultType="java.lang.Long" parameterType="kr.wisestone.owl.web.condition.WidgetCondition"> select count(distinct i.id) @@ -264,10 +592,41 @@ </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 isd on isd.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 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' </select> <!-- �궡媛� �떞�떦�븯�뒗 �씠�뒋 --> - <select id="findMyAssigneeIssue" resultType="java.util.HashMap" + <!--<select id="findMyAssigneeIssue" resultType="java.util.HashMap" parameterType="kr.wisestone.owl.web.condition.WidgetCondition"> select distinct i.id as id, @@ -292,6 +651,82 @@ </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_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> + 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 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"> + AND p.id IN + <foreach collection="meAndDownProjectIds" 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> and iss.issue_status_type != 'CLOSE' GROUP by i.id <if test="page != null and !page.equals('')"> @@ -334,9 +769,9 @@ inner join issue_status iss on iss.id = i.issue_status_id where iss.issue_status_type != 'CLOSE' <choose> - <when test="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </when> @@ -379,16 +814,17 @@ (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.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="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND p.id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </when> @@ -409,9 +845,9 @@ inner join issue_status iss on iss.id = i.issue_status_id where iss.issue_status_type != 'CLOSE' <choose> - <when test="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </when> @@ -433,6 +869,7 @@ , 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 @@ -446,9 +883,9 @@ WHERE 1=1 AND i.register_id = #{loginUserId} <choose> - <when test="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </when> @@ -477,9 +914,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="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </when> @@ -502,6 +939,7 @@ , 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 @@ -514,9 +952,9 @@ </if> WHERE 1=1 <choose> - <when test="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </when> @@ -540,9 +978,9 @@ </if> WHERE 1=1 <choose> - <when test="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </when> @@ -577,12 +1015,52 @@ inner join issue_status iss on iss.id = i.issue_status_id where 1=1 <choose> - <when test="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" 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 + 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="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 != 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> @@ -592,7 +1070,7 @@ <!-- 11踰� �쐞�젽 �떆�옉 --> <!-- 硫ㅻ쾭蹂� 吏꾪뻾瑜� --> - <select id="findProjectMemberIssue" resultType="java.util.HashMap" + <!--<select id="findProjectMemberIssue" resultType="java.util.HashMap" parameterType="kr.wisestone.owl.web.condition.WidgetCondition"> select u.name, u.profile, u.account, @@ -614,7 +1092,89 @@ 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 isd on isd.issue_id = i.id + inner join issue_status iss on iss.id = i.issue_status_id + where isd.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 isd on isd.issue_id = i.id + inner join issue_status iss on iss.id = i.issue_status_id + where isd.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 isd on isd.issue_id = i.id + inner join issue_status iss on iss.id = i.issue_status_id + where isd.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> + + <select id="findProjectMemberIssueByDepartment" 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 isd on isd.issue_id = i.id + inner join issue_status iss on iss.id = i.issue_status_id + where isd.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 isd on isd.issue_id = i.id + inner join issue_status iss on iss.id = i.issue_status_id + where isd.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 isd on isd.issue_id = i.id + inner join issue_status iss on iss.id = i.issue_status_id + where isd.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 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"> + p.id IN + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> + #{item} + </foreach> + </when> + </choose> + <choose> + <when test="myDepartmentIds.size != 0"> + AND prd.department_id IN + <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")"> + #{item} + </foreach> + </when> + <otherwise> + AND 1 != 1 + </otherwise> + </choose> + and p.status = '02'; + </select> + <!-- 11踰� �쐞�젽 �걹 --> @@ -629,9 +1189,9 @@ 'CLOSE') AND i.register_id = #{loginUserId} <choose> - <when test="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </when> @@ -647,9 +1207,9 @@ 'CLOSE') AND i.register_id = #{loginUserId} <choose> - <when test="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </when> @@ -658,7 +1218,7 @@ </select> <!-- �떞�떦�븳 �씠�뒋 以� �셿猷� 媛��닔 --> - <select id="findMyAssigneeCompleteIssue" resultType="java.util.HashMap" + <!--<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 @@ -673,10 +1233,39 @@ </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 isd on isd.issue_id = i.id + inner join issue_status iss on iss.id = i.issue_status_id + <choose> + <when test="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' + <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" + <!--<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 @@ -691,6 +1280,35 @@ </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 isd on isd.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"> + AND isd.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踰� �쐞�젽 �걹 --> @@ -699,9 +1317,30 @@ <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 issue.project_id = #{projectId} + 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> @@ -723,12 +1362,49 @@ WHERE w.id = #{workspaceId} AND iss.issue_status_type != 'CLOSE' <choose> - <when test="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </when> + </choose> + </select> + + <select id="countSeverityIssueByDepartment" 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 + 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"> + 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 isd.department_id IN + <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")"> + #{item} + </foreach> + </when> + <otherwise> + AND 1 != 1 + </otherwise> </choose> </select> @@ -737,11 +1413,13 @@ 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 @@ -753,12 +1431,59 @@ AND s.id = #{severityId} AND iss.issue_status_type != 'CLOSE' <choose> - <when test="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <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="findSeverityIssuesByDepartment" 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 + 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"> + 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 isd.department_id IN + <foreach collection="myDepartmentIds" item="item" index="index" separator="," open="(" close=")"> + #{item} + </foreach> + </when> + <otherwise> + AND 1 != 1 + </otherwise> </choose> <if test="page != null and !page.equals('')"> limit #{pageSize} offset #{page}; @@ -778,15 +1503,48 @@ AND s.id = #{severityId} AND iss.issue_status_type != 'CLOSE' <choose> - <when test="projectIds.size != 0"> + <when test="meAndDownProjectIds != null and meAndDownProjectIds.size != 0"> AND i.project_id IN - <foreach collection="projectIds" item="item" index="index" separator="," open="(" close=")"> + <foreach collection="meAndDownProjectIds" item="item" index="index" separator="," open="(" close=")"> #{item} </foreach> </when> </choose> </select> + <select id="countSearchIssueByDepartment" 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 + INNER JOIN issue_department isd on isd.issue_id = i.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> + <choose> + <when test="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> + </select> + <!-- 13踰� �쐞�젽 �걹 --> </mapper> -- Gitblit v1.8.0