You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
554 lines
17 KiB
554 lines
17 KiB
<?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.ccsens.tall.persist.dao.SysProjectDao">
|
|
<resultMap id="resultMap_ProjectInfo" type="com.ccsens.tall.bean.po.SysProject">
|
|
<id column="pId" property="id" />
|
|
<result column="pCreatorId" property="creatorId" />
|
|
<result column="pName" property="name" />
|
|
<result column="pDescription" property="description" />
|
|
<result column="pAddress" property="address" />
|
|
<result column="pBeginTime" property="beginTime" />
|
|
<result column="pEndTime" property="endTime" />
|
|
</resultMap>
|
|
|
|
<resultMap id="resultMap_ProjectInfo01" type="com.ccsens.tall.bean.vo.ProjectVo$ProjectInfo">
|
|
<id column="pId" property="id" />
|
|
<result column="pName" property="name" />
|
|
<result column="pAddress" property="address" />
|
|
<result column="pBeginTime" property="beginTime" />
|
|
<result column="pEndTime" property="endTime" />
|
|
<result column="pCreator" property="creator" />
|
|
<collection property="labelList" ofType="com.ccsens.tall.bean.vo.LabelVo$SelectLabel">
|
|
<id column="lId" property="id"/>
|
|
<result column="lName" property="name"/>
|
|
<result column="lCode" property="code"/>
|
|
<result column="lColor" property="color"/>
|
|
<result column="lLevel" property="level"/>
|
|
<result column="lDescription" property="description"/>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<resultMap id="resultMap_Relevance_Project" type="com.ccsens.tall.bean.vo.ProjectVo$RelevanceProject">
|
|
<id column="pId" property="id" />
|
|
<result column="pName" property="name" />
|
|
<result column="pAddress" property="address" />
|
|
<result column="pBeginTime" property="beginTime" />
|
|
<result column="pEndTime" property="endTime" />
|
|
<collection property="labelList" ofType="com.ccsens.tall.bean.vo.LabelVo$SelectLabel">
|
|
<id column="lId" property="id"/>
|
|
<result column="lName" property="name"/>
|
|
<result column="lCode" property="code"/>
|
|
<result column="lColor" property="color"/>
|
|
<result column="lLevel" property="level"/>
|
|
<result column="lDescription" property="description"/>
|
|
</collection>
|
|
</resultMap>
|
|
|
|
<resultMap id="resultMap_template" type="com.ccsens.tall.bean.vo.ProjectVo$TemplateStatus">
|
|
<id column="pId" property="id" />
|
|
<result column="pName" property="name" />
|
|
<result column="pTemplateStatus" property="templateStatus" />
|
|
</resultMap>
|
|
|
|
<resultMap id="resultMap_project_key" type="com.ccsens.tall.bean.vo.ProjectVo$ProjectByKey">
|
|
<id column="pId" property="id" />
|
|
<result column="pName" property="name" />
|
|
</resultMap>
|
|
|
|
<!-- <resultMap id="ChartVo_CompleteTaskNum" type="com.ccsens.tall.bean.vo.ChartVo$CompleteTaskNum">-->
|
|
<!-- <id column="roleId" property="roleId" />-->
|
|
<!-- <result column="roleName" property="roleName" />-->
|
|
<!-- <result column="total" property="total" />-->
|
|
<!-- <collection property="taskDetailId" ofType="java.lang.Long">-->
|
|
<!-- <id column="dId" property="taskDetailId"/>-->
|
|
<!-- </collection>-->
|
|
<!-- </resultMap>-->
|
|
|
|
<select id="findProjectIdByUserId" parameterType="java.util.Map"
|
|
resultMap="resultMap_ProjectInfo">
|
|
SELECT
|
|
p.id as pId,
|
|
p.creator_id as pCreatorId,
|
|
p.name as pName,
|
|
p.description as pDescription,
|
|
p.address as pAddress,
|
|
p.begin_time as pBeginTime,
|
|
p.end_time as pEndTime
|
|
FROM
|
|
t_sys_user_attention a JOIN t_sys_project p ON a.project_id = p.id
|
|
WHERE
|
|
a.user_id = #{userId}
|
|
AND
|
|
p.rec_status = 0
|
|
AND
|
|
p.template = 0
|
|
<if test="startTime != null">
|
|
<if test="endTime != null">
|
|
and
|
|
(
|
|
(p.begin_time <= #{startTime} and p.end_time >= #{endTime})
|
|
OR
|
|
(p.begin_time >= #{startTime} and p.begin_time <= #{endTime})
|
|
OR
|
|
(p.end_time >= #{startTime} and p.end_time <= #{endTime})
|
|
)
|
|
</if>
|
|
</if>
|
|
ORDER by p.begin_time
|
|
</select>
|
|
|
|
<select id="selectByTemplateStatus" parameterType="java.util.Map" resultMap="resultMap_template">
|
|
select
|
|
id as pId,
|
|
name as pName,
|
|
template as pTemplateStatus
|
|
from
|
|
t_sys_project
|
|
where
|
|
template=#{templateStatus}
|
|
AND
|
|
rec_status = 0
|
|
</select>
|
|
|
|
<select id="getProjectByKey" parameterType="java.util.Map" resultMap="resultMap_project_key">
|
|
select
|
|
s.id as pId,
|
|
s.name as pName
|
|
from
|
|
t_sys_project s JOIN t_sys_user_attention a on s.id = a.project_id
|
|
where
|
|
a.user_id=#{userId}
|
|
AND
|
|
s.name like concat('%',#{key},'%')
|
|
AND
|
|
s.rec_status = 0
|
|
</select>
|
|
|
|
<select id="findProjectIdByUserId01" parameterType="java.util.Map" resultMap="resultMap_ProjectInfo01">
|
|
SELECT
|
|
p.id AS pId,
|
|
p.NAME AS pName,
|
|
p.address AS pAddress,
|
|
p.begin_time AS pBeginTime,
|
|
p.end_time AS pEndTime,
|
|
if(p.creator_id = #{userId},true,false) as pCreator,
|
|
l.id as lId,
|
|
l.name as lName,
|
|
l.code as lCode,
|
|
l.color as lColor,
|
|
l.level as lLevle,
|
|
l.description as lDescription
|
|
FROM
|
|
t_sys_project p
|
|
LEFT JOIN t_sys_user_attention a ON a.project_id = p.id
|
|
left join t_sys_project_label pl on pl.project_id = p.id
|
|
left join t_sys_label l on pl.label_id = l.id and
|
|
l.user_id = #{userId}
|
|
WHERE
|
|
a.user_id = #{userId}
|
|
AND
|
|
p.rec_status = 0
|
|
and
|
|
a.rec_status = 0
|
|
and
|
|
(l.rec_status = 0 or l.rec_status is null)
|
|
and
|
|
(pl.rec_status = 0 or pl.rec_status is null)
|
|
AND
|
|
p.template = 0
|
|
<if test="startTime != null">
|
|
<if test="endTime != null">
|
|
and
|
|
(
|
|
(p.begin_time <= #{startTime} and p.end_time >= #{endTime})
|
|
OR
|
|
(p.begin_time >= #{startTime} and p.begin_time <= #{endTime})
|
|
OR
|
|
(p.end_time >= #{startTime} and p.end_time <= #{endTime})
|
|
)
|
|
</if>
|
|
</if>
|
|
ORDER BY
|
|
<if test="orderType == 0">
|
|
p.created_at
|
|
</if>
|
|
<if test="orderType == 1">
|
|
p.name
|
|
</if>
|
|
<if test="orderType == 2">
|
|
l.name
|
|
</if>
|
|
<if test="order == 0">
|
|
DESC
|
|
</if>
|
|
</select>
|
|
|
|
<select id="selectByLabelName" parameterType="java.util.Map" resultMap="resultMap_ProjectInfo01">
|
|
SELECT
|
|
p.id AS pId,
|
|
p.NAME AS pName,
|
|
p.address AS pAddress,
|
|
p.begin_time AS pBeginTime,
|
|
p.end_time AS pEndTime,
|
|
if(p.creator_id = #{userId},true,false) as pCreator,
|
|
l.id as lId,
|
|
l.name as lName,
|
|
l.code as lCode,
|
|
l.color as lColor,
|
|
l.level as lLevle,
|
|
l.description as lDescription
|
|
FROM
|
|
t_sys_user_attention a
|
|
left JOIN t_sys_project p ON a.project_id = p.id
|
|
left join t_sys_project_label pl on pl.project_id = p.id
|
|
left join t_sys_label l on pl.label_id = l.id and
|
|
l.user_id = #{userId}
|
|
WHERE
|
|
a.user_id = #{userId}
|
|
AND
|
|
p.rec_status = 0
|
|
and
|
|
(l.rec_status = 0 or l.rec_status is null)
|
|
and
|
|
(pl.rec_status = 0 or pl.rec_status is null)
|
|
AND
|
|
p.template = 0
|
|
and
|
|
l.name = #{labelName}
|
|
ORDER BY l.name
|
|
</select>
|
|
|
|
|
|
<select id="selectRelevanceProject" parameterType="java.util.Map" resultMap="resultMap_Relevance_Project">
|
|
SELECT
|
|
p.id AS pId,
|
|
p.NAME AS pName,
|
|
p.address AS pAddress,
|
|
p.begin_time AS pBeginTime,
|
|
p.end_time AS pEndTime,
|
|
l.id as lId,
|
|
l.name as lName,
|
|
l.code as lCode,
|
|
l.color as lColor,
|
|
l.level as lLevle,
|
|
l.description as lDescription
|
|
FROM
|
|
(
|
|
SELECT
|
|
r.relevance_project_id as rProjectId
|
|
FROM
|
|
t_sys_relevance_project r left JOIN t_sys_project sp ON r.project_id = sp.id
|
|
WHERE
|
|
r.project_id = #{projectId}
|
|
) t
|
|
LEFT JOIN t_sys_project p on p.id = t.rProjectId left join t_sys_project_label pl on pl.project_id = p.id
|
|
left join t_sys_label l on pl.label_id = l.id
|
|
WHERE
|
|
p.rec_status = 0
|
|
and
|
|
(l.rec_status = 0 or l.rec_status is null)
|
|
and
|
|
(pl.rec_status = 0 or pl.rec_status is null)
|
|
AND
|
|
p.template = 0
|
|
|
|
</select>
|
|
|
|
<select id="getExecutorChart" parameterType="java.util.Map" resultType="com.ccsens.tall.bean.vo.ChartVo$__ExecutorChart">
|
|
SELECT
|
|
r.id as roleId,
|
|
r.`name` as roleName,
|
|
if(#{type}=0,count(a.finish),SUM(a.dEndTime - a.dBeginTime)/60000) as `value`
|
|
FROM
|
|
`t_pro_role` r LEFT JOIN `t_pro_task_detail` d on r.id = d.executor_role
|
|
LEFT JOIN(
|
|
SELECT
|
|
td.id as dId,
|
|
td.begin_time as dBeginTime,
|
|
td.end_time as dEndTime,
|
|
if(sum(t.isFinish) = 0,2,1) as finish
|
|
FROM
|
|
t_pro_task_detail td LEFT JOIN
|
|
(
|
|
SELECT
|
|
s.id as sId,
|
|
s.task_detail_id as sTaskId,
|
|
m.real_finish_time,
|
|
m.complated_status,
|
|
if(count(m.id)=0,true,FALSE) as isFinish
|
|
FROM
|
|
t_pro_task_sub_time s LEFT JOIN t_pro_sub_time_member m on s.id = m.task_sub_time_id
|
|
WHERE
|
|
(
|
|
(
|
|
m.real_finish_time > s.begin_time
|
|
and
|
|
m.real_finish_time <= s.end_time
|
|
and
|
|
m.complated_status = 2
|
|
)
|
|
or
|
|
(m.real_finish_time is null))
|
|
GROUP BY s.id
|
|
) t on td.id = t.sTaskId
|
|
WHERE
|
|
td.`level` in (1,2,3)
|
|
GROUP BY td.Id
|
|
) a on a.dId = d.id
|
|
<if test="beginTime != null and beginTime != 0">
|
|
<if test="endTime != null and endTime != 0">
|
|
AND a.dEndTime > #{beginTime}
|
|
AND a.dBeginTime <= #{endTime}
|
|
</if>
|
|
</if>
|
|
WHERE
|
|
r.project_id = #{projectId}
|
|
and
|
|
(SELECT name FROM t_pro_role pr WHERE r.parent_id = pr.id) in ('PM','Member')
|
|
AND
|
|
r.name not IN ('观众','MVP')
|
|
<if test="roleIdList != null and roleIdList.size() > 0">
|
|
and
|
|
r.id in
|
|
<foreach collection="roleIdList" item="roleId" open="(" close=")" separator=",">
|
|
#{roleId}
|
|
</foreach>
|
|
</if>
|
|
|
|
AND
|
|
d.`level` in (1,2,3)
|
|
GROUP BY r.`name`
|
|
</select>
|
|
|
|
<select id="getCompleteTaskByTime" parameterType="java.util.Map" resultType="com.ccsens.tall.bean.vo.ChartVo$CompleteTaskNum">
|
|
SELECT
|
|
r.id as roleId,
|
|
r.`name` as roleName,
|
|
d.`name` as dId,
|
|
count(a.dId) as total,
|
|
sum(a.finish=1) as `value`
|
|
FROM
|
|
`t_pro_role` r LEFT JOIN `t_pro_task_detail` d on r.id = d.executor_role
|
|
LEFT JOIN(
|
|
SELECT
|
|
td.id as dId,
|
|
td.begin_time as dBeginTime,
|
|
td.end_time as dEndTime,
|
|
if(sum(t.isFinish) = 0,true,false) as finish
|
|
FROM
|
|
t_pro_task_detail td LEFT JOIN
|
|
(
|
|
SELECT
|
|
s.id as sId,
|
|
s.task_detail_id as sTaskId,
|
|
m.real_finish_time,
|
|
m.complated_status,
|
|
if(count(m.id)=0,true,FALSE) as isFinish
|
|
FROM
|
|
t_pro_task_sub_time s LEFT JOIN t_pro_sub_time_member m on s.id = m.task_sub_time_id
|
|
WHERE
|
|
(
|
|
(
|
|
m.real_finish_time > s.begin_time
|
|
and
|
|
m.real_finish_time <= s.end_time
|
|
and
|
|
m.complated_status = 2
|
|
)
|
|
or
|
|
(m.real_finish_time is null))
|
|
GROUP BY s.id
|
|
) t on td.id = t.sTaskId
|
|
WHERE
|
|
td.`level` in (2,3)
|
|
GROUP BY td.Id
|
|
) a on a.dId = d.id
|
|
<if test="beginTime != null and beginTime != 0">
|
|
<if test="endTime != null and endTime != 0">
|
|
AND a.dEndTime > #{beginTime}
|
|
AND a.dBeginTime <= #{endTime}
|
|
</if>
|
|
</if>
|
|
WHERE
|
|
r.project_id = #{projectId}
|
|
and
|
|
d.`level` in (2,3)
|
|
and
|
|
(SELECT name FROM t_pro_role pr WHERE r.parent_id = pr.id) in ('PM','Member')
|
|
<if test="roleIdList != null and roleIdList.size() > 0">
|
|
and
|
|
r.id in
|
|
<foreach collection="roleIdList" item="roleId" open="(" close=")" separator=",">
|
|
#{roleId}
|
|
</foreach>
|
|
</if>
|
|
AND
|
|
r.name not IN ('观众','MVP')
|
|
GROUP BY r.`id`
|
|
</select>
|
|
|
|
<select id="getProjectTrend" parameterType="java.util.Map" resultType="com.ccsens.tall.bean.vo.ChartVo$ProjectTrendVo">
|
|
SELECT
|
|
FROM_UNIXTIME(s.begin_time/1000,'%Y-%m-%d') as date,
|
|
count(s.id) as total,
|
|
sum(t.isFinish) as completed
|
|
FROM
|
|
t_pro_task_detail d LEFT JOIN t_pro_task_sub_time s on d.id = s.task_detail_id
|
|
LEFT JOIN
|
|
(
|
|
SELECT
|
|
st.id as sId,
|
|
st.task_detail_id,
|
|
m.real_finish_time,
|
|
m.complated_status,
|
|
m.id as mId,
|
|
if(count(m.id)=0,FALSE,true) as isFinish
|
|
FROM
|
|
t_pro_task_sub_time st LEFT JOIN t_pro_sub_time_member m on st.id = m.task_sub_time_id
|
|
WHERE
|
|
m.complated_status = 2
|
|
or
|
|
m.complated_status is null
|
|
GROUP BY st.id
|
|
) t on s.id = t.sId
|
|
WHERE
|
|
s.begin_time < #{end}
|
|
AND
|
|
s.end_time > #{start}
|
|
<if test="roleId != null">
|
|
and
|
|
d.executor_role in (#{roleId},#{allMemberId})
|
|
</if>
|
|
and
|
|
d.project_id = #{projectId}
|
|
group by FROM_UNIXTIME(s.begin_time/1000,'%Y-%m-%d')
|
|
</select>
|
|
|
|
<select id="getOverview" parameterType="java.util.Map" resultType="com.ccsens.tall.bean.vo.ChartVo$ProjectOverview">
|
|
SELECT
|
|
count(td.id) as total,
|
|
sum(t.isFinish) as completed,
|
|
sum(t.completedOnTime) as completedOnTime
|
|
FROM
|
|
t_pro_task_detail td LEFT JOIN
|
|
(
|
|
SELECT
|
|
st.id as sId,
|
|
st.task_detail_id as sTaskId,
|
|
if(count(m.id)=0,FALSE,true) as isFinish,
|
|
if(count(m.id)>0
|
|
and m.real_finish_time > st.begin_time
|
|
and m.real_finish_time <= st.end_time,true,false) as completedOnTime
|
|
FROM
|
|
t_pro_task_sub_time st LEFT JOIN t_pro_sub_time_member m on st.id = m.task_sub_time_id
|
|
WHERE
|
|
(m.complated_status = 2
|
|
or
|
|
m.complated_status is null)
|
|
GROUP BY st.task_detail_id
|
|
) t on t.sTaskId = td.id
|
|
WHERE
|
|
td.project_id = #{projectId}
|
|
and
|
|
td.`level` in (1,2,3)
|
|
<if test="beginTime != null and beginTime != 0">
|
|
<if test="endTime != null and endTime != 0">
|
|
AND td.end_time > #{beginTime}
|
|
AND td.begin_time <= #{endTime}
|
|
</if>
|
|
</if>
|
|
<if test="roleIdList != null and roleIdList.size() > 0">
|
|
and
|
|
td.executor_role in
|
|
<foreach collection="roleIdList" item="roleId" open="(" close=")" separator=",">
|
|
#{roleId}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
|
|
<select id="getOverviewByToDay" parameterType="java.util.Map" resultType="com.ccsens.tall.bean.vo.ChartVo$ProjectOverview">
|
|
SELECT
|
|
count(td.id) as today,
|
|
sum(t.isFinish) as todayCompleted
|
|
FROM
|
|
t_pro_task_detail td LEFT JOIN
|
|
(
|
|
SELECT
|
|
st.id as sId,
|
|
st.task_detail_id as sTaskId,
|
|
if(count(m.id)=0,FALSE,true) as isFinish,
|
|
if(count(m.id)>0
|
|
and m.real_finish_time > st.begin_time
|
|
and m.real_finish_time <= st.end_time,true,false) as completedOnTime
|
|
FROM
|
|
t_pro_task_sub_time st LEFT JOIN t_pro_sub_time_member m on st.id = m.task_sub_time_id
|
|
WHERE
|
|
(m.complated_status = 2
|
|
or
|
|
m.complated_status is null)
|
|
GROUP BY st.task_detail_id
|
|
) t on t.sTaskId = td.id
|
|
WHERE
|
|
td.project_id = #{projectId}
|
|
and
|
|
td.`level` in (2,3)
|
|
and
|
|
td.begin_time < #{endTime}
|
|
and
|
|
td.end_time > #{startTime}
|
|
<if test="roleIdList != null and roleIdList.size() > 0">
|
|
and
|
|
td.executor_role in
|
|
<foreach collection="roleIdList" item="roleId" open="(" close=")" separator=",">
|
|
#{roleId}
|
|
</foreach>
|
|
</if>
|
|
</select>
|
|
|
|
|
|
<select id="getBurnoutFigure" parameterType="java.util.Map" resultType="com.ccsens.tall.bean.vo.ChartVo$BurnoutFigure">
|
|
SELECT
|
|
<if test="type == null">
|
|
FROM_UNIXTIME(s.begin_time/1000,'%Y-%m-%d') as `date`,
|
|
</if>
|
|
count(s.id) as totalDay,
|
|
t.completed as completed
|
|
FROM
|
|
t_pro_task_detail d LEFT JOIN t_pro_task_sub_time s on d.id = s.task_detail_id
|
|
LEFT JOIN
|
|
(
|
|
SELECT
|
|
count(s.id) as completed,
|
|
FROM_UNIXTIME(m.real_finish_time/1000,'%Y-%m-%d') as `finishTime`
|
|
FROM
|
|
t_pro_task_detail d LEFT JOIN t_pro_task_sub_time s on d.id = s.task_detail_id
|
|
LEFT JOIN t_pro_sub_time_member m on s.id = m.task_sub_time_id
|
|
WHERE
|
|
m.complated_status = 2
|
|
AND
|
|
s.begin_time < #{end}
|
|
AND
|
|
s.end_time > #{start}
|
|
<if test="roleId != null">
|
|
and
|
|
d.executor_role = #{roleId}
|
|
</if>
|
|
and
|
|
d.project_id = #{projectId}
|
|
group by FROM_UNIXTIME(m.real_finish_time/1000,'%Y-%m-%d')
|
|
) t on t.finishTime = FROM_UNIXTIME(s.begin_time/1000,'%Y-%m-%d')
|
|
WHERE
|
|
s.begin_time < #{end}
|
|
AND
|
|
s.end_time > #{start}
|
|
<if test="roleId != null">
|
|
and
|
|
d.executor_role = #{roleId}
|
|
</if>
|
|
and
|
|
d.project_id = #{projectId}
|
|
<if test="type == null">
|
|
group by FROM_UNIXTIME(s.begin_time/1000,'%Y-%m-%d')
|
|
</if>
|
|
</select>
|
|
</mapper>
|