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.SurProjectWorkSpecialMapper" >
<resultMap type= "SurProjectWorkSpecial" id= "SurProjectWorkSpecialResult" >
<result property= "id" column= "id" />
<result property= "projectId" column= "project_id" />
<result property= "deptId" column= "dept_id" />
<result property= "name" column= "name" />
<result property= "sex" column= "sex" />
<result property= "age" column= "age" />
2023-08-14 22:51:52 +08:00
<result property= "phoneNumber" column= "phone_number" />
2023-08-10 21:09:49 +08:00
<result property= "idNumber" column= "id_number" />
<result property= "isCredential" column= "is_credential" />
<result property= "credentialNumber" column= "credential_number" />
<result property= "credentialExpirationTime" column= "credential_expiration_time" />
2023-08-14 22:51:52 +08:00
<result property= "credentialFile" column= "credential_file" />
2023-08-15 17:48:24 +08:00
<result property= "credentialType" column= "credential_type" />
2023-08-10 21:09:49 +08:00
<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-12 21:32:32 +08:00
<result property= "projectName" column= "projectName" />
<result property= "deptName" column= "dept_name" />
2023-08-10 21:09:49 +08:00
</resultMap>
<sql id= "selectSurProjectWorkSpecialVo" >
2023-08-15 17:48:24 +08:00
select id, project_id, dept_id, name, sex, age, phone_number, id_number, is_credential, credential_number, credential_expiration_time, credential_file, credential_type, is_del, create_by, create_time, update_by, update_time, remark from sur_project_work_special
2023-08-10 21:09:49 +08:00
</sql>
<select id= "selectSurProjectWorkSpecialList" parameterType= "SurProjectWorkSpecial" resultMap= "SurProjectWorkSpecialResult" >
2023-08-15 17:48:24 +08:00
select spwp.id, spwp.project_id, spwp.dept_id, spwp.name, spwp.sex, spwp.age, spwp.phone_number, spwp.id_number, spwp.is_credential, spwp.credential_number, spwp.credential_expiration_time, spwp.credential_file, spwp.credential_type, spwp.is_del, spwp.create_by, spwp.create_time, spwp.update_by, spwp.update_time, spwp.remark, sp.projectName, sd.dept_name from sur_project_work_special spwp
2023-08-12 21:32:32 +08:00
left join sur_project sp on sp.id = spwp.project_id
left join sys_dept sd on sd.dept_id = spwp.dept_id
<where >
<if test= "projectId != null " > and spwp.project_id = #{projectId}</if>
<if test= "deptId != null " > and spwp.dept_id = #{deptId}</if>
<if test= "name != null and name != ''" > and spwp.name like concat('%', #{name}, '%')</if>
<if test= "projectName != null and projectName != ''" > and sp.projectName like concat('%', #{projectName}, '%')</if>
<if test= "isCredential != null and isCredential != ''" > and spwp.is_credential = #{isCredential}</if>
2023-08-15 17:48:24 +08:00
<if test= "phoneNumber != null and phoneNumber != ''" > and spwp.phone_number like concat('%', #{phoneNumber}, '%')</if>
<if test= "credentialNumber != null and credentialNumber != ''" > and spwp.credential_number like concat('%', #{credentialNumber}, '%')</if>
2023-08-12 21:32:32 +08:00
<if test= "params.beginCredentialExpirationTime != null and params.beginCredentialExpirationTime != '' and params.endCredentialExpirationTime != null and params.endCredentialExpirationTime != ''" > and spwp.credential_expiration_time between #{params.beginCredentialExpirationTime} and #{params.endCredentialExpirationTime}</if>
<if test= "isDel != null and isDel != ''" > and spwp.is_del = #{isDel}</if>
2023-08-15 17:48:24 +08:00
<if test= "credentialType != null and credentialType != ''" > and spwp.credential_type = #{credentialType}</if>
2023-08-12 21:32:32 +08:00
<!-- 查询条件 - 项目部门 -->
<if test= "projectDeptId != null " > and sp.deptId = #{projectDeptId}</if>
<!-- 子部门数据 -->
<if test= 'nowRole == "4"' > and sp.deptId = #{nowDept}</if>
<!-- 监理单位/总包公司/分包单位查询当前关联数据 -->
2023-08-15 17:48:24 +08:00
<if test= 'nowRole == "5" or nowRole == "6" or nowRole == "7"' > and sp.id in (select DISTINCT spui.projectId from sur_project_unit_info spui where spui.unitId = #{nowDept})</if>
<if test= 'nowRole == "99"' > and sp.id in (select DISTINCT spu.project_id from sur_project_userinfo spu where spu.user_id = #{nowUser} and spu.is_del=0)</if>
2023-08-10 21:09:49 +08:00
</where>
</select>
2023-08-15 17:48:24 +08:00
<!-- 查询项目特种人员统计列表 -->
<select id= "selectBgscreenWorkSpecialList" parameterType= "SurProjectWorkSpecial" resultType= "map" >
SELECT
spws.project_id as projectId,
sp.projectName,
count(1) AS total,
IFNULL(expired.expired, 0) AS expired,
IFNULL(void.void, 0) AS void
FROM
sur_project_work_special spws
LEFT JOIN sur_project sp ON sp.id = spws.project_id
LEFT JOIN (
SELECT
s1.project_id AS pid,
count(1) AS expired
FROM
sur_project_work_special s1
left join sur_project sp1 on sp1.id = s1.project_id
WHERE
s1.is_del = 0
<if test= "nowDept != null and nowDept != ''" > and sp1.deptId = #{nowDept}</if>
<if test= "projectId != null " > and s1.project_id = #{projectId}</if>
AND s1.credential_expiration_time > NOW()
AND DATE_SUB(
s1.credential_expiration_time,
INTERVAL 1 MONTH
) <![CDATA[ <= ]]> NOW()
GROUP BY
s1.project_id
) expired ON expired.pid = spws.project_id
LEFT JOIN (
SELECT
s2.project_id AS pid,
count(1) AS void
FROM
sur_project_work_special s2
left join sur_project sp2 on sp2.id = s2.project_id
WHERE
s2.is_del = 0
<if test= "nowDept != null and nowDept != ''" > and sp2.deptId = #{nowDept}</if>
<if test= "projectId != null " > and s2.project_id = #{projectId}</if>
AND s2.credential_expiration_time <![CDATA[ < ]]> NOW()
GROUP BY
s2.project_id
) void ON void.pid = spws.project_id
WHERE
spws.is_del = 0
<if test= "nowDept != null and nowDept != ''" > and sp.deptId = #{nowDept}</if>
<if test= "projectId != null " > and spws.project_id = #{projectId}</if>
GROUP BY
spws.project_id
ORDER BY
sp.projectSort ASC
</select>
2023-08-10 21:09:49 +08:00
<select id= "selectSurProjectWorkSpecialById" parameterType= "Long" resultMap= "SurProjectWorkSpecialResult" >
<include refid= "selectSurProjectWorkSpecialVo" />
where id = #{id}
</select>
<insert id= "insertSurProjectWorkSpecial" parameterType= "SurProjectWorkSpecial" useGeneratedKeys= "true" keyProperty= "id" >
insert into sur_project_work_special
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "projectId != null" > project_id,</if>
<if test= "deptId != null" > dept_id,</if>
<if test= "name != null" > name,</if>
<if test= "sex != null" > sex,</if>
<if test= "age != null" > age,</if>
2023-08-14 22:51:52 +08:00
<if test= "phoneNumber != null" > phone_number,</if>
2023-08-10 21:09:49 +08:00
<if test= "idNumber != null" > id_number,</if>
<if test= "isCredential != null" > is_credential,</if>
<if test= "credentialNumber != null" > credential_number,</if>
<if test= "credentialExpirationTime != null" > credential_expiration_time,</if>
2023-08-14 22:51:52 +08:00
<if test= "credentialFile != null" > credential_file,</if>
2023-08-15 17:48:24 +08:00
<if test= "credentialType != null" > credential_type,</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= "projectId != null" > #{projectId},</if>
<if test= "deptId != null" > #{deptId},</if>
<if test= "name != null" > #{name},</if>
<if test= "sex != null" > #{sex},</if>
<if test= "age != null" > #{age},</if>
2023-08-14 22:51:52 +08:00
<if test= "phoneNumber != null" > #{phoneNumber},</if>
2023-08-10 21:09:49 +08:00
<if test= "idNumber != null" > #{idNumber},</if>
<if test= "isCredential != null" > #{isCredential},</if>
<if test= "credentialNumber != null" > #{credentialNumber},</if>
<if test= "credentialExpirationTime != null" > #{credentialExpirationTime},</if>
2023-08-14 22:51:52 +08:00
<if test= "credentialFile != null" > #{credentialFile},</if>
2023-08-15 17:48:24 +08:00
<if test= "credentialType != null" > #{credentialType},</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= "updateSurProjectWorkSpecial" parameterType= "SurProjectWorkSpecial" >
update sur_project_work_special
<trim prefix= "SET" suffixOverrides= "," >
<if test= "projectId != null" > project_id = #{projectId},</if>
<if test= "deptId != null" > dept_id = #{deptId},</if>
<if test= "name != null" > name = #{name},</if>
<if test= "sex != null" > sex = #{sex},</if>
<if test= "age != null" > age = #{age},</if>
2023-08-14 22:51:52 +08:00
<if test= "phoneNumber != null" > phone_number = #{phoneNumber},</if>
2023-08-10 21:09:49 +08:00
<if test= "idNumber != null" > id_number = #{idNumber},</if>
<if test= "isCredential != null" > is_credential = #{isCredential},</if>
<if test= "credentialNumber != null" > credential_number = #{credentialNumber},</if>
<if test= "credentialExpirationTime != null" > credential_expiration_time = #{credentialExpirationTime},</if>
2023-08-14 22:51:52 +08:00
<if test= "credentialFile != null" > credential_file = #{credentialFile},</if>
2023-08-15 17:48:24 +08:00
<if test= "credentialType != null" > credential_type = #{credentialType},</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= "deleteSurProjectWorkSpecialById" parameterType= "Long" >
delete from sur_project_work_special where id = #{id}
</delete>
<delete id= "deleteSurProjectWorkSpecialByIds" parameterType= "String" >
delete from sur_project_work_special where id in
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
</mapper>