YZProjectCloud/yanzhu-common/yanzhu-common-mapper/src/main/resources/mapper/manage/ProPlanMapper.xml

355 lines
18 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.yanzhu.manage.mapper.ProPlanMapper">
<resultMap type="ProPlan" id="ProPlanResult">
<result property="id" column="id" />
<result property="comid" column="comid" />
<result property="projectId" column="project_id" />
<result property="taskId" column="task_id" />
<result property="taskUniqueId" column="task_unique_id" />
<result property="parentId" column="parent_id" />
<result property="taskType" column="task_type" />
<result property="taskOutlineLevel" column="task_outline_level" />
<result property="taskName" column="task_name" />
<result property="taskDuation" column="task_duation" />
<result property="startDate" column="start_date" />
<result property="finishDate" column="finish_date" />
<result property="predecessors" column="predecessors" />
<result property="planStartDate" column="plan_start_date" />
<result property="planFinishDate" column="plan_finish_date" />
<result property="bimId" column="bim_id" />
<result property="operator" column="operator" />
<result property="operatorId" column="operator_id" />
<result property="groupId" column="group_id" />
<result property="groupName" column="group_name" />
<result property="scheduleNode" column="schedule_node" />
<result property="isDel" column="is_del" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="compName" column="comp_name"/>
<result property="projectName" column="project_name"/>
<result property="remark" column="remark" />
<result property="taskStatus" column="task_status" />
<result property="nowMonth" column="nowMonth" />
</resultMap>
<sql id="selectProPlanVo">
select pp.id, pp.comid, pp.project_id, pp.task_id, pp.task_unique_id, pp.parent_id, pp.task_type,
pp.task_outline_level, pp.task_name, pp.task_duation, pp.start_date, pp.finish_date,
pp.predecessors, pp.plan_start_date, pp.plan_finish_date, pp.bim_id, pp.operator, pp.operator_id,
pp.group_id, pp.group_name, pp.schedule_node, pp.is_del, pp.create_by, pp.create_time, pp.update_by, pp.update_time, pp.remark,
dp.`dept_name` comp_name,pi.`project_name`
from pro_plan pp
LEFT JOIN sys_dept dp ON pp.`comid`=dp.`dept_id`
LEFT JOIN pro_project_info pi ON pp.`project_id`=pi.`id`
</sql>
<select id="selectProPlanList" parameterType="ProPlan" resultMap="ProPlanResult">
<include refid="selectProPlanVo"/>
<where>
<if test="comid != null "> and pp.comid = #{comid}</if>
<if test="projectId != null "> and pp.project_id = #{projectId}</if>
<if test="taskId != null "> and pp.task_id = #{taskId}</if>
<if test="taskUniqueId != null "> and pp.task_unique_id = #{taskUniqueId}</if>
<if test="parentId != null "> and pp.parent_id = #{parentId}</if>
<if test="taskType != null and taskType != ''"> and pp.task_type = #{taskType}</if>
<if test="taskOutlineLevel != null "> and pp.task_outline_level = #{taskOutlineLevel}</if>
<if test="taskName != null and taskName != ''"> and pp.task_name like concat('%', #{taskName}, '%')</if>
<if test="taskDuation != null "> and pp.task_duation = #{taskDuation}</if>
<if test="startDate != null "> and pp.start_date = #{startDate}</if>
<if test="finishDate != null "> and pp.finish_date = #{finishDate}</if>
<if test="predecessors != null and predecessors != ''"> and pp.predecessors = #{predecessors}</if>
<if test="planStartDate != null "> and pp.plan_start_date = #{planStartDate}</if>
<if test="planFinishDate != null "> and pp.plan_finish_date = #{planFinishDate}</if>
<if test="bimId != null and bimId != ''"> and pp.bim_id = #{bimId}</if>
<if test="operator != null and operator != ''"> and pp.operator = #{operator}</if>
<if test="operatorId != null "> and pp.operator_id = #{operatorId}</if>
<if test="groupId != null "> and pp.group_id = #{groupId}</if>
<if test="groupName != null and groupName != ''"> and pp.group_name like concat('%', #{groupName}, '%')</if>
<if test="isDel != null "> and pp.is_del = #{isDel}</if>
</where>
order by pp.id
</select>
<select id="selectProPlanListView" parameterType="ProPlan" resultMap="ProPlanResult">
<include refid="selectProPlanVo"/>
<where>
<if test="comid != null "> and pp.comid = #{comid}</if>
<if test="projectId != null "> and pp.project_id = #{projectId}</if>
<if test="taskId != null "> and pp.task_id = #{taskId}</if>
<if test="taskUniqueId != null "> and pp.task_unique_id = #{taskUniqueId}</if>
<if test="parentId != null "> and pp.parent_id = #{parentId}</if>
<if test="taskType != null and taskType != ''"> and pp.task_type = #{taskType}</if>
<if test="taskOutlineLevel != null "> and pp.task_outline_level = #{taskOutlineLevel}</if>
<if test="taskName != null and taskName != ''"> and pp.task_name like concat('%', #{taskName}, '%')</if>
<if test="taskDuation != null "> and pp.task_duation = #{taskDuation}</if>
<if test="startDate != null "> and pp.start_date = #{startDate}</if>
<if test="finishDate != null "> and pp.finish_date = #{finishDate}</if>
<if test="predecessors != null and predecessors != ''"> and pp.predecessors = #{predecessors}</if>
<if test="planStartDate != null "> and pp.plan_start_date = #{planStartDate}</if>
<if test="planFinishDate != null "> and pp.plan_finish_date = #{planFinishDate}</if>
<if test="bimId != null and bimId != ''"> and pp.bim_id = #{bimId}</if>
<if test="operator != null and operator != ''"> and pp.operator = #{operator}</if>
<if test="operatorId != null "> and pp.operator_id = #{operatorId}</if>
<if test="groupId != null "> and pp.group_id = #{groupId}</if>
<if test="groupName != null and groupName != ''"> and pp.group_name like concat('%', #{groupName}, '%')</if>
<if test="isDel != null "> and pp.is_del = #{isDel}</if>
</where>
</select>
<select id="selectProPlanById" parameterType="Long" resultMap="ProPlanResult">
<include refid="selectProPlanVo"/>
where pp.id = #{id}
</select>
<select id="selectProPlanByParams" resultMap="ProPlanResult">
<include refid="selectProPlanVo"/>
where pp.project_id = #{proId} and pp.task_id = #{taskId}
</select>
<select id="selectProPlanBrothers" resultMap="ProPlanResult">
<include refid="selectProPlanVo"/>
where pp.project_id = #{proId} and pp.parent_id = #{taskId} and finish_date is null
</select>
<select id="selectProPlanBelows" resultMap="ProPlanResult">
<include refid="selectProPlanVo"/>
where pp.project_id = #{proId} and pp.parent_id = #{taskId}
</select>
<insert id="insertProPlan" parameterType="ProPlan" useGeneratedKeys="true" keyProperty="id">
insert into pro_plan
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="comid != null">comid,</if>
<if test="projectId != null">project_id,</if>
<if test="taskId != null">task_id,</if>
<if test="taskUniqueId != null">task_unique_id,</if>
<if test="parentId != null">parent_id,</if>
<if test="taskType != null">task_type,</if>
<if test="taskOutlineLevel != null">task_outline_level,</if>
<if test="taskName != null">task_name,</if>
<if test="taskDuation != null">task_duation,</if>
<if test="startDate != null">start_date,</if>
<if test="finishDate != null">finish_date,</if>
<if test="predecessors != null">predecessors,</if>
<if test="planStartDate != null">plan_start_date,</if>
<if test="planFinishDate != null">plan_finish_date,</if>
<if test="bimId != null">bim_id,</if>
<if test="operator != null">operator,</if>
<if test="operatorId != null">operator_id,</if>
<if test="groupId != null">group_id,</if>
<if test="groupName != null">group_name,</if>
<if test="scheduleNode != null">schedule_node,</if>
<if test="isDel != null">is_del,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="comid != null">#{comid},</if>
<if test="projectId != null">#{projectId},</if>
<if test="taskId != null">#{taskId},</if>
<if test="taskUniqueId != null">#{taskUniqueId},</if>
<if test="parentId != null">#{parentId},</if>
<if test="taskType != null">#{taskType},</if>
<if test="taskOutlineLevel != null">#{taskOutlineLevel},</if>
<if test="taskName != null">#{taskName},</if>
<if test="taskDuation != null">#{taskDuation},</if>
<if test="startDate != null">#{startDate},</if>
<if test="finishDate != null">#{finishDate},</if>
<if test="predecessors != null">#{predecessors},</if>
<if test="planStartDate != null">#{planStartDate},</if>
<if test="planFinishDate != null">#{planFinishDate},</if>
<if test="bimId != null">#{bimId},</if>
<if test="operator != null">#{operator},</if>
<if test="operatorId != null">#{operatorId},</if>
<if test="groupId != null">#{groupId},</if>
<if test="groupName != null">#{groupName},</if>
<if test="scheduleNode != null">#{scheduleNode},</if>
<if test="isDel != null">#{isDel},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateProPlan" parameterType="ProPlan">
update pro_plan
<trim prefix="SET" suffixOverrides=",">
<if test="comid != null">comid = #{comid},</if>
<if test="projectId != null">project_id = #{projectId},</if>
<if test="taskId != null">task_id = #{taskId},</if>
<if test="taskUniqueId != null">task_unique_id = #{taskUniqueId},</if>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="taskType != null">task_type = #{taskType},</if>
<if test="taskOutlineLevel != null">task_outline_level = #{taskOutlineLevel},</if>
<if test="taskName != null">task_name = #{taskName},</if>
<if test="taskDuation != null">task_duation = #{taskDuation},</if>
<if test="startDate != null">start_date = #{startDate},</if>
<if test="finishDate != null">finish_date = #{finishDate},</if>
<if test="predecessors != null">predecessors = #{predecessors},</if>
<if test="planStartDate != null">plan_start_date = #{planStartDate},</if>
<if test="planFinishDate != null">plan_finish_date = #{planFinishDate},</if>
<if test="bimId != null">bim_id = #{bimId},</if>
<if test="operator != null">operator = #{operator},</if>
<if test="operatorId != null">operator_id = #{operatorId},</if>
<if test="groupId != null">group_id = #{groupId},</if>
<if test="groupName != null">group_name = #{groupName},</if>
<if test="scheduleNode != null">schedule_node = #{scheduleNode},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<update id="updateProPlanStartDate" parameterType="ProPlan">
update pro_plan set start_date = #{startDate}
<if test="scheduleNode != null">,schedule_node = #{scheduleNode}</if>
where id = #{id}
</update>
<update id="updateProPlanFinishDate" parameterType="ProPlan">
update pro_plan set finish_date = #{finishDate}
<if test="scheduleNode != null">,schedule_node = #{scheduleNode}</if>
where id = #{id}
</update>
<delete id="deleteProPlanById" parameterType="Long">
delete from pro_plan where id = #{id}
</delete>
<delete id="deleteProPlanByIds" parameterType="String">
delete from pro_plan where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="findOnlyPlan" parameterType="ProPlan" resultMap="ProPlanResult">
select id, comid, project_id, task_id, task_unique_id, parent_id, task_type,
task_outline_level,
<if test="taskName != null and taskName != ''"> concat(#{taskName}, ' / ', task_name) as task_name,</if>
<if test="taskName == null or taskName == ''"> task_name,</if>
task_duation, start_date, finish_date,
predecessors, plan_start_date, plan_finish_date, bim_id, operator, operator_id,
group_id, group_name, schedule_node, is_del from pro_plan
<where>
<if test="projectId != null "> and project_id = #{projectId}</if>
<if test="taskId != null "> and parent_id = #{taskId}</if>
and is_del = 0 and task_outline_level <![CDATA[ > ]]> 1 and finish_date is null
</where>
order by id limit 1
</select>
<select id="findPlanDatas" parameterType="ProPlan" resultMap="ProPlanResult">
select id, comid, project_id, task_id, task_unique_id, parent_id, task_type,
task_outline_level,
<if test="taskName != null and taskName != ''"> concat(#{taskName}, ' / ', task_name) as task_name,</if>
<if test="taskName == null or taskName == ''"> task_name,</if>
task_duation, start_date, finish_date,
predecessors, plan_start_date, plan_finish_date, bim_id, operator, operator_id,
group_id, group_name, schedule_node, is_del from pro_plan
<where>
<if test="projectId != null "> and project_id = #{projectId}</if>
<if test="taskId != null "> and task_id = #{taskId}</if>
and is_del = 0 and task_outline_level <![CDATA[ > ]]> 1 and finish_date is null
</where>
order by id
</select>
<select id="findRecursionPlan" parameterType="ProPlan" resultMap="ProPlanResult">
select id, comid, project_id, task_id, task_unique_id, parent_id, task_type,
task_outline_level,
<if test="taskName != null and taskName != ''"> concat(task_name, ' / ', #{taskName}) as task_name,</if>
task_duation, start_date, finish_date,
predecessors, plan_start_date, plan_finish_date, bim_id, operator, operator_id,
group_id, group_name, schedule_node, is_del from pro_plan
<where>
<if test="projectId != null "> and project_id = #{projectId}</if>
<if test="taskId != null "> and task_id = #{taskId}</if>
</where>
</select>
<select id="findAllPlanDatasByProId" parameterType="Long" resultMap="ProPlanResult">
SELECT
pp.id,
CASE
WHEN pp.start_date IS NULL THEN
'wks'
WHEN pp.start_date IS NOT NULL
AND pp.finish_date IS NOT NULL
AND pp.plan_finish_date <![CDATA[ >= ]]> pp.finish_date THEN
'zcwc'
WHEN pp.start_date IS NOT NULL
AND pp.finish_date IS NOT NULL
AND pp.plan_finish_date <![CDATA[ < ]]> pp.finish_date THEN
'zhwc'
WHEN pp.start_date IS NOT NULL
AND pp.finish_date IS NULL
AND pp.plan_finish_date <![CDATA[ >= ]]> NOW() THEN
'zcjxz'
WHEN pp.start_date IS NOT NULL
AND pp.finish_date IS NULL
AND pp.plan_finish_date <![CDATA[ < ]]> NOW() THEN
'zhjxz'
END AS task_status,
CASE
WHEN (
pp.start_date IS NOT NULL
AND DATE_FORMAT(pp.start_date, '%Y-%m') = DATE_FORMAT(CURRENT_DATE, '%Y-%m')
)
OR (
pp.finish_date IS NOT NULL
AND DATE_FORMAT(pp.finish_date, '%Y-%m') = DATE_FORMAT(CURRENT_DATE, '%Y-%m')
)
THEN 'Y' ELSE 'N' END as nowMonth,
pp.comid,
pp.project_id,
pp.task_id,
pp.task_unique_id,
pp.parent_id,
pp.task_type,
pp.task_outline_level,
pp.task_name,
pp.task_duation,
pp.start_date,
pp.finish_date,
pp.predecessors,
pp.plan_start_date,
pp.plan_finish_date,
pp.bim_id,
pp.operator,
pp.operator_id,
pp.group_id,
pp.group_name,
pp.schedule_node,
pp.is_del,
pp.create_by,
pp.create_time,
pp.update_by,
pp.update_time,
pp.remark,
dp.`dept_name` comp_name,
pi.`project_name`
FROM
pro_plan pp
LEFT JOIN sys_dept dp ON pp.`comid` = dp.`dept_id`
LEFT JOIN pro_project_info pi ON pp.`project_id` = pi.`id`
WHERE
pp.project_id = #{proId}
AND pp.task_outline_level <![CDATA[ > ]]> 1 and pp.is_del = 0
</select>
</mapper>