123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220 |
- <?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.management.platform.mapper.TaskMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="BaseResultMap" type="com.management.platform.entity.Task">
- <id column="id" property="id" />
- <result column="name" property="name" />
- <result column="task_desc" property="taskDesc" />
- <result column="creater_id" property="createrId" />
- <result column="creater_name" property="createrName" />
- <result column="creator_color" property="creatorColor" />
- <result column="executor_id" property="executorId" />
- <result column="executor_name" property="executorName" />
- <result column="executor_color" property="executorColor" />
- <result column="task_level" property="taskLevel" />
- <result column="task_status" property="taskStatus" />
- <result column="create_date" property="createDate" />
- <result column="end_date" property="endDate" />
- <result column="project_id" property="projectId" />
- <result column="stages_id" property="stagesId" />
- <result column="company_id" property="companyId" />
- <result column="indate" property="indate" />
- <result column="parent_tid" property="parentTid" />
- <result column="group_id" property="groupId" />
- <result column="seq" property="seq" />
- <result column="plan_hours" property="planHours" />
- <result column="task_type" property="taskType" />
- <result column="parent_tname" property="parentTname" />
- <result column="finish_date" property="finishDate" />
- <result column="start_date" property="startDate" />
- </resultMap>
- <resultMap id="timeResultMap" type="com.management.platform.entity.TimeTask" >
- <id column="id" property="id" />
- <result column="name" property="name" />
- <result column="task_desc" property="taskDesc" />
- <result column="creater_id" property="createrId" />
- <result column="creater_name" property="createrName" />
- <result column="creator_color" property="creatorColor" />
- <result column="executor_id" property="executorId" />
- <result column="executor_name" property="executorName" />
- <result column="executor_color" property="executorColor" />
- <result column="task_level" property="taskLevel" />
- <result column="task_status" property="taskStatus" />
- <result column="create_date" property="createDate" />
- <result column="end_date" property="endDate" />
- <result column="project_id" property="projectId" />
- <result column="stages_id" property="stagesId" />
- <result column="company_id" property="companyId" />
- <result column="indate" property="indate" />
- <result column="parent_tid" property="parentTid" />
- <result column="group_id" property="groupId" />
- <result column="seq" property="seq" />
- <result column="plan_hours" property="planHours" />
- <result column="task_type" property="taskType" />
- <result column="parent_tname" property="parentTname" />
- <result column="finish_date" property="finishDate" />
- <result column="start_date" property="startDate" />
- <result column="work_hours" property="workHours" />
- </resultMap>
- <resultMap id="RichResultMap" type="com.management.platform.entity.Task">
- <id column="id" property="id" />
- <result column="name" property="name" />
- <result column="task_desc" property="taskDesc" />
- <result column="creater_id" property="createrId" />
- <result column="creater_name" property="createrName" />
- <result column="creator_color" property="creatorColor" />
- <result column="executor_id" property="executorId" />
- <result column="executor_name" property="executorName" />
- <result column="executor_color" property="executorColor" />
- <result column="task_level" property="taskLevel" />
- <result column="task_status" property="taskStatus" />
- <result column="create_date" property="createDate" />
- <result column="end_date" property="endDate" />
- <result column="project_id" property="projectId" />
- <result column="stages_id" property="stagesId" />
- <result column="company_id" property="companyId" />
- <result column="indate" property="indate" />
- <result column="parent_tid" property="parentTid" />
- <result column="group_id" property="groupId" />
- <result column="seq" property="seq" />
- <result column="plan_hours" property="planHours" />
- <result column="task_type" property="taskType" />
- <result column="parent_tname" property="parentTname" />
- <result column="finish_date" property="finishDate" />
- <result column="project_name" property="projectName" />
- <result column="start_date" property="startDate" />
- <result column="stages_name" property="stagesName" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="Base_Column_List">
- id, name, task_desc, creater_id, creater_name, creator_color, executor_id, executor_name, executor_color, task_level, task_status, create_date, end_date, project_id, stages_id, company_id, indate, parent_tid, group_id, seq, plan_hours, task_type, parent_tname, finish_date, start_date
- </sql>
- <select id="simpleList" resultMap="BaseResultMap">
- select id, name, creater_id, creater_name, creator_color, executor_id, executor_name, executor_color, task_level, task_status, create_date, end_date, project_id, stages_id, company_id, indate, parent_tid, group_id, seq, plan_hours, task_type, parent_tname, finish_date, start_date
- from task
- ${ew.customSqlSegment}
- </select>
- <select id="nameList" resultMap="BaseResultMap">
- select id, name, task_level, stages_id, company_id, indate, group_id, seq,task_type
- from task
- ${ew.customSqlSegment}
- </select>
- <!--计算执行人任务分布-->
- <select id="getExecutorPanel" resultType="java.util.Map">
- SELECT IFNULL(b.executor_id,0) as executorId,IFNULL( b.executor_name,'待认领') as executorName, count(1) AS taskCount
- FROM task a left join task_executor b on b.task_id = a.id
- WHERE a.project_id = #{projectId}
- GROUP BY b.executor_id
- </select>
- <!--计算执行人任务计划工时-->
- <select id="getExecutorPlanHour" resultType="java.util.Map">
- SELECT IFNULL(b.executor_id,0) as executorId,IFNULL( b.executor_name,'待认领') as executorName, sum(a.plan_hours) AS taskHours
- FROM task a left join task_executor b on b.task_id = a.id
- WHERE a.project_id = #{projectId}
- GROUP BY b.executor_id
- </select>
- <!--计算任务列表的任务分布-->
- <select id="getStagesPanel" resultType="java.util.Map">
- SELECT a.stages_id AS stagesId, stages.`stages_name` AS name, COUNT(1) AS value
- FROM task a
- LEFT JOIN stages ON stages.id = a.`stages_id`
- WHERE a.project_id = #{projectId}
- GROUP BY a.stages_id
- ORDER BY stages.`sequence`
- </select>
- <!--计算耗时排名前十的任务-->
- <select id="getTopCostTask" resultType="java.util.Map">
- SELECT task.id , task.name AS name, IFNULL(SUM(report.`working_time`),0) AS value FROM task
- LEFT JOIN report ON report.`task_id` = task.id
- WHERE task.project_id = #{projectId} and report.state = 1
- GROUP BY task.id ORDER BY SUM(report.`working_time`) DESC LIMIT 10
- </select>
- <!-- 查询任务实际工时和计划工时对比,仅查询有实际工时的数据 -->
- <select id="getTaskTimeCompare" resultType="java.util.Map">
- SELECT task.id , task.name AS name, task.plan_hours as planHours, IFNULL(SUM(report.`working_time`),0) AS workHours FROM report
- LEFT JOIN task ON report.`task_id` = task.id AND report.state = 1
- WHERE task.project_id = #{projectId}
- GROUP BY task.id
- </select>
- <!--查询任务,带实际工时-->
- <select id="getTaskWithWorktime" resultMap="timeResultMap">
- SELECT task.* , IFNULL(SUM(report.`working_time`),0) AS work_hours FROM task
- LEFT JOIN report ON report.`task_id` = task.id and report.state = 1
- WHERE task.project_id = #{projectId}
- <if test="taskType != null" >
- and task.task_type = #{taskType}
- </if>
- GROUP BY task.id
- </select>
- <select id="getProjectTask" resultType="java.util.Map">
- SELECT task.id, task.`name`, DATE_FORMAT(task.`end_date`, '%Y-%m-%d') as end_date, task.`plan_hours`,
- (SELECT IFNULL(SUM(working_time),0) FROM report WHERE report.`task_id` = task.id AND report.`state` = 1) AS real_hours,
- task.`task_status`, task.`task_type`,
- project.`project_code`, project.`project_name` FROM task LEFT JOIN project ON project.id = task.`project_id`
- WHERE project.`company_id` = #{companyId}
- <if test="projectId != null">
- and task.project_id = #{projectId}
- </if>
- ORDER BY project.is_public desc, project.id ASC, task.stages_id asc, task.seq asc
- <if test="pageStart != null and pageSize != null">
- limit #{pageStart}, #{pageSize}
- </if>
- </select>
- <select id="getProjectTaskCount" resultType="java.lang.Integer">
- SELECT count(1) as total FROM task LEFT JOIN project ON project.id = task.`project_id`
- WHERE project.`company_id` = #{companyId}
- <if test="projectId != null">
- and task.project_id = #{projectId}
- </if>
- </select>
- <select id="getTaskWithProjectName" resultMap="RichResultMap">
- SELECT task.*, project.`project_name`, stages.stages_name FROM task LEFT JOIN project ON project.id = task.`project_id`
- left join stages on stages.id = task.stages_id
- ${ew.customSqlSegment}
- ORDER BY task.indate desc
- <if test="pageStart != null and pageSize != null">
- limit #{pageStart}, #{pageSize}
- </if>
- </select>
- <select id="recentSimpleList" resultType="java.util.Map">
- select task.id as taskId, task.name as taskName, stages.stages_name as stagesName
- from task left join stages on stages.id = task.stages_id
- where task.project_id = #{projectId}
- <if test="userId != null">
- and executor_id like '%${userId}%'
- </if>
- and task_status = 0 order by task.id desc limit 50
- </select>
- <select id="selectMilepost" resultType="com.management.platform.entity.Task">
- select * from task where
- task.task_type=1
- <if test="ids!=null">
- and task.project_id in
- <foreach collection="ids" index="index" close=")" open="(" separator="," item="item">
- #{item}
- </foreach>
- </if>
- and task.finish_date in
- (select MAX(task.finish_date)from task where
- task.task_type=1
- <if test="ids!=null">
- and task.project_id in
- <foreach collection="ids" index="index" close=")" open="(" separator="," item="item">
- #{item}
- </foreach>
- </if>
- group by project_id) group by task.project_id
- </select>
- </mapper>
|