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-10 21:09:49 +08:00
<result property= "deptId" column= "dept_id" />
<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,
spwa.dept_id,
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
<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>
<if test= "deptId != null " > and spwa.dept_id = #{deptId}</if>
<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>
<if test= "workDate != null" > and DATE_FORMAT(spwa.work_date,'%Y-%m-%d')=DATE_FORMAT(#{workDate},'%Y-%m-%d')</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>
<if test= "workDate != null" > and DATE_FORMAT(spwa.work_date,'%Y-%m-%d')=DATE_FORMAT(#{workDate},'%Y-%m-%d')</if>
</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>
<delete id= "deleteSurProjectWorkAttendanceById" parameterType= "Long" >
delete from sur_project_work_attendance where id = #{id}
</delete>
<delete id= "deleteSurProjectWorkAttendanceByIds" parameterType= "String" >
delete from sur_project_work_attendance where id in
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
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>