|
@@ -94,6 +94,8 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
private SysMessageService sysMessageService;
|
|
private SysMessageService sysMessageService;
|
|
@Autowired
|
|
@Autowired
|
|
private HolidaysFestivalsDao holidaysFestivalsDao;
|
|
private HolidaysFestivalsDao holidaysFestivalsDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private PinaoRoomTimeDao pinaoRoomTimeDao;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public CourseScheduleDao getDao() {
|
|
public CourseScheduleDao getDao() {
|
|
@@ -1483,7 +1485,11 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
*/
|
|
*/
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public void scheduleTask() {
|
|
public void scheduleTask() {
|
|
- baseMapper.updateStartTime();
|
|
|
|
|
|
+ //查询课程id(开课时间 ≤ NOW ≤ 结束时间)
|
|
|
|
+ List<Long> startIds=baseMapper.selectUpStartIds();
|
|
|
|
+ if (CollectionUtils.isNotEmpty(startIds)){
|
|
|
|
+ baseMapper.updateStartTime(startIds);
|
|
|
|
+ }
|
|
baseMapper.updateEndTime();
|
|
baseMapper.updateEndTime();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1503,4 +1509,146 @@ public class CourseScheduleServiceImpl extends ServiceImpl<CourseScheduleDao, Co
|
|
//更新老师课酬表
|
|
//更新老师课酬表
|
|
baseMapper.updateTeacherSalary(idList);
|
|
baseMapper.updateTeacherSalary(idList);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public PinaoRoomTimeVo selectRemainTime(Long teacherId) {
|
|
|
|
+ return pinaoRoomTimeDao.selectRemainTime(teacherId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+// public PageInfo<CourseStudentVo> selectStudent(Map<String, Object> param) {
|
|
|
|
+// Integer courseId = (Integer) param.get("courseId");
|
|
|
|
+// if (courseId != null) {
|
|
|
|
+// CourseScheduleStudent teacherTime = baseMapper.selectOne(Wrappers.<CourseScheduleStudent>lambdaQuery().eq(CourseScheduleStudent::getCourseScheduleId, courseId));
|
|
|
|
+// if (teacherTime == null) {
|
|
|
|
+// throw new BizException("未查到课程");
|
|
|
|
+// }
|
|
|
|
+// String studentIdList = teacherTime.getStudentIdList();
|
|
|
|
+// List<String> idList = Arrays.asList(studentIdList.split(","));
|
|
|
|
+// param.put("idList", idList);//根据课程id查询报课学员
|
|
|
|
+// }
|
|
|
|
+// return PageUtil.pageInfo(userBindingTeacherDao.selectStudent(PageUtil.getPageInfo(param), param));
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// public void arrangeCourse(ArrangeCourseVo arrangeCourseVo, Long teacherId) {
|
|
|
|
+// DistributedLock.of(redissonClient)
|
|
|
|
+// .runIfLockCanGet(CacheNameEnum.LOCK_EXECUTE_ORDER.getRedisKey("teacherId:" + teacherId)
|
|
|
|
+// , () -> this.checkArrangeCourse(arrangeCourseVo, teacherId), 60L, TimeUnit.SECONDS);
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// @Transactional(rollbackFor = Exception.class)
|
|
|
|
+// public void checkArrangeCourse(ArrangeCourseVo arrangeCourseVo, Long teacherId) {
|
|
|
|
+// Integer classNum = arrangeCourseVo.getClassNum();//课时数
|
|
|
|
+// Integer singleClssTime = arrangeCourseVo.getSingleClssTime();//单课时长
|
|
|
|
+// List<Long> studentIds = arrangeCourseVo.getStudentIds();//学员id集合
|
|
|
|
+// Integer consumTime = classNum * singleClssTime * studentIds.size();//消耗时长
|
|
|
|
+// List<CourseTimeEntity> timeList = arrangeCourseVo.getTimeList();//选课时间
|
|
|
|
+// Integer consumeTime = arrangeCourseVo.getConsumeTime();
|
|
|
|
+//
|
|
|
|
+// //校验课时
|
|
|
|
+// if (timeList.size() != classNum) {
|
|
|
|
+// throw new BizException("课时数与排课数不符");
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //校验消耗时长
|
|
|
|
+// if (!consumTime.equals(consumeTime)) {
|
|
|
|
+// throw new BizException("时长计算错误");
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //校验上下课时间
|
|
|
|
+// for (int i = 1; i <= timeList.size(); i++) {
|
|
|
|
+// if (!DateUtil.offsetMinute(timeList.get(i).getStartTime(), singleClssTime).equals(timeList.get(i).getEndTime())) {
|
|
|
|
+// throw new BizException("第{}节课结束时间计算错误", i);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //校验时长
|
|
|
|
+// PinaoRoomTime pinaoRoomTime = pinaoRoomTimeDao.selectOne(Wrappers.<PinaoRoomTime>lambdaQuery().eq(PinaoRoomTime::getTeacherId, teacherId));
|
|
|
|
+// if (pinaoRoomTime == null) {
|
|
|
|
+// throw new BizException("未查询到老师剩余时长");
|
|
|
|
+// }
|
|
|
|
+// Long remainTime = pinaoRoomTime.getRemainTime();
|
|
|
|
+// Long frozenTime = pinaoRoomTime.getFrozenTime();
|
|
|
|
+// if (consumTime > remainTime) {
|
|
|
|
+// throw new BizException("剩余时长不足");
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //校验学员是否绑定
|
|
|
|
+// List<UserBindingTeacher> bindingTeachers = userBindingTeacherDao.selectList(Wrappers.<UserBindingTeacher>lambdaQuery().eq(UserBindingTeacher::getTeacherId, teacherId));
|
|
|
|
+// if (com.baomidou.mybatisplus.core.toolkit.CollectionUtils.isEmpty(bindingTeachers)) {
|
|
|
|
+// throw new BizException("无绑定学员");
|
|
|
|
+// }
|
|
|
|
+// List<Long> studentList = bindingTeachers.stream().map(UserBindingTeacher::getStudentId).collect(Collectors.toList());
|
|
|
|
+// for (Long studentId : studentIds) {
|
|
|
|
+// if (!studentList.contains(studentId)) {
|
|
|
|
+// throw new BizException("学员id:{},未绑定", studentId);
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //校验传入时间是否交集
|
|
|
|
+// if (timeList.size() > 1) {
|
|
|
|
+// for (int i = 0; i < timeList.size(); i++) {
|
|
|
|
+// if (i == timeList.size() - 1) {
|
|
|
|
+// break;
|
|
|
|
+// }
|
|
|
|
+// CourseTimeEntity o = timeList.get(i);
|
|
|
|
+// List<CourseTimeEntity> newList = timeList.subList(i + 1, timeList.size());
|
|
|
|
+// boolean checkParamTime = courseScheduleService.checkCourseTime(newList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime, o.getStartTime(), o.getEndTime());
|
|
|
|
+// if (checkParamTime) {
|
|
|
|
+// throw new BizException(DateUtil.dateToString(o.getStartTime(), "yyyy年MM月dd号 HH点mm分") + "的课程时间重复!");
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //批量检查老师课时在数据库是否重复
|
|
|
|
+// groupService.batchCheckTeacherCourseTime(teacherId, timeList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime);
|
|
|
|
+//
|
|
|
|
+// //校验购买的课程组每节课时间是否和自己的课时冲突
|
|
|
|
+// for (Long studentId : studentIds) {
|
|
|
|
+// groupService.batchCheckStudentCourseTime(studentId, timeList, CourseTimeEntity::getStartTime, CourseTimeEntity::getEndTime);
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //添加课程组
|
|
|
|
+// CourseGroup courseGroup = new CourseGroup();
|
|
|
|
+// courseGroup.setType(CourseScheduleEnum.PIANO_ROOM_CLASS.getCode());
|
|
|
|
+// courseGroup.setTeacherId(teacherId);
|
|
|
|
+// courseGroup.setName(arrangeCourseVo.getCourseName());
|
|
|
|
+// courseGroup.setSubjectId(arrangeCourseVo.getSubjectId());
|
|
|
|
+// courseGroup.setSingleCourseMinutes(singleClssTime);
|
|
|
|
+// courseGroup.setCourseNum(classNum);
|
|
|
|
+// courseGroup.setStatus(CourseGroupEnum.NOT_SALE.getCode());
|
|
|
|
+// courseGroup.setCreatedBy(teacherId);
|
|
|
|
+// courseGroupDao.insert(courseGroup);
|
|
|
|
+//
|
|
|
|
+// for (int i = 0; i < timeList.size(); i++) {
|
|
|
|
+// //添加课程
|
|
|
|
+// CourseTimeEntity courseTimeEntity = timeList.get(i);
|
|
|
|
+// CourseSchedule schedule = new CourseSchedule();
|
|
|
|
+// schedule.setCourseGroupId(courseGroup.getId());
|
|
|
|
+// schedule.setType(CourseScheduleEnum.PIANO_ROOM_CLASS.getCode());
|
|
|
|
+// schedule.classNum(i + 1);
|
|
|
|
+// schedule.setTeacherId(teacherId);
|
|
|
|
+// schedule.setClassDate(DateUtil.trunc(courseTimeEntity.getStartTime()));
|
|
|
|
+// schedule.setStartTime(courseTimeEntity.getStartTime());
|
|
|
|
+// schedule.setEndTime(courseTimeEntity.getEndTime());
|
|
|
|
+// schedule.setLock(0);
|
|
|
|
+// schedule.setStatus(CourseScheduleEnum.NOT_START.getCode());
|
|
|
|
+// schedule.setCreatedBy(teacherId);
|
|
|
|
+// courseScheduleDao.insert(schedule);
|
|
|
|
+//
|
|
|
|
+// //添加course_schedule_teacher_time
|
|
|
|
+// CourseScheduleStudent teacherTime = new CourseScheduleStudent();
|
|
|
|
+// teacherTime.setCourseGroupId(courseGroup.getId());
|
|
|
|
+// teacherTime.setCourseScheduleId(schedule.getId());
|
|
|
|
+// teacherTime.setTeacherId(teacherId);
|
|
|
|
+// teacherTime.setStudentIdList(org.apache.commons.lang.StringUtils.join(studentIds, ","));
|
|
|
|
+// teacherTime.setClassNum(i + 1);
|
|
|
|
+// teacherTime.setConsumeTime(Long.valueOf(singleClssTime));
|
|
|
|
+// baseMapper.insert(teacherTime);
|
|
|
|
+// }
|
|
|
|
+//
|
|
|
|
+// //扣减pinao_room_time
|
|
|
|
+// PinaoRoomTime roomTime = new PinaoRoomTime();
|
|
|
|
+// roomTime.setRemainTime(remainTime - consumTime);
|
|
|
|
+// roomTime.setFrozenTime(frozenTime + consumTime);
|
|
|
|
+// pinaoRoomTimeDao.update(roomTime, Wrappers.<PinaoRoomTime>lambdaQuery().eq(PinaoRoomTime::getTeacherId, teacherId));
|
|
|
|
+// }
|
|
}
|
|
}
|