|
@@ -5258,11 +5258,15 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void mergeCourseReplace(List<CourseSchedule> courseSchedules) {
|
|
|
+ public List<CourseSchedule> mergeCourseReplace(Long classGroupId) {
|
|
|
+ List<CourseSchedule> courseSchedules = courseScheduleDao.getClassGroupCourses(classGroupId);
|
|
|
Set<Long> newCourseIds = courseSchedules.stream().filter(c -> Objects.nonNull(c.getNewCourseId())).map(CourseSchedule::getNewCourseId).collect(Collectors.toSet());
|
|
|
if(CollectionUtils.isEmpty(newCourseIds)){
|
|
|
- return;
|
|
|
+ return Collections.EMPTY_LIST;
|
|
|
}
|
|
|
+
|
|
|
+ Date now = new Date();
|
|
|
+
|
|
|
List<CourseSchedule> mainCourses = courseScheduleDao.findByCourseScheduleIds(new ArrayList<>(newCourseIds));
|
|
|
Map<Long, CourseSchedule> idCourseMap = mainCourses.stream().collect(Collectors.toMap(CourseSchedule::getId, c -> c, (c1, c2) -> c1));
|
|
|
Iterator<CourseSchedule> iterator = courseSchedules.iterator();
|
|
@@ -5271,7 +5275,8 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
if(Objects.isNull(next.getNewCourseId())){
|
|
|
continue;
|
|
|
}
|
|
|
- if(next.getClassGroupId().equals(idCourseMap.get(next.getNewCourseId()).getClassGroupId())){
|
|
|
+ CourseSchedule mainCourse = idCourseMap.get(next.getNewCourseId());
|
|
|
+ if(next.getClassGroupId().equals(mainCourse.getClassGroupId())||mainCourse.getStartClassTime().compareTo(now)<0){
|
|
|
iterator.remove();
|
|
|
}
|
|
|
}
|
|
@@ -5281,6 +5286,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
|
}
|
|
|
courseSchedule = idCourseMap.get(courseSchedule.getId());
|
|
|
}
|
|
|
+ return courseSchedules;
|
|
|
}
|
|
|
|
|
|
@Override
|