jhprjv2/yanzhu-jh/src/main/resources/mapper/project/SurProjectAttendanceUserMap...

558 lines
34 KiB
XML

<?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" />
<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,sur_project_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.remark,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
FROM sur_project_attendance_user u,sur_project_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="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>
</select>
<select id="selectSurProjectAttendanceUserList" parameterType="SurProjectAttendanceUser" resultMap="SurProjectAttendanceUserResult">
<include refid="selectSurProjectAttendanceUserVo"/>
<where>
<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,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.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 sur_project_attendance_cfg WHERE project_id=#{projectId} AND sub_dept_id=#{subDeptId}
) ) xx
</sql>
<select id="queryAttendanceData" parameterType="SurProjectAttendanceCfg" 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="SurProjectAttendanceCfg">
select count(1) cnt from sur_project_attendance_user u, sur_project_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 sur_project_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, sur_project_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 sur_project_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, sur_project_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 sur_project WHERE deptid=#{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, sur_project_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 sur_project WHERE deptid=#{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, sur_project_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 sur_project WHERE deptid=#{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.*,b.project_id,b.sub_dept_id
FROM sur_project_attendance_user u,sur_project_attendance_cfg b,view_sur_project_attendance_group g
WHERE u.cfgid=b.id and u.state=0 and u.companyId=g.companyId
<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 b.project_id in (SELECT id FROM sur_project WHERE deptid=#{deptId})
</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="groupByWorkerOnDutyByDept" parameterType="SurProjectAttendanceUser" resultMap="SurProjectAttendanceUserResult">
SELECT p.id, p.projectName NAME,c.dept_name groupName,g.companyTypeId companyId,COUNT(1) cfgid
FROM sur_project_attendance_user u,sur_project_attendance_cfg b,view_sur_project_attendance_group g,sur_project 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.sub_dept_id
and g.companyTypeId in (1,6,0,2,3,4,5,8)
<if test="deptId!=null and deptId>0">
and b.project_id in (SELECT id FROM sur_project WHERE deptid=#{deptId})
</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>
</mapper>