Browse Source

增加 陪练课自动生成课时功能

hgw 3 years ago
parent
commit
f37c3cfff2

+ 15 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/CheckLiveCourseTimeDto.java → cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/dto/CheckCourseTimeDto.java

@@ -4,6 +4,7 @@ import com.yonge.cooleshow.biz.dal.entity.CourseTimeEntity;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 
 
+import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 import java.io.Serializable;
 import java.util.List;
 import java.util.List;
@@ -12,8 +13,8 @@ import java.util.List;
  * @author hgw
  * @author hgw
  * Created by 2022-03-30
  * Created by 2022-03-30
  */
  */
-@ApiModel(value = "创建直播课组验校时间接收类")
-public class CheckLiveCourseTimeDto implements Serializable {
+@ApiModel(value = "创建课程组验校时间接是否可用参数类")
+public class CheckCourseTimeDto implements Serializable {
 
 
     @NotNull(message = "老师Id不能为空")
     @NotNull(message = "老师Id不能为空")
     @ApiModelProperty(value = "老师Id")
     @ApiModelProperty(value = "老师Id")
@@ -23,6 +24,10 @@ public class CheckLiveCourseTimeDto implements Serializable {
     @ApiModelProperty(value = "是否需要循环 0:不需要 1:需要")
     @ApiModelProperty(value = "是否需要循环 0:不需要 1:需要")
     private Integer loop;
     private Integer loop;
 
 
+    @NotBlank(message = "课程类型不能为空")
+    @ApiModelProperty(value = "PRACTICE:陪练课,LIVE:直播课")
+    private String  courseType;
+
     @NotNull(message = "课程数不能为空")
     @NotNull(message = "课程数不能为空")
     @ApiModelProperty(value = "课程数")
     @ApiModelProperty(value = "课程数")
     private Integer courseNum;
     private Integer courseNum;
@@ -62,4 +67,12 @@ public class CheckLiveCourseTimeDto implements Serializable {
     public void setTimeList(List<CourseTimeEntity> timeList) {
     public void setTimeList(List<CourseTimeEntity> timeList) {
         this.timeList = timeList;
         this.timeList = timeList;
     }
     }
+
+    public String getCourseType() {
+        return courseType;
+    }
+
+    public void setCourseType(String courseType) {
+        this.courseType = courseType;
+    }
 }
 }

+ 8 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/enums/CourseScheduleEnum.java

@@ -36,9 +36,15 @@ public enum CourseScheduleEnum implements BaseEnum<String,CourseScheduleEnum> {
      * @param code   code
      * @param code   code
      * @param errMsg 错误异常
      * @param errMsg 错误异常
      */
      */
-    public static void existCourseType(String code, String errMsg) {
+    public static CourseScheduleEnum existCourseType(String code, String errMsg) {
         CourseScheduleEnum[] values = {PRACTICE, LIVE};
         CourseScheduleEnum[] values = {PRACTICE, LIVE};
         existCourse(values, code, errMsg);
         existCourse(values, code, errMsg);
+        //陪练课-校验学生时间是否交集
+        if (code.equals(CourseScheduleEnum.PRACTICE.getCode())) {
+            return CourseScheduleEnum.PRACTICE;
+        } else {
+            return CourseScheduleEnum.LIVE;
+        }
     }
     }
 
 
     /**
     /**
@@ -52,7 +58,7 @@ public enum CourseScheduleEnum implements BaseEnum<String,CourseScheduleEnum> {
         existCourse(values, code, errMsg);
         existCourse(values, code, errMsg);
     }
     }
 
 
-    private static void existCourse(CourseScheduleEnum[] values,String code,String errMsg){
+    private static void existCourse(CourseScheduleEnum[] values, String code, String errMsg) {
         List<String> collect = Arrays.stream(values).map(CourseScheduleEnum::getCode).collect(Collectors.toList());
         List<String> collect = Arrays.stream(values).map(CourseScheduleEnum::getCode).collect(Collectors.toList());
         boolean typeFlag = collect.contains(code);
         boolean typeFlag = collect.contains(code);
         if (!typeFlag) {
         if (!typeFlag) {

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CourseGroupService.java

@@ -2,7 +2,7 @@ package com.yonge.cooleshow.biz.dal.service;
 
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.yonge.cooleshow.biz.dal.dao.CourseGroupDao;
 import com.yonge.cooleshow.biz.dal.dao.CourseGroupDao;
-import com.yonge.cooleshow.biz.dal.dto.CheckLiveCourseTimeDto;
+import com.yonge.cooleshow.biz.dal.dto.CheckCourseTimeDto;
 import com.yonge.cooleshow.biz.dal.dto.LiveCourseGroupDto;
 import com.yonge.cooleshow.biz.dal.dto.LiveCourseGroupDto;
 import com.yonge.cooleshow.biz.dal.entity.CourseGroup;
 import com.yonge.cooleshow.biz.dal.entity.CourseGroup;
 import com.yonge.cooleshow.biz.dal.entity.CourseTimeEntity;
 import com.yonge.cooleshow.biz.dal.entity.CourseTimeEntity;
@@ -47,7 +47,7 @@ public interface CourseGroupService extends IService<CourseGroup> {
     /**
     /**
      * 创建直播课程组时将课时写到缓存当作锁定的时间
      * 创建直播课程组时将课时写到缓存当作锁定的时间
      */
      */
-    List<CourseTimeEntity> lockCourseToCache(CheckLiveCourseTimeDto dto);
+    List<CourseTimeEntity> lockCourseToCache(CheckCourseTimeDto dto);
 
 
     /**
     /**
      * 创建直播课程组-解除锁定课程时间-删除写到缓存当作锁定的课时
      * 创建直播课程组-解除锁定课程时间-删除写到缓存当作锁定的课时

+ 8 - 0
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/CourseScheduleService.java

@@ -121,6 +121,14 @@ public interface CourseScheduleService extends IService<CourseSchedule> {
     List<CourseCalendarEntity> createLiveCourseCalendar(Map<String, Object> param);
     List<CourseCalendarEntity> createLiveCourseCalendar(Map<String, Object> param);
 
 
     /**
     /**
+     * 根据年份获取当年节假日
+     *
+     * @param year 年
+     * @return 年月日
+     */
+    List<String> getHoliday(int year);
+
+    /**
      * 生成陪练课日历-用于学生购买指定老师陪练课
      * 生成陪练课日历-用于学生购买指定老师陪练课
      *
      *
      * @param param 传入参数
      * @param param 传入参数

+ 60 - 17
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseGroupServiceImpl.java

@@ -1,30 +1,29 @@
 package com.yonge.cooleshow.biz.dal.service.impl;
 package com.yonge.cooleshow.biz.dal.service.impl;
 
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 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.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.constant.CourseConstant;
 import com.yonge.cooleshow.biz.dal.constant.CourseConstant;
 import com.yonge.cooleshow.biz.dal.constant.LiveRoomConstant;
 import com.yonge.cooleshow.biz.dal.constant.LiveRoomConstant;
-import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.cooleshow.biz.dal.dao.CourseGroupDao;
 import com.yonge.cooleshow.biz.dal.dao.CourseGroupDao;
-import com.yonge.cooleshow.biz.dal.dto.CheckLiveCourseTimeDto;
+import com.yonge.cooleshow.biz.dal.dto.CheckCourseTimeDto;
 import com.yonge.cooleshow.biz.dal.dto.LiveCourseGroupDto;
 import com.yonge.cooleshow.biz.dal.dto.LiveCourseGroupDto;
 import com.yonge.cooleshow.biz.dal.dto.LiveCourseGroupDto.CoursePlanDto;
 import com.yonge.cooleshow.biz.dal.dto.LiveCourseGroupDto.CoursePlanDto;
-import com.yonge.cooleshow.biz.dal.entity.CourseGroup;
-import com.yonge.cooleshow.biz.dal.entity.CoursePlan;
-import com.yonge.cooleshow.biz.dal.entity.CourseSchedule;
-import com.yonge.cooleshow.biz.dal.entity.CourseTimeEntity;
+import com.yonge.cooleshow.biz.dal.entity.*;
 import com.yonge.cooleshow.biz.dal.enums.CourseGroupEnum;
 import com.yonge.cooleshow.biz.dal.enums.CourseGroupEnum;
 import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
 import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
 import com.yonge.cooleshow.biz.dal.service.*;
 import com.yonge.cooleshow.biz.dal.service.*;
 import com.yonge.cooleshow.biz.dal.support.PageUtil;
 import com.yonge.cooleshow.biz.dal.support.PageUtil;
 import com.yonge.cooleshow.biz.dal.vo.CourseGroupVo;
 import com.yonge.cooleshow.biz.dal.vo.CourseGroupVo;
 import com.yonge.cooleshow.biz.dal.vo.LiveCourseInfoVo;
 import com.yonge.cooleshow.biz.dal.vo.LiveCourseInfoVo;
+import com.yonge.cooleshow.common.constant.SysConfigConstant;
 import com.yonge.cooleshow.common.exception.BizException;
 import com.yonge.cooleshow.common.exception.BizException;
 import com.yonge.cooleshow.common.page.PageInfo;
 import com.yonge.cooleshow.common.page.PageInfo;
 import com.yonge.toolset.utils.date.DateUtil;
 import com.yonge.toolset.utils.date.DateUtil;
+import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.redisson.api.RMap;
 import org.redisson.api.RMap;
 import org.redisson.api.RedissonClient;
 import org.redisson.api.RedissonClient;
@@ -34,6 +33,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
+import java.time.LocalDate;
 import java.util.*;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -67,7 +67,8 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
     private SubjectService subjectService;
     private SubjectService subjectService;
     @Autowired
     @Autowired
     private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;
     private CourseScheduleStudentPaymentService courseScheduleStudentPaymentService;
-
+    @Autowired
+    private TeacherFreeTimeService teacherFreeTimeService;
 
 
     @Override
     @Override
     public CourseGroupDao getDao() {
     public CourseGroupDao getDao() {
@@ -201,9 +202,11 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
     }
     }
 
 
     /**
     /**
-     * 创建直播课程组时将课时写到缓存当作锁定时间
+     * 创建课时写到缓存锁定时间
      */
      */
-    public List<CourseTimeEntity> lockCourseToCache(CheckLiveCourseTimeDto dto) {
+    public List<CourseTimeEntity> lockCourseToCache(CheckCourseTimeDto dto) {
+        //获取课程类型
+        CourseScheduleEnum courseType = CourseScheduleEnum.existCourseType(dto.getCourseType(), "课程类型不正确!");
         //先自校验传入时间是否交集
         //先自校验传入时间是否交集
         List<CourseTimeEntity> timeList = dto.getTimeList();
         List<CourseTimeEntity> timeList = dto.getTimeList();
         if (timeList.size() > 1) {
         if (timeList.size() > 1) {
@@ -228,7 +231,7 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
         //需要自动补全课时
         //需要自动补全课时
         if (dto.getLoop() == 1) {
         if (dto.getLoop() == 1) {
             //自动排课,获取排课后所有的课程时间
             //自动排课,获取排课后所有的课程时间
-            List<CourseTimeEntity> allCourseTime = teacherAutoPlanningLiveCourseTime(dto.getTeacherId(), dto.getCourseNum(), timeList);
+            List<CourseTimeEntity> allCourseTime = autoPlanningLiveCourseTime(dto.getTeacherId(), dto.getCourseNum(), timeList, courseType);
             allCourseTime.sort(Comparator.comparing(CourseTimeEntity::getStartTime));
             allCourseTime.sort(Comparator.comparing(CourseTimeEntity::getStartTime));
             //替换掉原有的课时
             //替换掉原有的课时
             dto.setTimeList(allCourseTime);
             dto.setTimeList(allCourseTime);
@@ -255,7 +258,7 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
     }
     }
 
 
     /**
     /**
-     * 老师创建直播课自动排课
+     * 自动排课
      * <p>自动排课规则及场景:总5节课,填入2节,需要自动补3节
      * <p>自动排课规则及场景:总5节课,填入2节,需要自动补3节
      * <p>1.把前面2节课的时间循环+1周直到填满5节课为止
      * <p>1.把前面2节课的时间循环+1周直到填满5节课为止
      * <p>2.如果自动排课时的时间和未来课程时间有冲突则继续往后面延续一周
      * <p>2.如果自动排课时的时间和未来课程时间有冲突则继续往后面延续一周
@@ -263,9 +266,24 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
      * @param teacherId      老师id
      * @param teacherId      老师id
      * @param totalCourseNum 总课程数量
      * @param totalCourseNum 总课程数量
      * @param paramTimeList  当前课程的时间段
      * @param paramTimeList  当前课程的时间段
+     * @param courseType     PRACTICE陪练课  LIVE直播课
      * @return 自动排课后的全部课时
      * @return 自动排课后的全部课时
      */
      */
-    private List<CourseTimeEntity> teacherAutoPlanningLiveCourseTime(Long teacherId, int totalCourseNum, List<CourseTimeEntity> paramTimeList) {
+    private List<CourseTimeEntity> autoPlanningLiveCourseTime(Long teacherId, int totalCourseNum, List<CourseTimeEntity> paramTimeList, CourseScheduleEnum courseType) {
+        //是否跳过节假日  0:不跳过 1跳过
+        boolean skipHoliday = false;
+        //true 陪练课
+        boolean courseTypeFlag = courseType.equals(CourseScheduleEnum.PRACTICE);
+        if (courseTypeFlag) {
+            //查询老师陪练课设置
+            TeacherFreeTime teacherTime = teacherFreeTimeService.getOne(Wrappers.<TeacherFreeTime>lambdaQuery()
+                    .eq(TeacherFreeTime::getDefaultFlag, true)
+                    .eq(TeacherFreeTime::getTeacherId, teacherId)
+            );
+            Optional.ofNullable(teacherTime).orElseThrow(() -> new BizException("未查询到老师陪练课设置!"));
+            skipHoliday = teacherTime.getSkipHolidayFlag();
+        }
+
         //获取当前课程
         //获取当前课程
         int nowCourseNum = paramTimeList.size();
         int nowCourseNum = paramTimeList.size();
         //获取总课程数量 - 获取当前选择的课程数量 = 要自动排课的课程数量
         //获取总课程数量 - 获取当前选择的课程数量 = 要自动排课的课程数量
@@ -276,16 +294,19 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
                 .collect(Collectors.toList());
                 .collect(Collectors.toList());
         //获取最大排课周
         //获取最大排课周
         String maxWeekStr = sysConfigService.findConfigValue(SysConfigConstant.AUTO_PLANNING_COURSE_MAX_WEEK);
         String maxWeekStr = sysConfigService.findConfigValue(SysConfigConstant.AUTO_PLANNING_COURSE_MAX_WEEK);
-        int maxWeek = 26;//默认 26周
+        int maxWeek = 26;//自动生成课时最大的生成周数  默认 26周
         if (StringUtils.isBlank(maxWeekStr)) {
         if (StringUtils.isBlank(maxWeekStr)) {
             maxWeek = Integer.parseInt(maxWeekStr);
             maxWeek = Integer.parseInt(maxWeekStr);
         }
         }
+        //从第index课程开始生成时间
         int index = 0;
         int index = 0;
-        //自动补全课时
+        //节假日缓存数据,避免多次查询
+        Map<Integer, List<String>> holidayMap = new HashMap<>();
+        //开始自动补全课时
         for (int i = 0; i < diffCourse; i++) {
         for (int i = 0; i < diffCourse; i++) {
             //需要增加的周数
             //需要增加的周数
             AtomicInteger week = new AtomicInteger(1);
             AtomicInteger week = new AtomicInteger(1);
-            //是否要一直生成课程 true 一直增加周数并生成到不冲突的时间为止
+            //是否要一直生成课程 true一直增加周数并生成到不冲突的时间为止
             AtomicBoolean flag = new AtomicBoolean(true);
             AtomicBoolean flag = new AtomicBoolean(true);
             //生成课程
             //生成课程
             while (flag.get()) {
             while (flag.get()) {
@@ -301,7 +322,7 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
                 Date autoStartDate = DateUtil.addWeeks(timeDto.getStartTime(), week.get());
                 Date autoStartDate = DateUtil.addWeeks(timeDto.getStartTime(), week.get());
                 Date autoEndDate = DateUtil.addWeeks(timeDto.getEndTime(), week.get());
                 Date autoEndDate = DateUtil.addWeeks(timeDto.getEndTime(), week.get());
 
 
-                //true  flag = true 并且 周数+1
+                //传入 ->true :周数+1   ->false:停止生成时间
                 Consumer<Boolean> con = (check) -> {
                 Consumer<Boolean> con = (check) -> {
                     //check = true ,有交集延续1周后继续生成时间
                     //check = true ,有交集延续1周后继续生成时间
                     if (check) {
                     if (check) {
@@ -312,8 +333,30 @@ public class CourseGroupServiceImpl extends ServiceImpl<CourseGroupDao, CourseGr
                     }
                     }
                 };
                 };
 
 
-                boolean checkTime;
+                //是否跳过节假日
+                if (skipHoliday) {
+                    //将自动生成的开始日期转换为字符串
+                    String dateStr = DateUtil.dateToString(autoStartDate);
+                    //取年份
+                    int calendarYear = LocalDate.parse(dateStr).getYear();
+                    //获取节假日信息
+                    List<String> holiday = Optional.of(calendarYear)
+                            .map(holidayMap::get)
+                            .filter(CollectionUtils::isNotEmpty)
+                            .orElseGet(() -> {
+                                List<String> list = courseScheduleService.getHoliday(calendarYear);
+                                holidayMap.put(calendarYear, list);
+                                return list;
+                            });
 
 
+                    //如果生成的日期是节假日 则跳过当前日期
+                    con.accept(holiday.contains(dateStr));
+                    if (flag.get()) {
+                        continue;
+                    }
+                }
+
+                boolean checkTime;
                 //若:传入时间是1号10点和8号10点,然后1号10点自动生成的课时是8号10点那么就和传入的8号10点冲突了,这种情况需要继续往后延续1周
                 //若:传入时间是1号10点和8号10点,然后1号10点自动生成的课时是8号10点那么就和传入的8号10点冲突了,这种情况需要继续往后延续1周
                 checkTime = courseScheduleService.checkCourseTime(resultCourseTime, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime, autoStartDate, autoEndDate);
                 checkTime = courseScheduleService.checkCourseTime(resultCourseTime, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime, autoStartDate, autoEndDate);
                 con.accept(checkTime);
                 con.accept(checkTime);

+ 22 - 17
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/CourseScheduleServiceImpl.java

@@ -86,16 +86,19 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
      *              <p> - subjectId 声部id
      *              <p> - subjectId 声部id
      */
      */
     public PageInfo<TeacherLiveCourseInfoVo> queryTeacherLiveCourse(Map<String, Object> param) {
     public PageInfo<TeacherLiveCourseInfoVo> queryTeacherLiveCourse(Map<String, Object> param) {
-        String status = WrapperUtil.toStr(param, "status", "课程状态不能为空!");
-        CourseScheduleEnum.existCourseState(status, "查询条件错误,课程状态不正确");
+        String status = WrapperUtil.toStr(param, "status");
+        if (StringUtils.isNotBlank(status)) {
+            CourseScheduleEnum.existCourseState(status, "查询条件错误,课程状态不正确");
+        }
+        param.put("status",status);
         String classDate = WrapperUtil.toStr(param, "classDate", "查询时间不能为空!");
         String classDate = WrapperUtil.toStr(param, "classDate", "查询时间不能为空!");
-        String[] classDateSp = classDate.split("-");
         //本月的第一天
         //本月的第一天
         LocalDate firstDay;
         LocalDate firstDay;
         try {
         try {
+            String[] classDateSp = classDate.split("-");
             firstDay = LocalDate.of(Integer.parseInt(classDateSp[0]), Integer.parseInt(classDateSp[1]), 1);
             firstDay = LocalDate.of(Integer.parseInt(classDateSp[0]), Integer.parseInt(classDateSp[1]), 1);
         } catch (Exception e) {
         } catch (Exception e) {
-            throw new BizException("查询时间格式不正确 ["+classDate+"]");
+            throw new BizException("查询时间格式不正确 [" + classDate + "]");
         }
         }
         //本月的最后一天
         //本月的最后一天
         LocalDate lastDay = firstDay.with(TemporalAdjusters.lastDayOfMonth());
         LocalDate lastDay = firstDay.with(TemporalAdjusters.lastDayOfMonth());
@@ -305,7 +308,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
             int calendarYear = LocalDate.parse(calendarEntity.getDate()).getYear();
             int calendarYear = LocalDate.parse(calendarEntity.getDate()).getYear();
             List<String> holiday = Optional.of(calendarYear)
             List<String> holiday = Optional.of(calendarYear)
                     .map(holidayMap::get)
                     .map(holidayMap::get)
-                    .filter(Objects::nonNull)
+                    .filter(CollectionUtils::isNotEmpty)
                     .orElseGet(() -> {
                     .orElseGet(() -> {
                         List<String> list = getHoliday(calendarYear);
                         List<String> list = getHoliday(calendarYear);
                         holidayMap.put(calendarYear, list);
                         holidayMap.put(calendarYear, list);
@@ -409,7 +412,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
      * @param year 年
      * @param year 年
      * @return 年月日
      * @return 年月日
      */
      */
-    private List<String> getHoliday(int year) {
+    @Override
+    public List<String> getHoliday(int year) {
         HolidaysFestivals holidaysFestivals = holidaysFestivalsService.queryByYear(year);
         HolidaysFestivals holidaysFestivals = holidaysFestivalsService.queryByYear(year);
         if (Objects.isNull(holidaysFestivals)) {
         if (Objects.isNull(holidaysFestivals)) {
             return Collections.emptyList();
             return Collections.emptyList();
@@ -614,16 +618,16 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
 
 
     /**
     /**
      * 老师端-首页-我的课程-陪练课
      * 老师端-首页-我的课程-陪练课
-     *      search:{"classMonth":"2022-03","status":"COMPLETE","subjectId":1}
-     *
+     * search:{"classMonth":"2022-03","status":"COMPLETE","subjectId":1}
+     * <p>
      * 老师端-首页-课后评价
      * 老师端-首页-课后评价
-     *      search:{"classMonth":"2022-03","replied":0,"studentName":"测试王"}
-     *
+     * search:{"classMonth":"2022-03","replied":0,"studentName":"测试王"}
+     * <p>
      * 老师端-我的-我的主页
      * 老师端-我的-我的主页
-     *      search:{"classMonth":"2022-03"}
-     *
+     * search:{"classMonth":"2022-03"}
+     * <p>
      * 老师端-课表
      * 老师端-课表
-     *      search:{"classDate":"2022-03-27"}
+     * search:{"classDate":"2022-03-27"}
      *
      *
      * @Description: 根据老师id查询购课学员
      * @Description: 根据老师id查询购课学员
      * @Author: cy
      * @Author: cy
@@ -631,17 +635,17 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
      */
      */
     public IPage<MyCourseVo> queryTeacherPracticeCourse(IPage<MyCourseVo> page, MyCourseSearch search) {
     public IPage<MyCourseVo> queryTeacherPracticeCourse(IPage<MyCourseVo> page, MyCourseSearch search) {
         //查询所有已评价学生id
         //查询所有已评价学生id
-        List<Long> studentList=repliedDao.selectAll();
+        List<Long> studentList = repliedDao.selectAll();
 
 
         Integer replied = search.getReplied();
         Integer replied = search.getReplied();
-        if (replied!=null){
+        if (replied != null) {
             //按评价筛选 0:未评价 1:已评价
             //按评价筛选 0:未评价 1:已评价
             if (replied == 0) {
             if (replied == 0) {
                 //查询所有购课用户
                 //查询所有购课用户
-                List<Long> userList=paymentDao.selectAll();
+                List<Long> userList = paymentDao.selectAll();
                 //取差集
                 //取差集
                 userList.removeAll(studentList);
                 userList.removeAll(studentList);
-                if (userList.isEmpty()){
+                if (userList.isEmpty()) {
                     return page.setRecords(new ArrayList<>());
                     return page.setRecords(new ArrayList<>());
                 }
                 }
                 search.setRepliedIds(userList);
                 search.setRepliedIds(userList);
@@ -684,6 +688,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
         CourseSchedule courseSchedule = this.getById(courseId);
         CourseSchedule courseSchedule = this.getById(courseId);
         return teacherId.equals(courseSchedule.getTeacherId());
         return teacherId.equals(courseSchedule.getTeacherId());
     }
     }
+
     /**
     /**
      * @Description: 查询学生约课日历
      * @Description: 查询学生约课日历
      * @Author: cy
      * @Author: cy

+ 17 - 23
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/LiveRoomServiceImpl.java

@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dao.LiveRoomDao;
 import com.yonge.cooleshow.biz.dal.dao.LiveRoomDao;
-import com.yonge.cooleshow.biz.dal.dto.CheckLiveCourseTimeDto;
+import com.yonge.cooleshow.biz.dal.dto.CheckCourseTimeDto;
 import com.yonge.cooleshow.biz.dal.entity.*;
 import com.yonge.cooleshow.biz.dal.entity.*;
 import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
 import com.yonge.cooleshow.biz.dal.enums.CourseScheduleEnum;
 import com.yonge.cooleshow.biz.dal.enums.RoomTypeEnum;
 import com.yonge.cooleshow.biz.dal.enums.RoomTypeEnum;
@@ -407,29 +407,23 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
     }
     }
 
 
     /**
     /**
-     * 查询用户是否在聊天室-不是实时的
+     * 学生购买直播课程
      *
      *
-     * @param chatroomId 要查询的聊天室 ID(必传)
-     * @param userId     要查询的用户 ID(必传)
-     * @return true 在聊天室,false 不在聊天室
-     * <p>注意:有可能出现已退出聊天室后使用该功能查询,得到的结果是未退出聊天室
-     * <p>触发融云退出聊天室机制:
-     * <p>1.聊天室中用户在离线 30 秒后有新消息产生时状态改变为退出聊天室
-     * <p>2.离线后聊天室中产生 30 条消息时状态时状态改变为退出聊天室
+     * @param param 传入参数
+     *              <p> - groupId    直播课程组id
+     *              <p> - studentId    学员id
+     *              <p> - price 价格
      */
      */
-    private boolean userExistInRoom(String chatroomId, String userId) {
-        log.info("userExistInRoom chatroomId : {}  userId : {}", chatroomId, userId);
-        IMApiResultInfo resultInfo;
-        try {
-            resultInfo = imHelper.isInChartRoom(chatroomId, userId);
-        } catch (Exception e) {
-            throw new BizException("查询失败" + e.getMessage());
-        }
-        if (!resultInfo.isSuccess()) {
-            log.error("userExistInRoom  chatroomId : {}  userId : {}", chatroomId, userId);
-            throw new BizException("查询失败!");
-        }
-        return resultInfo.isSuccess() && resultInfo.getInChrm();
+    public void buyLiveCourse(Map<String, Object> param) {
+        //锁定课程时间
+
+    }
+
+    /**
+     * 学生购买直播课程成功-回调成功
+     */
+    public void buyLiveCourseSuccess() {
+
     }
     }
 
 
     private SysUser getSysUser(Long userId) {
     private SysUser getSysUser(Long userId) {
@@ -503,7 +497,7 @@ public class LiveRoomServiceImpl extends ServiceImpl<LiveRoomDao, LiveRoom> impl
         //result
         //result
         Map<String, Object> result = new HashMap<>();
         Map<String, Object> result = new HashMap<>();
         //模拟排课数据 测试用
         //模拟排课数据 测试用
-        CheckLiveCourseTimeDto dto = new CheckLiveCourseTimeDto();
+        CheckCourseTimeDto dto = new CheckCourseTimeDto();
         dto.setTeacherId(99L);
         dto.setTeacherId(99L);
         dto.setCourseNum(6);
         dto.setCourseNum(6);
         dto.setLoop(1);
         dto.setLoop(1);

+ 2 - 2
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/support/WrapperUtil.java

@@ -37,8 +37,8 @@ public class WrapperUtil {
                 .orElse(null);
                 .orElse(null);
     }
     }
 
 
-    public static <S,O> Long toLong(Map<S, O> map, S str,String exMsg){
-       return Optional.ofNullable(map.get(str))
+    public static <S, O> Long toLong(Map<S, O> map, S str, String exMsg) {
+        return Optional.ofNullable(map.get(str))
                 .map(String::valueOf)
                 .map(String::valueOf)
                 .map(Long::parseLong)
                 .map(Long::parseLong)
                 .orElseThrow(() -> new BizException(exMsg));
                 .orElseThrow(() -> new BizException(exMsg));

+ 5 - 3
cooleshow-user/user-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -126,11 +126,13 @@
         left join course_group as b on a.course_group_id_ = b.id_
         left join course_group as b on a.course_group_id_ = b.id_
         left join subject as s on b.subject_id_ = s.id_
         left join subject as s on b.subject_id_ = s.id_
         where b.teacher_id_ = #{param.teacherId}
         where b.teacher_id_ = #{param.teacherId}
-        and a.lock_ = 0
-        and a.status_ = #{param.status}
-        and a.type_ = #{param.type}
+        AND a.lock_ = 0
+        AND a.type_ = #{param.type}
         <![CDATA[ AND a.class_date_  >= #{param.startDate} ]]>
         <![CDATA[ AND a.class_date_  >= #{param.startDate} ]]>
         <![CDATA[ AND a.class_date_  <= #{param.endDate} ]]>
         <![CDATA[ AND a.class_date_  <= #{param.endDate} ]]>
+        <if test="param.status !=null and param.status !=''">
+            AND a.status_ = #{param.status}
+        </if>
         <if test="param.subjectId != null">
         <if test="param.subjectId != null">
             AND b.subject_id_ = #{param.subjectId}
             AND b.subject_id_ = #{param.subjectId}
         </if>
         </if>

+ 2 - 2
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/CourseGroupController.java

@@ -1,7 +1,7 @@
 package com.yonge.cooleshow.teacher.controller;
 package com.yonge.cooleshow.teacher.controller;
 
 
 
 
-import com.yonge.cooleshow.biz.dal.dto.CheckLiveCourseTimeDto;
+import com.yonge.cooleshow.biz.dal.dto.CheckCourseTimeDto;
 import com.yonge.cooleshow.biz.dal.dto.LiveCourseGroupDto;
 import com.yonge.cooleshow.biz.dal.dto.LiveCourseGroupDto;
 import com.yonge.cooleshow.biz.dal.entity.CourseTimeEntity;
 import com.yonge.cooleshow.biz.dal.entity.CourseTimeEntity;
 import com.yonge.cooleshow.biz.dal.service.CourseGroupService;
 import com.yonge.cooleshow.biz.dal.service.CourseGroupService;
@@ -60,7 +60,7 @@ public class CourseGroupController extends BaseController {
 
 
     @ApiOperation("创建直播课程组-锁定课程时间-将课时写到缓存当作锁定的时间")
     @ApiOperation("创建直播课程组-锁定课程时间-将课时写到缓存当作锁定的时间")
     @PostMapping("/lockCourseToCache")
     @PostMapping("/lockCourseToCache")
-    public HttpResponseResult<List<CourseTimeEntity>> lockCourseToCache(@RequestBody CheckLiveCourseTimeDto dto) {
+    public HttpResponseResult<List<CourseTimeEntity>> lockCourseToCache(@RequestBody CheckCourseTimeDto dto) {
         return succeed(courseGroupService.lockCourseToCache(dto));
         return succeed(courseGroupService.lockCourseToCache(dto));
     }
     }