|
@@ -707,11 +707,15 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
.distinct()
|
|
|
.collect(Collectors.toList());
|
|
|
//班级与学生的关联记录
|
|
|
+ List<CourseScheduleStudentPayment> exitStudentPaymentList = courseScheduleStudentPaymentDao.findByCourseScheduleIds(existCourseScheduleIds);
|
|
|
+
|
|
|
List<ClassGroupStudentMapper> classGroupStudentMappers = classGroupStudentMapperDao.findByClassGroups(classGroupIds);
|
|
|
Map<Integer, List<ClassGroupStudentMapper>> classGroupStudentsMap = classGroupStudentMappers
|
|
|
.stream()
|
|
|
.collect(Collectors.groupingBy(ClassGroupStudentMapper::getClassGroupId));
|
|
|
|
|
|
+ Map<Long, List<CourseScheduleStudentPayment>> exitStudentPaymentMap = exitStudentPaymentList.stream().collect(Collectors.groupingBy(CourseScheduleStudentPayment::getId));
|
|
|
+
|
|
|
//根据课程获取教师id关联集合
|
|
|
List<IntegerAndIntegerListDto> courseScheduleTeachingTeacherIdList = new ArrayList<>();
|
|
|
if (!CollectionUtils.isEmpty(existCourseScheduleIds)) {
|
|
@@ -730,13 +734,12 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
|
|
|
newNode:
|
|
|
for (CourseSchedule newCourseSchedule : courseSchedules) {
|
|
|
- exitNode:
|
|
|
for (CourseSchedule existCourseSchedule : existCourseSchedules) {
|
|
|
- if(newCourseSchedule.getEndClassTime().compareTo(existCourseSchedule.getStartClassTime()) <= 0){
|
|
|
+ if (newCourseSchedule.getEndClassTime().compareTo(existCourseSchedule.getStartClassTime()) <= 0) {
|
|
|
continue newNode;
|
|
|
}
|
|
|
- if(existCourseSchedule.getEndClassTime().compareTo(newCourseSchedule.getStartClassTime()) <= 0){
|
|
|
- continue exitNode;
|
|
|
+ if (existCourseSchedule.getEndClassTime().compareTo(newCourseSchedule.getStartClassTime()) <= 0) {
|
|
|
+ continue;
|
|
|
}
|
|
|
|
|
|
boolean isTeacherRepeat = false;
|
|
@@ -761,22 +764,23 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
|
|
|
//学生冲突检测
|
|
|
if (newCourseSchedule.getClassGroupId().equals(existCourseSchedule.getClassGroupId())) {
|
|
|
- //如果班级相同,则学生肯定存在冲突
|
|
|
+ //如果班级相同,则学生肯定全部存在冲突,当做老师冲突处理
|
|
|
isTeacherRepeat = true;
|
|
|
}
|
|
|
- //如果班级不同,则需要检测两个班级是否存在重复的学生
|
|
|
- List<ClassGroupStudentMapper> preClassGroupStudents = classGroupStudentsMap.get(newCourseSchedule.getClassGroupId());
|
|
|
- List<ClassGroupStudentMapper> backClassGroupStudents = classGroupStudentsMap.get(existCourseSchedule.getClassGroupId());
|
|
|
|
|
|
List<Integer> repeatStudentIds = new ArrayList<>();
|
|
|
- if (classGroupStudentsMap.containsKey(newCourseSchedule.getClassGroupId()) && classGroupStudentsMap.containsKey(existCourseSchedule.getClassGroupId())) {
|
|
|
+ if (!isTeacherRepeat && classGroupStudentsMap.containsKey(newCourseSchedule.getClassGroupId()) && exitStudentPaymentMap.containsKey(existCourseSchedule.getId())) {
|
|
|
+ //如果班级不同,则需要检测两个班级是否存在重复的学生
|
|
|
+ List<ClassGroupStudentMapper> preClassGroupStudents = classGroupStudentsMap.get(newCourseSchedule.getClassGroupId());
|
|
|
+ List<CourseScheduleStudentPayment> backClassGroupStudents = exitStudentPaymentMap.get(existCourseSchedule.getId());
|
|
|
+
|
|
|
//当前课程所在班级的学生编号列表
|
|
|
List<Integer> preClassGroupStudentIds = preClassGroupStudents.stream()
|
|
|
.map(ClassGroupStudentMapper::getUserId)
|
|
|
.collect(Collectors.toList());
|
|
|
//后面一节课程所在班级的学生编号列表
|
|
|
List<Integer> backClassGroupStudentIds = backClassGroupStudents.stream()
|
|
|
- .map(ClassGroupStudentMapper::getUserId)
|
|
|
+ .map(CourseScheduleStudentPayment::getUserId)
|
|
|
.collect(Collectors.toList());
|
|
|
repeatStudentIds = preClassGroupStudentIds.stream()
|
|
|
.filter(backClassGroupStudentIds::contains)
|
|
@@ -784,7 +788,13 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
if (!CollectionUtils.isEmpty(repeatStudentIds)) {
|
|
|
isStudentRepeat = true;
|
|
|
}
|
|
|
+
|
|
|
+ if(isStudentRepeat && (backClassGroupStudentIds.size() == repeatStudentIds.size())){
|
|
|
+ isStudentRepeat = false;
|
|
|
+ isTeacherRepeat = true;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
if (!isTeacherRepeat && !isStudentRepeat) {
|
|
|
continue;
|
|
|
}
|