123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870 |
- <?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" />
- <result column="meeting_id" property="meetingId" />
- <result column="ahead_tid" property="aheadTid" />
- <result column="sap_task_code" property="sapTaskCode" />
- <result column="plan_cost" property="planCost" />
- <result column="attach_file_required" property="attachFileRequired" />
- <result column="task_plan_type" property="taskPlanType" />
- <result column="task_plan" property="taskPlan" />
- <result column="is_task_plan" property="isTaskPlan" />
- <result column="center_id" property="centerId" />
- <result column="center_name" property="centerName" />
- <result column="reject_user_id" property="rejectUserId" />
- <result column="task_reject_reason" property="taskRejectReason" />
- <result column="reject_time" property="rejectTime" />
- </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="meeting_id" property="meetingId" />
- <result column="ahead_tid" property="aheadTid" />
- <result column="sap_task_code" property="sapTaskCode" />
- <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="meeting_id" property="meetingId" />
- <result column="ahead_tid" property="aheadTid" />
- <result column="sap_task_code" property="sapTaskCode" />
- <result column="stages_name" property="stagesName" />
- <result column="department_name" property="departmentName" />
- <result column="attach_file_required" property="attachFileRequired" />
- <result column="center_id" property="centerId" />
- <result column="center_name" property="centerName" />
- </resultMap>
- <resultMap id="AuditorResultMap" type="com.management.platform.entity.TaskWithAuditor">
- <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="meeting_id" property="meetingId" />
- <result column="ahead_tid" property="aheadTid" />
- <result column="sap_task_code" property="sapTaskCode" />
- <result column="stages_name" property="stagesName" />
- <result column="department_name" property="departmentName" />
- <result column="attach_file_required" property="attachFileRequired" />
- <result column="center_id" property="centerId" />
- <result column="center_name" property="centerName" />
- <result column="first_auditor_id" property="firstAuditorId" />
- <result column="first_auditor_name" property="firstAuditorName" />
- <result column="second_auditor_id" property="secondAuditorId" />
- <result column="second_auditor_name" property="secondAuditorName" />
- <result column="reject_user_name" property="rejectUserName" />
- </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, meeting_id, ahead_tid, sap_task_code, plan_cost, attach_file_required, task_plan_type, task_plan, is_task_plan, center_id, center_name, reject_user_id, task_reject_reason, reject_time
- </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}
- <if test="start!=null and size!=null">
- limit #{start},#{size}
- </if>
- </select>
- <select id="nameList" resultMap="BaseResultMap">
- select id, name, task_level, stages_id, company_id, indate, group_id, seq,task_type,task_desc
- 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 t.id , t.name AS name ,IFNULL(SUM(te.plan_hours),0) AS planHours, IFNULL((SELECT SUM(r.`working_time`) FROM report r WHERE r.task_id=t.id AND r.state=1),0) AS workHours FROM
- task_executor te
- LEFT JOIN user u ON te.executor_id=u.id
- LEFT JOIN task t ON t.id=te.task_id
- LEFT JOIN project p ON p.id=t.project_id
- WHERE p.id= #{projectId}
- <if test="deptId!=null and deptId">
- and u.department_id=#{deptId}
- </if>
- GROUP BY t.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,tg.id as groupId, task.`name`,task.executor_name,task.executor_id,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,
- (SELECT IFNULL(SUM(cost),0) FROM report WHERE report.`task_id` = task.id AND report.`state` = 1) AS real_cost,
- task.`task_status`, task.`task_type`,
- project.`project_code`, project.`project_name`,tg.name as groupName
- FROM task
- LEFT JOIN project ON project.id = task.`project_id`
- LEFT JOIN task_group tg on tg.id=task.`group_id`
- WHERE project.`company_id` = #{companyId}
- <if test="projectId != null">
- and task.project_id = #{projectId}
- </if>
- <if test="groupId != null">
- and task.group_id = #{groupId}
- </if>
- <if test="taskType!=null">
- and task.task_type=#{taskType}
- </if>
- <if test="inchagerIds!=null and inchagerIds.size()>0">
- and task.project_id in
- <foreach collection="inchagerIds" open="(" separator="," close=")" item="item">
- #{item}
- </foreach>
- </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>
- <if test="groupId != null">
- and task.group_id = #{groupId}
- </if>
- <if test="taskType!=null">
- and task.task_type=#{taskType}
- </if>
- <if test="inchagerIds!=null and inchagerIds.size()>0">
- and task.project_id in
- <foreach collection="inchagerIds" open="(" separator="," close=")" item="item">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="getTaskPlanRealData" resultType="java.util.Map">
- SELECT task.id,task.`name`,task_executor.id as teId, DATE_FORMAT(task.`end_date`, '%Y-%m-%d') as endDate, task_executor.`plan_hours` as planHours,task.plan_cost as planCost,
- (SELECT IFNULL(SUM(working_time),0) FROM report WHERE report.`task_id` = task.id AND report.`state` = 1 and report.creator_id = task_executor.executor_id) AS realHours,
- task_executor.executor_id as executorId,task_executor.executor_name AS executorName,
- IF(task_executor.real_cost = 0, task.plan_cost, task_executor.real_cost) AS realCost,
- task.`task_status` as taskStatus, task.`task_type` as taskType,
- project.`project_code` as projectCode, project.`project_name` as projectName
- FROM task
- LEFT JOIN project ON project.id = task.`project_id`
- left join task_executor on task_executor.task_id=task.id
- WHERE project.`company_id` = #{companyId}
- <if test="projectId != null">
- and task.project_id = #{projectId}
- </if>
- <if test="taskType!=null">
- and task.task_type=#{taskType}
- </if>
- <if test="inchagerIds!=null and inchagerIds.size()>0">
- and task.project_id in
- <foreach collection="inchagerIds" open="(" separator="," close=")" item="item">
- #{item}
- </foreach>
- </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="getTaskPlanRealCount" resultType="java.lang.Integer">
- SELECT count(1) as total FROM task LEFT JOIN project ON project.id = task.`project_id`
- left join task_executor on task_executor.task_id=task.id
- WHERE project.`company_id` = #{companyId}
- <if test="projectId != null">
- and task.project_id = #{projectId}
- </if>
- <if test="taskType!=null">
- and task.task_type=#{taskType}
- </if>
- <if test="inchagerIds!=null and inchagerIds.size()>0">
- and task.project_id in
- <foreach collection="inchagerIds" open="(" separator="," close=")" item="item">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="getTaskWithProjectName" resultMap="AuditorResultMap">
- SELECT task.id, task.project_id, task.name, task.executor_name, task.start_date, task.`end_date`,task.create_date, task.`creater_id`, task.`creater_name`, task.group_id,
- task.plan_hours, task.task_type,task.task_plan_type, task.task_reject_reason,task.reject_user_id, user.name as reject_user_name, task.reject_time, task.task_level, task.task_status, task.`finish_date`, project.`project_name`, stages.stages_name,department.department_name,
- task_executor.`first_auditor_id`, group_concat(task_executor.`second_auditor_id`) as second_auditor_id, u1.name AS first_auditor_name, group_concat(u2.`name`) AS second_auditor_name
- FROM task LEFT JOIN project ON project.id = task.`project_id`
- left join task_executor on task_executor.task_id=task.id
- LEFT JOIN USER u1 ON u1.id = task_executor.`first_auditor_id`
- LEFT JOIN USER u2 ON u2.id = task_executor.`second_auditor_id`
- left join user on user.id = task.`reject_user_id`
- left join stages on stages.id = task.stages_id
- left join department on department.department_id=project.dept_id
- ${ew.customSqlSegment}
- <if test="deptIds!=null and deptIds.size()>0">
- and project.dept_id in
- <foreach collection="deptIds" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- </if>
- group by task.id
- 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,task.group_id as groupId
- 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>
- <if test="stage != null">
- and stages.stages_name = #{stage}
- </if>
- <if test="groupId != null">
- and task.group_id = #{groupId}
- </if>
- and task_status = 0 order by task.id desc limit 300
- </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>
- <select id="userTaskCompleteDetail" resultType="java.util.Map">
- SELECT u.id as userId, u.name AS userName,u.corpwx_userid AS corpWxUserId,d.corpwx_deptid AS corpWxDeptId,d.department_name AS deptName,COUNT(t.name) AS allNum,COUNT(CASE WHEN t.task_status=0 THEN 1 END) AS noCompletedNum,COUNT(CASE WHEN t.task_status=1 THEN 1 END) AS completedNum,
- COUNT(CASE WHEN t.finish_date <= t.end_date AND t.task_status=1 THEN 1 END) AS onTimeNum,COUNT(CASE WHEN t.finish_date>t.end_date AND t.task_status=1 THEN 1 END) AS noOnTimeNum,
- CONCAT(FORMAT(COUNT(CASE WHEN t.task_status=0 THEN 1 END)/COUNT(t.name)*100, 2), '%') AS noCompletedPercent,CONCAT(FORMAT(COUNT(CASE WHEN t.finish_date <= t.end_date AND t.task_status=1 THEN 1 END)/COUNT(t.name)*100, 2), '%') AS onTimePercent
- FROM
- task_executor te
- LEFT JOIN `user` u ON te.executor_id=u.id
- LEFT JOIN department d ON u.department_id=d.department_id
- LEFT JOIN task t ON te.task_id=t.`id`
- WHERE u.company_id=#{companyId}
- <if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
- AND t.start_date < #{endDate} AND t.end_date > #{startDate}
- </if>
- <if test="userId!=null and userId!=''">
- and u.id=#{userId}
- </if>
- <if test="deptId!=null">
- and d.department_id=#{deptId}
- </if>
- <if test="list!=null and list.size()>0">
- and d.department_id in
- <foreach collection="list" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- group by te.executor_id
- <if test="pageStart != null and pageSize != null">
- limit #{pageStart}, #{pageSize}
- </if>
- </select>
- <select id="userTaskCompleteDetailCount" resultType="java.lang.Integer">
- select count(1) from (
- SELECT u.id as userId
- FROM
- task_executor te
- LEFT JOIN `user` u ON te.executor_id=u.id
- LEFT JOIN department d ON u.department_id=d.department_id
- LEFT JOIN task t ON te.task_id=t.`id`
- WHERE u.company_id=#{companyId}
- <if test="startDate!=null and startDate!='' and endDate!=null and endDate!=''">
- AND t.start_date < #{endDate} AND t.end_date > #{startDate}
- </if>
- <if test="userId!=null and userId!=''">
- and u.id=#{userId}
- </if>
- <if test="deptId!=null">
- and d.department_id=#{deptId}
- </if>
- <if test="list!=null and list.size()>0">
- and d.department_id in
- <foreach collection="list" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- group by te.executor_id
- ) as total
- </select>
- <select id="getTaskByUserId" resultType="java.util.Map">
- SELECT t.`name` AS taskName,GROUP_CONCAT(u.name) AS executorNames,GROUP_CONCAT(u.corpwx_userid) AS executorCorpWxUserIds,
- date_format(t.`start_date`,'%Y-%m-%d') AS startDate,date_format(t.`end_date`,'%Y-%m-%d') AS endDate,date_format(t.`finish_date`,'%Y-%m-%d') AS finishDate,
- (CASE t.`task_status` WHEN 0 THEN '进行中' WHEN 1 THEN '已完成' ELSE '已撤销' END) AS stateValue
- FROM
- task_executor te
- LEFT JOIN `user` u ON te.executor_id=u.id
- LEFT JOIN task t ON te.task_id=t.`id`
- WHERE t.start_date < #{endDate} AND t.end_date > #{startDate} AND FIND_IN_SET(#{userId},t.`executor_id`) GROUP BY t.`id`
- <if test="pageStart != null and pageSize != null">
- limit #{pageStart}, #{pageSize}
- </if>
- </select>
- <select id="getTaskByUserIdCount" resultType="java.lang.Integer">
- select count(1) from (
- SELECT t.`name` AS taskName
- FROM
- task_executor te
- LEFT JOIN `user` u ON te.executor_id=u.id
- LEFT JOIN task t ON te.task_id=t.`id`
- WHERE t.start_date < #{endDate} AND t.end_date > #{startDate} AND FIND_IN_SET(#{userId},t.`executor_id`) GROUP BY t.`id`
- )as total
- </select>
- <select id="getTaskWithProjectNameWithCharge" resultMap="RichResultMap">
- SELECT task.id, task.project_id, task.name, task.executor_name, task.start_date, task.`end_date`,task.create_date, task.`creater_id`, task.`creater_name`, task.group_id,
- task.plan_hours, task.task_type, task.task_level, task.task_status, task.`finish_date`, project.`project_name`, stages.stages_name,department.department_name
- <!-- ,task.charge_one_id,task.charge_one_status,task.charge_two_id,task.charge_two_status,task.charge_stage,task.final_charge_status-->
- FROM task LEFT JOIN project ON project.id = task.`project_id`
- left join stages on stages.id = task.stages_id
- left join department on department.department_id=project.dept_id
- ${ew.customSqlSegment}
- <if test="deptIds!=null and deptIds.size()>0">
- and project.dept_id in
- <foreach collection="deptIds" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- </if>
- <if test="userId != null and userId != ''">
- and task.final_charge_status = 0
- and case task.charge_stage
- when 1 then task.charge_one_id = #{userId} and task.charge_one_status = 0
- when 2 then task.charge_two_id = #{userId} and task.charge_two_status = 0
- end
- </if>
- ORDER BY task.indate desc
- <if test="pageStart != null and pageSize != null">
- limit #{pageStart}, #{pageSize}
- </if>
- </select>
- <select id="selectCountWithCharge" resultType="java.lang.Integer">
- SELECT count(*)
- FROM task
- ${ew.customSqlSegment}
- <if test="userId != null and userId != ''">
- and task.final_charge_status = 0
- and case task.charge_stage
- when 1 then task.charge_one_id = #{userId} and task.charge_one_status = 0
- when 2 then task.charge_two_id = #{userId} and task.charge_two_status = 0
- end
- </if>
- </select>
- <select id="getTaskChargePage" resultType="com.management.platform.entity.vo.TaskChargePageVO">
- select tmp1.*,user.name as finalChargeName
- from
- (
- select tf.task_id,task.creater_id,task.name as taskName,task.charge_stage
- ,task.charge_one_id,task.charge_one_status,task.executor_id,task.group_id
- ,task.charge_two_id,task.charge_two_status,p.id as projectId,p.project_name,
- case task.charge_stage
- when 1 then task.charge_one_id
- when 2 then task.charge_two_id
- end as finalChargeId
- from
- task_files tf
- left join task on tf.task_id = task.id
- left join project p on task.project_id = p.id
- <where>
- task.final_charge_status = 0
- and case task.charge_stage
- when 1 then (p.incharger_id = task.charge_one_id and task.charge_one_status != 2)
- when 2 then (p.incharger_id = task.charge_two_id and task.charge_two_status != 2)
- end
- <if test="queryBO.projectId != null">
- and tf.project_id = #{queryBO.projectId}
- </if>
- <if test="queryBO.taskName != null and queryBO.taskName != ''">
- and task.name like concat('%',#{queryBO.taskName},'%')
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and p.dept_id in
- <foreach collection="deptIds" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- </if>
- </where>
- )
- tmp1 left join user on tmp1.finalChargeId = user.id
- where tmp1.finalChargeId = #{queryBO.userId}
- group by tmp1.task_id
- union all
- select tmp1.*,user.name as finalChargeName
- from
- (
- select tf.task_id,task.creater_id,task.name as taskName,task.charge_stage
- ,task.charge_one_id,task.charge_one_status,task.executor_id,task.group_id
- ,task.charge_two_id,task.charge_two_status,project.id as projectId,project.project_name,
- case task.charge_stage
- when 1 then task.charge_one_id
- when 2 then task.charge_two_id
- end as finalChargeId
- from
- task_files tf
- left join task on tf.task_id = task.id
- left join project on task.project_id = project.id
- left join user on task.creater_id = user.id
- left join department d on user.department_id = d.department_id
- <where>
- task.final_charge_status = 0
- and case task.charge_stage
- when 1 then (d.manager_id = task.charge_one_id and task.charge_one_status != 2)
- when 2 then (d.manager_id = task.charge_two_id and task.charge_two_status != 2)
- end
- <if test="queryBO.projectId != null">
- and tf.project_id = #{queryBO.projectId}
- </if>
- <if test="queryBO.taskName != null and queryBO.taskName != ''">
- and task.name like concat('%',#{queryBO.taskName},'%')
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and project.dept_id in
- <foreach collection="deptIds" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- </if>
- </where>
- )
- tmp1 left join user on tmp1.finalChargeId = user.id
- where tmp1.finalChargeId = #{queryBO.userId}
- group by tmp1.task_id
- ORDER BY task_id desc
- <if test="queryBO.pageIndex != null and queryBO.pageSize != null">
- limit #{queryBO.pageIndex}, #{queryBO.pageSize}
- </if>
- </select>
- <select id="getTaskChargePageTotal" resultType="java.lang.Integer">
- select count(*)
- from(
- select tmp1.*,user.name as finalChargeName
- from
- (
- select tf.task_id,task.creater_id,task.name,task.charge_stage
- ,task.charge_one_id,task.charge_one_status,task.executor_id
- ,task.charge_two_id,task.charge_two_status,p.id,p.project_name,
- case task.charge_stage
- when 1 then task.charge_one_id
- when 2 then task.charge_two_id
- end as finalChargeId
- from
- task_files tf
- left join task on tf.task_id = task.id
- left join project p on task.project_id = p.id
- <where>
- task.final_charge_status = 0
- and case task.charge_stage
- when 1 then (p.incharger_id = task.charge_one_id and task.charge_one_status != 2)
- when 2 then (p.incharger_id = task.charge_two_id and task.charge_two_status != 2)
- end
- <if test="queryBO.projectId != null">
- and tf.project_id = #{queryBO.projectId}
- </if>
- <if test="queryBO.taskName != null and queryBO.taskName != ''">
- and task.task_name like concat('%',#{queryBO.taskName},'%')
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and p.dept_id in
- <foreach collection="deptIds" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- </if>
- </where>
- )
- tmp1 left join user on tmp1.finalChargeId = user.id
- where tmp1.finalChargeId = #{queryBO.userId}
- group by tmp1.task_id
- union all
- select tmp1.*,user.name as finalChargeName
- from
- (
- select tf.task_id,task.creater_id,task.name,task.charge_stage
- ,task.charge_one_id,task.charge_one_status,task.executor_id
- ,task.charge_two_id,task.charge_two_status,project.id,project.project_name,
- case task.charge_stage
- when 1 then task.charge_one_id
- when 2 then task.charge_two_id
- end as finalChargeId
- from
- task_files tf
- left join task on tf.task_id = task.id
- left join project on task.project_id = project.id
- left join user on task.creater_id = user.id
- left join department d on user.department_id = d.department_id
- <where>
- task.final_charge_status = 0
- and case task.charge_stage
- when 1 then (d.manager_id = task.charge_one_id and task.charge_one_status != 2)
- when 2 then (d.manager_id = task.charge_two_id and task.charge_two_status != 2)
- end
- <if test="queryBO.projectId != null">
- and tf.project_id = #{queryBO.projectId}
- </if>
- <if test="queryBO.taskName != null and queryBO.taskName != ''">
- and task.task_name like concat('%',#{queryBO.taskName},'%')
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and project.dept_id in
- <foreach collection="deptIds" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- </if>
- </where>
- )
- tmp1 left join user on tmp1.finalChargeId = user.id
- where tmp1.finalChargeId = #{queryBO.userId}
- group by tmp1.task_id
- )tmpAll
- </select>
- <resultMap id="taskFileChargeMap" type="com.management.platform.entity.vo.TaskFileChargePageVO">
- <result property="taskId" column="task_id"></result>
- <result property="taskName" column="taskName"></result>
- <result property="groupId" column="group_id"></result>
- <result property="executorId" column="executor_id"></result>
- <result property="projectId" column="projectId"></result>
- <result property="projectName" column="project_name"></result>
- <collection property="childFiles" ofType="com.management.platform.entity.TaskFiles">
- <result property="id" column="id"></result>
- <result property="documentName" column="document_name"></result>
- <result property="creatorId" column="creator_id"></result>
- <result property="creatorName" column="creator_name"></result>
- <result property="chargeOneId" column="charge_one_id"></result>
- <result property="chargeOneStatus" column="charge_one_status"></result>
- <result property="chargeOneTime" column="charge_one_time"></result>
- <result property="chargeTwoId" column="charge_two_id"></result>
- <result property="chargeTwoStatus" column="charge_two_status"></result>
- <result property="chargeTwoTime" column="charge_two_time"></result>
- <result property="chargeStage" column="charge_stage"></result>
- <result property="finalChargeStatus" column="final_charge_status"></result>
- <result property="fileRejectReason" column="file_reject_reason"></result>
- <result property="needFileCharge" column="need_file_charge"></result>
- </collection>
- </resultMap>
- <select id="getTaskFileChargePage" resultMap="taskFileChargeMap">
- select tf.task_id,task.name as taskName,task.group_id,task.executor_id
- ,p.id as projectId,p.project_name
- from task_files tf
- left join task on tf.task_id = task.id
- left join project p on task.project_id = p.id
- <where>
- tf.need_file_charge = 1
- and tf.final_charge_status = 0
- and task.company_id = #{queryBO.companyId}
- and case tf.charge_stage
- when 1 then tf.charge_one_id = #{queryBO.userId} and tf.charge_one_status = 0
- when 2 then tf.charge_two_id = #{queryBO.userId} and tf.charge_two_status = 0
- end
- <if test="queryBO.taskName != null and queryBO.taskName != ''">
- and task.name like concat('%',#{queryBO.taskName},'%')
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and p.dept_id in
- <foreach collection="deptIds" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- </if>
- </where>
- group by tf.task_id
- ORDER BY tf.task_id desc
- <if test="queryBO.pageIndex != null and queryBO.pageSize != null">
- limit #{queryBO.pageIndex}, #{queryBO.pageSize}
- </if>
- </select>
- <select id="getTaskFileChargePageTotal" resultType="java.lang.Integer">
- select count(*)
- from
- (
- select tf.task_id
- from task_files tf
- left join task on tf.task_id = task.id
- left join project p on task.project_id = p.id
- <where>
- tf.need_file_charge = 1
- and tf.final_charge_status = 0
- and task.company_id = #{queryBO.companyId}
- and case tf.charge_stage
- when 1 then tf.charge_one_id = #{queryBO.userId} and tf.charge_one_status = 0
- when 2 then tf.charge_two_id = #{queryBO.userId} and tf.charge_two_status = 0
- end
- <if test="queryBO.taskName != null and queryBO.taskName != ''">
- and task.name like concat('%',#{queryBO.taskName},'%')
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and p.dept_id in
- <foreach collection="deptIds" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- </if>
- </where>
- group by tf.task_id
- )tmp1
- </select>
- <select id="getProjectAllTaskTimeCost"
- resultType="com.management.platform.entity.vo.ProjectTaskTimeCostVO">
- SELECT task.id as taskId,ifnull(task_executor.`plan_hours`,0) as planHours,
- (SELECT IFNULL(SUM(working_time),0) FROM report WHERE report.`task_id` = task.id AND report.`state` = 1
- and report.creator_id = task_executor.executor_id) AS realHours,
- task_executor.executor_id as executorId
- FROM task
- LEFT JOIN project ON project.id = task.`project_id`
- left join task_executor on task_executor.task_id=task.id
- WHERE task.project_id = #{projectId}
- and project.id = #{projectId}
- </select>
- <select id="getProjectTaskTimeCostByIds" resultType="com.management.platform.entity.vo.ProjectTimeCostVO">
- select project_id,sum(planHours) as planHoursSum,sum(realHours) as realHoursSum
- from
- (
- SELECT task.project_id,task.id as taskId,ifnull(task_executor.`plan_hours`,0) as planHours,
- (SELECT IFNULL(SUM(working_time),0) FROM report
- WHERE report.`task_id` = task.id AND report.`state` = 1 and report.creator_id = task_executor.executor_id) AS realHours,
- task_executor.executor_id as executorId
- FROM task
- LEFT JOIN project ON project.id = task.`project_id`
- left join task_executor on task_executor.task_id=task.id
- WHERE task.project_id in
- <foreach collection="projectIds" item="projectId" separator="," open="(" close=")">
- #{projectId}
- </foreach>
- )tmp1
- group by project_id
- </select>
- <select id="getOtherTaskChargePage" resultType="com.management.platform.entity.vo.OtherTaskFileInfoVO">
- select tf.task_id,task.name as taskName,tf.url
- ,p.id as projectId,p.project_name,task.group_id
- ,tf.creator_id,tf.creator_name,tf.document_name
- ,case tf.charge_stage
- when 1 then tf.charge_one_id when 2 then tf.charge_two_id
- end as final_charge_id
- from task_files tf
- left join task on tf.task_id = task.id
- left join project p on task.project_id = p.id
- <where>
- tf.need_file_charge = 1
- and tf.final_charge_status = 0
- and task.company_id = #{queryBO.companyId}
- and case tf.charge_stage
- when 1 then tf.charge_one_id != #{queryBO.userId} and tf.charge_one_status = 0
- when 2 then tf.charge_two_id != #{queryBO.userId} and tf.charge_two_status = 0
- end
- <if test="queryBO.taskName != null and queryBO.taskName != ''">
- and task.name like concat('%',#{queryBO.taskName},'%')
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and p.dept_id in
- <foreach collection="deptIds" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- </if>
- </where>
- ORDER BY tf.task_id ,tf.id desc
- <if test="queryBO.pageIndex != null and queryBO.pageSize != null">
- limit #{queryBO.pageIndex}, #{queryBO.pageSize}
- </if>
- </select>
- <select id="getOtherTaskChargePageTotal" resultType="java.lang.Integer">
- select count(*)
- from (
- select tf.task_id,task.name as taskName
- ,p.id as projectId,p.project_name
- ,tf.creator_id
- from task_files tf
- left join task on tf.task_id = task.id
- left join project p on task.project_id = p.id
- <where>
- tf.need_file_charge = 1
- and tf.final_charge_status = 0
- and task.company_id = #{queryBO.companyId}
- and case tf.charge_stage
- when 1 then tf.charge_one_id != #{queryBO.userId} and tf.charge_one_status = 0
- when 2 then tf.charge_two_id != #{queryBO.userId} and tf.charge_two_status = 0
- end
- <if test="queryBO.taskName != null and queryBO.taskName != ''">
- and task.name like concat('%',#{queryBO.taskName},'%')
- </if>
- <if test="deptIds!=null and deptIds.size()>0">
- and p.dept_id in
- <foreach collection="deptIds" open="(" close=")" separator="," item="item">
- #{item}
- </foreach>
- </if>
- </where>
- ) tmp1
- </select>
- <select id="getMyAuditTaskList"
- resultMap="AuditorResultMap">
- SELECT task.*, task_executor.`first_auditor_id`, group_concat(task_executor.`second_auditor_id`) as second_auditor_id, u1.name AS first_auditor_name, group_concat(u2.`name`) AS second_auditor_name, project.`project_name`, stages.stages_name
- FROM task LEFT JOIN task_executor ON task.id = task_executor.`task_id`
- left join project on project.id = task.`project_id`
- LEFT JOIN USER u1 ON u1.id = task_executor.`first_auditor_id` LEFT JOIN USER u2 ON u2.id = task_executor.`second_auditor_id`
- left join stages on stages.id = task.stages_id
- ${ew.customSqlSegment}
- and (task_executor.`audit_status` = 3 AND task_executor.`first_auditor_id` = #{userId} ) or (task.task_status = 4 and task_executor.`audit_status` = 4 AND task_executor.`second_auditor_id` = #{userId} )
- group by task.id
- order by task.id desc
- <if test="pageStart != null and pageSize != null">
- limit #{pageStart}, #{pageSize}
- </if>
- </select>
- <select id="getMyAuditTaskCount"
- resultType="java.lang.Integer">
- SELECT count(DISTINCT task.id) FROM task LEFT JOIN task_executor ON task.id = task_executor.`task_id`
- LEFT JOIN USER u1 ON u1.id = task_executor.`first_auditor_id` LEFT JOIN USER u2 ON u2.id = task_executor.`second_auditor_id`
- ${ew.customSqlSegment}
- and (task_executor.`audit_status` = 3 AND task_executor.`first_auditor_id` = #{userId} ) or (task.task_status = 4 and task_executor.`audit_status` = 4 AND task_executor.`second_auditor_id` = #{userId} )
- </select>
- </mapper>
|