<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "mybatis-3-mapper.dtd">
<mapper namespace="com.mortals.xhx.module.attendance.dao.ibatis.AttendanceRecordErrorDaoImpl">
    <!-- 获取每月异常top10列表 -->
    <select id="getMonthTop10" parameterType="com.mortals.xhx.module.attendance.model.AttendanceRecordErrorQuery"
            resultType="com.mortals.xhx.module.attendance.model.vo.ErrorSummaryVo">
        SELECT
        *
        FROM
        (
        SELECT
        staffId,
        staffName,
        count(1) AS errorCount
        FROM
        mortals_xhx_attendance_record_error
        WHERE
        errorDateTime <![CDATA[ >= ]]> STR_TO_DATE(left(concat(#{errorDateTimeStart},' 00:00:00'),19),'%Y-%m-%d %k:%i:%s')
        AND errorDateTime <![CDATA[ <= ]]> STR_TO_DATE(left(concat(#{errorDateTimeEnd},' 23:59:59'),19),'%Y-%m-%d %k:%i:%s')
        GROUP BY
        staffId,
        staffName
        ) AS a
        ORDER BY
        errorCount DESC
        LIMIT 10
    </select>
</mapper>