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

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.ym.mec.biz.dal.entity.ClassGroupTeacherMapper;
import org.apache.ibatis.annotations.Param;

import com.ym.mec.biz.dal.dto.CourseScheduleDto;
import com.ym.mec.biz.dal.dto.TeacherAttendanceDto;
import com.ym.mec.biz.dal.entity.CourseSchedule;
import com.ym.mec.biz.dal.entity.StudentCourseScheduleRecordDto;
import com.ym.mec.biz.dal.enums.CourseStatusEnum;
import com.ym.mec.common.dal.BaseDAO;

public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {

    /**
     * 根据教师ID获取当前课程信息
     *
     * @param teacherID
     * @return
     */
    TeacherAttendanceDto getCurrentCourseDetail(@Param("courseID") Long courseID);

    /**
     * @Author: Joburgess
     * @Date: 2019/10/16
     * @params [startTime, endTime, teacherId]
     * @return com.ym.mec.biz.dal.dto.TeacherAttendanceDto
     * @describe 根据时间区间获取教师上课的课程
     */
    TeacherAttendanceDto getTeacherCourseByDateSpeed(@Param("startTime") Date startTime, @Param("endTime") Date endTime, @Param("teacherId") Long teacherId);

    int batchAddCourseSchedules(List<CourseSchedule> courseSchedules);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/17
     * 统计学生所属班级数量
     */
    Integer[] countStudentInClass(List<Integer> classGroupIDs);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/17
     * 根据日期获取当日排课信息
     */
    List<CourseScheduleDto> getCourseSchedulesWithDate(@Param("classDate") Date classDate);

    /**
     * @Author: Joburgess
     * @Date: 2019/10/14
     * @params [classDates, classGroupId]
     * @return java.util.List<com.ym.mec.biz.dal.entity.CourseSchedule>
     * @describe 根据班级和上课日期获取课程计划
     */
    List<CourseSchedule> findByClassGroupAndDate(@Param("classDates") List<Date> classDates, @Param("classGroupId") Long classGroupId);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/17
     * 根据日期获取学生当日排课信息
     */
    List<CourseScheduleDto> getStudentCourseSchedulesWithDate(@Param("classDate") Date classDate, @Param("studentId") Long studentId);

    /**
     * @Author: Joburgess
     * @Date: 2019/10/11
     * @params [courseScheduleId]
     * @return java.util.List<java.lang.String>
     * @describe 获取课程签到学生姓名
     */
    List<String> findStudentNamesByCourseSchedule(Long courseScheduleId);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/17
     * 根据日期获取老师当日排课信息
     */
    List<CourseScheduleDto> getTeacherCourseSchedulesWithDate(@Param("classDate") Date classDate, @Param("teacherId") Long teacherId);

    /**
     * @Author: Joburgess
     * @Date: 2019/10/11
     * @params [params]
     * @return java.util.List<com.ym.mec.biz.dal.dto.CourseScheduleDto>
     * @describe 根据
     */
    List<CourseScheduleDto> getCourseSchedulesWithDate(Map<String, Object> params);

    int countCourseSchedulesWithDate(Map<String, Object> params);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/17
     * 根据乐团ID删除排课
     */
    int deleteCourseSchedulesByMusicGroupID(@Param("musicGroupID") Long musicGroupID);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/17
     * 根据月份获取乐团在该月有课的日期
     */
    List<Date> getCourseScheduleDateByMonth(@Param("musicGroupID") Long musicGroupID, @Param("month") Date month);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/27
     * 获取学生有课日期
     */
    List<Date> getStudentCourseScheduleDate(@Param("studentId") Long studentId, @Param("month") Date month, @Param("isAttend") Integer isAttend);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/27
     * 获取教师有课日期
     */
    List<Date> getTeacherCourseScheduleDate(@Param("teacherId") Long teacherId, @Param("month") Date month);

    /**
     * @Author: Joburgess
     * @Date: 2019/10/11
     * @params [month, organId]
     * @return java.util.List<java.util.Date>
     * @describe 获取当月有课的日期
     */
    List<Date> getCourseScheduleDate(@Param("month") Date month, @Param("organId") Long organId);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/23
     * 统计教师在一天内有时间重复的课数
     */
    int countTeacherCourseInOnDayRepeats(CourseSchedule courseSchedule);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/24
     * 根据日期获取对应老师的课程
     */
    List<CourseSchedule> findTeacherCoursesInDates(@Param("dates") List<Date> dates, @Param("teacherId") Long teacherId);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/24
     * 根据日期获取课程
     */
    List<CourseSchedule> findCoursesByDates(@Param("dates") List<Date> dates);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/24
     * 获取在指定时间段内存在重复的课程
     */
    List<CourseSchedule> findOverLapCoursesInDay(@Param("dates") List<Date> dates, @Param("startClassTime") Date startClassTime,
                                                 @Param("endClassTime") Date endClassTime);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/29
     * 获取班级的声部
     */
    String[] findClassSubjects(List<Integer> ids);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/24
     * 根据id批量获取课程
     */
    List<CourseSchedule> findCourseSchedulesByIds(@Param("ids") Long[] ids);

    /**
     * 获取班级未开始的课程计划
     * @param classGroupTeacherMapperList
     * @return
     */
    List<CourseSchedule> findClassGroupNoStartCourseSchedules(@Param("classGroupTeacherMapperList") List<ClassGroupTeacherMapper> classGroupTeacherMapperList);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/30
     * 获取学生上课记录
     */
    List<StudentCourseScheduleRecordDto> findStudentCourseScheduleRecords(Map<String, Object> params);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/30
     * 统计学生上课记录
     */
    int countStudentCourseScheduleRecords(Map<String, Object> params);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/30
     * 获取学生未上课记录
     */
    List<StudentCourseScheduleRecordDto> findStudentCourseScheduleNotStartRecords(@Param("userId") Long userId, @Param("date") Date date);

    /**
     * @Author: Joburgess
     * @Date: 2019/10/8
     * @params [classGroupId]
     * @return int
     * @describe 统计已上课次
     */
    int countClassTimes(Long classGroupId);

    /**
     * @Author: Joburgess
     * @Date: 2019/9/17
     * 获取课程信息
     */
    CourseScheduleDto getCourseSchedules(@Param("courseScheduleId") Long courseScheduleId);

    /**
     * @Author: Joburgess
     * @Date: 2019/10/14
     * @params [vipGroupId]
     * @return java.util.List<com.ym.mec.biz.dal.entity.CourseSchedule>
     * @describe 获取vip课排课计划
     */
    List<CourseSchedule> findVipGroupCourseSchedules(@Param("vipGroupId") Long vipGroupId);

    /**
     * @Author: Joburgess
     * @Date: 2019/10/16
     * @params [courseScheduleId]
     * @return java.lang.String
     * @describe 获取课程关联班级类型
     */
    String findClassTypeByCourse(@Param("courseScheduleId") Long courseScheduleId);

    /**
     * 根据课程状态查询老师指定月份的VIP课程记录数
     * @param monthDate 指定月份
     * @param status 课程状态
     * @return
     */
    List<Map<Integer, Integer>> queryVipGroupTeachereClassTimesByMonth(@Param("monthDate") Date monthDate,@Param("status") CourseStatusEnum status);

    /**
     * 查询已完成未更新状态的课程列表
     * @return
     */
    List<CourseSchedule> queryFinishedWithNoUpdateStatus();
    
    int batchUpdate(List<CourseSchedule> courseScheduleList);
}