2023-08-10 21:09:49 +08:00
<?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.jh.project.mapper.SurProjectScheduleMapper" >
<resultMap type= "SurProjectSchedule" id= "SurProjectScheduleResult" >
<result property= "id" column= "id" />
<result property= "projectId" column= "project_id" />
<result property= "projectName" column= "projectName" />
<result property= "image" column= "image" />
<result property= "plannedNode" column= "planned_node" />
<result property= "actualNode" column= "actual_node" />
<result property= "purchaseProgress" column= "purchase_progress" />
<result property= "designProgress" column= "design_progress" />
<result property= "constructionProgress" column= "construction_progress" />
<result property= "acceptanceProgress" column= "acceptance_progress" />
<result property= "planForNextWeek" column= "plan_for_next_week" />
<result property= "existingProblem" column= "existing_problem" />
<result property= "problemProgress" column= "problem_progress" />
<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= "remark" column= "remark" />
2023-08-28 22:36:00 +08:00
<result property= "mainImage" column= "mainImage" />
<result property= "dataTemplate" column= "data_template" />
<result property= "projectType" column= "projectType" />
2024-04-16 00:22:29 +08:00
<result property= "createUser" column= "createUser" />
<result property= "createDate" column= "createDate" />
2023-08-23 00:03:39 +08:00
<association property= "surProject" javaType= "SurProject" >
<result property= "id" column= "project_id" />
<result property= "projectName" column= "projectName" />
<result property= "projectSort" column= "projectSort" />
<result property= "projectSchedule" column= "projectSchedule" />
</association>
2023-08-10 21:09:49 +08:00
</resultMap>
<sql id= "selectSurProjectScheduleVo" >
SELECT * from (
2024-04-16 00:22:29 +08:00
SELECT s.*,p.projectType,p.projectName,u.nick_name createUser,s.create_time createDate
FROM sur_project_schedule AS s LEFT JOIN sur_project AS p ON s.project_id=p.id left join sys_user u on s.create_by=u.phonenumber ) as a
2023-08-10 21:09:49 +08:00
</sql>
<select id= "selectSurProjectScheduleList" parameterType= "SurProjectSchedule" resultMap= "SurProjectScheduleResult" >
SELECT * from (
2024-04-16 00:22:29 +08:00
SELECT s.*,substring_index(s.image,',',1) as mainImage,p.projectName,u.nick_name createUser,s.create_time createDate
FROM sur_project_schedule AS s LEFT JOIN sur_project AS p ON s.project_id=p.id left join sys_user u on s.create_by=u.phonenumber
2023-08-10 21:09:49 +08:00
<!-- 监理单位/总包公司/分包单位 -->
<if test= 'nowRole == "5" or nowRole == "6" or nowRole == "7"' > left join sur_project_unit_info spui on spui.projectId = p.id</if>
<!-- 普通用户查询项目人员 -->
2023-09-05 00:45:38 +08:00
<if test= 'nowRole == "15" or nowRole == "16" or nowRole == "17" or nowRole == "99"' > left join sur_project_userinfo spu on spu.project_id = p.id</if>
2023-08-10 21:09:49 +08:00
where 1=1
<!-- 子部门数据 -->
<if test= 'nowRole == "4"' > and p.deptId = #{nowDept}</if>
<!-- 监理单位/总包公司/分包单位查询当前关联数据 -->
<if test= 'nowRole == "5" or nowRole == "6" or nowRole == "7"' > and spui.unitId = #{nowDept}</if>
<!-- 普通用户查询项目人员 -->
2023-09-05 00:45:38 +08:00
<if test= 'nowRole == "15" or nowRole == "16" or nowRole == "17" or nowRole == "99"' > and spu.user_id = #{nowUser} and spu.is_del=0</if>
2023-08-12 12:18:27 +08:00
<!-- 查询条件 - 项目部门 -->
<if test= "projectDeptId != null " > and p.deptId = #{projectDeptId}</if>
2023-08-10 21:09:49 +08:00
) as a
<where >
<if test= "projectId != null " > and project_id = #{projectId}</if>
<if test= "plannedNode != null and plannedNode != ''" > and planned_node = #{plannedNode}</if>
<if test= "actualNode != null and actualNode != ''" > and actual_node = #{actualNode}</if>
<if test= "purchaseProgress != null and purchaseProgress != ''" > and purchase_progress = #{purchaseProgress}</if>
<if test= "designProgress != null and designProgress != ''" > and design_progress = #{designProgress}</if>
<if test= "constructionProgress != null and constructionProgress != ''" > and construction_progress = #{constructionProgress}</if>
<if test= "acceptanceProgress != null and acceptanceProgress != ''" > and acceptance_progress = #{acceptanceProgress}</if>
<if test= "planForNextWeek != null and planForNextWeek != ''" > and plan_for_next_week = #{planForNextWeek}</if>
<if test= "existingProblem != null and existingProblem != ''" > and existing_problem = #{existingProblem}</if>
<if test= "problemProgress != null and problemProgress != ''" > and problem_progress = #{problemProgress}</if>
<if test= "params.beginMarksTime != null and params.beginMarksTime != '' and params.endMarksTime != null and params.endMarksTime != ''" > and create_time between #{params.beginMarksTime} and #{params.endMarksTime}</if>
<if test= "isDel != null " > and is_del = #{isDel}</if>
<if test= "projectName != null and projectName != ''" >
AND projectName like concat('%', #{projectName}, '%')
</if>
</where>
order by create_time desc
</select>
<select id= "selectSurProjectScheduleById" parameterType= "Long" resultMap= "SurProjectScheduleResult" >
<include refid= "selectSurProjectScheduleVo" />
where id = #{id}
</select>
<select id= "getProjectConstructionProgress" parameterType= "Long" resultMap= "SurProjectScheduleResult" >
<include refid= "selectSurProjectScheduleVo" />
<where >
<if test= "projectId != null " > project_id = #{projectId}</if>
</where>
order by id desc LIMIT 0,1 ;
</select>
<insert id= "insertSurProjectSchedule" parameterType= "SurProjectSchedule" >
insert into sur_project_schedule
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "id != null" > id,</if>
<if test= "projectId != null" > project_id,</if>
<if test= "image != null" > image,</if>
<if test= "plannedNode != null" > planned_node,</if>
<if test= "actualNode != null" > actual_node,</if>
<if test= "purchaseProgress != null" > purchase_progress,</if>
<if test= "designProgress != null" > design_progress,</if>
<if test= "constructionProgress != null" > construction_progress,</if>
<if test= "acceptanceProgress != null" > acceptance_progress,</if>
<if test= "planForNextWeek != null" > plan_for_next_week,</if>
<if test= "existingProblem != null" > existing_problem,</if>
<if test= "problemProgress != null" > problem_progress,</if>
2023-08-28 22:36:00 +08:00
<if test= "dataTemplate != null" > data_template,</if>
2023-08-10 21:09:49 +08:00
<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= "id != null" > #{id},</if>
<if test= "projectId != null" > #{projectId},</if>
<if test= "image != null" > #{image},</if>
<if test= "plannedNode != null" > #{plannedNode},</if>
<if test= "actualNode != null" > #{actualNode},</if>
<if test= "purchaseProgress != null" > #{purchaseProgress},</if>
<if test= "designProgress != null" > #{designProgress},</if>
<if test= "constructionProgress != null" > #{constructionProgress},</if>
<if test= "acceptanceProgress != null" > #{acceptanceProgress},</if>
<if test= "planForNextWeek != null" > #{planForNextWeek},</if>
<if test= "existingProblem != null" > #{existingProblem},</if>
<if test= "problemProgress != null" > #{problemProgress},</if>
2023-08-28 22:36:00 +08:00
<if test= "dataTemplate != null" > #{dataTemplate},</if>
2023-08-10 21:09:49 +08:00
<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= "updateSurProjectSchedule" parameterType= "SurProjectSchedule" >
update sur_project_schedule
<trim prefix= "SET" suffixOverrides= "," >
<if test= "projectId != null" > project_id = #{projectId},</if>
<if test= "image != null" > image = #{image},</if>
<if test= "plannedNode != null" > planned_node = #{plannedNode},</if>
<if test= "actualNode != null" > actual_node = #{actualNode},</if>
<if test= "purchaseProgress != null" > purchase_progress = #{purchaseProgress},</if>
<if test= "designProgress != null" > design_progress = #{designProgress},</if>
<if test= "constructionProgress != null" > construction_progress = #{constructionProgress},</if>
<if test= "acceptanceProgress != null" > acceptance_progress = #{acceptanceProgress},</if>
<if test= "planForNextWeek != null" > plan_for_next_week = #{planForNextWeek},</if>
<if test= "existingProblem != null" > existing_problem = #{existingProblem},</if>
<if test= "problemProgress != null" > problem_progress = #{problemProgress},</if>
2023-08-28 22:36:00 +08:00
<if test= "dataTemplate != null" > data_template = #{dataTemplate},</if>
2023-08-10 21:09:49 +08:00
<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>
<delete id= "deleteSurProjectScheduleById" parameterType= "Long" >
delete from sur_project_schedule where id = #{id}
</delete>
<delete id= "deleteSurProjectScheduleByIds" parameterType= "String" >
delete from sur_project_schedule where id in
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
2023-08-23 00:03:39 +08:00
2023-09-10 15:44:04 +08:00
<select id= "selectByProjectType" parameterType= "SurProjectScheduleWhere" resultMap= "SurProjectScheduleResult" >
2024-04-06 01:31:05 +08:00
select * from vw_sur_project_schedule c
left join sur_project p on c.project_id = p.id
WHERE c.id IN (
SELECT MAX(spc.id) FROM sur_project_schedule spc
left join sur_project sp on spc.project_id = sp.id
2024-08-13 22:10:53 +08:00
where spc.is_del=0 and sp.projectType=#{prjType} and sp.isDel=0
2024-04-06 01:31:05 +08:00
<if test= "deptId>0" > and sp.deptId=#{deptId}</if>
<if test= "proType != null and proType != ''" > and sp.projectType = #{proType}</if>
<if test= "prjIds !=null and prjIds.size()>0" >
and spc.project_id in
<foreach collection= "prjIds" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
GROUP BY spc.project_id
2023-08-23 00:03:39 +08:00
)
2024-04-06 01:31:05 +08:00
order by p.projectSort
2023-08-23 00:03:39 +08:00
</select>
2023-10-16 23:52:32 +08:00
<select id= "getConstructionProgressByDept" parameterType= "SurProjectScheduleWhere" resultMap= "SurProjectScheduleResult" >
select s.*,p.projectName from (
select * from sur_project_schedule where id in (
2024-04-06 01:31:05 +08:00
select max(spc.id)
from sur_project_schedule spc
left join sur_project sp on sp.id=spc.project_id
2024-08-13 22:10:53 +08:00
where spc.is_del=0 and sp.isDel=0
2023-10-16 23:52:32 +08:00
<if test= "deptId!=null and deptId>0" >
2024-04-06 01:31:05 +08:00
and sp.deptId= #{deptId}
</if>
<if test= "proType != null and proType != ''" > and sp.projectType = #{proType}</if>
<if test= "prjIds !=null and prjIds.size()>0" >
and spc.project_id in
<foreach collection= "prjIds" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
2023-10-16 23:52:32 +08:00
</if>
2023-11-29 21:19:47 +08:00
<!--
2023-10-16 23:52:32 +08:00
and ( (existing_problem is not null and existing_problem not like '暂无%' and existing_problem not like '无%' and length(trim(existing_problem))>0 )
or (problem_progress IS NOT NULL AND problem_progress NOT LIKE '暂无%' AND problem_progress NOT LIKE '无%' AND LENGTH(TRIM(problem_progress))>0 ))
2023-11-29 21:19:47 +08:00
-->
2024-04-06 01:31:05 +08:00
group by spc.project_id
2023-10-16 23:52:32 +08:00
)
) s LEFT JOIN sur_project AS p ON s.project_id=p.id order by p.projectSort
</select>
2023-08-10 21:09:49 +08:00
</mapper>