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.SurProjectWorkAttendanceMapper" >
<resultMap type= "SurProjectWorkAttendance" id= "SurProjectWorkAttendanceResult" >
<result property= "id" column= "id" />
2023-08-16 11:51:34 +08:00
<result property= "projectId" column= "project_id" />
2023-08-17 19:39:25 +08:00
<result property= "projectName" column= "project_name" />
2023-08-10 21:09:49 +08:00
<result property= "deptId" column= "dept_id" />
2023-08-17 19:39:25 +08:00
<result property= "deptName" column= "dept_name" />
2023-08-10 21:09:49 +08:00
<result property= "servicePersonnel" column= "service_personnel" />
<result property= "supervisorPersonnel" column= "supervisor_personnel" />
<result property= "contractorPersonnel" column= "contractor_personnel" />
<result property= "workDate" column= "work_date" />
<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" />
</resultMap>
<sql id= "selectSurProjectWorkAttendanceVo" >
2023-08-16 11:51:34 +08:00
select id, project_id, dept_id, service_personnel, supervisor_personnel, contractor_personnel, work_date, is_del, create_by, create_time, update_by, update_time, remark from sur_project_work_attendance
2023-08-10 21:09:49 +08:00
</sql>
<select id= "selectSurProjectWorkAttendanceList" parameterType= "SurProjectWorkAttendance" resultMap= "SurProjectWorkAttendanceResult" >
2023-08-16 11:51:34 +08:00
SELECT
spwa.id,
spwa.project_id,
2023-08-17 19:39:25 +08:00
sp.projectName as project_name,
2023-08-16 11:51:34 +08:00
spwa.dept_id,
2023-08-17 19:39:25 +08:00
d.dept_name,
2023-08-16 11:51:34 +08:00
IFNULL(spwa.service_personnel, 0) AS service_personnel,
IFNULL(spwa.supervisor_personnel, 0) AS supervisor_personnel,
IFNULL(spwa.contractor_personnel, 0) AS contractor_personnel,
spwa.work_date,
spwa.is_del,
spwa.create_by,
spwa.create_time,
spwa.update_by,
spwa.update_time,
spwa.remark
FROM
sur_project_work_attendance spwa
2023-08-17 19:39:25 +08:00
left join sur_project sp on sp.id=spwa.project_id
left join sys_dept d on d.dept_id=spwa.dept_id
2023-08-17 23:39:50 +08:00
<!-- 监理单位/总包公司/分包单位 -->
<if test= 'nowRole == "5" or nowRole == "6" or nowRole == "7"' > left join sur_project_unit_info spui on spui.projectId = sp.id</if>
<!-- 普通用户查询项目人员 -->
<if test= 'nowRole == "99"' > left join sur_project_userinfo spu on spu.project_id = sp.id</if>
2023-08-16 11:51:34 +08:00
<where >
2023-08-16 20:40:54 +08:00
and spwa.is_del=0
2023-08-16 11:51:34 +08:00
<if test= "projectId != null " > and spwa.project_id = #{projectId}</if>
2023-08-17 19:39:25 +08:00
<if test= "projectName != null and projectName != ''" > and sp.projectName like concat('%', #{projectName}, '%')</if>
2023-08-16 11:51:34 +08:00
<if test= "deptId != null " > and spwa.dept_id = #{deptId}</if>
2023-08-17 19:39:25 +08:00
<if test= "deptName != null and deptName != ''" > and d.dept_name like concat('%', #{deptName}, '%')</if>
2023-08-16 11:51:34 +08:00
<if test= "params.beginWorkDate != null and params.beginWorkDate != '' and params.endWorkDate != null and params.endWorkDate != ''" > and spwa.work_date between #{params.beginWorkDate} and #{params.endWorkDate}</if>
2023-08-19 13:22:38 +08:00
<if test= "workDate != null" > and date(spwa.work_date)=date(#{workDate})</if>
2023-08-17 23:39:50 +08:00
<!-- 查询条件 - 项目部门 -->
<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>
<!-- 普通用户查询项目人员 -->
<if test= 'nowRole == "99"' > and spu.user_id = #{nowUser} and spu.is_del=0</if>
2023-08-10 21:09:49 +08:00
</where>
</select>
2023-08-16 20:40:54 +08:00
<select id= "selectBgscreenWorkAttendanceList" parameterType= "SurProjectWorkAttendance" resultMap= "SurProjectWorkAttendanceResult" >
SELECT
<if test= "projectId != null " > spwa.project_id,</if>
<if test= "deptId != null and projectId == null " > spwa.dept_id,</if>
SUM(spwa.service_personnel) AS service_personnel,
SUM(spwa.supervisor_personnel) AS supervisor_personnel,
SUM(spwa.contractor_personnel) AS contractor_personnel
FROM
sur_project_work_attendance spwa
<where >
and spwa.is_del=0
<if test= "projectId != null " > and spwa.project_id = #{projectId}</if>
<if test= "deptId != null " > and spwa.dept_id = #{deptId}</if>
2023-08-18 00:58:57 +08:00
<if test= "workDate != null" > and date(spwa.work_date)=date(#{workDate})</if>
2023-08-16 20:40:54 +08:00
</where>
<if test= "projectId != null " > group by spwa.project_id</if>
<if test= "deptId != null and projectId == null" > group by spwa.dept_id</if>
</select>
2023-08-10 21:09:49 +08:00
<select id= "selectSurProjectWorkAttendanceById" parameterType= "Long" resultMap= "SurProjectWorkAttendanceResult" >
<include refid= "selectSurProjectWorkAttendanceVo" />
where id = #{id}
</select>
<insert id= "insertSurProjectWorkAttendance" parameterType= "SurProjectWorkAttendance" useGeneratedKeys= "true" keyProperty= "id" >
insert into sur_project_work_attendance
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
2023-08-16 11:51:34 +08:00
<if test= "projectId != null" > project_id,</if>
2023-08-10 21:09:49 +08:00
<if test= "deptId != null" > dept_id,</if>
<if test= "servicePersonnel != null" > service_personnel,</if>
<if test= "supervisorPersonnel != null" > supervisor_personnel,</if>
<if test= "contractorPersonnel != null" > contractor_personnel,</if>
<if test= "workDate != null" > work_date,</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= "," >
2023-08-16 11:51:34 +08:00
<if test= "projectId != null" > #{projectId},</if>
2023-08-10 21:09:49 +08:00
<if test= "deptId != null" > #{deptId},</if>
<if test= "servicePersonnel != null" > #{servicePersonnel},</if>
<if test= "supervisorPersonnel != null" > #{supervisorPersonnel},</if>
<if test= "contractorPersonnel != null" > #{contractorPersonnel},</if>
<if test= "workDate != null" > #{workDate},</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= "updateSurProjectWorkAttendance" parameterType= "SurProjectWorkAttendance" >
update sur_project_work_attendance
<trim prefix= "SET" suffixOverrides= "," >
2023-08-16 11:51:34 +08:00
<if test= "projectId != null" > project_id = #{projectId},</if>
2023-08-10 21:09:49 +08:00
<if test= "deptId != null" > dept_id = #{deptId},</if>
<if test= "servicePersonnel != null" > service_personnel = #{servicePersonnel},</if>
<if test= "supervisorPersonnel != null" > supervisor_personnel = #{supervisorPersonnel},</if>
<if test= "contractorPersonnel != null" > contractor_personnel = #{contractorPersonnel},</if>
<if test= "workDate != null" > work_date = #{workDate},</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>
2023-08-17 19:39:25 +08:00
<update id= "deleteSurProjectWorkAttendanceById" parameterType= "Long" >
update sur_project_work_attendance set is_del=1 where id = #{id}
</update>
2023-08-10 21:09:49 +08:00
2023-08-17 19:39:25 +08:00
<update id= "deleteSurProjectWorkAttendanceByIds" parameterType= "String" >
update sur_project_work_attendance set is_del=1 where id in
2023-08-10 21:09:49 +08:00
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
2023-08-17 19:39:25 +08:00
</update>
2023-08-14 00:02:18 +08:00
<select id= "selectByDate" parameterType= "SurProjectWorkAttendance" resultMap= "SurProjectWorkAttendanceResult" >
<include refid= "selectSurProjectWorkAttendanceVo" />
<where >
2023-08-16 11:51:34 +08:00
<if test= "projectId != null " > and project_id = #{projectId}</if>
2023-08-14 00:02:18 +08:00
<if test= "deptId != null " > and dept_id = #{deptId}</if>
<if test= "createTime != null" > and date(create_time)=date(#{createTime}) </if>
and is_del = 0
</where>
</select>
2023-08-10 21:09:49 +08:00
</mapper>