<?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.xjrsoft.module.outint.mapper.StudentOutInRecordMapper">
    <select id="getNotStayClassCount" resultType="com.xjrsoft.module.outint.vo.IdCountVo">
        SELECT t1.class_id AS id,COUNT(t1.user_id) FROM student_out_in_record t1
        INNER JOIN base_student_school_roll t2 ON t1.user_id = t2.user_id
        WHERE t1.delete_mark = 0 AND t1.status = 0 AND t2.delete_mark = 0
        AND t2.stduy_status = 'FB3002'
        AND t1.record_time BETWEEN #{startTime} AND #{endTime}
        GROUP BY t1.class_id
    </select>
    <select id="getStayClassCount" resultType="com.xjrsoft.module.outint.vo.IdCountVo">
        SELECT t1.class_id AS id,COUNT(t1.user_id) FROM student_out_in_record t1
        INNER JOIN base_student_school_roll t2 ON t1.user_id = t2.user_id
        WHERE t1.delete_mark = 0 AND t1.status = 0 AND t2.delete_mark = 0
        AND t2.stduy_status = 'FB3002'
        AND t1.record_time BETWEEN #{startTime} AND #{endTime}
        GROUP BY t1.class_id
    </select>

    <select id="getNotStayList" resultType="com.xjrsoft.module.outint.vo.StudentOutInRecordVo">
        SELECT t1.* FROM student_out_in_record t1
        INNER JOIN base_student_school_roll t2 ON t1.user_id = t2.user_id
        WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
        AND t2.stduy_status = 'FB3001'
        AND t1.record_time BETWEEN #{startTime} AND #{endTime}
        and DATE_FORMAT(t1.record_time, '%Y-%m-%d') not in (
            SELECT holiday_date.date FROM holiday_date WHERE STATUS IN (0, 2) AND delete_status = 0
            AND holiday_date.date BETWEEN DATE_FORMAT(#{startTime}, '%Y-%m-%d') AND DATE_FORMAT(#{endTime}, '%Y-%m-%d')
        )
    </select>
    <select id="getStayList" resultType="com.xjrsoft.module.outint.vo.StudentOutInRecordVo">
        SELECT t1.* FROM student_out_in_record t1
        INNER JOIN base_student_school_roll t2 ON t1.user_id = t2.user_id
        WHERE t1.delete_mark = 0 AND t2.delete_mark = 0
        AND t2.stduy_status = 'FB3002'
        AND t1.record_time BETWEEN #{startTime} AND #{endTime}
        and DATE_FORMAT(t1.record_time, '%Y-%m-%d') not in (
            SELECT holiday_date.date FROM holiday_date WHERE STATUS IN (0, 2) AND delete_status = 0
            AND holiday_date.date BETWEEN DATE_FORMAT(#{startTime}, '%Y-%m-%d') AND DATE_FORMAT(#{endTime}, '%Y-%m-%d')
        )
    </select>
    <select id="getList" resultType="com.xjrsoft.module.outint.vo.StudentOutInRecordVo">
        SELECT t1.* FROM student_out_in_record t1
        INNER JOIN base_student_school_roll t2 ON t1.user_id = t2.user_id
        WHERE t1.delete_mark = 0 AND t2.delete_mark = 0 and t1.status = #{status}
        AND t1.record_time BETWEEN #{startTime} AND #{endTime}
        AND t2.stduy_status = 'FB3001'
        order by t1.record_time
    </select>
</mapper>