<?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.AttendanceStaffStatDaoImpl">

    <select id="getListExt" parameterType="com.mortals.xhx.module.attendance.model.vo.AttendanceSummaryQuery" resultMap="AttendanceStaffStatEntity-Map">
        select s.*
        from mortals_xhx_attendance_staff_stat as s
        where
        <if test="staffId != null">
         s.staffId=#{staffId} AND
        </if>
        STR_TO_DATE(CONCAT(s.`year`,'-',s.`month`,'-',s.`day`),'%Y-%m-%d') <![CDATA[ >= ]]> STR_TO_DATE(#{summaryTimeStart},'%Y-%m-%d')
        AND STR_TO_DATE(CONCAT(s.`year`,'-',s.`month`,'-',s.`day`),'%Y-%m-%d') <![CDATA[ <= ]]> STR_TO_DATE(#{summaryTimeEnd},'%Y-%m-%d')
        <if test="staffIdList != null and staffIdList.size>0">
            AND s.staffId in
            <foreach collection="staffIdList" open="(" close=")" index="index" item="item" separator=",">
                #{item}
            </foreach>
        </if>

        <if test="summaryTypeList != null and summaryTypeList.size>0">
            AND s.attendanceSummary REGEXP
            replace(<foreach collection="summaryTypeList" open="'" close="'" index="index" item="item" separator="|">${item}</foreach>,' ','')
        </if>

    </select>
</mapper>