2025-05-08 00:21:11 +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.manage.mapper.SurProjectAttendanceUserMapper" >
<resultMap type= "SurProjectAttendanceUser" id= "SurProjectAttendanceUserResult" >
<result property= "id" column= "id" />
<result property= "cfgid" column= "cfgid" />
<result property= "appId" column= "app_id" />
<result property= "vendorsCode" column= "vendors_code" />
<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" />
<result property= "projectId" column= "project_id" />
<result property= "subDeptId" column= "sub_dept_id" />
<result property= "companyTypeId" column= "companyTypeId" />
</resultMap>
<sql id= "selectSurProjectAttendanceUserVo" >
SELECT * FROM (
SELECT a.*,b.project_id,b.sub_dept_id
FROM sur_project_attendance_user a,attendance_cfg b
WHERE a.cfgid=b.id )
sur_project_attendance_user
</sql>
<select id= "selectSurProjectAttendanceUserListJgw" parameterType= "SurProjectAttendanceUser" resultMap= "SurProjectAttendanceUserResult" >
SELECT u.id,u.cfgid,u.app_id,u.vendors_code,u.workerId,u.laborWorkerId,u.workerCategory,u.qrCode,u.name,
u.ethnic,u.nativePlace,u.gender,u.birthDate,u.phone,u.degreeName,u.photo,u.recentPhoto,
u.groupId,u.leader,u.workTypeCode,u.specWorkType,
u.hatCode,u.state,u.enterDate,u.exitDate,u.companyId,u.vendorId,
u.teamId,u.teamName,u.enterType,u.is_del,u.create_by,u.create_time,u.update_by,u.update_time,
c.project_id,c.sub_dept_id,u.companyName,u.workTypeName,g.teamname groupName,g.companyName remark
FROM sur_project_attendance_user u,attendance_cfg c,sur_project_attendance_group g
WHERE u.cfgid=c.id AND g.companyid=u.companyid AND u.vendors_code='jgw'
<if test= "companyTypeId!=null" >
<if test= "companyTypeId>100" >
<if test= "companyTypeId==101" >
and g.companyTypeId in (1,6)
</if>
<if test= "companyTypeId==102" >
and g.companyTypeId =8
</if>
<if test= "companyTypeId==103" >
and g.companyTypeId in (0,2,3,4,5)
</if>
</if>
<if test= "companyTypeId <100" >
and g.companyTypeId=#{companyTypeId}
</if>
</if>
<if test= "cfgid != null " > and u.cfgid = #{cfgid}</if>
<if test= "appId != null " > and u.app_id = #{appId}</if>
<if test= "vendorsCode != null and vendorsCode != ''" > and u.vendors_code = #{vendorsCode}</if>
<if test= "workerId != null " > and u.workerId = #{workerId}</if>
<if test= "laborWorkerId != null " > and u.laborWorkerId = #{laborWorkerId}</if>
<if test= "workerCategory != null " > and u.workerCategory = #{workerCategory}</if>
<if test= "qrCode != null " > and u.qrCode = #{qrCode}</if>
<if test= "name != null and name != ''" > and u.name like concat('%', #{name}, '%')</if>
<if test= "ethnic != null and ethnic != ''" > and u.ethnic = #{ethnic}</if>
<if test= "nativePlace != null and nativePlace != ''" > and u.nativePlace = #{nativePlace}</if>
<if test= "gender != null " > and u.gender = #{gender}</if>
<if test= "birthDate != null " > and u.birthDate = #{birthDate}</if>
<if test= "phone != null and phone != ''" > and u.phone = #{phone}</if>
<if test= "degreeName != null and degreeName != ''" > and u.degreeName like concat('%', #{degreeName}, '%')</if>
<if test= "photo != null and photo != ''" > and u.photo = #{photo}</if>
<if test= "recentPhoto != null and recentPhoto != ''" > and u.recentPhoto = #{recentPhoto}</if>
<if test= "groupId != null " > and u.groupId = #{groupId}</if>
<if test= "groupName != null and groupName != ''" > and u.groupName like concat('%', #{groupName}, '%')</if>
<if test= "leader != null " > and u.leader = #{leader}</if>
<if test= "workTypeCode != null and workTypeCode != ''" > and u.workTypeCode = #{workTypeCode}</if>
<if test= "workTypeName != null and workTypeName != ''" > and u.workTypeName like concat('%', #{workTypeName}, '%')</if>
<if test= "specWorkType != null " > and u.specWorkType = #{specWorkType}</if>
<if test= "hatCode != null and hatCode != ''" > and u.hatCode = #{hatCode}</if>
<if test= "state != null " > and u.state = #{state}</if>
<if test= "enterDate != null and enterDate != ''" > and u.enterDate = #{enterDate}</if>
<if test= "exitDate != null and exitDate != ''" > and u.exitDate = #{exitDate}</if>
<if test= "companyId != null " > and u.companyId = #{companyId}</if>
<if test= "companyName != null and companyName != ''" > and u.companyName like concat('%', #{companyName}, '%')</if>
<if test= "vendorId != null " > and u.vendorId = #{vendorId}</if>
<if test= "teamId != null " > and u.teamId = #{teamId}</if>
<if test= "teamName != null and teamName != ''" > and u.teamName like concat('%', #{teamName}, '%')</if>
<if test= "enterType != null and enterType != ''" > and u.enterType = #{enterType}</if>
<if test= "other != null and other != ''" > and u.other = #{other}</if>
<if test= "projectId != null and projectId > 0 " > and c.project_id = #{projectId}</if>
<if test= "subDeptId != null and subDeptId >0 " > and c.sub_dept_id = #{subDeptId}</if>
<if test= "isDel != null " > and u.is_del = #{isDel}</if>
</select>
<select id= "querySurProjectAttendanceUserList" parameterType= "SurProjectAttendanceUser" resultMap= "SurProjectAttendanceUserResult" >
SELECT * FROM (
SELECT a.id,
a.cfgid,
a.app_id,
a.vendors_code,
a.workerId,
a.laborWorkerId,
a.workerCategory,
a.qrCode,
a.name,
a.ethnic,
a.nativePlace,
a.gender,
a.birthDate,
a.phone,
a.degreeName,
a.photo,
a.recentPhoto,
a.groupId,
a.groupName,
a.leader,
a.workTypeCode,
a.workTypeName,
a.specWorkType,
a.hatCode,
a.state,
a.enterDate,
a.exitDate,
a.companyId,
a.companyName,
a.vendorId,
a.teamId,
a.teamName,
a.enterType,
a.other,
a.is_del,
a.create_by,
a.create_time,
a.update_by,
a.update_time,b.project_id,b.sub_dept_id,g.companyTypeId,g.companyName as remark
FROM sur_project_attendance_user a,attendance_cfg b,view_sur_project_attendance_group g
WHERE a.cfgid=b.id and a.companyId=g.companyId and g.id in(select min(id) from view_sur_project_attendance_group group by companyid)
)
sur_project_attendance_user
<where >
<if test= "companyTypeId!=null" >
<if test= "companyTypeId>100" >
<if test= "companyTypeId==101" >
and companyTypeId in (1,6)
</if>
<if test= "companyTypeId==102" >
and companyTypeId =8
</if>
<if test= "companyTypeId==103" >
and companyTypeId in (0,2,3,4,5)
</if>
</if>
<if test= "companyTypeId <100" >
and companyTypeId=#{companyTypeId}
</if>
</if>
<if test= "cfgid != null " > and cfgid = #{cfgid}</if>
<if test= "appId != null " > and app_id = #{appId}</if>
<if test= "vendorsCode != null and vendorsCode != ''" > and vendors_code = #{vendorsCode}</if>
<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>
<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>
<if test= "isDel != null " > and is_del = #{isDel}</if>
</where>
</select>
<select id= "selectSurProjectAttendanceUserList" parameterType= "SurProjectAttendanceUser" resultMap= "SurProjectAttendanceUserResult" >
<include refid= "selectSurProjectAttendanceUserVo" />
<where >
<if test= "companyTypeId!=null" >
<if test= "companyTypeId>100" >
<if test= "companyTypeId==101" >
and companyTypeId in (1,6)
</if>
<if test= "companyTypeId==102" >
and companyTypeId =8
</if>
<if test= "companyTypeId==103" >
and companyTypeId in (0,2,3,4,5)
</if>
</if>
<if test= "companyTypeId <100" >
and companyTypeId=#{companyTypeId}
</if>
</if>
<if test= "cfgid != null " > and cfgid = #{cfgid}</if>
<if test= "appId != null " > and app_id = #{appId}</if>
<if test= "vendorsCode != null and vendorsCode != ''" > and vendors_code = #{vendorsCode}</if>
<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>
<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>
<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>
<select id= "findCurrentAttendanceUser" parameterType= "SurProjectAttendanceUser" resultMap= "SurProjectAttendanceUserResult" >
select u.companyId,u.companyName,u.`name`,u.recentPhoto,u.gender,u.birthDate,u.ethnic,u.nativePlace,u.phone,
u.workTypeName,u.specWorkType,u.groupName,g.companyTypeId,u.workTypeCode
from sur_project_attendance_user u
left join sur_project_attendance_group g on u.companyId = g.companyId and g.cfgid = u.cfgid
where u.cfgid=#{cfgid} and u.workerId=#{workerId}
</select>
<select id= "findYzCurrentAttendanceUser" parameterType= "SurProjectAttendanceUser" resultMap= "SurProjectAttendanceUserResult" >
select u.companyId,g.companyName,u.`name`,u.recentPhoto,u.gender,u.birthDate,u.ethnic,u.nativePlace,u.phone,
u.workTypeName,u.specWorkType,u.groupName,g.companyTypeId,u.workTypeCode
from sur_project_attendance_user u
left join sur_project_attendance_group g on u.groupId = g.serverid and g.cfgid = u.cfgid
where u.cfgid=#{cfgid} and u.workerId=#{workerId} ORDER BY u.id desc LIMIT 1
</select>
<insert id= "insertSurProjectAttendanceUser" parameterType= "SurProjectAttendanceUser" useGeneratedKeys= "true" keyProperty= "id" >
insert into sur_project_attendance_user
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "cfgid != null" > cfgid,</if>
<if test= "appId != null" > app_id,</if>
<if test= "vendorsCode != null" > vendors_code,</if>
<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= "," >
<if test= "cfgid != null" > #{cfgid},</if>
<if test= "appId != null" > #{appId},</if>
<if test= "vendorsCode != null" > #{vendorsCode},</if>
<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= "," >
<if test= "cfgid != null" > cfgid = #{cfgid},</if>
<if test= "appId != null" > app_id = #{appId},</if>
<if test= "vendorsCode != null" > vendors_code = #{vendorsCode},</if>
<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>
<delete id= "deleteSurProjectAttendanceUserByParams" parameterType= "String" >
delete from sur_project_attendance_user where CONCAT(app_id,'-',workerId) in
<foreach collection= "list" item= "item" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</delete>
<insert id= "batchSurProjectAttendanceUser" >
insert into sur_project_attendance_user( id, cfgid, vendors_code, workerId, laborWorkerId, workerCategory, qrCode, name, ethnic, nativePlace, gender, birthDate, phone, degreeName, photo, recentPhoto, groupId, groupName, leader, workTypeCode, workTypeName, specWorkType, hatCode, state, enterDate, exitDate, companyId, companyName, vendorId, teamId, teamName, enterType, other, remark, is_del, create_by, create_time, update_by, update_time) values
<foreach item= "item" index= "index" collection= "list" separator= "," >
( #{item.id}, #{item.cfgid}, #{item.vendorsCode}, #{item.workerId}, #{item.laborWorkerId}, #{item.workerCategory}, #{item.qrCode}, #{item.name}, #{item.ethnic}, #{item.nativePlace}, #{item.gender}, #{item.birthDate}, #{item.phone}, #{item.degreeName}, #{item.photo}, #{item.recentPhoto}, #{item.groupId}, #{item.groupName}, #{item.leader}, #{item.workTypeCode}, #{item.workTypeName}, #{item.specWorkType}, #{item.hatCode}, #{item.state}, #{item.enterDate}, #{item.exitDate}, #{item.companyId}, #{item.companyName}, #{item.vendorId}, #{item.teamId}, #{item.teamName}, #{item.enterType}, #{item.other}, #{item.remark}, #{item.isDel}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
</foreach>
</insert>
<sql id= "sqlAttendanceData" >
(
SELECT * FROM sur_project_attendance_data WHERE DATE(attendance_time)=date(#{createBy}) AND cfgid IN (
SELECT id FROM attendance_cfg WHERE project_id=#{projectId} AND sub_dept_id=#{subDeptId}
) ) xx
</sql>
<select id= "queryAttendanceData" parameterType= "AttendanceCfg" resultMap= "SurProjectAttendanceUserResult" >
select * from (
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
) oo
</select>
<select id= "countAttendance" resultType= "Long" parameterType= "AttendanceCfg" >
select count(1) cnt from sur_project_attendance_user u, attendance_cfg c,view_sur_project_attendance_group g
where u.cfgid=c.id and u.state=0 and u.companyId=g.companyId
and u.workerid in(
SELECT workerid FROM sur_project_attendance_data WHERE DATE(attendance_time)=date(#{createBy}) AND cfgid IN (
SELECT id FROM attendance_cfg WHERE project_id=#{projectId} AND sub_dept_id=#{subDeptId}
) group by workerid
)
</select>
<select id= "queryAttendanceByUserIds" parameterType= "SurProjectAttendanceUser" resultMap= "SurProjectAttendanceUserResult" >
select workerid,attendance_type name,min(attendance_time) inTime,max(attendance_time) outTime from sur_project_attendance_data
where DATE(attendance_time)=date(#{createBy})
<if test= "workerIds !=null and workerIds.size()>0" >
and workerid in
<foreach collection= "workerIds" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
group by workerid,attendance_type
</select>
<select id= "queryAttendanceUsers" parameterType= "SurProjectAttendanceUser" resultMap= "SurProjectAttendanceUserResult" >
select u.* from sur_project_attendance_user u, attendance_cfg c,view_sur_project_attendance_group g
where u.cfgid=c.id and u.state=0 and u.companyId=g.companyId
and u.workerid in(
SELECT workerid FROM sur_project_attendance_data WHERE DATE(attendance_time)=date(#{createBy}) AND cfgid IN (
SELECT id FROM attendance_cfg WHERE project_id=#{projectId} AND sub_dept_id=#{subDeptId}
) group by workerid
)
order by u.id limit #{index},#{size}
</select>
<select id= "countTodayAttendance" resultType= "Long" parameterType= "SurProjectAttendanceUser" >
select count(1) cnt from sur_project_attendance_user u, attendance_cfg c,view_sur_project_attendance_group g
where u.cfgid=c.id and u.state=0 and u.companyId=g.companyId
and u.workerid in(
SELECT workerid FROM sur_project_attendance_data WHERE DATE(attendance_time)=CURDATE() group by workerid
)
<if test= "id==1" >
and g.companyTypeId in (1,6)
</if>
<if test= "id==2" >
and g.companyTypeId in (0,2,3,4,5)
</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 pro_project_info WHERE dis_dept_id=#{deptId})
</if>
<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>
</select>
<select id= "todayAttendanceOld" 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)=CURDATE() 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)=CURDATE() AND b.attendance_type='l') outTime
from (
select u.* from sur_project_attendance_user u, attendance_cfg c,view_sur_project_attendance_group g
where u.cfgid=c.id and u.state=0 and u.companyId=g.companyId
and u.workerid in(
SELECT workerid FROM sur_project_attendance_data WHERE DATE(attendance_time)=CURDATE()
)
<if test= "id==1" >
and g.companyTypeId in (1,6)
</if>
<if test= "id==2" >
and g.companyTypeId in (0,2,3,4,5)
</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 pro_project_info WHERE dis_dept_id=#{deptId})
</if>
<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>
order by u.id limit #{index},#{size} ) a
</select>
<select id= "todayAttendance" parameterType= "SurProjectAttendanceUser" resultMap= "SurProjectAttendanceUserResult" >
select u.* from sur_project_attendance_user u, attendance_cfg c,view_sur_project_attendance_group g
where u.cfgid=c.id and u.state=0 and u.companyId=g.companyId
and u.workerid in(
SELECT workerid FROM sur_project_attendance_data WHERE DATE(attendance_time)=CURDATE() group by workerid
)
<if test= "id==1" >
and g.companyTypeId in (1,6)
</if>
<if test= "id==2" >
and g.companyTypeId in (0,2,3,4,5)
</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 pro_project_info WHERE dis_dept_id=#{deptId})
</if>
<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>
order by u.id limit #{index},#{size}
</select>
<select id= "todayAttendanceData" parameterType= "java.util.List" resultMap= "SurProjectAttendanceUserResult" >
select workerid,attendance_type name,min(attendance_time) inTime,max(attendance_time) outTime from sur_project_attendance_data where DATE(attendance_time)=CURDATE()
<if test= "list !=null and list.size()>0" >
and workerid in
<foreach collection= "list" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
group by workerid,attendance_type
</select>
<select id= "todayAttendanceOtherData" parameterType= "map" resultMap= "SurProjectAttendanceUserResult" >
select workerid,min(attendance_time) inTime,max(attendance_time) outTime from sur_project_attendance_data where cfgid=#{cfgid} and DATE(attendance_time)=#{date}
<if test= "list !=null and list.size()>0" >
and workerid in
<foreach collection= "list" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
group by workerid
</select>
<select id= "queryWorkerOnDuty" parameterType= "SurProjectAttendanceUser" resultMap= "SurProjectAttendanceUserResult" >
SELECT u.id,u.cfgid,u.app_id,u.vendors_code,u.workerId,u.laborWorkerId,u.workerCategory,u.qrCode,u.name,
u.ethnic,u.nativePlace,u.gender,u.birthDate,u.phone,u.photo,u.recentPhoto,
u.groupId,u.leader,u.workTypeCode,u.specWorkType,
u.hatCode,u.state,u.enterDate,u.exitDate,u.companyId,u.vendorId,
u.teamId,u.teamName,u.enterType,u.is_del,u.create_by,u.create_time,u.update_by,u.update_time,
b.project_id,b.sub_dept_id,u.companyName,u.workTypeName,u.groupName,
b.project_id,b.sub_dept_id, g.teamname remark,g.companyName degreeName
FROM sur_project_attendance_user u,attendance_cfg b,view_sur_project_attendance_group g,pro_project_info sp
WHERE u.cfgid=b.id and u.state=0 and u.companyId=g.companyId and sp.is_Del=0 and b.project_id = sp.id
<if test= "id==101" >
and g.companyTypeId in (1,6)
</if>
<if test= "id==102" >
and g.companyTypeId =8
</if>
<if test= "id==103" >
and g.companyTypeId in (0,2,3,4,5)
</if>
<if test= "projectId!=null and projectId>0" >
and b.project_id=#{projectId}
</if>
<if test= "deptId!=null and deptId>0" >
and sp.dis_dept_id=#{deptId}
</if>
<if test= 'proType != null and proType != "" and proType != "0"' > and sp.project_Type = #{proType}</if>
<if test= "prjIds !=null and prjIds.size()>0" >
and b.project_id in
<foreach collection= "prjIds" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
</select>
<select id= "attendanceUserList" parameterType= "SurProjectAttendanceUser" resultMap= "SurProjectAttendanceUserResult" >
SELECT u.id,u.cfgid,u.app_id,u.vendors_code,u.workerId,u.laborWorkerId,u.workerCategory,u.qrCode,u.name,
u.ethnic,u.nativePlace,u.gender,u.birthDate,u.phone,u.photo,u.recentPhoto,
u.groupId,u.leader,u.workTypeCode,u.specWorkType,
u.hatCode,u.state,u.enterDate,u.exitDate,u.companyId,u.vendorId,
u.teamId,u.teamName,u.enterType,u.is_del,u.create_by,u.create_time,u.update_by,u.update_time,
b.project_id,b.sub_dept_id,u.companyName,u.workTypeName,u.groupName,
b.project_id,b.sub_dept_id, g.teamname remark,g.companyName degreeName,g.companyTypeId
FROM sur_project_attendance_user u,attendance_cfg b,view_sur_project_attendance_group g,pro_project_info sp
WHERE u.cfgid=b.id and u.companyId=g.companyId and sp.is_Del=0 and b.project_id = sp.id
<if test= "companyTypeId==101" >
and g.companyTypeId in (1,6)
</if>
<if test= "companyTypeId==102" >
and g.companyTypeId =8
</if>
<if test= "companyTypeId==103" >
and g.companyTypeId in (0,2,3,4,5)
</if>
<if test= "projectId!=null and projectId>0" >
and b.project_id=#{projectId}
</if>
<if test= "id != null" > and u.id = #{id}</if>
<if test= "state != null " > and u.state = #{state}</if>
<if test= "name != null and name != ''" > and u.name like concat('%', #{name}, '%')</if>
order by id
</select>
<select id= "groupByWorkerOnDutyByDept" parameterType= "SurProjectAttendanceUser" resultMap= "SurProjectAttendanceUserResult" >
SELECT p.id, p.project_Name NAME,c.dept_name groupName,g.companyTypeId companyId,COUNT(1) cfgid
FROM sur_project_attendance_user u,attendance_cfg b,view_sur_project_attendance_group g,pro_project_info p,sys_dept c
where u.cfgid=b.id and u.state=0 and u.companyId=g.companyId and b.project_id=p.id and c.dept_id=b.dept_id
and p.is_Del=0
and g.companyTypeId in (1,6,0,2,3,4,5,8)
<if test= "deptId!=null and deptId>0" >
and p.dis_dept_id=#{deptId}
</if>
<if test= 'proType != null and proType != "" and proType != "0"' > and p.projectType = #{proType}</if>
<if test= "prjIds !=null and prjIds.size()>0" >
and b.project_id in
<foreach collection= "prjIds" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
group by p.projectName,c.dept_name,g.companyTypeId,p.id
order by p.id
</select>
<select id= "groupUserByParams" parameterType= "SurProjectAttendanceUser" resultType= "Map" >
select '1' as type,g.companyTypeId,count(1) as total
from sur_project_attendance_user u
left join view_sur_project_attendance_group g on g.cfgid = u.cfgid and u.companyId=g.companyId
where u.cfgid in (select cfg.id from attendance_cfg cfg where cfg.project_id=#{projectId} and cfg.is_del=0)
and g.companyTypeId in (0,1,2,3,4,5,6,8)
and u.state=0
<if test= "name != null and name != ''" > and u.name like concat('%', #{name}, '%')</if>
group by g.companyTypeId
UNION ALL
select '2' as type,g.companyTypeId,count(1) as total
from sur_project_attendance_user u
left join view_sur_project_attendance_group g on g.cfgid = u.cfgid and u.companyId=g.companyId
where u.cfgid in (select cfg.id from attendance_cfg cfg where cfg.project_id=#{projectId} and cfg.is_del=0)
and g.companyTypeId in (0,1,2,3,4,5,6,8)
and u.state=1
<if test= "name != null and name != ''" > and u.name like concat('%', #{name}, '%')</if>
group by g.companyTypeId
</select>
<select id= "findUserAllByDays" parameterType= "Long" resultType= "Map" >
select '1' as type,g.companyTypeId,count(1) as total
from sur_project_attendance_user u
left join view_sur_project_attendance_group g on g.cfgid = u.cfgid and u.companyId=g.companyId
where u.cfgid in (select cfg.id from attendance_cfg cfg where cfg.project_id=#{projectId} and cfg.is_del=0)
and g.companyTypeId in (0,1,2,3,4,5,6,8)
and u.state=0
group by g.companyTypeId
</select>
<select id= "groupByWorkerByDept" parameterType= "SurProjectAttendanceUser" resultMap= "SurProjectAttendanceUserResult" >
SELECT p.id, p.project_Name NAME,c.dept_name groupName,g.companyTypeId companyId,COUNT(1) cfgid
FROM sur_project_attendance_user u,attendance_cfg b,view_sur_project_attendance_group g,pro_project_info p,sys_dept c
where u.cfgid=b.id and u.state= #{state} and u.companyId=g.companyId and b.project_id=p.id and c.dept_id=b.dept_id
and p.is_Del=0
and g.companyTypeId in (1,6,0,2,3,4,5,8)
<if test= "deptId!=null and deptId>0" >
and p.dis_dept_id=#{deptId}
</if>
<if test= 'proType != null and proType != "" and proType != "0"' > and p.project_Type = #{proType}</if>
<if test= "prjIds !=null and prjIds.size()>0" >
and b.project_id in
<foreach collection= "prjIds" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
group by p.projectName,c.dept_name,g.companyTypeId,p.id
order by p.id
</select>
<select id= "queryWorkerByState" parameterType= "SurProjectAttendanceUser" resultMap= "SurProjectAttendanceUserResult" >
SELECT u.id,u.cfgid,u.app_id,u.vendors_code,u.workerId,u.laborWorkerId,u.workerCategory,u.qrCode,u.name,
u.ethnic,u.nativePlace,u.gender,u.birthDate,u.phone,u.photo,u.recentPhoto,
u.groupId,u.leader,u.workTypeCode,u.specWorkType,
u.hatCode,u.state,u.enterDate,u.exitDate,u.companyId,u.vendorId,
u.teamId,u.teamName,u.enterType,u.is_del,u.create_by,u.create_time,u.update_by,u.update_time,
b.project_id,b.dept_id,u.companyName,u.workTypeName,u.groupName,
g.teamname remark,g.companyName degreeName
FROM sur_project_attendance_user u,attendance_cfg b,view_sur_project_attendance_group g,pro_project_info sp
WHERE u.cfgid=b.id and u.state=#{state} and u.companyId=g.companyId and sp.is_Del=0 and b.project_id = sp.id
<if test= "id==101" >
and g.companyTypeId in (1,6)
</if>
<if test= "id==102" >
and g.companyTypeId =8
</if>
<if test= "id==103" >
and g.companyTypeId in (0,2,3,4,5)
</if>
<if test= "projectId!=null and projectId>0" >
and b.project_id=#{projectId}
</if>
<if test= "deptId!=null and deptId>0" >
and sp.dis_dept_id=#{deptId}
</if>
<if test= 'proType != null and proType != "" and proType != "0"' > and sp.project_Type = #{proType}</if>
<if test= "prjIds !=null and prjIds.size()>0" >
and b.project_id in
<foreach collection= "prjIds" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
</select>
2025-05-19 00:12:03 +08:00
<select id= "groupWorkderNative" resultMap= "SurProjectAttendanceUserResult" >
select birthDate,nativePlace
from sur_project_attendance_user
where cfgid in (select id from attendance_cfg where project_id= #{projectId}) and is_del!=1 and state=0
</select>
<select id= "getWorkerCountGroupByType" resultMap= "SurProjectAttendanceUserResult" >
select workTypeName,count(1) id from sur_project_attendance_user
2025-05-23 00:08:04 +08:00
where cfgid in (select id from attendance_cfg where project_id= #{projectId})
and is_del!=1 and state=0
2025-05-19 00:12:03 +08:00
group by workTypeName
order by count(1) DESC
</select>
<select id= "getAttendanceAlert" resultMap= "SurProjectAttendanceUserResult" >
2025-05-23 00:08:04 +08:00
<!--
2025-05-19 00:12:03 +08:00
select u.*,TIMESTAMPDIFF(Day, att.dt,now()) id
from (
select su.workerId,su.name,pi.project_name companyName, pdept.sub_dept_name teamName
from sur_project_attendance_user su
left join attendance_cfg cfg on su.cfgId=cfg.ID
left join pro_project_info pi on pi.id = cfg.project_id
join pro_project_info_subdepts pdept on cfg.dept_id=pdept.id
where
su.is_del!=1 and su.state=0
and cfg.project_id=#{projectId} ) u
join
(
select workerId,max(ifnull(attendance_time,attendance_out_time)) dt
from sur_project_attendance_data_${year}
where projectid=#{projectId} and is_del!=1
GROUP BY workerId
order by max(ifnull(attendance_time,attendance_out_time))
) att on u.workerId=att.workerId
2025-05-23 00:08:04 +08:00
-->
select u.*,TIMESTAMPDIFF(Day, att.dt,now()) id
from (
select su.workerId,su.name,pi.project_name companyName, pdept.sub_dept_name teamName
from ( select 11 cfgid, name,workerId
from yanzhu_jh.sur_project_attendance_user where cfgId=1) su
left join attendance_cfg cfg on su.cfgId=cfg.ID
left join pro_project_info pi on pi.id = cfg.project_id
join pro_project_info_subdepts pdept on cfg.dept_id=pdept.id
) u
join
(
select workerId,max(ifnull(attendance_time,attendance_out_time)) dt
from yanzhu_jh.sur_project_attendance_data_2024
where projectid=644 and is_del!=1
GROUP BY workerId
order by max(ifnull(attendance_time,attendance_out_time))
) att on u.workerId=att.workerId
LIMIT 10
2025-05-19 00:12:03 +08:00
</select>
2025-05-08 00:21:11 +08:00
</mapper>