2023-08-18 17:58:35 +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.SurProjectCheckingMapper" >
<resultMap type= "SurProjectChecking" id= "SurProjectCheckingResult" >
<result property= "id" column= "id" />
<result property= "projectId" column= "project_id" />
<result property= "deptId" column= "dept_id" />
<result property= "groupDeptId" column= "group_dept_id" />
<result property= "checkType" column= "check_type" />
<result property= "mainImage" column= "main_image" />
<result property= "imageUrls" column= "image_urls" />
<result property= "workingPositionType" column= "working_position_type" />
<result property= "checkWorkingPosition" column= "check_working_position" />
<result property= "checkingNum" column= "checking_num" />
<result property= "checkResult" column= "check_result" />
<result property= "intro" column= "intro" />
<result property= "qualityUser" column= "quality_user" />
<result property= "qualityUserName" column= "quality_user_name" />
<result property= "superviseUser" column= "supervise_user" />
<result property= "superviseUserName" column= "supervise_user_name" />
<result property= "groupDeptUser" column= "group_dept_user" />
<result property= "groupDeptUserName" column= "group_dept_user_name" />
<result property= "checkingDate" column= "checking_date" />
<result property= "checkingFiles" column= "checking_files" />
<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-20 15:46:23 +08:00
<result property= "projectName" column= "projectName" />
<result property= "deptName" column= "dept_name" />
2023-09-21 23:17:09 +08:00
<result property= "approveStatus" column= "approve_status" />
2023-08-18 17:58:35 +08:00
</resultMap>
<sql id= "selectSurProjectCheckingVo" >
2023-09-23 01:33:54 +08:00
select spc.id, spc.project_id, spc.dept_id, spc.group_dept_id, spc.check_type, spc.main_image, spc.image_urls, spc.working_position_type, spc.check_working_position, spc.checking_num, spc.check_result, spc.intro, spc.quality_user, spc.quality_user_name, spc.supervise_user, spc.supervise_user_name, spc.group_dept_user, spc.group_dept_user_name, spc.checking_date, spc.checking_files, spc.is_del, spc.create_by, spc.create_time, spc.update_by, spc.update_time, spc.remark, spc.approve_status, sp.projectName, sd.dept_name from sur_project_checking spc
left join sur_project sp on spc.project_id = sp.id
left join sys_dept sd on sd.dept_id = spc.dept_id
2023-08-18 17:58:35 +08:00
</sql>
<select id= "selectSurProjectCheckingList" parameterType= "SurProjectChecking" resultMap= "SurProjectCheckingResult" >
2023-09-21 23:17:09 +08:00
select spc.id, spc.project_id, spc.dept_id, spc.group_dept_id, spc.check_type, spc.main_image, spc.image_urls, spc.working_position_type, spc.check_working_position, spc.checking_num, spc.check_result, spc.intro, spc.quality_user, spc.quality_user_name, spc.supervise_user, spc.supervise_user_name, spc.group_dept_user, spc.group_dept_user_name, spc.checking_date, spc.checking_files, spc.is_del, spc.create_by, spc.create_time, spc.update_by, spc.update_time, spc.remark, spc.approve_status, sp.projectName, sd.dept_name from sur_project_checking spc
2023-08-20 15:46:23 +08:00
left join sur_project sp on spc.project_id = sp.id
left join sys_dept sd on sd.dept_id = spc.dept_id
<!-- 监理单位/总包公司/分包单位 -->
<if test= 'nowRole == "5" or nowRole == "6" or nowRole == "7"' > left join sur_project_unit_info spui on spui.projectId = sp.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 = sp.id</if>
2023-08-20 15:46:23 +08:00
<where >
2023-08-20 16:44:59 +08:00
and spc.is_del=0
2023-09-23 01:33:54 +08:00
<if test= "id != null " > and spc.id = #{id}</if>
2023-08-20 15:46:23 +08:00
<if test= "projectId != null " > and spc.project_id = #{projectId}</if>
<if test= "projectName != null and projectName != ''" > and sp.projectName like concat('%', #{projectName}, '%')</if>
2023-08-21 18:56:31 +08:00
<if test= "deptId != null " >
2023-08-24 18:42:44 +08:00
and spc.dept_id = #{deptId}
2023-08-21 18:56:31 +08:00
</if>
2023-08-20 15:46:23 +08:00
<if test= "deptName != null and deptName != ''" > and sd.dept_name like concat('%', #{deptName}, '%')</if>
<if test= "groupDeptId != null " > and spc.group_dept_id = #{groupDeptId}</if>
<if test= "checkType != null and checkType != ''" > and spc.check_type = #{checkType}</if>
2023-09-21 23:17:09 +08:00
<if test= "approveStatus != null and approveStatus != ''" > and spc.approve_status = #{approveStatus}</if>
2023-08-20 15:46:23 +08:00
<if test= "workingPositionType != null and workingPositionType != ''" > and spc.working_position_type = #{workingPositionType}</if>
<if test= "checkWorkingPosition != null and checkWorkingPosition != ''" > and spc.check_working_position like concat('%', #{checkWorkingPosition}, '%')</if>
<if test= "checkResult != null and checkResult != ''" > and spc.check_result = #{checkResult}</if>
<if test= "qualityUser != null and qualityUser != ''" > and (spc.quality_user like concat('%', #{qualityUser}, '%') or spc.quality_user_name like concat('%', #{qualityUser}, '%'))</if>
<if test= "qualityUserName != null and qualityUserName != ''" > and spc.quality_user_name like concat('%', #{qualityUserName}, '%')</if>
<if test= "superviseUser != null and superviseUser != ''" > and (spc.supervise_user like concat('%', #{superviseUser}, '%') or spc.supervise_user_name like concat('%', #{superviseUser}, '%'))</if>
<if test= "superviseUserName != null and superviseUserName != ''" > and spc.supervise_user_name like concat('%', #{superviseUserName}, '%')</if>
<if test= "groupDeptUser != null and groupDeptUser != ''" > and spc.group_dept_user like concat('%', #{groupDeptUser}, '%')</if>
<if test= "groupDeptUserName != null and groupDeptUserName != ''" > and spc.group_dept_user_name like concat('%', #{groupDeptUserName}, '%')</if>
<if test= "params.beginCheckingDate != null and params.beginCheckingDate != '' and params.endCheckingDate != null and params.endCheckingDate != ''" > and spc.checking_date between #{params.beginCheckingDate} and #{params.endCheckingDate}</if>
<if test= "isDel != null " > and spc.is_del = #{isDel}</if>
<!-- 查询条件 - 项目部门 -->
<if test= "projectDeptId != null " > and sp.deptId = #{projectDeptId}</if>
<!-- 子部门数据 -->
2023-08-22 14:02:51 +08:00
<if test= 'nowRole == "4"' > and (sp.deptId = #{nowDept} or spc.quality_user=#{nowUserName} or spc.supervise_user=#{nowUserName})</if>
2023-08-20 15:46:23 +08:00
<!-- 监理单位/总包公司/分包单位查询当前关联数据 -->
2023-08-24 18:42:44 +08:00
<if test= 'nowRole == "5" or nowRole == "6" or nowRole == "7"' > and spui.unitId = #{nowDept}</if>
2023-08-20 15:46:23 +08:00
<!-- 普通用户查询项目人员 -->
2023-09-05 00:45:38 +08:00
<if test= 'nowRole == "15" or nowRole == "16" or nowRole == "17" or nowRole == "99"' > and spu.is_del=0 and (spu.user_id = #{nowUser} or spc.quality_user=#{nowUserName} or spc.supervise_user=#{nowUserName})</if>
2023-08-18 17:58:35 +08:00
</where>
2023-08-20 15:46:23 +08:00
order by checking_date desc
2023-08-18 17:58:35 +08:00
</select>
2023-08-20 16:44:59 +08:00
<select id= "selectBgscreenProjectCheckingList" parameterType= "SurProjectChecking" resultMap= "SurProjectCheckingResult" >
2023-09-21 23:17:09 +08:00
select spc.id, spc.project_id, spc.dept_id, spc.group_dept_id, spc.check_type, spc.main_image, spc.image_urls, spc.working_position_type, spc.check_working_position, spc.checking_num, spc.check_result, spc.intro, spc.quality_user, spc.quality_user_name, spc.supervise_user, spc.supervise_user_name, spc.group_dept_user, spc.group_dept_user_name, spc.checking_date, spc.checking_files, spc.is_del, spc.create_by, spc.create_time, spc.update_by, spc.update_time, spc.remark, spc.approve_status, sp.projectName, sd.dept_name from sur_project_checking spc
2023-08-20 16:44:59 +08:00
left join sur_project sp on spc.project_id = sp.id
left join sys_dept sd on sd.dept_id = spc.dept_id
<!-- 监理单位/总包公司/分包单位 -->
<if test= 'nowRole == "5" or nowRole == "6" or nowRole == "7"' > left join sur_project_unit_info spui on spui.projectId = sp.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 = sp.id</if>
2023-08-20 16:44:59 +08:00
<where >
and spc.is_del=0
<if test= "projectId != null " > and spc.project_id = #{projectId}</if>
<if test= "projectName != null and projectName != ''" > and sp.projectName like concat('%', #{projectName}, '%')</if>
<if test= "deptId != null " > and spc.dept_id = #{deptId}</if>
<if test= "deptName != null and deptName != ''" > and sd.dept_name like concat('%', #{deptName}, '%')</if>
<if test= "groupDeptId != null " > and spc.group_dept_id = #{groupDeptId}</if>
<if test= "checkType != null and checkType != ''" > and spc.check_type = #{checkType}</if>
<if test= "workingPositionType != null and workingPositionType != ''" > and spc.working_position_type = #{workingPositionType}</if>
<if test= "checkWorkingPosition != null and checkWorkingPosition != ''" > and spc.check_working_position like concat('%', #{checkWorkingPosition}, '%')</if>
<if test= "checkResult != null and checkResult != ''" > and spc.check_result = #{checkResult}</if>
<if test= "qualityUser != null and qualityUser != ''" > and (spc.quality_user like concat('%', #{qualityUser}, '%') or spc.quality_user_name like concat('%', #{qualityUser}, '%'))</if>
<if test= "qualityUserName != null and qualityUserName != ''" > and spc.quality_user_name like concat('%', #{qualityUserName}, '%')</if>
<if test= "superviseUser != null and superviseUser != ''" > and (spc.supervise_user like concat('%', #{superviseUser}, '%') or spc.supervise_user_name like concat('%', #{superviseUser}, '%'))</if>
<if test= "superviseUserName != null and superviseUserName != ''" > and spc.supervise_user_name like concat('%', #{superviseUserName}, '%')</if>
<if test= "groupDeptUser != null and groupDeptUser != ''" > and spc.group_dept_user like concat('%', #{groupDeptUser}, '%')</if>
<if test= "groupDeptUserName != null and groupDeptUserName != ''" > and spc.group_dept_user_name like concat('%', #{groupDeptUserName}, '%')</if>
<if test= "params.beginCheckingDate != null and params.beginCheckingDate != '' and params.endCheckingDate != null and params.endCheckingDate != ''" > and spc.checking_date between #{params.beginCheckingDate} and #{params.endCheckingDate}</if>
<if test= "isDel != null " > and spc.is_del = #{isDel}</if>
<!-- 查询条件 - 项目部门 -->
<if test= "projectDeptId != null " > and sp.deptId = #{projectDeptId}</if>
<!-- 子部门数据 -->
<if test= 'nowRole == "4"' > and sp.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-20 16:44:59 +08:00
</where>
order by checking_date desc
limit 0,10
</select>
<select id= "selectBgscreenProjectCheckingView" parameterType= "SurProjectChecking" resultType= "map" >
select spc.check_result, count(spc.id) as total from sur_project_checking spc
left join sur_project sp on spc.project_id = sp.id
<where >
and spc.is_del=0
<if test= "projectId != null " > and spc.project_id = #{projectId}</if>
<if test= "projectDeptId != null " > and sp.deptId = #{projectDeptId}</if>
</where>
group by check_result
</select>
2023-08-18 17:58:35 +08:00
<select id= "selectSurProjectCheckingById" parameterType= "Long" resultMap= "SurProjectCheckingResult" >
2023-09-21 23:17:09 +08:00
select spc.id, spc.project_id, spc.dept_id, spc.group_dept_id, spc.check_type, spc.main_image, spc.image_urls, spc.working_position_type, spc.check_working_position, spc.checking_num, spc.check_result, spc.intro, spc.quality_user, spc.quality_user_name, spc.supervise_user, spc.supervise_user_name, spc.group_dept_user, spc.group_dept_user_name, spc.checking_date, spc.checking_files, spc.is_del, spc.create_by, spc.create_time, spc.update_by, spc.update_time, spc.remark, spc.approve_status, sp.projectName, sd.dept_name from sur_project_checking spc
2023-08-21 18:56:31 +08:00
left join sur_project sp on spc.project_id = sp.id
left join sys_dept sd on sd.dept_id = spc.dept_id
where spc.id = #{id}
2023-08-18 17:58:35 +08:00
</select>
2023-09-03 14:07:36 +08:00
<select id= "findStatisticsByProjectId" parameterType= "Long" resultType= "map" >
SELECT
spc.project_id,
count(1) AS total,
pass.pass
FROM
sur_project_checking spc
LEFT JOIN (
SELECT
pass.project_id,
count(1) AS pass
FROM
sur_project_checking pass
WHERE
pass.is_del = 0
AND pass.check_result = '1'
AND pass.project_id = #{projectId}
GROUP BY
pass.project_id
) pass ON pass.project_id = spc.project_id
WHERE
is_del = 0
AND spc.project_id = #{projectId}
GROUP BY
spc.project_id
</select>
2023-08-18 17:58:35 +08:00
<insert id= "insertSurProjectChecking" parameterType= "SurProjectChecking" useGeneratedKeys= "true" keyProperty= "id" >
insert into sur_project_checking
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "projectId != null" > project_id,</if>
<if test= "deptId != null" > dept_id,</if>
<if test= "groupDeptId != null" > group_dept_id,</if>
<if test= "checkType != null" > check_type,</if>
<if test= "mainImage != null" > main_image,</if>
<if test= "imageUrls != null" > image_urls,</if>
<if test= "workingPositionType != null" > working_position_type,</if>
<if test= "checkWorkingPosition != null" > check_working_position,</if>
<if test= "checkingNum != null" > checking_num,</if>
<if test= "checkResult != null" > check_result,</if>
<if test= "intro != null" > intro,</if>
<if test= "qualityUser != null" > quality_user,</if>
<if test= "qualityUserName != null" > quality_user_name,</if>
<if test= "superviseUser != null" > supervise_user,</if>
<if test= "superviseUserName != null" > supervise_user_name,</if>
<if test= "groupDeptUser != null" > group_dept_user,</if>
<if test= "groupDeptUserName != null" > group_dept_user_name,</if>
<if test= "checkingDate != null" > checking_date,</if>
<if test= "checkingFiles != null" > checking_files,</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>
2023-09-21 23:17:09 +08:00
<if test= "approveStatus != null" > approve_status,</if>
2023-08-18 17:58:35 +08:00
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
<if test= "projectId != null" > #{projectId},</if>
<if test= "deptId != null" > #{deptId},</if>
<if test= "groupDeptId != null" > #{groupDeptId},</if>
<if test= "checkType != null" > #{checkType},</if>
<if test= "mainImage != null" > #{mainImage},</if>
<if test= "imageUrls != null" > #{imageUrls},</if>
<if test= "workingPositionType != null" > #{workingPositionType},</if>
<if test= "checkWorkingPosition != null" > #{checkWorkingPosition},</if>
<if test= "checkingNum != null" > #{checkingNum},</if>
<if test= "checkResult != null" > #{checkResult},</if>
<if test= "intro != null" > #{intro},</if>
<if test= "qualityUser != null" > #{qualityUser},</if>
<if test= "qualityUserName != null" > #{qualityUserName},</if>
<if test= "superviseUser != null" > #{superviseUser},</if>
<if test= "superviseUserName != null" > #{superviseUserName},</if>
<if test= "groupDeptUser != null" > #{groupDeptUser},</if>
<if test= "groupDeptUserName != null" > #{groupDeptUserName},</if>
<if test= "checkingDate != null" > #{checkingDate},</if>
<if test= "checkingFiles != null" > #{checkingFiles},</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>
2023-09-21 23:17:09 +08:00
<if test= "approveStatus != null" > #{approveStatus},</if>
2023-08-18 17:58:35 +08:00
</trim>
</insert>
<update id= "updateSurProjectChecking" parameterType= "SurProjectChecking" >
update sur_project_checking
<trim prefix= "SET" suffixOverrides= "," >
<if test= "projectId != null" > project_id = #{projectId},</if>
<if test= "deptId != null" > dept_id = #{deptId},</if>
<if test= "groupDeptId != null" > group_dept_id = #{groupDeptId},</if>
<if test= "checkType != null" > check_type = #{checkType},</if>
<if test= "mainImage != null" > main_image = #{mainImage},</if>
<if test= "imageUrls != null" > image_urls = #{imageUrls},</if>
<if test= "workingPositionType != null" > working_position_type = #{workingPositionType},</if>
<if test= "checkWorkingPosition != null" > check_working_position = #{checkWorkingPosition},</if>
<if test= "checkingNum != null" > checking_num = #{checkingNum},</if>
<if test= "checkResult != null" > check_result = #{checkResult},</if>
<if test= "intro != null" > intro = #{intro},</if>
<if test= "qualityUser != null" > quality_user = #{qualityUser},</if>
<if test= "qualityUserName != null" > quality_user_name = #{qualityUserName},</if>
<if test= "superviseUser != null" > supervise_user = #{superviseUser},</if>
<if test= "superviseUserName != null" > supervise_user_name = #{superviseUserName},</if>
<if test= "groupDeptUser != null" > group_dept_user = #{groupDeptUser},</if>
<if test= "groupDeptUserName != null" > group_dept_user_name = #{groupDeptUserName},</if>
<if test= "checkingDate != null" > checking_date = #{checkingDate},</if>
<if test= "checkingFiles != null" > checking_files = #{checkingFiles},</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>
2023-09-21 23:17:09 +08:00
<if test= "approveStatus != null" > approve_status = #{approveStatus},</if>
2023-08-18 17:58:35 +08:00
</trim>
where id = #{id}
</update>
<delete id= "deleteSurProjectCheckingById" parameterType= "Long" >
delete from sur_project_checking where id = #{id}
</delete>
<delete id= "deleteSurProjectCheckingByIds" parameterType= "String" >
delete from sur_project_checking where id in
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
</mapper>