|
@@ -11,10 +11,7 @@ import com.yonge.cooleshow.biz.dal.dao.CourseScheduleDao;
|
|
|
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.service.*;
|
|
|
import com.yonge.cooleshow.biz.dal.support.PageUtil;
|
|
|
import com.yonge.cooleshow.biz.dal.support.WrapperUtil;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.MyCourseVo;
|
|
@@ -25,6 +22,7 @@ import com.yonge.cooleshow.common.page.PageInfo;
|
|
|
import com.yonge.toolset.utils.date.DateUtil;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.redisson.api.RMap;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -59,6 +57,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
private SysConfigService sysConfigService;
|
|
|
@Autowired
|
|
|
private TeacherFreeTimeService teacherFreeTimeService;
|
|
|
+ @Autowired
|
|
|
+ private CourseGroupService courseGroupService;
|
|
|
|
|
|
@Override
|
|
|
public CourseScheduleDao getDao() {
|
|
@@ -519,7 +519,7 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 查询老师及当前学生的课时
|
|
|
+ * 查询老师及当前学生的课时和目前直播课排课锁定在缓存的的课时
|
|
|
*
|
|
|
* @param teacherId 老师id
|
|
|
* @param studentId 学员id
|
|
@@ -544,11 +544,35 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
if (CollectionUtils.isNotEmpty(studentCourse)) {
|
|
|
courseList.addAll(studentCourse);
|
|
|
}
|
|
|
+ //查询当前老师直播课当前排课锁定的课时缓存-因为在学生购买老师课程时候老师可能正在排直播课,并且也将时间已经预排好了,所以需要查询缓存中的课时
|
|
|
+ RMap<Long, List<CourseTimeEntity>> lockTimeCache = courseGroupService.getLiveLockTimeCache(teacherId);
|
|
|
+ if (lockTimeCache.isExists()) {
|
|
|
+ List<CourseSchedule> lockCourseList = new ArrayList<>();
|
|
|
+ List<CourseTimeEntity> timeEntities = lockTimeCache.get(teacherId);
|
|
|
+ if (CollectionUtils.isNotEmpty(timeEntities)) {
|
|
|
+ timeEntities.forEach(courseTimeEntity -> {
|
|
|
+ CourseSchedule lockCourse = new CourseSchedule();
|
|
|
+ String ymd = DateUtil.dateToString(courseTimeEntity.getStartTime());
|
|
|
+ lockCourse.setClassDate(DateUtil.toDate(ymd));
|
|
|
+ lockCourse.setStartTime(courseTimeEntity.getStartTime());
|
|
|
+ lockCourse.setEndTime(courseTimeEntity.getEndTime());
|
|
|
+ lockCourseList.add(lockCourse);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(lockCourseList)) {
|
|
|
+ courseList.addAll(lockCourseList);
|
|
|
+ }
|
|
|
+ }
|
|
|
return getCourseListMap(courseList);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 将课时数据结构化
|
|
|
+ *
|
|
|
+ * @param courseList 课程列表
|
|
|
+ * @return key:课程日期-年月日 value:课程
|
|
|
+ */
|
|
|
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)
|
|
@@ -566,8 +590,12 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
|
return nowCourse;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取当前登录人信息
|
|
|
+ */
|
|
|
private SysUser getSysUser() {
|
|
|
- return Optional.ofNullable(sysUserFeignService.queryUserInfo()).orElseThrow(() -> new BizException("用户不存在"));
|
|
|
+ return Optional.ofNullable(sysUserFeignService.queryUserInfo())
|
|
|
+ .orElseThrow(() -> new BizException("用户不存在"));
|
|
|
}
|
|
|
|
|
|
/**
|