|
@@ -364,7 +364,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
latestCourseSchedule = courseSchedules.stream().max(Comparator.comparing(CourseSchedule::getEndClassTime)).get();
|
|
|
}
|
|
|
//获取第一节课和最后一节课所包含的时间段内已存在的课程
|
|
|
- List<CourseSchedule> existCourseSchedules = courseScheduleDao.findByDateZone(firstCourseSchedule.getStartClassTime(), latestCourseSchedule.getEndClassTime());
|
|
|
+ List<CourseSchedule> existCourseSchedules = courseScheduleDao.findAllCourseByDateZone(firstCourseSchedule.getStartClassTime(), latestCourseSchedule.getEndClassTime());
|
|
|
|
|
|
//只需要调整课程信息的课程编号列表
|
|
|
List<Long> updateCourseScheduleIds = courseSchedules
|
|
@@ -442,18 +442,12 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- //提示信息
|
|
|
- StringBuffer errInfo = new StringBuffer("在");
|
|
|
- errInfo.append(DateUtil.dateToString(preCourseSchedule.getStartClassTime(),"yyyy-MM-dd HH:mm"));
|
|
|
- errInfo.append("至");
|
|
|
- errInfo.append(DateUtil.dateToString(backCourseSchedule.getEndClassTime(),"yyyy-MM-dd HH:mm"));
|
|
|
- errInfo.append("的时间段内");
|
|
|
//如果存在时间重叠,则需要判断前后两节课的教师和学生是否存在冲突
|
|
|
//主教冲突检测
|
|
|
if(Objects.nonNull(preCourseSchedule.getActualTeacherId())
|
|
|
&&preCourseSchedule.getActualTeacherId().equals(backCourseSchedule.getActualTeacherId())){
|
|
|
- errInfo.append("安排的主教有课程冲突");
|
|
|
- throw new BizException(errInfo.toString());
|
|
|
+
|
|
|
+ throw new BizException(courseCheckInfo(preCourseSchedule,backCourseSchedule,existCourseScheduleIds,1));
|
|
|
}
|
|
|
//助教冲突检测
|
|
|
if(Objects.isNull(preCourseSchedule.getId())){
|
|
@@ -484,15 +478,13 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
.stream().filter(backCourseSchedule.getTeachingTeacherIdList()::contains)
|
|
|
.collect(Collectors.toList());
|
|
|
if(!CollectionUtils.isEmpty(repeatIds)){
|
|
|
- errInfo.append("安排的助教存在冲突");
|
|
|
- throw new BizException(errInfo.toString());
|
|
|
+ throw new BizException(courseCheckInfo(preCourseSchedule,backCourseSchedule,existCourseScheduleIds,2));
|
|
|
}
|
|
|
}
|
|
|
//学生冲突检测
|
|
|
if(preCourseSchedule.getClassGroupId().equals(backCourseSchedule.getClassGroupId())){
|
|
|
//如果班级相同,则学生肯定存在冲突
|
|
|
- errInfo.append("安排的课程存在学生冲突");
|
|
|
- throw new BizException(errInfo.toString());
|
|
|
+ throw new BizException(courseCheckInfo(preCourseSchedule,backCourseSchedule,existCourseScheduleIds,3));
|
|
|
}
|
|
|
//如果班级不同,则需要检测两个班级是否存在重复的学生
|
|
|
List<ClassGroupStudentMapper> preClassGroupStudents=classGroupStudentsMap.get(preCourseSchedule.getClassGroupId());
|
|
@@ -513,8 +505,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
.filter(backClassGroupStudentIds::contains)
|
|
|
.collect(Collectors.toList());
|
|
|
if(!CollectionUtils.isEmpty(repeatStudentIds)){
|
|
|
- errInfo.append("安排的课程存在学生冲突");
|
|
|
- throw new BizException(errInfo.toString());
|
|
|
+ throw new BizException(courseCheckInfo(preCourseSchedule,backCourseSchedule,existCourseScheduleIds,3));
|
|
|
}
|
|
|
if(j==repeatTimes){
|
|
|
repeatTimes+=1;
|
|
@@ -528,6 +519,46 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private String courseCheckInfo(CourseSchedule preCourseSchedule,CourseSchedule backCourseSchedule,List<Long> existCourseScheduleIds,Integer type){
|
|
|
+ //提示信息
|
|
|
+ StringBuffer errInfo = new StringBuffer("在");
|
|
|
+ errInfo.append(DateUtil.dateToString(preCourseSchedule.getStartClassTime(),"yyyy-MM-dd HH:mm"));
|
|
|
+ errInfo.append("至");
|
|
|
+ errInfo.append(DateUtil.dateToString(backCourseSchedule.getEndClassTime(),"yyyy-MM-dd HH:mm"));
|
|
|
+ errInfo.append("的时间段内");
|
|
|
+ errInfo.append("安排的课程存在冲突,");
|
|
|
+ errInfo.append("冲突课程为:");
|
|
|
+ if(Objects.nonNull(preCourseSchedule.getId())&&existCourseScheduleIds.contains(preCourseSchedule.getId())){
|
|
|
+ errInfo.append(preCourseSchedule.getName());
|
|
|
+ errInfo.append("(");
|
|
|
+ errInfo.append(preCourseSchedule.getId());
|
|
|
+ errInfo.append(")");
|
|
|
+ }
|
|
|
+ if(Objects.nonNull(backCourseSchedule.getId())&&existCourseScheduleIds.contains(backCourseSchedule.getId())){
|
|
|
+ errInfo.append(backCourseSchedule.getName());
|
|
|
+ errInfo.append("(");
|
|
|
+ errInfo.append(backCourseSchedule.getId());
|
|
|
+ errInfo.append("),");
|
|
|
+ }
|
|
|
+ errInfo.append("类型为:");
|
|
|
+ switch (type){
|
|
|
+ case 1:
|
|
|
+ errInfo.append("主教冲突");
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ errInfo.append("助教冲突");
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ errInfo.append("学生冲突");
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ errInfo.append("未知冲突");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ return errInfo.toString();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 判断课程安排中是否存在冲突
|
|
|
* 计算课程课次
|