|
@@ -358,20 +358,16 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
if(CollectionUtils.isEmpty(courseSchedules)){
|
|
|
return;
|
|
|
}
|
|
|
- //第一节课
|
|
|
- CourseSchedule firstCourseSchedule;
|
|
|
- //最后一节课
|
|
|
- CourseSchedule latestCourseSchedule;
|
|
|
- if(courseSchedules.size()==1){
|
|
|
- firstCourseSchedule = courseSchedules.get(0);
|
|
|
- latestCourseSchedule = courseSchedules.get(0);
|
|
|
- }else{
|
|
|
- firstCourseSchedule = courseSchedules.stream().min(Comparator.comparing(CourseSchedule::getStartClassTime)).get();
|
|
|
- latestCourseSchedule = courseSchedules.stream().max(Comparator.comparing(CourseSchedule::getEndClassTime)).get();
|
|
|
- }
|
|
|
+
|
|
|
+ List<String> classDates = courseSchedules.stream()
|
|
|
+ .map(courseSchedule -> DateUtil.dateToString(courseSchedule.getClassDate(), "yyyy-MM-dd"))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+
|
|
|
//获取第一节课和最后一节课所包含的时间段内已存在的课程
|
|
|
- List<CourseSchedule> existCourseSchedules = courseScheduleDao
|
|
|
- .findAllCourseByDateZone(firstCourseSchedule.getStartClassTime(), latestCourseSchedule.getEndClassTime());
|
|
|
+ List<CourseSchedule> existCourseSchedules = courseScheduleDao.findByClassDate(classDates);
|
|
|
+
|
|
|
+ System.out.println(System.currentTimeMillis());
|
|
|
|
|
|
//只需要调整课程信息的课程编号列表
|
|
|
List<Long> updateCourseScheduleIds = courseSchedules
|
|
@@ -427,25 +423,31 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
Map<Integer, IntegerAndIntegerListDto> classGroupTeachingTeacherMap = classGroupAndUserIdsMap.stream()
|
|
|
.collect(Collectors.toMap(IntegerAndIntegerListDto::getId, integerAndIntegerListDto -> integerAndIntegerListDto));
|
|
|
|
|
|
+ System.out.println(System.currentTimeMillis());
|
|
|
+
|
|
|
//将课程计划按照开课时间排序
|
|
|
allCourseSchedules.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
|
|
|
if(allCourseSchedules.size()>1){
|
|
|
//记录连续冲突的次数
|
|
|
- Integer repeatTimes=0;
|
|
|
- for (int i=1;i<allCourseSchedules.size();i++){
|
|
|
- for(int j=1;j<=repeatTimes+1&&j<=i;j++){
|
|
|
+ Integer repeatTimes=1;
|
|
|
+ for (int i=0;i<allCourseSchedules.size();i++){
|
|
|
+ if(i==0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for(int j=repeatTimes;j>0;j--){
|
|
|
//当前课程
|
|
|
CourseSchedule preCourseSchedule = allCourseSchedules.get(i-j);
|
|
|
//后面一节课程
|
|
|
CourseSchedule backCourseSchedule = allCourseSchedules.get(i);
|
|
|
//判断前后两节课是否存在冲突
|
|
|
if(backCourseSchedule.getStartClassTime().before(preCourseSchedule.getEndClassTime())){
|
|
|
+ if(repeatTimes==j){
|
|
|
+ repeatTimes+=1;
|
|
|
+ }
|
|
|
+
|
|
|
if(!checkExistCourseSchedule
|
|
|
&&existCourseScheduleIds.contains(preCourseSchedule.getId())
|
|
|
&&existCourseScheduleIds.contains(backCourseSchedule.getId())){
|
|
|
- if(j==repeatTimes){
|
|
|
- repeatTimes+=1;
|
|
|
- }
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -514,9 +516,6 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
if(!CollectionUtils.isEmpty(repeatStudentIds)){
|
|
|
throw new BizException(courseCheckInfo(preCourseSchedule,backCourseSchedule,existCourseScheduleIds,3));
|
|
|
}
|
|
|
- if(j==repeatTimes){
|
|
|
- repeatTimes+=1;
|
|
|
- }
|
|
|
}else{
|
|
|
repeatTimes=j;
|
|
|
break;
|
|
@@ -842,6 +841,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void vipCourseAdjust(VipGroupCourseAdjustInfoDto vipGroupCourseAdjustInfo) {
|
|
|
if(Objects.isNull(vipGroupCourseAdjustInfo.getVipGroupId())){
|
|
|
throw new BizException("请指定小课");
|