<?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.ruoyi.wgz.mapper.WgzAttendanceMapper">

    <resultMap type="com.ruoyi.wgz.domain.WgzAttendance" id="WgzAttendanceResult">
        <result property="id" column="id"/>
        <result property="recruitId" column="recruit_id"/>
        <result property="userId" column="user_id"/>
        <result property="leaveMarkId" column="leave_mark_id"/>
        <result property="dailyWage" column="daily_wage"/>
        <result property="date" column="date"/>
        <result property="pnchOsition" column="pnch_osition"/>
        <result property="clockInTime" column="clock_in_time"/>
        <result property="clockOutTime" column="clock_out_time"/>
        <result property="late" column="late"/>
        <result property="lateTime" column="late_time"/>
        <result property="earlyLeave" column="early_leave"/>
        <result property="earlyLeaveTime" column="early_leave_time"/>
        <result property="missedIn" column="missed_in"/>
        <result property="missedOut" column="missed_out"/>
        <result property="exceptionType" column="exceptionType"/>
        <result property="delFlag" column="del_flag"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
        <result property="remark" column="remark"/>
    </resultMap>


    <select id="countByTaskId" resultType="com.ruoyi.bgt.domain.vo.BgtAttendanceCountVO">
        select count(1) as reportToDutyNum,
        date,
        (select count(1) from bgt_project_recruit_apply where entry_time &lt;= date and (leave_time is null or leave_time>date)
        and recruit_id in (select id from bgt_project_recruit where task_id = #{taskId} )) as totalNum
        from wgz_attendance
        where date between #{beginDate} and #{endDate}
        and (missed_in = 0 or missed_out = 0)
        and recruit_id in (select id from bgt_project_recruit where task_id = #{taskId} )
        group by date order by date
    </select>

</mapper>
