Files
zentao/src/main/resources/mapper/ZtProjectMapper.xml

444 lines
15 KiB
XML

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sa.zentao.mapper.ZtProjectMapper">
<resultMap id="BaseResultMap" type="com.sa.zentao.entity.ZtProject">
<result column="id" property="id"/>
<result column="project" property="project"/>
<result column="charter" property="charter"/>
<result column="model" property="model"/>
<result column="type" property="type"/>
<result column="category" property="category"/>
<result column="lifetime" property="lifetime"/>
<result column="budget" property="budget"/>
<result column="budgetUnit" property="budgetUnit"/>
<result column="attribute" property="attribute"/>
<result column="percent" property="percent"/>
<result column="milestone" property="milestone"/>
<result column="output" property="output"/>
<result column="auth" property="auth"/>
<result column="parent" property="parent"/>
<result column="path" property="path"/>
<result column="grade" property="grade"/>
<result column="name" property="name"/>
<result column="code" property="code"/>
<result column="hasProduct" property="hasProduct"/>
<result column="begin" property="begin"/>
<result column="end" property="end"/>
<result column="firstEnd" property="firstEnd"/>
<result column="realBegan" property="realBegan"/>
<result column="realEnd" property="realEnd"/>
<result column="days" property="days"/>
<result column="status" property="status"/>
<result column="subStatus" property="subStatus"/>
<result column="pri" property="pri"/>
<result column="desc" property="desc"/>
<result column="version" property="version"/>
<result column="parentVersion" property="parentVersion"/>
<result column="planDuration" property="planDuration"/>
<result column="realDuration" property="realDuration"/>
<result column="progress" property="progress"/>
<result column="estimate" property="estimate"/>
<result column="left" property="left"/>
<result column="consumed" property="consumed"/>
<result column="teamCount" property="teamCount"/>
<result column="market" property="market"/>
<result column="openedBy" property="openedBy"/>
<result column="openedDate" property="openedDate"/>
<result column="openedVersion" property="openedVersion"/>
<result column="lastEditedBy" property="lastEditedBy"/>
<result column="lastEditedDate" property="lastEditedDate"/>
<result column="closedBy" property="closedBy"/>
<result column="closedDate" property="closedDate"/>
<result column="closedReason" property="closedReason"/>
<result column="canceledBy" property="canceledBy"/>
<result column="canceledDate" property="canceledDate"/>
<result column="suspendedDate" property="suspendedDate"/>
<result column="PO" property="po"/>
<result column="PM" property="pm"/>
<result column="QD" property="qd"/>
<result column="RD" property="rd"/>
<result column="team" property="team"/>
<result column="acl" property="acl"/>
<result column="whitelist" property="whitelist"/>
<result column="order" property="order"/>
<result column="vision" property="vision"/>
<result column="division" property="division"/>
<result column="displayCards" property="displayCards"/>
<result column="fluidBoard" property="fluidBoard"/>
<result column="multiple" property="multiple"/>
<result column="colWidth" property="colWidth"/>
<result column="minColWidth" property="minColWidth"/>
<result column="maxColWidth" property="maxColWidth"/>
<result column="deleted" property="deleted"/>
</resultMap>
<select id="pageProject" resultType="com.sa.zentao.dao.ZtProjectDTO">
select * from zt_project s
where 1= 1
and deleted = '0'
and type = 'project'
<if test="qo.projectIds != null and qo.projectIds.size() > 0">
and s.id in
<foreach collection="qo.projectIds" item="id" index="index"
open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="qo.searchVal != null and qo.searchVal != '' ">
<if test="qo.searchVal == 'ALL' ">
</if>
<if test="qo.searchVal == 'WGB' ">
and s.status != 'closed'
</if>
<if test="qo.searchVal == 'WKS' ">
and s.status= 'wait'
</if>
<if test="qo.searchVal == 'JXZ' ">
and s.status= 'doing'
</if>
<if test="qo.searchVal == 'YGQ' ">
-- 已挂起
and s.status= 'suspended'
</if>
<if test="qo.searchVal == 'YGB' ">
and s.status= 'closed'
</if>
</if>
order by id desc
</select>
<select id="groupPageList" resultType="com.sa.zentao.dao.ZtProjectDTO">
select * from zt_project s
where 1= 1
and deleted = '0'
and type ='program'
<if test="qo.productIds != null and qo.productIds.size() > 0">
and s.id in
<foreach collection="qo.productIds" item="id" index="index"
open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="qo.searchVal != null and qo.searchVal != '' ">
<if test="qo.searchVal == 'ALL' ">
</if>
<if test="qo.searchVal == 'WGB' ">
and s.status != 'closed'
</if>
<if test="qo.searchVal == 'WKS' ">
and s.status= 'wait'
</if>
<if test="qo.searchVal == 'JXZ' ">
and s.status= 'doing'
</if>
<if test="qo.searchVal == 'YGQ' ">
-- 已挂起
and s.status= 'suspended'
</if>
<if test="qo.searchVal == 'YGB' ">
and s.status= 'closed'
</if>
</if>
order by s.id desc
</select>
<select id="implementPageList" resultType="com.sa.zentao.dao.ZtProjectDTO">
select p.* from zt_project p
where 1= 1
and deleted = '0'
and type= 'sprint'
<if test="qo.searchVal != null and qo.searchVal != '' ">
<if test="qo.searchVal == 'ALL' ">
</if>
<if test="qo.searchVal == 'WGB' ">
and p.status != 'closed'
</if>
<if test="qo.searchVal == 'WKS' ">
and p.status= 'wait'
</if>
<if test="qo.searchVal == 'JXZ' ">
and p.status= 'doing'
</if>
<if test="qo.searchVal == 'YGQ' ">
-- 已挂起
and p.status= 'suspended'
</if>
<if test="qo.searchVal == 'YGB' ">
and p.status= 'closed'
</if>
</if>
<if test="qo.projectIds != null and qo.projectIds.size() > 0">
and p.id in
<foreach collection="qo.projectIds" item="id" index="index"
open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="qo.userName != null and qo.userName != '' ">
and ( p.acl = 'open'
or whitelist like concat('%', #{qo.userName}, '%')
)
</if>
order by p.id desc
</select>
<select id="getProjectByProduct" resultType="com.sa.zentao.entity.ZtProject">
SELECT * from zt_project pj,zt_projectproduct pd
WHERE pj.id = pd.project
and pj.type = 'project'
and pd.product = #{qo.productId}
</select>
<select id="executionListByProduct" resultType="com.sa.zentao.entity.ZtProject">
SELECT * from zt_project pj,zt_projectproduct pd
WHERE pj.id = pd.project
and pj.type = 'sprint'
and pd.product = #{qo.productId}
<if test="qo.project !=null ">
and pj.parent = #{qo.project}
</if>
</select>
<select id="selectPrdByName" resultType="com.sa.zentao.dao.ZtProjectDTO">
SELECT * from zt_project WHERE `name` = #{name} and type = 'sprint'
</select>
<select id="selectPrdById" resultType="com.sa.zentao.dao.ZtProjectDTO">
SELECT * from zt_project WHERE id = #{id} and type = 'sprint'
</select>
<select id="performanceCount" resultType="com.sa.zentao.dao.PerformanceDTO">
SELECT
`姓名` as userName,
account,
`天数` as days,
`可用工时` as totalTime,
`达标工时` as examineTime,
`产出工时` as workTime,
`分配总工时` as allocationTime,
`工作饱和率` as saturation,
`饱和率得分` as saturationScore,
`逾期任务` as delayTask,
`完成任务` as finishTask,
`完成准时率` as finishPunctuality,
`准时率得分` as punctualityScore,
`线上严重bug` as seriousBug,
`线上普通bug` as slightBug,
`线上bug得分` bugScore ,
if(account in ('chenlu', 'yanyanjie'), `线上bug得分` + `准时率得分` + 50, `饱和率得分`+ `线上bug得分` + `准时率得分` + 25 ) AS `score`
FROM
(
SELECT
`姓名`,
account,
`天数`,
`可用工时`,
`达标工时`,
`产出工时`,
`分配总工时`,
`工作饱和率`,
IF
(
`饱和率得分` > 40,
40,
IF
( `饱和率得分` <![CDATA[ < ]]> 0, 0, `饱和率得分` )) AS `饱和率得分`,
`逾期任务`,
`完成任务`,
`完成准时率`,
`准时率得分`,
`线上严重bug`,
`线上普通bug`,
IF
( `线上bug得分` <![CDATA[ < ]]> 0, 0, `线上bug得分` ) AS `线上bug得分`
FROM
(
SELECT
`姓名`,
account,
`天数`,
`可用工时`,
`达标工时`,
`产出工时`,
`分配总工时`,
`工作饱和率`,
IF
(
`工作饱和率` <![CDATA[ < ]]> 0.70,
0,
IF
( `工作饱和率` <![CDATA[ < ]]> 0.9 , 40 - ( 0.9 - `工作饱和率` ) * 100 * 1, 40 )) `饱和率得分`,
`逾期任务`,
`完成任务`,
`完成准时率`,
IF
(
`完成准时率` <![CDATA[ < ]]> 0.80,
0,
IF
( `完成准时率` <![CDATA[ < ]]> 1 , 25 - (1 - `完成准时率`) * 100 * 1, 25 )) `准时率得分`,
`线上严重bug`,
`线上普通bug`,
IF
( account in ('chenlu', 'yanyanjie'), if(`线上严重bug` = 0 AND `线上普通bug` = 0, 20, 20 - `线上严重bug` * 20 - `线上普通bug` * 5 ), if(`线上严重bug` = 0 AND `线上普通bug` = 0, 10, 10 - `线上严重bug` * 10 - `线上普通bug` * 3 )) `线上bug得分`
FROM
(
SELECT
*,
IFNULL( `_线上严重bug`, 0 ) `线上严重bug`,
IFNULL( `_线上普通bug`, 0 ) `线上普通bug`
FROM
(
SELECT
gs.nickname `姓名`,
gs.account,
SUM(
IF
( gs.`hour` <![CDATA[ > ]]> 0, 1, 0 )) `天数`,
SUM(
IF
( gs.`hour` <![CDATA[ > ]]> 0, 1, 0 ))* 1 `测试bug数量`,
SUM(
IF
( gs.`hour` <![CDATA[ > ]]> 0, 1, 0 ))* 0.3 `开发bug数量`,
SUM( gs.`hour` ) `可用工时`,
SUM( gs.`hour` ) * 0.75 `达标工时`,
ROUND( SUM( tc.estimate ), 2 ) `分配总工时`,
ROUND( SUM( tc.consumed ), 2 ) `产出工时`,
ROUND( SUM( tc.estimate )/ (SUM( gs.`hour` )*0.75), 2 ) `工作饱和率`,
SUM( tc.yuqi_count ) `逾期任务` ,
SUM( tc.finish_count ) `完成任务`,
(1 - ROUND( SUM( tc.yuqi_count )/ SUM( tc.finish_count ) , 2 )) `完成准时率`
FROM
(
SELECT
md.mydate,
u.nickname,
u.account,
if( a.apply_days IS NULL , 8 ,
if(a.apply_days <![CDATA[ < ]]> 480,
ROUND((8 * 60 - a.apply_days) / 60, 2),0)
)
`hour`
FROM
my_date md
LEFT JOIN zt_holiday h ON md.mydate BETWEEN h.`begin`
AND h.`end`
LEFT JOIN zt_user u ON 1 = 1
LEFT JOIN os_system.it_approval a ON a.NAME = u.nickname
AND md.mydate BETWEEN date( a.`apply_time_start` )
AND date( a.`apply_time_end` )
WHERE
( md.mydayofweek IN ( 2, 3, 4, 5, 6 ) OR h.type = 'working' )
AND ( h.id IS NULL OR h.type = 'working' )
-- AND ( u.dept IN ( 24 ) OR u.account = 'songzhiling' )
AND u.deleted = '0'
AND md.mydate <![CDATA[ >= ]]> date( #{startDate } )
AND md.mydate <![CDATA[ < ]]> date(#{endDate } )
ORDER BY
u.nickname,
md.mydate
) gs
LEFT JOIN (
SELECT
t.finishedBy,
SUM( t.estimate ) estimate,
SUM( t.consumed ) consumed,
date( t.finishedDate ) `date`,
count( t.id ) `finish_count`,
SUM(
IF
( DATEDIFF(t.finishedDate, t.deadline) > 3 , 1, 0 )) `yuqi_count`
FROM
zt_task t
WHERE
t.deleted = '0'
-- and t.openedBy in ('wangyuhang', 'liyuyan')
-- AND t.finishedBy = 'guoshangyu'
AND date( t.openedDate ) <![CDATA[ < ]]> date(#{endDate } )
AND date(t.finishedDate) BETWEEN date(#{startDate } )
AND date(#{endDate } )
GROUP BY
t.finishedBy,
date( t.finishedDate )
) tc ON tc.finishedBy = gs.account
AND tc.date = gs.mydate
WHERE
gs.nickname NOT IN ( '王宇航', '徐申靓', '刘圣清' )
GROUP BY
gs.nickname
) gsu
LEFT JOIN (
SELECT
account1,
sum( `_bug数量` ) AS `_bug数量`,
sum( `_线上严重bug` ) AS `_线上严重bug`,
sum( `_线上普通bug` ) AS `_线上普通bug`
FROM
(
SELECT
IFNULL(zb.resolvedBy,zb.assignedTo) `account1`,
count( zb.id ) `_bug数量`,
count(
IF
( zb.severity = 1, 1, NULL )) `_线上严重bug`,
count(
IF
( zb.severity = 2, 1, NULL )) `_线上普通bug`
FROM
zt_bug zb
WHERE
(
zb.severity IN ( 2, 1 ))
AND IFNULL( zb.deadline, zb.openedDate ) BETWEEN date(#{startDate } )
AND date(#{endDate } )
GROUP BY
IFNULL(zb.resolvedBy,zb.assignedTo)
) zbjs
GROUP BY
zbjs.account1
) zbu ON gsu.account = zbu.account1
GROUP BY
gsu.account
) gzu
GROUP BY
account
) gaaa
GROUP BY
account
) zzzzz where account in ('jiangheng', 'guoshangyu', 'jinliang','songzhiling', 'yumengcheng','zhoulinfang','zhouxueli','chenlu','yanyanjie','chenhaidong')
</select>
</mapper>