<?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="cn.com.oa.mapper.AttendanceRecordResultMapper">

    <select id="getResultMonth" resultType="java.util.Map">
        SELECT
            (
                SELECT
                    COUNT(*)
                FROM
                    hr_attendance_record_result
                WHERE
                    special_type = '1'
                    <if test="attendanceRecordResult.unitId!=null">
                        AND unit_id = #{attendanceRecordResult.unitId}
                    </if>
                  AND att_date BETWEEN DATE_FORMAT(CURDATE(), '%Y-%m-01') AND LAST_DAY(CURDATE())
                  AND late1_num = 0
                  AND late2_num = 0
                  AND late3_num = 0
                  AND late4_num = 0
                  AND late5_num = 0
                  AND leave_early1_num = 0
                  AND absenteeism_num = 0
            ) AS zcCount,
            (
                SELECT
                    COUNT(*)
                FROM
                    hr_attendance_record_result
                WHERE
                    special_type = '1'
                    <if test="attendanceRecordResult.unitId!=null">
                        AND unit_id = #{attendanceRecordResult.unitId}
                    </if>
                  AND att_date BETWEEN DATE_FORMAT(CURDATE(), '%Y-%m-01') AND LAST_DAY(CURDATE())
                  AND general_holiday_num > 0
            ) AS gxCount,
            (
                SELECT
                    COUNT(*)
                FROM
                    hr_attendance_record_result
                WHERE
                    special_type = '1'
                    <if test="attendanceRecordResult.unitId!=null">
                        AND unit_id = #{attendanceRecordResult.unitId}
                    </if>
                  AND att_date BETWEEN DATE_FORMAT(CURDATE(), '%Y-%m-01') AND LAST_DAY(CURDATE())
                  AND out_num > 0
            ) AS wcCount,
            (
                SELECT
                    COUNT(*)
                FROM
                    hr_attendance_record_result
                WHERE
                    special_type = '1'
                    <if test="attendanceRecordResult.unitId!=null">
                        AND unit_id = #{attendanceRecordResult.unitId}
                    </if>
                  AND att_date BETWEEN DATE_FORMAT(CURDATE(), '%Y-%m-01') AND LAST_DAY(CURDATE())
                  AND segment_name IS NULL
                  AND general_holiday_num = 0
            ) AS wpbCount,
            (
                SELECT
                    COUNT(*)
                FROM
                    hr_attendance_record_result
                WHERE
                    special_type = '1'
                    <if test="attendanceRecordResult.unitId!=null">
                        AND unit_id = #{attendanceRecordResult.unitId}
                    </if>
                  AND att_date BETWEEN DATE_FORMAT(CURDATE(), '%Y-%m-01') AND LAST_DAY(CURDATE())
                  AND (late1_num > 0 OR late2_num > 0 OR late3_num > 0 OR late4_num > 0 OR late5_num > 0)
            ) AS cdCount,
            (
                SELECT
                    COUNT(*)
                FROM
                    hr_attendance_record_result
                WHERE
                    special_type = '1'
                    <if test="attendanceRecordResult.unitId!=null">
                        AND unit_id = #{attendanceRecordResult.unitId}
                    </if>
                  AND att_date BETWEEN DATE_FORMAT(CURDATE(), '%Y-%m-01') AND LAST_DAY(CURDATE())
                  AND leave_early1_num > 0
            ) AS ztCount,
            (
                SELECT
                    COUNT(*)
                FROM
                    hr_attendance_record_result
                WHERE
                    special_type = '1'
                    <if test="attendanceRecordResult.unitId!=null">
                        AND unit_id = #{attendanceRecordResult.unitId}
                    </if>
                  AND att_date BETWEEN DATE_FORMAT(CURDATE(), '%Y-%m-01') AND LAST_DAY(CURDATE())
                  AND absenteeism_num > 0
            ) AS qqCount
    </select>
</mapper>
