2023-09-24 18:35:52 +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.SurProjectAttendanceUserMapper" >
<resultMap type= "SurProjectAttendanceUser" id= "SurProjectAttendanceUserResult" >
<result property= "id" column= "id" />
2023-09-25 00:32:36 +08:00
<result property= "cfgid" column= "cfgid" />
<result property= "vendorsCode" column= "vendors_code" />
2023-09-24 18:35:52 +08:00
<result property= "workerId" column= "workerId" />
<result property= "laborWorkerId" column= "laborWorkerId" />
<result property= "workerCategory" column= "workerCategory" />
<result property= "qrCode" column= "qrCode" />
<result property= "name" column= "name" />
<result property= "ethnic" column= "ethnic" />
<result property= "nativePlace" column= "nativePlace" />
<result property= "gender" column= "gender" />
<result property= "birthDate" column= "birthDate" />
<result property= "phone" column= "phone" />
<result property= "degreeName" column= "degreeName" />
<result property= "photo" column= "photo" />
<result property= "recentPhoto" column= "recentPhoto" />
<result property= "groupId" column= "groupId" />
<result property= "groupName" column= "groupName" />
<result property= "leader" column= "leader" />
<result property= "workTypeCode" column= "workTypeCode" />
<result property= "workTypeName" column= "workTypeName" />
<result property= "specWorkType" column= "specWorkType" />
<result property= "hatCode" column= "hatCode" />
<result property= "state" column= "state" />
<result property= "enterDate" column= "enterDate" />
<result property= "exitDate" column= "exitDate" />
<result property= "companyId" column= "companyId" />
<result property= "companyName" column= "companyName" />
<result property= "vendorId" column= "vendorId" />
<result property= "teamId" column= "teamId" />
<result property= "teamName" column= "teamName" />
<result property= "enterType" column= "enterType" />
<result property= "other" column= "other" />
<result property= "remark" column= "remark" />
<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" />
2023-09-29 00:24:15 +08:00
<result property= "projectId" column= "project_id" />
<result property= "subDeptId" column= "sub_dept_id" />
2023-09-24 18:35:52 +08:00
</resultMap>
<sql id= "selectSurProjectAttendanceUserVo" >
2023-09-29 00:24:15 +08:00
SELECT * FROM (
SELECT a.*,b.project_id,b.sub_dept_id
FROM sur_project_attendance_user a,sur_project_attendance_cfg b
WHERE a.cfgid=b.id )
sur_project_attendance_user
2023-09-24 18:35:52 +08:00
</sql>
<select id= "selectSurProjectAttendanceUserList" parameterType= "SurProjectAttendanceUser" resultMap= "SurProjectAttendanceUserResult" >
<include refid= "selectSurProjectAttendanceUserVo" />
<where >
2023-09-25 00:32:36 +08:00
<if test= "cfgid != null " > and cfgid = #{cfgid}</if>
<if test= "vendorsCode != null and vendorsCode != ''" > and vendors_code = #{vendorsCode}</if>
2023-09-24 18:35:52 +08:00
<if test= "workerId != null " > and workerId = #{workerId}</if>
<if test= "laborWorkerId != null " > and laborWorkerId = #{laborWorkerId}</if>
<if test= "workerCategory != null " > and workerCategory = #{workerCategory}</if>
<if test= "qrCode != null " > and qrCode = #{qrCode}</if>
<if test= "name != null and name != ''" > and name like concat('%', #{name}, '%')</if>
<if test= "ethnic != null and ethnic != ''" > and ethnic = #{ethnic}</if>
<if test= "nativePlace != null and nativePlace != ''" > and nativePlace = #{nativePlace}</if>
<if test= "gender != null " > and gender = #{gender}</if>
<if test= "birthDate != null " > and birthDate = #{birthDate}</if>
<if test= "phone != null and phone != ''" > and phone = #{phone}</if>
<if test= "degreeName != null and degreeName != ''" > and degreeName like concat('%', #{degreeName}, '%')</if>
<if test= "photo != null and photo != ''" > and photo = #{photo}</if>
<if test= "recentPhoto != null and recentPhoto != ''" > and recentPhoto = #{recentPhoto}</if>
<if test= "groupId != null " > and groupId = #{groupId}</if>
<if test= "groupName != null and groupName != ''" > and groupName like concat('%', #{groupName}, '%')</if>
<if test= "leader != null " > and leader = #{leader}</if>
<if test= "workTypeCode != null and workTypeCode != ''" > and workTypeCode = #{workTypeCode}</if>
<if test= "workTypeName != null and workTypeName != ''" > and workTypeName like concat('%', #{workTypeName}, '%')</if>
<if test= "specWorkType != null " > and specWorkType = #{specWorkType}</if>
<if test= "hatCode != null and hatCode != ''" > and hatCode = #{hatCode}</if>
<if test= "state != null " > and state = #{state}</if>
<if test= "enterDate != null and enterDate != ''" > and enterDate = #{enterDate}</if>
<if test= "exitDate != null and exitDate != ''" > and exitDate = #{exitDate}</if>
<if test= "companyId != null " > and companyId = #{companyId}</if>
<if test= "companyName != null and companyName != ''" > and companyName like concat('%', #{companyName}, '%')</if>
<if test= "vendorId != null " > and vendorId = #{vendorId}</if>
<if test= "teamId != null " > and teamId = #{teamId}</if>
<if test= "teamName != null and teamName != ''" > and teamName like concat('%', #{teamName}, '%')</if>
<if test= "enterType != null and enterType != ''" > and enterType = #{enterType}</if>
<if test= "other != null and other != ''" > and other = #{other}</if>
2023-09-29 00:24:15 +08:00
<if test= "projectId != null and projectId > 0 " > and project_id = #{projectId}</if>
<if test= "subDeptId != null and subDeptId >0 " > and sub_dept_id = #{subDeptId}</if>
2023-09-24 18:35:52 +08:00
<if test= "isDel != null " > and is_del = #{isDel}</if>
</where>
</select>
<select id= "selectSurProjectAttendanceUserById" parameterType= "Long" resultMap= "SurProjectAttendanceUserResult" >
<include refid= "selectSurProjectAttendanceUserVo" />
where id = #{id}
</select>
<insert id= "insertSurProjectAttendanceUser" parameterType= "SurProjectAttendanceUser" useGeneratedKeys= "true" keyProperty= "id" >
insert into sur_project_attendance_user
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
2023-09-25 00:32:36 +08:00
<if test= "cfgid != null" > cfgid,</if>
<if test= "vendorsCode != null" > vendors_code,</if>
2023-09-24 18:35:52 +08:00
<if test= "workerId != null" > workerId,</if>
<if test= "laborWorkerId != null" > laborWorkerId,</if>
<if test= "workerCategory != null" > workerCategory,</if>
<if test= "qrCode != null" > qrCode,</if>
<if test= "name != null" > name,</if>
<if test= "ethnic != null" > ethnic,</if>
<if test= "nativePlace != null" > nativePlace,</if>
<if test= "gender != null" > gender,</if>
<if test= "birthDate != null" > birthDate,</if>
<if test= "phone != null and phone != ''" > phone,</if>
<if test= "degreeName != null" > degreeName,</if>
<if test= "photo != null" > photo,</if>
<if test= "recentPhoto != null" > recentPhoto,</if>
<if test= "groupId != null" > groupId,</if>
<if test= "groupName != null" > groupName,</if>
<if test= "leader != null" > leader,</if>
<if test= "workTypeCode != null" > workTypeCode,</if>
<if test= "workTypeName != null" > workTypeName,</if>
<if test= "specWorkType != null" > specWorkType,</if>
<if test= "hatCode != null" > hatCode,</if>
<if test= "state != null" > state,</if>
<if test= "enterDate != null" > enterDate,</if>
<if test= "exitDate != null" > exitDate,</if>
<if test= "companyId != null" > companyId,</if>
<if test= "companyName != null" > companyName,</if>
<if test= "vendorId != null" > vendorId,</if>
<if test= "teamId != null" > teamId,</if>
<if test= "teamName != null" > teamName,</if>
<if test= "enterType != null" > enterType,</if>
<if test= "other != null and other != ''" > other,</if>
<if test= "remark != null" > remark,</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>
</trim>
<trim prefix= "values (" suffix= ")" suffixOverrides= "," >
2023-09-25 00:32:36 +08:00
<if test= "cfgid != null" > #{cfgid},</if>
<if test= "vendorsCode != null" > #{vendorsCode},</if>
2023-09-24 18:35:52 +08:00
<if test= "workerId != null" > #{workerId},</if>
<if test= "laborWorkerId != null" > #{laborWorkerId},</if>
<if test= "workerCategory != null" > #{workerCategory},</if>
<if test= "qrCode != null" > #{qrCode},</if>
<if test= "name != null" > #{name},</if>
<if test= "ethnic != null" > #{ethnic},</if>
<if test= "nativePlace != null" > #{nativePlace},</if>
<if test= "gender != null" > #{gender},</if>
<if test= "birthDate != null" > #{birthDate},</if>
<if test= "phone != null and phone != ''" > #{phone},</if>
<if test= "degreeName != null" > #{degreeName},</if>
<if test= "photo != null" > #{photo},</if>
<if test= "recentPhoto != null" > #{recentPhoto},</if>
<if test= "groupId != null" > #{groupId},</if>
<if test= "groupName != null" > #{groupName},</if>
<if test= "leader != null" > #{leader},</if>
<if test= "workTypeCode != null" > #{workTypeCode},</if>
<if test= "workTypeName != null" > #{workTypeName},</if>
<if test= "specWorkType != null" > #{specWorkType},</if>
<if test= "hatCode != null" > #{hatCode},</if>
<if test= "state != null" > #{state},</if>
<if test= "enterDate != null" > #{enterDate},</if>
<if test= "exitDate != null" > #{exitDate},</if>
<if test= "companyId != null" > #{companyId},</if>
<if test= "companyName != null" > #{companyName},</if>
<if test= "vendorId != null" > #{vendorId},</if>
<if test= "teamId != null" > #{teamId},</if>
<if test= "teamName != null" > #{teamName},</if>
<if test= "enterType != null" > #{enterType},</if>
<if test= "other != null and other != ''" > #{other},</if>
<if test= "remark != null" > #{remark},</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>
</trim>
</insert>
<update id= "updateSurProjectAttendanceUser" parameterType= "SurProjectAttendanceUser" >
update sur_project_attendance_user
<trim prefix= "SET" suffixOverrides= "," >
2023-09-25 00:32:36 +08:00
<if test= "cfgid != null" > cfgid = #{cfgid},</if>
<if test= "vendorsCode != null" > vendors_code = #{vendorsCode},</if>
2023-09-24 18:35:52 +08:00
<if test= "workerId != null" > workerId = #{workerId},</if>
<if test= "laborWorkerId != null" > laborWorkerId = #{laborWorkerId},</if>
<if test= "workerCategory != null" > workerCategory = #{workerCategory},</if>
<if test= "qrCode != null" > qrCode = #{qrCode},</if>
<if test= "name != null" > name = #{name},</if>
<if test= "ethnic != null" > ethnic = #{ethnic},</if>
<if test= "nativePlace != null" > nativePlace = #{nativePlace},</if>
<if test= "gender != null" > gender = #{gender},</if>
<if test= "birthDate != null" > birthDate = #{birthDate},</if>
<if test= "phone != null and phone != ''" > phone = #{phone},</if>
<if test= "degreeName != null" > degreeName = #{degreeName},</if>
<if test= "photo != null" > photo = #{photo},</if>
<if test= "recentPhoto != null" > recentPhoto = #{recentPhoto},</if>
<if test= "groupId != null" > groupId = #{groupId},</if>
<if test= "groupName != null" > groupName = #{groupName},</if>
<if test= "leader != null" > leader = #{leader},</if>
<if test= "workTypeCode != null" > workTypeCode = #{workTypeCode},</if>
<if test= "workTypeName != null" > workTypeName = #{workTypeName},</if>
<if test= "specWorkType != null" > specWorkType = #{specWorkType},</if>
<if test= "hatCode != null" > hatCode = #{hatCode},</if>
<if test= "state != null" > state = #{state},</if>
<if test= "enterDate != null" > enterDate = #{enterDate},</if>
<if test= "exitDate != null" > exitDate = #{exitDate},</if>
<if test= "companyId != null" > companyId = #{companyId},</if>
<if test= "companyName != null" > companyName = #{companyName},</if>
<if test= "vendorId != null" > vendorId = #{vendorId},</if>
<if test= "teamId != null" > teamId = #{teamId},</if>
<if test= "teamName != null" > teamName = #{teamName},</if>
<if test= "enterType != null" > enterType = #{enterType},</if>
<if test= "other != null and other != ''" > other = #{other},</if>
<if test= "remark != null" > remark = #{remark},</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>
</trim>
where id = #{id}
</update>
<delete id= "deleteSurProjectAttendanceUserById" parameterType= "Long" >
delete from sur_project_attendance_user where id = #{id}
</delete>
<delete id= "deleteSurProjectAttendanceUserByIds" parameterType= "String" >
delete from sur_project_attendance_user where id in
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
2023-09-26 00:01:20 +08:00
<sql id= "sqlAttendanceData" >
(
SELECT * FROM sur_project_attendance_data WHERE DATE(attendance_time)=date(#{createBy}) AND cfgid IN (
SELECT id FROM sur_project_attendance_cfg WHERE project_id=#{projectId} AND sub_dept_id=#{subDeptId} AND vendors_code=#{vendorsCode}
) ) xx
</sql>
<select id= "queryAttendanceData" parameterType= "SurProjectAttendanceCfg" resultMap= "SurProjectAttendanceUserResult" >
2023-09-27 00:09:47 +08:00
select * from (
2023-09-26 00:01:20 +08:00
select n.*,m.inTime,m.outTime from (
SELECT * FROM (
SELECT workerId,attendance_time inTime,null outtime FROM sur_project_attendance_data WHERE id IN (
SELECT min(id) id FROM <include refid= "sqlAttendanceData" /> WHERE attendance_type='e' GROUP BY workerId )) X WHERE workerId NOT IN (
SELECT workerId FROM <include refid= "sqlAttendanceData" /> WHERE attendance_type='l' GROUP BY workerId
)
union
select * from (
select workerId,null inTime,attendance_time outTime from sur_project_attendance_data where id in (
select max(id) id from <include refid= "sqlAttendanceData" /> where attendance_type='l' group by workerId )) x where workerId not in (
SELECT workerId FROM <include refid= "sqlAttendanceData" /> WHERE attendance_type='e' GROUP BY workerId
)
union
select x.workerId,y.attendance_time inTime,x.attendance_time outTime from (
SELECT id,workerId,attendance_time FROM sur_project_attendance_data WHERE id IN (
SELECT MAX(id) id FROM <include refid= "sqlAttendanceData" /> WHERE attendance_type='l' GROUP BY workerId )
) x cross join (
SELECT id,workerId,attendance_time FROM sur_project_attendance_data WHERE id IN (
SELECT MIN(id) id FROM <include refid= "sqlAttendanceData" /> WHERE attendance_type='e' GROUP BY workerId )
) y on x.workerId=y.workerId
) m left join sur_project_attendance_user n on m.workerId=n.workerId
2023-09-27 00:09:47 +08:00
) oo
2023-09-26 00:01:20 +08:00
</select>
2023-09-30 23:03:37 +08:00
<select id= "countTodayAttendance" resultType= "Long" parameterType= "SurProjectAttendanceUser" >
select count(1) cnt from sur_project_attendance_user u, sur_project_attendance_cfg c,vw_sur_project_attendance_group g
where u.cfgid=c.id and u.state=0 and u.companyId=g.companyId
<if test= "id==1" >
and g.companyTypeId =1
</if>
<if test= "id==2" >
and g.companyTypeId in (2,3)
</if>
<if test= "id==8" >
and g.companyTypeId =8
</if>
<if test= "projectId!=null and projectId>0" >
and c.project_id=#{projectId}
</if>
<if test= "deptId!=null and deptId>0" >
and c.project_id in (SELECT id FROM sur_project WHERE deptid=#{deptId})
</if>
2023-10-11 23:24:45 +08:00
<if test= "prjIds !=null and prjIds.size()>0" >
and c.project_id in
<foreach collection= "prjIds" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
2023-09-30 23:03:37 +08:00
</select>
<select id= "todayAttendance" parameterType= "SurProjectAttendanceUser" resultMap= "SurProjectAttendanceUserResult" >
select a.* ,
(select min(attendance_time) from sur_project_attendance_data b where b.workerId=a.workerId and date(b.attendance_time)='2023-09-28' and b.attendance_type='e') inTime,
(SELECT Max(attendance_time) FROM sur_project_attendance_data b WHERE b.workerId=a.workerId AND DATE(b.attendance_time)='2023-09-28' AND b.attendance_type='l') outTime
from (
select u.* from sur_project_attendance_user u, sur_project_attendance_cfg c,vw_sur_project_attendance_group g
where u.cfgid=c.id and u.state=0 and u.companyId=g.companyId
<if test= "id==1" >
and g.companyTypeId =1
</if>
<if test= "id==2" >
and g.companyTypeId in (2,3)
</if>
<if test= "id==8" >
and g.companyTypeId =8
</if>
<if test= "projectId!=null and projectId>0" >
and c.project_id=#{projectId}
</if>
<if test= "deptId!=null and deptId>0" >
and c.project_id in (SELECT id FROM sur_project WHERE deptid=#{deptId})
</if>
2023-10-11 23:24:45 +08:00
<if test= "prjIds !=null and prjIds.size()>0" >
and c.project_id in
<foreach collection= "prjIds" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
2023-09-30 23:03:37 +08:00
order by u.id limit #{index},#{size} ) a
</select>
2023-09-24 18:35:52 +08:00
</mapper>