|  | @@ -1,26 +1,25 @@
 | 
	
		
			
				|  |  |  package com.yonge.cooleshow.biz.dal.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 | 
	
		
			
				|  |  |  import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  | -import com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch;
 | 
	
		
			
				|  |  | -import com.yonge.cooleshow.biz.dal.vo.MyCourseVo;
 | 
	
		
			
				|  |  | -import com.yonge.cooleshow.common.constant.SysConfigConstant;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.dao.CourseScheduleDao;
 | 
	
		
			
				|  |  | -import com.yonge.cooleshow.biz.dal.entity.CourseCalendarEntity;
 | 
	
		
			
				|  |  | -import com.yonge.cooleshow.biz.dal.entity.CourseSchedule;
 | 
	
		
			
				|  |  | -import com.yonge.cooleshow.biz.dal.entity.CourseTimeEntity;
 | 
	
		
			
				|  |  | -import com.yonge.cooleshow.biz.dal.entity.HolidaysFestivals;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.dto.search.MyCourseSearch;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.entity.*;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.service.CourseScheduleService;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.service.HolidaysFestivalsService;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.service.SysConfigService;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.service.TeacherFreeTimeService;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.support.PageUtil;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.support.WrapperUtil;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.biz.dal.vo.MyCourseVo;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.biz.dal.vo.TeacherLiveCourseInfoVo;
 | 
	
		
			
				|  |  | +import com.yonge.cooleshow.common.constant.SysConfigConstant;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.common.exception.BizException;
 | 
	
		
			
				|  |  |  import com.yonge.cooleshow.common.page.PageInfo;
 | 
	
		
			
				|  |  |  import com.yonge.toolset.utils.date.DateUtil;
 | 
	
	
		
			
				|  | @@ -37,6 +36,7 @@ import javax.validation.Valid;
 | 
	
		
			
				|  |  |  import java.time.LocalDate;
 | 
	
		
			
				|  |  |  import java.time.temporal.TemporalAdjusters;
 | 
	
		
			
				|  |  |  import java.util.*;
 | 
	
		
			
				|  |  | +import java.util.function.BiConsumer;
 | 
	
		
			
				|  |  |  import java.util.function.Function;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
	
		
			
				|  | @@ -57,6 +57,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 | 
	
		
			
				|  |  |      private HolidaysFestivalsService holidaysFestivalsService;
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private SysConfigService sysConfigService;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private TeacherFreeTimeService teacherFreeTimeService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public CourseScheduleDao getDao() {
 | 
	
	
		
			
				|  | @@ -108,7 +110,12 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 | 
	
		
			
				|  |  |          //获取日期-目前上课没有跨天情况
 | 
	
		
			
				|  |  |          String ymd = DateUtil.format(startTime, DateUtil.DEFAULT_PATTERN);
 | 
	
		
			
				|  |  |          //查询大于当前时间并未开始的课程
 | 
	
		
			
				|  |  | -        List<CourseSchedule> list = baseMapper.queryStudentCourse(studentId, ymd);
 | 
	
		
			
				|  |  | +        Map<String, Object> param = new HashMap<>();
 | 
	
		
			
				|  |  | +        param.put("studentId", studentId);
 | 
	
		
			
				|  |  | +        param.put("greaterDate", new Date());
 | 
	
		
			
				|  |  | +        param.put("classDate", ymd);
 | 
	
		
			
				|  |  | +        param.put("status", CourseScheduleEnum.NOT_START.getCode());
 | 
	
		
			
				|  |  | +        List<CourseSchedule> list = baseMapper.queryStudentCourse(param);
 | 
	
		
			
				|  |  |          return checkCourseTime(list, CourseSchedule::getStartTime, CourseSchedule::getEndTime, startTime, endTime);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -155,8 +162,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 | 
	
		
			
				|  |  |       * @param endTime      新增课程结束时间
 | 
	
		
			
				|  |  |       * @return true 有交集 false 没有交集
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public <T> boolean checkCourseTime(List<T> list, Function<T, Date> startTimeFun, Function<T, Date> endTimeFun,
 | 
	
		
			
				|  |  | -                                       Date startTime, Date endTime) {
 | 
	
		
			
				|  |  | +    public <T> boolean checkCourseTime(List<T> list, Function<T, Date> startTimeFun, Function<T, Date> endTimeFun, Date startTime, Date endTime) {
 | 
	
		
			
				|  |  |          WrapperUtil.checkObj(startTime, "开始时间不能为空!");
 | 
	
		
			
				|  |  |          WrapperUtil.checkObj(endTime, "结束时间不能为空!");
 | 
	
		
			
				|  |  |          // 如果没有课程,直接返回false
 | 
	
	
		
			
				|  | @@ -241,12 +247,25 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 | 
	
		
			
				|  |  |          LocalDate lastDay = firstDay.with(TemporalAdjusters.lastDayOfMonth());
 | 
	
		
			
				|  |  |          //获取老师的课程  key:日期-年月日 value:课程时间-开始时间,结束时间
 | 
	
		
			
				|  |  |          Map<String, List<CourseTimeEntity>> nowCourseMap = getTeacherCourseTime(teacherId, firstDay.toString(), lastDay.toString());
 | 
	
		
			
				|  |  | -        //储存节假日数据,避免重复查询
 | 
	
		
			
				|  |  | -        Map<Integer, List<String>> holidayMap = new HashMap<>();
 | 
	
		
			
				|  |  |          //生成日历数据
 | 
	
		
			
				|  |  |          List<CourseCalendarEntity> courseCalendarEntities = generateCourseData(firstDay, lastDay, singleCourseMinutes);
 | 
	
		
			
				|  |  | +        //对比课程数据,筛选出空余的课程时间
 | 
	
		
			
				|  |  | +        opsCourseCalendarData(nowCourseMap, courseCalendarEntities, 0);
 | 
	
		
			
				|  |  | +        return courseCalendarEntities;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 对比课程数据,筛选出空余的课程时间
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param nowCourseMap           现有课程
 | 
	
		
			
				|  |  | +     * @param courseCalendarEntities 课程时间日历
 | 
	
		
			
				|  |  | +     * @param skipHoliday            是否跳过节假日  0:不跳过 1跳过
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private void opsCourseCalendarData(Map<String, List<CourseTimeEntity>> nowCourseMap, List<CourseCalendarEntity> courseCalendarEntities, Integer skipHoliday) {
 | 
	
		
			
				|  |  | +        //储存节假日数据,避免重复查询
 | 
	
		
			
				|  |  | +        Map<Integer, List<String>> holidayMap = new HashMap<>();
 | 
	
		
			
				|  |  |          courseCalendarEntities.forEach(calendarEntity -> {
 | 
	
		
			
				|  |  | -            //获取课程数据,并剔除交集时间段数据,
 | 
	
		
			
				|  |  | +            //获取课程数据,并剔除交集时间段数据
 | 
	
		
			
				|  |  |              List<CourseTimeEntity> nowCourse = nowCourseMap.get(calendarEntity.getDate());
 | 
	
		
			
				|  |  |              if (CollectionUtils.isEmpty(nowCourse)) {
 | 
	
		
			
				|  |  |                  //当日没课
 | 
	
	
		
			
				|  | @@ -280,9 +299,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 | 
	
		
			
				|  |  |                      });
 | 
	
		
			
				|  |  |              //是否是节假日  0:不是 1是
 | 
	
		
			
				|  |  |              calendarEntity.setHoliday(holiday.contains(calendarEntity.getDate()) ? 1 : 0);
 | 
	
		
			
				|  |  | +            calendarEntity.setSkipHoliday(skipHoliday);//直播课日历只展示节假日 不跳过节假日
 | 
	
		
			
				|  |  |          });
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        return courseCalendarEntities;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
	
		
			
				|  | @@ -300,23 +318,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 | 
	
		
			
				|  |  |                  .ge(CourseSchedule::getClassDate, startDate)
 | 
	
		
			
				|  |  |                  .le(CourseSchedule::getClassDate, endDate)
 | 
	
		
			
				|  |  |          );
 | 
	
		
			
				|  |  | -        //老师课程 key:日期-年月日  value:课程
 | 
	
		
			
				|  |  | -        Map<String, List<CourseTimeEntity>> nowCourse = new HashMap<>();
 | 
	
		
			
				|  |  | -        if (CollectionUtils.isNotEmpty(courseList)) {
 | 
	
		
			
				|  |  | -            WrapperUtil.groupList(courseList, CourseSchedule::getClassDate)
 | 
	
		
			
				|  |  | -                    .forEach((k, v) -> {
 | 
	
		
			
				|  |  | -                                List<CourseTimeEntity> value = new ArrayList<>();
 | 
	
		
			
				|  |  | -                                v.forEach(course -> {
 | 
	
		
			
				|  |  | -                                    CourseTimeEntity courseTimeEntity = new CourseTimeEntity();
 | 
	
		
			
				|  |  | -                                    courseTimeEntity.setStartTime(course.getStartTime());
 | 
	
		
			
				|  |  | -                                    courseTimeEntity.setEndTime(course.getEndTime());
 | 
	
		
			
				|  |  | -                                    value.add(courseTimeEntity);
 | 
	
		
			
				|  |  | -                                });
 | 
	
		
			
				|  |  | -                                nowCourse.put(DateUtil.dateToString(k), value);
 | 
	
		
			
				|  |  | -                            }
 | 
	
		
			
				|  |  | -                    );
 | 
	
		
			
				|  |  | -        }
 | 
	
		
			
				|  |  | -        return nowCourse;
 | 
	
		
			
				|  |  | +        return getCourseListMap(courseList);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
	
		
			
				|  | @@ -348,14 +350,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 | 
	
		
			
				|  |  |              List<CourseTimeEntity> times = new ArrayList<>();
 | 
	
		
			
				|  |  |              //获取当前日期
 | 
	
		
			
				|  |  |              entity.setDate(firstDay.toString());
 | 
	
		
			
				|  |  | -            int finalAddDay = addDay;
 | 
	
		
			
				|  |  | -            dayTime.forEach(time -> {
 | 
	
		
			
				|  |  | -                CourseTimeEntity courseTimeEntity = new CourseTimeEntity();
 | 
	
		
			
				|  |  | -                courseTimeEntity.setStartTime(DateUtil.addDays(time.getStartTime(), finalAddDay));
 | 
	
		
			
				|  |  | -                courseTimeEntity.setEndTime(DateUtil.addDays(time.getEndTime(), finalAddDay));
 | 
	
		
			
				|  |  | -                times.add(courseTimeEntity);
 | 
	
		
			
				|  |  | -            });
 | 
	
		
			
				|  |  | -            entity.courseTime(times);
 | 
	
		
			
				|  |  | +            //将每日上课时间时间添加到日历中
 | 
	
		
			
				|  |  | +            opsCourseDayTime(addDay, entity, times, dayTime);
 | 
	
		
			
				|  |  |              list.add(entity);
 | 
	
		
			
				|  |  |              firstDay = firstDay.plusDays(1L);
 | 
	
		
			
				|  |  |              addDay++;
 | 
	
	
		
			
				|  | @@ -411,18 +407,168 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  | -     * 生成陪练课日历
 | 
	
		
			
				|  |  | +     * 生成陪练课日历-用于学生购买指定老师陪练课
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param param 传入参数
 | 
	
		
			
				|  |  | +     *              <p> - teacherId 老师id
 | 
	
		
			
				|  |  | +     *              <p> - studentId 学生id
 | 
	
		
			
				|  |  | +     *              <p> - year 年
 | 
	
		
			
				|  |  | +     *              <p> - month 月
 | 
	
		
			
				|  |  | +     *              <p> - day 日
 | 
	
		
			
				|  |  | +     * @return 返回传入时间当月每日的剩余时间段
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    public void generatePracticeCourseCalender() {
 | 
	
		
			
				|  |  | -        //todo 注意:如果是陪练课的日历需要查询老师设置的陪练课时间有哪些,不能直接根据时间段来
 | 
	
		
			
				|  |  | -        //获取周 int value = calendarDay.getDayOfWeek().getValue();
 | 
	
		
			
				|  |  | +    public List<CourseCalendarEntity> createPracticeCourseCalender(Map<String, Object> param) {
 | 
	
		
			
				|  |  | +        //校验数据
 | 
	
		
			
				|  |  | +        Long teacherId = WrapperUtil.toLong(param, "teacherId", "老师id不能为空!");
 | 
	
		
			
				|  |  | +        Long studentId = WrapperUtil.toLong(param, "teacherId", "学生id不能为空!");
 | 
	
		
			
				|  |  | +        Integer year = WrapperUtil.toInt(param, "year", "日历的时间年份不能为空!");
 | 
	
		
			
				|  |  | +        Integer month = WrapperUtil.toInt(param, "month", "日历的时间月份不能为空!");
 | 
	
		
			
				|  |  | +        Integer day = WrapperUtil.toInt(param, "month", "日历的时间日期不能为空!");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        //传入的日期+1天开始
 | 
	
		
			
				|  |  | +        LocalDate firstDay = LocalDate.of(year, month, day).plusDays(1L);
 | 
	
		
			
				|  |  | +        //根据firstDay计算出该月的最后一天
 | 
	
		
			
				|  |  | +        LocalDate lastDay = firstDay.with(TemporalAdjusters.lastDayOfMonth());
 | 
	
		
			
				|  |  | +        //查询老师陪练课设置
 | 
	
		
			
				|  |  | +        TeacherFreeTime teacherTime = teacherFreeTimeService.getOne(Wrappers.<TeacherFreeTime>lambdaQuery()
 | 
	
		
			
				|  |  | +                .eq(TeacherFreeTime::getDefaultFlag, true)
 | 
	
		
			
				|  |  | +                .eq(TeacherFreeTime::getTeacherId, teacherId)
 | 
	
		
			
				|  |  | +        );
 | 
	
		
			
				|  |  | +        Optional.ofNullable(teacherTime).orElseThrow(() -> new BizException("未查询到老师陪练课设置!"));
 | 
	
		
			
				|  |  | +        //根据老师设置的陪练课时间生成当月日历
 | 
	
		
			
				|  |  | +        List<CourseCalendarEntity> courseCalendarEntities = generatePracticeCalendar(teacherTime, firstDay, lastDay);
 | 
	
		
			
				|  |  | +        //查询老师及当前学生的课时
 | 
	
		
			
				|  |  | +        Map<String, List<CourseTimeEntity>> nowCourseMap = getAllPracticeCourseTime(teacherId, studentId, firstDay.toString(), lastDay.toString());
 | 
	
		
			
				|  |  | +        //和生成的日历对比,筛选出空余的课程时间
 | 
	
		
			
				|  |  | +        opsCourseCalendarData(nowCourseMap, courseCalendarEntities, teacherTime.getSkipHolidayFlag() ? 1 : 0);
 | 
	
		
			
				|  |  | +        return courseCalendarEntities;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -    private SysUser getSysUser() {
 | 
	
		
			
				|  |  | -        return Optional.ofNullable(sysUserFeignService.queryUserInfo())
 | 
	
		
			
				|  |  | -                .orElseThrow(() -> new BizException("用户不存在"));
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 生成老师陪练课日历
 | 
	
		
			
				|  |  | +     * <p>陪练课的日历需要查询老师设置的陪练课时间,根据设置的时间来生成日历
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private List<CourseCalendarEntity> generatePracticeCalendar(TeacherFreeTime teacherTime, LocalDate firstDay, LocalDate lastDay) {
 | 
	
		
			
				|  |  | +        //将老师设置的陪练课时间结构化   key::数字周几 1~7  value:具体的时间 开始时间-结束时间
 | 
	
		
			
				|  |  | +        Map<Integer, List<CourseTimeEntity>> teacherPracticeTime = getTeacherPracticeTime(teacherTime);
 | 
	
		
			
				|  |  | +        //每日日期数据
 | 
	
		
			
				|  |  | +        List<CourseCalendarEntity> list = new ArrayList<>();
 | 
	
		
			
				|  |  | +        //添加的天数
 | 
	
		
			
				|  |  | +        int addDay = 0;
 | 
	
		
			
				|  |  | +        //获取每日日期数据
 | 
	
		
			
				|  |  | +        while (firstDay.isBefore(lastDay) || firstDay.isEqual(lastDay)) {
 | 
	
		
			
				|  |  | +            CourseCalendarEntity entity = new CourseCalendarEntity();
 | 
	
		
			
				|  |  | +            List<CourseTimeEntity> times = new ArrayList<>();
 | 
	
		
			
				|  |  | +            //获取当前日期
 | 
	
		
			
				|  |  | +            entity.setDate(firstDay.toString());
 | 
	
		
			
				|  |  | +            //获取当前日期周几
 | 
	
		
			
				|  |  | +            int weekNum = firstDay.getDayOfWeek().getValue();
 | 
	
		
			
				|  |  | +            List<CourseTimeEntity> timeEntities = teacherPracticeTime.get(weekNum);
 | 
	
		
			
				|  |  | +            if (CollectionUtils.isNotEmpty(timeEntities)) {
 | 
	
		
			
				|  |  | +                //将每日上课时间时间添加到日历中
 | 
	
		
			
				|  |  | +                opsCourseDayTime(addDay, entity, times, timeEntities);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            list.add(entity);
 | 
	
		
			
				|  |  | +            firstDay = firstDay.plusDays(1L);
 | 
	
		
			
				|  |  | +            addDay++;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return list;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 将每日上课时间时间添加到日历中
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param addDay       添加的天数
 | 
	
		
			
				|  |  | +     * @param entity       实体数据
 | 
	
		
			
				|  |  | +     * @param times        课程数据集合
 | 
	
		
			
				|  |  | +     * @param timeEntities 每日上课时间集合
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private void opsCourseDayTime(int addDay, CourseCalendarEntity entity, List<CourseTimeEntity> times, List<CourseTimeEntity> timeEntities) {
 | 
	
		
			
				|  |  | +        timeEntities.forEach(time -> {
 | 
	
		
			
				|  |  | +            CourseTimeEntity courseTimeEntity = new CourseTimeEntity();
 | 
	
		
			
				|  |  | +            courseTimeEntity.setStartTime(DateUtil.addDays(time.getStartTime(), addDay));
 | 
	
		
			
				|  |  | +            courseTimeEntity.setEndTime(DateUtil.addDays(time.getEndTime(), addDay));
 | 
	
		
			
				|  |  | +            times.add(courseTimeEntity);
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        entity.setCourseTime(times);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 将老师设置的陪练课时间结构化
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @return key::数字周几 1~7  value:具体的时间 开始时间-结束时间
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private Map<Integer, List<CourseTimeEntity>> getTeacherPracticeTime(TeacherFreeTime teacherTime) {
 | 
	
		
			
				|  |  | +        Map<Integer, List<CourseTimeEntity>> teacherPracticeTime = new HashMap<>();
 | 
	
		
			
				|  |  | +        //将老师设置的陪练课时间放入map中
 | 
	
		
			
				|  |  | +        BiConsumer<String, Integer> timeCon = (timeStr, weekNum) -> {
 | 
	
		
			
				|  |  | +            if (StringUtils.isBlank(timeStr)) {
 | 
	
		
			
				|  |  | +                return;
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            List<CourseTimeEntity> timeEntityList = new ArrayList<>(JSONObject.parseArray(timeStr, CourseTimeEntity.class));
 | 
	
		
			
				|  |  | +            teacherPracticeTime.put(weekNum, timeEntityList);
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        timeCon.accept(teacherTime.getMonday(), 1);
 | 
	
		
			
				|  |  | +        timeCon.accept(teacherTime.getTuesday(), 2);
 | 
	
		
			
				|  |  | +        timeCon.accept(teacherTime.getWednesday(), 3);
 | 
	
		
			
				|  |  | +        timeCon.accept(teacherTime.getThursday(), 4);
 | 
	
		
			
				|  |  | +        timeCon.accept(teacherTime.getFriday(), 5);
 | 
	
		
			
				|  |  | +        timeCon.accept(teacherTime.getSaturday(), 6);
 | 
	
		
			
				|  |  | +        timeCon.accept(teacherTime.getSunday(), 7);
 | 
	
		
			
				|  |  | +        return teacherPracticeTime;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    /**
 | 
	
		
			
				|  |  | +     * 查询老师及当前学生的课时
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  | +     * @param teacherId 老师id
 | 
	
		
			
				|  |  | +     * @param studentId 学员id
 | 
	
		
			
				|  |  | +     */
 | 
	
		
			
				|  |  | +    private Map<String, List<CourseTimeEntity>> getAllPracticeCourseTime(Long teacherId, Long studentId, String startDate, String endDate) {
 | 
	
		
			
				|  |  | +        //查询该老师指定时间段的课程
 | 
	
		
			
				|  |  | +        List<CourseSchedule> courseList = this.list(Wrappers.<CourseSchedule>lambdaQuery()
 | 
	
		
			
				|  |  | +                .eq(CourseSchedule::getTeacherId, teacherId)
 | 
	
		
			
				|  |  | +                .ge(CourseSchedule::getClassDate, startDate)
 | 
	
		
			
				|  |  | +                .le(CourseSchedule::getClassDate, endDate)
 | 
	
		
			
				|  |  | +        );
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isEmpty(courseList)) {
 | 
	
		
			
				|  |  | +            courseList = new ArrayList<>();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        //查询学生的课程
 | 
	
		
			
				|  |  | +        Map<String, Object> param = new HashMap<>();
 | 
	
		
			
				|  |  | +        param.put("studentId", studentId);
 | 
	
		
			
				|  |  | +        param.put("startClassDate", startDate);
 | 
	
		
			
				|  |  | +        param.put("endClassDate", endDate);
 | 
	
		
			
				|  |  | +        List<CourseSchedule> studentCourse = baseMapper.queryStudentCourse(param);
 | 
	
		
			
				|  |  | +        //将数据合并
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isNotEmpty(studentCourse)) {
 | 
	
		
			
				|  |  | +            courseList.addAll(studentCourse);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return getCourseListMap(courseList);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private Map<String, List<CourseTimeEntity>> getCourseListMap(List<CourseSchedule> courseList) {
 | 
	
		
			
				|  |  | +        //key:课程日期-年月日  value:课程
 | 
	
		
			
				|  |  | +        Map<String, List<CourseTimeEntity>> nowCourse = new HashMap<>();
 | 
	
		
			
				|  |  | +        if (CollectionUtils.isNotEmpty(courseList)) {
 | 
	
		
			
				|  |  | +            WrapperUtil.groupList(courseList, CourseSchedule::getClassDate)
 | 
	
		
			
				|  |  | +                    .forEach((k, v) -> {
 | 
	
		
			
				|  |  | +                        List<CourseTimeEntity> value = new ArrayList<>();
 | 
	
		
			
				|  |  | +                        v.forEach(course -> {
 | 
	
		
			
				|  |  | +                            CourseTimeEntity courseTimeEntity = new CourseTimeEntity();
 | 
	
		
			
				|  |  | +                            courseTimeEntity.setStartTime(course.getStartTime());
 | 
	
		
			
				|  |  | +                            courseTimeEntity.setEndTime(course.getEndTime());
 | 
	
		
			
				|  |  | +                            value.add(courseTimeEntity);
 | 
	
		
			
				|  |  | +                        });
 | 
	
		
			
				|  |  | +                        nowCourse.put(DateUtil.dateToString(k), value);
 | 
	
		
			
				|  |  | +                    });
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return nowCourse;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    private SysUser getSysUser() {
 | 
	
		
			
				|  |  | +        return Optional.ofNullable(sysUserFeignService.queryUserInfo()).orElseThrow(() -> new BizException("用户不存在"));
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * @Description: 老师端-首页-我的课程-陪练课
 |