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.SurProjectAttendanceDataMapper" >
<resultMap type= "SurProjectAttendanceData" id= "SurProjectAttendanceDataResult" >
<result property= "id" column= "id" />
<result property= "cfgid" column= "cfgid" />
<result property= "appId" column= "app_id" />
<result property= "projectId" column= "projectId" />
<result property= "projectName" column= "projectName" />
<result property= "deptId" column= "deptId" />
<result property= "deptName" column= "deptName" />
<result property= "vendorsCode" column= "vendors_code" />
<result property= "serverid" column= "serverid" />
<result property= "workerId" column= "workerId" />
<result property= "workerName" column= "workerName" />
<result property= "identification" column= "identification" />
<result property= "workerPhoto" column= "workerPhoto" />
<result property= "workerGender" column= "workerGender" />
<result property= "birthDate" column= "birthDate" />
<result property= "ethnic" column= "ethnic" />
<result property= "nativePlace" column= "nativePlace" />
<result property= "phone" column= "phone" />
<result property= "workTypeName" column= "workTypeName" />
<result property= "specWorkType" column= "specWorkType" />
<result property= "groupName" column= "groupName" />
<result property= "companyTypeId" column= "companyTypeId" />
<result property= "companyName" column= "companyName" />
<result property= "attendanceTime" column= "attendance_time" />
<result property= "attendanceOutTime" column= "attendance_out_time" />
<result property= "scanPhoto" column= "scanPhoto" />
<result property= "teamId" column= "teamId" />
<result property= "workTypeCode" column= "workTypeCode" />
<result property= "companyId" column= "companyId" />
<result property= "vendorId" column= "vendorId" />
<result property= "deviceCode" column= "device_code" />
<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" />
<result property= "days" column= "days" />
</resultMap>
<sql id= "selectSurProjectAttendanceDataVo" >
select
id,
cfgid,
app_id,
projectId,
projectName,
deptId,
deptName,
vendors_code,
serverid,
workerId,
workerName,
identification,
workerPhoto,
workerGender,
birthDate,
ethnic,
nativePlace,
phone,
workTypeName,
specWorkType,
groupName,
companyTypeId,
companyName,
attendance_time,
attendance_out_time,
scanPhoto,
teamId,
workTypeCode,
companyId,
vendorId,
device_code,
is_del,
create_by,
create_time,
update_by,
update_time,
remark
from sur_project_attendance_data_${year}
</sql>
<select id= "findCurrentAttendanceData" parameterType= "SurProjectAttendanceData" resultMap= "SurProjectAttendanceDataResult" >
select * from sur_project_attendance_data_${year}
<where >
<if test= "cfgid != null " > and cfgid = #{cfgid}</if>
<if test= "appId != null " > and app_id = #{appId}</if>
<if test= "workerId != null and workerId != ''" > and workerId = #{workerId}</if>
<if test= "attendanceTime != null and attendanceTime != ''" > and date(attendance_time) = date(#{attendanceTime})</if>
</where>
order by id desc LIMIT 1
</select>
<select id= "selectSurProjectAttendanceDataListEx" parameterType= "SurProjectAttendanceData" resultMap= "SurProjectAttendanceDataResult" >
select * from sur_project_attendance_data_${year}
<where >
<if test= "cfgid != null " > and cfgid = #{cfgid}</if>
<if test= "appId != null " > and app_id = #{appId}</if>
<if test= "projectId != null " > and projectId = #{projectId}</if>
<if test= "deptId != null " > and deptId = #{deptId}</if>
<if test= "vendorsCode != null and vendorsCode != ''" > and vendors_code = #{vendorsCode}</if>
<if test= "serverid != null " > and serverid = #{serverid}</if>
<if test= "workerId != null " > and workerId = #{workerId}</if>
<if test= "identification != null and identification != ''" > and identification = #{identification}</if>
<if test= "teamId != null " > and teamId = #{teamId}</if>
<if test= "workTypeCode != null and workTypeCode != ''" > and workTypeCode = #{workTypeCode}</if>
<if test= "companyId != null " > and companyId = #{companyId}</if>
<if test= "vendorId != null " > and vendorId = #{vendorId}</if>
<if test= "deviceCode != null and deviceCode != ''" > and device_code = #{deviceCode}</if>
<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= "scanPhoto != null and scanPhoto != ''" > and scanPhoto = #{scanPhoto}</if>
<if test= "isDel != null " > and is_del = #{isDel}</if>
<if test= "attendanceTime != null and attendanceTime != ''" > and date(attendance_time) = date(#{attendanceTime})</if>
</where>
order by id desc
</select>
<select id= "selectSurProjectAttendanceDataList" parameterType= "SurProjectAttendanceData" resultMap= "SurProjectAttendanceDataResult" >
<include refid= "selectSurProjectAttendanceDataVo" />
<where >
<if test= "cfgid != null " > and cfgid = #{cfgid}</if>
<if test= "appId != null " > and app_id = #{appId}</if>
<if test= "projectId != null " > and cfgid in (select id from attendance_cfg where projectId = #{projectId})</if>
<if test= "deptId != null " > and deptId = #{deptId}</if>
<if test= "vendorsCode != null and vendorsCode != ''" > and vendors_code = #{vendorsCode}</if>
<if test= "serverid != null " > and serverid = #{serverid}</if>
<if test= "workerId != null " > and workerId = #{workerId}</if>
<if test= "attendanceOutTime!=null and attendanceOutTime!=''" >
and (date(attendance_out_time) < =date(#{attendanceOutTime}) or date(attendance_time) < =date(#{attendanceOutTime}))
</if>
<if test= "teamId != null " > and teamId = #{teamId}</if>
<if test= "workTypeCode != null and workTypeCode != ''" > and workTypeCode = #{workTypeCode}</if>
<if test= "companyId != null " > and companyId = #{companyId}</if>
<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= "vendorId != null " > and vendorId = #{vendorId}</if>
<if test= "deviceCode != null and deviceCode != ''" > and device_code = #{deviceCode}</if>
<if test= "scanPhoto != null and scanPhoto != ''" > and scanPhoto like concat('%', #{scanPhoto}, '%')</if>
<if test= "workerName != null and workerName != ''" > and workerName like concat('%', #{workerName}, '%')</if>
<if test= "isDel != null " > and is_del = #{isDel}</if>
<if test= "attendanceTime != null and attendanceTime != ''" > and
(date(attendance_time) > = date(#{attendanceTime}) or date(attendance_out_time) > = date(#{attendanceTime}) )</if>
<if test= "identification != null and identification != ''" > and identification = #{identification}</if>
</where>
order by id desc
</select>
<select id= "selectSurProjectAttendanceDataById" parameterType= "Long" resultMap= "SurProjectAttendanceDataResult" >
<include refid= "selectSurProjectAttendanceDataVo" />
where id = #{id}
</select>
<insert id= "insertSurProjectAttendanceData" parameterType= "SurProjectAttendanceData" useGeneratedKeys= "true" keyProperty= "id" >
insert into sur_project_attendance_data_${year}
<trim prefix= "(" suffix= ")" suffixOverrides= "," >
<if test= "cfgid != null" > cfgid,</if>
<if test= "appId != null" > app_id,</if>
<if test= "projectId != null" > projectId,</if>
<if test= "projectName != null" > projectName,</if>
<if test= "deptId != null" > deptId,</if>
<if test= "deptName != null" > deptName,</if>
<if test= "vendorsCode != null" > vendors_code,</if>
<if test= "serverid != null" > serverid,</if>
<if test= "workerId != null" > workerId,</if>
<if test= "workerName != null" > workerName,</if>
<if test= "identification != null" > identification,</if>
<if test= "workerPhoto != null" > workerPhoto,</if>
<if test= "workerGender != null" > workerGender,</if>
<if test= "birthDate != null" > birthDate,</if>
<if test= "ethnic != null" > ethnic,</if>
<if test= "nativePlace != null" > nativePlace,</if>
<if test= "phone != null" > phone,</if>
<if test= "workTypeName != null" > workTypeName,</if>
<if test= "specWorkType != null" > specWorkType,</if>
<if test= "groupName != null" > groupName,</if>
<if test= "companyTypeId != null" > companyTypeId,</if>
<if test= "companyName != null" > companyName,</if>
<if test= "attendanceTime != null" > attendance_time,</if>
<if test= "attendanceOutTime != null" > attendance_out_time,</if>
<if test= "scanPhoto != null" > scanPhoto,</if>
<if test= "teamId != null" > teamId,</if>
<if test= "workTypeCode != null" > workTypeCode,</if>
<if test= "companyId != null" > companyId,</if>
<if test= "vendorId != null" > vendorId,</if>
<if test= "deviceCode != null" > device_code,</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= "," >
<if test= "cfgid != null" > #{cfgid},</if>
<if test= "appId != null" > #{appId},</if>
<if test= "projectId != null" > #{projectId},</if>
<if test= "projectName != null" > #{projectName},</if>
<if test= "deptId != null" > #{deptId},</if>
<if test= "deptName != null" > #{deptName},</if>
<if test= "vendorsCode != null" > #{vendorsCode},</if>
<if test= "serverid != null" > #{serverid},</if>
<if test= "workerId != null" > #{workerId},</if>
<if test= "workerName != null" > #{workerName},</if>
<if test= "identification != null" > #{identification},</if>
<if test= "workerPhoto != null" > #{workerPhoto},</if>
<if test= "workerGender != null" > #{workerGender},</if>
<if test= "birthDate != null" > #{birthDate},</if>
<if test= "ethnic != null" > #{ethnic},</if>
<if test= "nativePlace != null" > #{nativePlace},</if>
<if test= "phone != null" > #{phone},</if>
<if test= "workTypeName != null" > #{workTypeName},</if>
<if test= "specWorkType != null" > #{specWorkType},</if>
<if test= "groupName != null" > #{groupName},</if>
<if test= "companyTypeId != null" > #{companyTypeId},</if>
<if test= "companyName != null" > #{companyName},</if>
<if test= "attendanceTime != null" > #{attendanceTime},</if>
<if test= "attendanceOutTime != null" > #{attendanceOutTime},</if>
<if test= "scanPhoto != null" > #{scanPhoto},</if>
<if test= "teamId != null" > #{teamId},</if>
<if test= "workTypeCode != null" > #{workTypeCode},</if>
<if test= "companyId != null" > #{companyId},</if>
<if test= "vendorId != null" > #{vendorId},</if>
<if test= "deviceCode != null" > #{deviceCode},</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= "updateSurProjectAttendanceData" parameterType= "SurProjectAttendanceData" >
update sur_project_attendance_data_${year}
<trim prefix= "SET" suffixOverrides= "," >
<if test= "cfgid != null" > cfgid = #{cfgid},</if>
<if test= "appId != null" > app_id = #{appId},</if>
<if test= "projectId != null" > projectId = #{projectId},</if>
<if test= "projectName != null" > projectName = #{projectName},</if>
<if test= "deptId != null" > deptId = #{deptId},</if>
<if test= "deptName != null" > deptName = #{deptName},</if>
<if test= "vendorsCode != null" > vendors_code = #{vendorsCode},</if>
<if test= "serverid != null" > serverid = #{serverid},</if>
<if test= "workerId != null" > workerId = #{workerId},</if>
<if test= "workerName != null" > workerName = #{workerName},</if>
<if test= "identification != null" > identification = #{identification},</if>
<if test= "workerPhoto != null" > workerPhoto = #{workerPhoto},</if>
<if test= "workerGender != null" > workerGender = #{workerGender},</if>
<if test= "birthDate != null" > birthDate = #{birthDate},</if>
<if test= "ethnic != null" > ethnic = #{ethnic},</if>
<if test= "nativePlace != null" > nativePlace = #{nativePlace},</if>
<if test= "phone != null" > phone = #{phone},</if>
<if test= "workTypeName != null" > workTypeName = #{workTypeName},</if>
<if test= "specWorkType != null" > specWorkType = #{specWorkType},</if>
<if test= "groupName != null" > groupName = #{groupName},</if>
<if test= "companyTypeId != null" > companyTypeId = #{companyTypeId},</if>
<if test= "companyName != null" > companyName = #{companyName},</if>
<if test= "attendanceTime != null" > attendance_time = #{attendanceTime},</if>
<if test= "attendanceOutTime != null" > attendance_out_time = #{attendanceOutTime},</if>
<if test= "scanPhoto != null" > scanPhoto = #{scanPhoto},</if>
<if test= "teamId != null" > teamId = #{teamId},</if>
<if test= "workTypeCode != null" > workTypeCode = #{workTypeCode},</if>
<if test= "companyId != null" > companyId = #{companyId},</if>
<if test= "vendorId != null" > vendorId = #{vendorId},</if>
<if test= "deviceCode != null" > device_code = #{deviceCode},</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= "deleteSurProjectAttendanceDataById" parameterType= "Long" >
delete from sur_project_attendance_data_${year} where id = #{id}
</delete>
<delete id= "deleteSurProjectAttendanceDataByIds" parameterType= "String" >
delete from sur_project_attendance_data_${year} where id in
<foreach item= "id" collection= "array" open= "(" separator= "," close= ")" >
#{id}
</foreach>
</delete>
<delete id= "deleteSurProjectAttendanceDataByParams" parameterType= "String" >
delete from sur_project_attendance_data_${year} where CONCAT(app_id,'-',serverid,'-',workerId) in
<foreach collection= "list" item= "item" separator= "," open= "(" close= ")" >
#{item}
</foreach>
</delete>
<insert id= "batchSurProjectAttendanceData" >
insert into sur_project_attendance_data_${year}( id, cfgid, app_id, projectId, projectName, deptId, deptName, vendors_code, serverid, workerId, workerName, identification, workerPhoto, workerGender, birthDate, ethnic, nativePlace, phone, workTypeName, specWorkType, groupName, companyTypeId,
companyName, attendance_time, attendance_out_time, scanPhoto, teamId,workTypeCode, companyId, vendorId, device_code, is_del, create_by, create_time, update_by, update_time) values
<foreach item= "item" index= "index" collection= "list" separator= "," >
( #{item.id}, #{item.cfgid},#{item.appId}, #{item.projectId}, #{item.projectName}, #{item.deptId}, #{item.deptName}, #{item.vendorsCode}, #{item.serverid}, #{item.workerId}, #{item.workerName}, #{item.identification},#{item.workerPhoto}, #{item.workerGender}, #{item.birthDate},#{item.ethnic}, #{item.nativePlace}, #{item.phone}, #{item.workTypeName}, #{item.specWorkType}, #{item.groupName}, #{item.companyTypeId},
#{item.companyName}, #{item.attendanceTime}, #{item.attendanceOutTime}, #{item.scanPhoto},#{item.teamId}, #{item.workTypeCode}, #{item.companyId}, #{item.vendorId}, #{item.deviceCode},#{item.isDel}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
</foreach>
</insert>
<select id= "getLastServerId" parameterType= "SurProjectAttendanceData" resultType= "Long" >
SELECT IF(MAX(serverid+0),MAX(serverid+0),0) serverid FROM sur_project_attendance_data_${year} WHERE cfgid=#{cfgid}
</select>
<select id= "groupByComanyOld" parameterType= "SurProjectAttendanceData" resultMap= "SurProjectAttendanceDataResult" >
select companyTypeId,count(1) id from ( <include refid= "selectSurProjectAttendanceDataVo" /> ) x2 where id in (
select min(id) from ( <include refid= "selectSurProjectAttendanceDataVo" /> ) x1
where date(attendance_time)=#{attendanceTime}
<if test= "subDeptId!=null and subDeptId>0" > and project_id in (
SELECT id FROM pro_project_info WHERE is_del=0 AND deptid = #{subDeptId}
)
</if>
<if test= "prjIds !=null and prjIds.size()>0" >
and project_id in
<foreach collection= "prjIds" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
<if test= "projectId!=null and projectId>0" > and project_id=#{projectId}</if>
group by workerId )
and companyTypeId in (1,2,3,4,5,6,8) group by companyTypeId
</select>
<select id= "groupByComany" parameterType= "SurProjectAttendanceData" resultMap= "SurProjectAttendanceDataResult" >
select g.companyTypeId,count(1) id 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()
and cfgid in (select id from attendance_cfg
<where >
<if test= "projectId!=null and projectId>0" >
and project_id=#{projectId}
</if>
<if test= "subDeptId!=null and subDeptId>0" >
and project_id in (SELECT id FROM pro_project_info WHERE dis_dept_id=#{subDeptId})
</if>
<if test= "prjIds !=null and prjIds.size()>0" >
and project_id in
<foreach collection= "prjIds" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
</where>
)
)
and g.companyTypeId in (1,2,3,4,5,6,8)
<if test= "projectId!=null and projectId>0" >
and c.project_id=#{projectId}
</if>
<if test= "subDeptId!=null and subDeptId>0" >
and c.project_id in (SELECT id FROM pro_project_info WHERE dis_dept_id=#{subDeptId})
</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>
group by g.companyTypeId
</select>
<select id= "groupAllByComany" parameterType= "SurProjectAttendanceData" resultMap= "SurProjectAttendanceDataResult" >
2025-06-26 14:49:00 +08:00
select g.companyTypeId,count(1) id
from sur_project_attendance_user u, attendance_cfg c,view_sur_project_attendance_group g,
pro_project_info sp
where u.cfgid=c.id and u.groupId=g.teamId and u.state=#{id} and c.project_id = sp.id
2025-06-25 23:15:23 +08:00
and sp.is_Del=0
2025-06-26 14:49:00 +08:00
and g.companyTypeId in (0,1,2,3,4,5,6,8)
2025-05-08 00:21:11 +08:00
<if test= "projectId!=null and projectId>0" >
and c.project_id=#{projectId}
</if>
<if test= "subDeptId!=null and subDeptId>0" >
and sp.dis_dept_id=#{subDeptId}
</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 c.project_id in
<foreach collection= "prjIds" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
2025-06-26 14:49:00 +08:00
group by g.companyTypeId
2025-05-08 00:21:11 +08:00
</select>
<select id= "getHuazhuPage" parameterType= "SurProjectAttendanceData" resultType= "Long" >
select max(vendorId) vendorId from sur_project_attendance_data_${year} WHERE cfgid=#{id}
</select>
<select id= "initOtherData" parameterType= "map" resultType= "map" >
select d.workerId,d.app_id,d.serverid,u.companyId,u.companyName,u.`name`,d.identification,u.recentPhoto,u.gender,u.birthDate,u.ethnic,u.nativePlace,u.phone,
u.workTypeName,u.specWorkType,u.groupName,g.companyTypeId,d.teamId,u.workTypeCode,d.vendorId,d.device_code,d.scanPhoto,d.is_del
from sur_project_attendance_data d
left JOIN sur_project_attendance_user u on d.workerId = u.workerId and d.cfgid = u.cfgid
left join sur_project_attendance_group g on u.companyId = g.companyId and g.cfgid = u.cfgid
where d.cfgid=#{cfgid} and date(d.attendance_time) = #{date}
GROUP BY d.workerId
</select>
<select id= "initHuaZhuData" parameterType= "map" resultType= "map" >
select d.workerId,d.app_id,d.serverid,u.companyId,u.companyName,u.`name`,d.identification,u.recentPhoto,u.gender,u.birthDate,u.ethnic,u.nativePlace,u.phone,
u.workTypeName,u.specWorkType,u.groupName,d.teamId,u.workTypeCode,d.vendorId,d.device_code,d.scanPhoto,d.is_del,
CASE WHEN sd.type_flag = 2 THEN '1' WHEN sd.type_flag = 3 THEN '2' WHEN sd.type_flag = 4 THEN '8' else '0' end as companyTypeId
from sur_project_attendance_data d
left JOIN sur_project_attendance_user u on d.workerId = u.workerId and d.cfgid = u.cfgid
left join sys_dept sd on u.companyName = sd.dept_name
where d.cfgid=#{cfgid} and date(d.attendance_time) = #{date}
GROUP BY d.workerId
</select>
<select id= "findHuaZhuCompanyType" parameterType= "string" resultType= "string" >
select CASE WHEN sd.type_flag = 2 THEN '1' WHEN sd.type_flag = 3 THEN '2' WHEN sd.type_flag = 4 THEN '8' else '0' end as companyTypeId
from sys_dept sd
where sd.dept_name = #{deptName}
</select>
<select id= "selectSurProjectAttendanceDataListByDate" parameterType= "surProjectAttendanceData" resultMap= "SurProjectAttendanceDataResult" >
<include refid= "selectSurProjectAttendanceDataVo" />
<where >
<if test= "cfgid != null " > and cfgid = #{cfgid}</if>
<if test= "appId != null " > and app_id = #{appId}</if>
<if test= "projectId != null " > and cfgid in (select id from attendance_cfg where projectId = #{projectId}
<if test= "deptId != null " > and sub_dept_id = #{deptId}</if>
)</if>
<if test= "vendorsCode != null and vendorsCode != ''" > and vendors_code = #{vendorsCode}</if>
<if test= "serverid != null " > and serverid = #{serverid}</if>
<if test= "workerId != null " > and workerId = #{workerId}</if>
<if test= "attendanceOutTime!=null and attendanceOutTime!=''" >
and (date(attendance_out_time) =date(#{attendanceOutTime}) or date(attendance_time) =date(#{attendanceOutTime}))
</if>
<if test= "teamId != null " > and teamId = #{teamId}</if>
<if test= "workTypeCode != null and workTypeCode != ''" > and workTypeCode = #{workTypeCode}</if>
<if test= "companyId != null " > and companyId = #{companyId}</if>
<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= "vendorId != null " > and vendorId = #{vendorId}</if>
<if test= "deviceCode != null and deviceCode != ''" > and device_code = #{deviceCode}</if>
<if test= "scanPhoto != null and scanPhoto != ''" > and scanPhoto like concat('%', #{scanPhoto}, '%')</if>
<if test= "workerName != null and workerName != ''" > and workerName like concat('%', #{workerName}, '%')</if>
<if test= "isDel != null " > and is_del = #{isDel}</if>
<if test= "attendanceTime != null and attendanceTime != ''" > and
(date(attendance_time) = date(#{attendanceTime}) or date(attendance_out_time) = date(#{attendanceTime}) )</if>
<if test= "identification != null and identification != ''" > and identification = #{identification}</if>
</where>
order by id desc
</select>
<select id= "selectSurProjectAttendanceDataListByMonth" parameterType= "surProjectAttendanceData" resultMap= "SurProjectAttendanceDataResult" >
WITH RankedAttendance AS (
SELECT
id,
workerId,
COUNT(1) OVER (PARTITION BY workerId) AS days,
ROW_NUMBER() OVER (PARTITION BY workerId ORDER BY id) AS rn
FROM sur_project_attendance_data_${year}
<where >
<if test= "cfgid != null " > and cfgid = #{cfgid}</if>
<if test= "projectId != null " > and cfgid in (select id from attendance_cfg where projectId = #{projectId}
<if test= "deptId != null " > and sub_dept_id = #{deptId}</if>
)</if>
<if test= "attendanceTime!=null or attendanceOutTime!=null" >
<if test= "attendanceTime!=null and attendanceOutTime!=null" >
AND (date(attendance_time) > = date(#{attendanceTime}) or date(attendance_out_time) > = date(#{attendanceTime}))
AND (date(attendance_time) < = date(#{attendanceOutTime}) or date(attendance_out_time) < = date(#{attendanceOutTime}))
</if>
<if test= "attendanceTime==null and attendanceOutTime!=null" >
AND (date(attendance_time) < = date(#{attendanceOutTime}) or date(attendance_out_time) < = date(#{attendanceOutTime}))
</if>
<if test= "attendanceTime!=null and attendanceOutTime==null" >
AND (date(attendance_time) > = date(#{attendanceTime}) or date(attendance_out_time) > = date(#{attendanceTime}))
</if>
</if>
</where>
)
SELECT a.*, b.days
FROM sur_project_attendance_data_${year} a
JOIN RankedAttendance b ON a.id = b.id
WHERE b.rn = 1
order by a.workerId
</select>
<select id= "todayAttendance" parameterType= "SurProjectAttendanceData" resultMap= "SurProjectAttendanceDataResult" >
select ady.* from sur_project_attendance_data_${year} ady
left join pro_project_info sp on sp.id = ady.projectId
where sp.is_Del=0
<if test= "projectId!=null and projectId>0" >
and ady.projectId=#{projectId}
</if>
<if test= "id==1" >
and ady.companyTypeId in (1,6)
</if>
<if test= "id==2" >
and ady.companyTypeId in (0,2,3,4,5)
</if>
<if test= "id==8" >
and ady.companyTypeId =8
</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 ady.projectId in
<foreach collection= "prjIds" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
<if test= "attendanceTime != null and attendanceTime != ''" > and date(ady.attendance_time) =date(#{attendanceTime})</if>
</select>
<select id= "attendanceDataList" parameterType= "SurProjectAttendanceData" resultMap= "SurProjectAttendanceDataResult" >
select ady.* from sur_project_attendance_data_${year} ady
where ady.cfgid in (select cfg.id from attendance_cfg cfg where cfg.project_id=#{projectId} and cfg.is_del=0)
<if test= "companyTypeId==101" >
and ady.companyTypeId in (1,6)
</if>
<if test= "companyTypeId==103" >
and ady.companyTypeId in (0,2,3,4,5)
</if>
<if test= "companyTypeId==102" >
and ady.companyTypeId =8
</if>
<if test= "workerId != null and workerId != ''" > and ady.workerId = #{workerId}</if>
<if test= "workerName != null and workerName != ''" > and ady.workerName like concat('%', #{workerName}, '%')</if>
<if test= "attendanceTime != null and attendanceTime != ''" > and date(ady.attendance_time) = date(#{attendanceTime})</if>
and ady.is_del=0
order by ady.id desc
</select>
<select id= "groupTodayCompanyTypeId" parameterType= "SurProjectAttendanceData" resultMap= "SurProjectAttendanceDataResult" >
select ady.companyTypeId,count(1) id from sur_project_attendance_data_${year} ady
where ady.cfgid in (select id from attendance_cfg where
is_del=0
<if test= "projectId!=null and projectId>0" >
and projectId=#{projectId}
</if>
and projectId in (select id from pro_project_info sp where sp.is_Del=0
<if test= "deptId!=null and deptId>0" >
and sp.dis_dept_id=#{deptId}
</if>
<if test= "attendanceTime != null and attendanceTime != ''" > and date(ady.attendance_time) =date(#{attendanceTime})</if>
<if test= 'proType != null and proType != "" and proType != "0"' > and sp.projectType = #{proType}</if>
<if test= "prjIds !=null and prjIds.size()>0" >
and ady.projectId in
<foreach collection= "prjIds" item= "item" index= "index" open= "(" close= ")" separator= "," >
#{item}
</foreach>
</if>
)
)
group by ady.companyTypeId
</select>
<select id= "findGroupAllByParams" parameterType= "SurProjectAttendanceData" 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
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
group by g.companyTypeId
UNION ALL
select '3' as type, d.companyTypeId,count(1) as total from sur_project_attendance_data_${year} d
where d.cfgid in (select cfg.id from attendance_cfg cfg where cfg.project_id=#{projectId} and cfg.is_del=0)
and d.is_del=0
and date(d.attendance_time) = date(now())
group by d.companyTypeId
</select>
<select id= "groupDataByParams" parameterType= "SurProjectAttendanceData" resultType= "Map" >
select d.companyTypeId,count(1) as total from sur_project_attendance_data_${year} d
where d.cfgid in (select cfg.id from attendance_cfg cfg where cfg.project_id=#{projectId} and cfg.is_del=0)
and d.is_del=0
<if test= "attendanceTime != null and attendanceTime != ''" > and date(d.attendance_time) = date(#{attendanceTime})</if>
<if test= "workerName != null and workerName != ''" > and d.workerName like concat('%', #{workerName}, '%')</if>
group by d.companyTypeId
</select>
<select id= "findGroupAllByDays" parameterType= "SurProjectAttendanceData" resultType= "Map" >
select '3' as type, DATE_FORMAT(days.attendanceTime, '%m-%d') as attendanceTime,days.total from(
select date(d.attendance_time) as attendanceTime, DATE_FORMAT(d.attendance_time, '%m-%d'),count(1) as total from sur_project_attendance_data_${year} d
where d.cfgid in (select cfg.id from attendance_cfg cfg where cfg.project_id=#{projectId} and cfg.is_del=0)
2025-05-19 00:12:03 +08:00
and d.is_del=0 and state=0
2025-05-08 00:21:11 +08:00
and date(d.attendance_time) between #{attendanceTime} and #{attendanceOutTime}
group by date(d.attendance_time)
order by date(d.attendance_time)
)days
</select>
2025-05-19 00:12:03 +08:00
<select id= "groupAttendanceLastWeek" resultMap= "SurProjectAttendanceDataResult" >
SELECT dt deptName,count(1) deptId
from (
select DISTINCT workerId, date(ifnull(attendance_time,attendance_out_time)) dt
from sur_project_attendance_data_${year} where
2025-05-21 00:47:25 +08:00
is_del !=1
2025-05-19 00:12:03 +08:00
and projectid=#{prjId}
2025-06-25 23:15:23 +08:00
AND DATE( ifnull( attendance_time, attendance_out_time ) ) > = date(#{dateStart})
AND DATE( ifnull( attendance_time, attendance_out_time ) ) < = date(#{dateEnd})
2025-05-19 00:12:03 +08:00
) tmp
group by dt
</select>
<select id= "getRealAttendance" resultMap= "SurProjectAttendanceDataResult" >
select * from sur_project_attendance_data_${year}
where date(attendance_time)=date(now()) or date(attendance_out_time)=date(now())
and is_del!=1
2025-05-23 00:08:04 +08:00
and projectid=#{prjId}
order by ifnull(attendance_time,attendance_out_time) DESC
2025-05-19 00:12:03 +08:00
LIMIT 4
</select>
2025-06-27 00:32:10 +08:00
<select id= "statsAttendanceDaysByProId" parameterType= "SurProjectAttendanceData" resultType= "Map" >
select '1' as craftType,count(1) as total from sur_project_attendance_data_${year}
where projectId=#{projectId} and specWorkType = 1 and companyTypeId != 1
UNION ALL
select '2' as craftType,count(1) as total from sur_project_attendance_data_${year}
where projectId=#{projectId} and specWorkType = 0 and companyTypeId != 1
UNION ALL
select '3' as craftType,count(1) as total from sur_project_attendance_data_${year}
where projectId=#{projectId} and companyTypeId = 1
</select>
<select id= "statsAttendanceViewByProId" parameterType= "SurProjectAttendanceData" resultType= "Map" >
select DATE_FORMAT(days.attendanceTime, '%m-%d') as attendanceTime,days.total from(
select date(d.create_time) as attendanceTime, count(1) as total from sur_project_attendance_data_${year} d
<where >
<if test= "projectId != null " > and d.projectId = #{projectId}</if>
<if test= "params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''" > and date(d.create_time) between #{params.beginTime} and #{params.endTime}</if>
</where>
group by attendanceTime
order by attendanceTime
)days
</select>
2025-05-08 00:21:11 +08:00
</mapper>