package com.ym.mec.biz.dal.dao;

import com.ym.mec.biz.dal.dto.*;
import com.ym.mec.biz.dal.entity.TeacherAttendance;
import com.ym.mec.biz.dal.enums.GroupType;
import com.ym.mec.common.dal.BaseDAO;
import org.apache.ibatis.annotations.Param;

import java.util.*;

public interface TeacherAttendanceDao extends BaseDAO<Long, TeacherAttendance> {

    /**
     * 获取教师个人的签到记录
     * @param params
     * @return
     */
    List<TeacherPersonalAttendanceDto> getTeacherPersonalAttendances(Map<String,Object> params);

    /**
     * 获取教师签到列表
     * @param params
     * @return
     */
    List<TeacherAttendancesDto> queryTeacherAttendances(Map<String,Object> params);

    int batchInsert(@Param("teacherAttendances") List<TeacherAttendance> teacherAttendances);

    int batchDeleteByCourseSchedules(@Param("courseScheduleIds") List<Long> courseScheduleIds);

    int batchDeleteByCourseAndUsers(@Param("courseScheduleId") Integer courseScheduleId,
                                    @Param("userIds") List<Integer> userIds);

    /**
     * 教师个人签到记录统计
     * @param params
     * @return
     */
    int getTeacherPersonalAttendancesCount(Map<String,Object> params);

    /**
     * 获取教师签到列表
     * @param params
     * @return
     */
    int countTeacherAttendances(Map<String,Object> params);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/24
     * 统计课次
     */
    int countClassTime(Long classGroupId);

    /**
     * @Author: Joburgess
     * @Date: 2019/10/11
     * @params [teacherId, courseScheduleId]
     * @return com.ym.mec.biz.dal.entity.TeacherAttendance
     * @describe 根据老师编号和课程编号获取老师签到记录
     */
    TeacherAttendance findByTeacherAttendanceInfo(@Param("teacherId") Long teacherId,
                                                  @Param("courseScheduleId") Long courseScheduleId);
	
    /**
     * 查询超过指定分钟数还未签退的用户
     * @param minutes 分钟数
     * @return
     */
    List<Mapper> queryNoSignOutListByOverMinutes(Integer minutes);

    /**
     * @describe 根据日期获取部门下异常签到的课程记录
     * @author Joburgess
     * @date 2019/10/25
     * @param organId: 部门编号
     * @param date: 日期
     * @param signInStatus: 签到状态：0异常，1正常，null未签到
     * @return java.util.List<com.ym.mec.biz.dal.dto.TeacherAbnormalAttendanceInfoDto>
     */
    List<TeacherAbnormalAttendanceInfoDto> findTeacherAbnormalSignInCourseScheduleRecord(@Param("organId") Integer organId,
                                                                                         @Param("date") Date date,
                                                                                         @Param("signInStatus") Integer signInStatus);

    /**
     * @describe 根据月份获取部门下异常签到的日期
     * @author Joburgess
     * @date 2019/10/25
     * @param organId: 部门编号
     * @param date: 日期
     * @return java.util.List<java.util.Date>
     */
    List<Date> findTeacherAbnormalSignInDates(@Param("organId") Integer organId,@Param("date") Date date);

    /**
     * @describe 根据日期获取对应签到状态的课程数量
     * @author Joburgess
     * @date 2019/10/25
     * @param organId: 部门编号
     * @param date: 日期
     * @param signInStatus: 签到状态：0异常，1正常，null未签到
     * @return int
     */
    int countTeacherAbnormalSignInClassTimes(@Param("organId") Integer organId,
                                             @Param("date") Date date,
                                             @Param("signInStatus") Integer signInStatus);

    /**
     * @describe
     * @author Joburgess
     * @date 2019/11/11
     * @param courseScheduleIds: 课程编号列表
     * @return java.util.List<java.util.Map<java.lang.Integer,java.lang.Integer>>
     */
    List<TeacherAttendance> findTeacherIdByCourseSchedule(@Param("courseScheduleIds") List<Long> courseScheduleIds);

    /**
     * @describe 获取指定课程的教师签到记录
     * @author Joburgess
     * @date 2020.10.19
     * @param courseScheduleIds:
     * @return java.util.List<com.ym.mec.biz.dal.entity.TeacherAttendance>
     */
    List<TeacherAttendance> findByCourseSchedules(@Param("courseScheduleIds") List<Long> courseScheduleIds);
    
	/**
	 * 更新vip课的签退状态
	 * @param courseScheduleIdList
	 * @return
	 */
	int updateViPSignOutStatus(String courseScheduleIdList);

	/**
	 * @describe 获取班级上已结束课程的课次
	 * @author Joburgess
	 * @date 2019/11/22
	 * @param classGroupId: 班级编号
	 * @return java.util.List<java.util.Map<java.lang.Integer,java.lang.Integer>>
	 */
	List<Map<Integer,Integer>> findCourseTimeByClassGroup(Integer classGroupId);

    /**
     * @describe 获取指定课程的课次
     * @author Joburgess
     * @date 2019/11/22
     * @param courseScheduleIds: 课程编号列表
     * @return java.util.List<java.util.Map<java.lang.Integer,java.lang.Integer>>
     */
    List<Map<Integer,Integer>> findCourseTimeByCourseSchedules(@Param("courseScheduleIds") List<Integer> courseScheduleIds);
	
	/**
	 * 批量删除
	 * @param musicGroupId
	 * @param groupType
	 * @return
	 */
	int deleteByMusicGroupId(@Param("musicGroupId")String musicGroupId, @Param("groupType")GroupType groupType);
	
	int deletebyCourseScheduleId(@Param("courseScheduleId") Long courseScheduleId);

	/**
	 * @describe 清空指定课程教师签到信息
	 * @author Joburgess
	 * @date 2020/1/9
	 * @param courseScheduleId: 课程编号
	 * @return int
	 */
	int cleanCourseTeacherSignInfo(@Param("courseScheduleId") Long courseScheduleId);

	/**
	 * @describe 批量清空指定课程的教师签到信息
	 * @author Joburgess
	 * @date 2020/2/16
	 * @param courseScheduleIds:
	 * @return int
	 */
	int batchCleanCourseTeacherSignInfo(@Param("courseScheduleIds") List<Long> courseScheduleIds);

    TeacherAttendance getMainTeacherAttendance(Integer courseScheduleId);

	/**
	 * 连堂课签到，签退
	 * @param courseScheduleId
	 */
	void cuntinueCourseSign(@Param("courseScheduleId")Long courseScheduleId,@Param("startDateTime")Date startDateTime,@Param("endDateTime")Date endDateTime,@Param("status")Integer status);

	/**
	 * 修改课程的签到老师
	 * @param courseScheduleIds
	 * @param teacherId
	 */
    void batchUpdateTeacher(@Param("courseScheduleIds") Set<Long> courseScheduleIds, @Param("teacherId") Integer teacherId);

	/**
	 * 清除考勤申述
	 * @param courseScheduleIds
	 */
    void clearAttendanceComplaints(@Param("courseScheduleIds") Collection<Long> courseScheduleIds);

	/**
	 * 清除考勤申述
	 * @param courseScheduleId
	 */
    void clearAttendanceComplaint(@Param("courseScheduleId") Long courseScheduleId);

	/**
	 * @describe 根据团体删除班级
	 * @author Joburgess
	 * @date 2020/2/17
	 * @param groupId:
	 * @param groupType:
	 * @return int
	 */
	int deleteByGroup(@Param("groupId") String groupId,
					  @Param("groupType")GroupType groupType);

	/**
	 * 获取当前课程老师总上课时长
	 * @param courseId
	 * @param teacherId
	 * @return
	 */
    int getTotalMinutes(@Param("courseId") Long courseId, @Param("teacherId") Integer teacherId);

	/**
	 * 清空签退信息
	 * @param courseId
	 */
	void cleanCourseTeacherSignOut(@Param("courseId") Long courseId);

	/**
	 * 获取当天有异常考勤的老师列表
	 * @param format
	 * @return
	 */
    Set<Integer> queryTeacherExceptionAttendance(String format);

	/**
	 * 获取教师课时申述列表
	 * @param params
	 * @return
	 */
	List<TeacherAttendanceComplaintsDto> queryTeacherAttendanceComplaints(Map<String, Object> params);

	/**
	 * COUNT教师课时申述列表
	 * @param params
	 * @return
	 */
	int countTeacherAttendanceComplaints(Map<String, Object> params);

	/**
	 * 获取上课时间
	 * @param courseScheduleId
	 * @return
	 */
    Integer getAttendClassTime(Integer courseScheduleId);

    /**
     * @describe 获取连堂课里第一次签到的课程
     * @apiNote 时光荏苒，认真工作的时间总是过得很快，而我、享受这一刻！
     * @author zouxuan
     * @date 2020/9/26
     * @time 16:58
     * @param currentScheduleId:
     * @return java.lang.Long
     */
	Long findFirstSign(@Param("currentScheduleId") Long currentScheduleId, @Param("userId") Integer userId);
}
