|
@@ -5169,11 +5169,13 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
List<CourseRepeatCheckDto> courseRepeatCheckInfos = courseScheduleDao.getCourseRepeatCheckInfos();
|
|
List<CourseRepeatCheckDto> courseRepeatCheckInfos = courseScheduleDao.getCourseRepeatCheckInfos();
|
|
courseRepeatCheckInfos.sort(Comparator.comparing(CourseRepeatCheckDto::getStartClassTime));
|
|
courseRepeatCheckInfos.sort(Comparator.comparing(CourseRepeatCheckDto::getStartClassTime));
|
|
Map<Date, List<CourseRepeatCheckDto>> dayCourseMap = courseRepeatCheckInfos.stream().collect(Collectors.groupingBy(CourseRepeatCheckDto::getClassDate));
|
|
Map<Date, List<CourseRepeatCheckDto>> dayCourseMap = courseRepeatCheckInfos.stream().collect(Collectors.groupingBy(CourseRepeatCheckDto::getClassDate));
|
|
- Map<Long, List<Long>> courseRepeatIdMap = new HashMap<>();
|
|
|
|
|
|
+ Map<Long, Map<String, Object>> courseRepeatIdMap = new HashMap<>();
|
|
int needAdjustCourseNum = 0;
|
|
int needAdjustCourseNum = 0;
|
|
for (CourseRepeatCheckDto cs1 : courseRepeatCheckInfos) {
|
|
for (CourseRepeatCheckDto cs1 : courseRepeatCheckInfos) {
|
|
if(!courseRepeatIdMap.containsKey(cs1.getCourseId())){
|
|
if(!courseRepeatIdMap.containsKey(cs1.getCourseId())){
|
|
- courseRepeatIdMap.put(cs1.getCourseId(), new ArrayList<>());
|
|
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
+ result.put("repeatCourseId", new ArrayList<>());
|
|
|
|
+ courseRepeatIdMap.put(cs1.getCourseId(), result);
|
|
// courseRepeatIdMap.get(cs1.getCourseId()).add(cs1.getCourseId());
|
|
// courseRepeatIdMap.get(cs1.getCourseId()).add(cs1.getCourseId());
|
|
}else{
|
|
}else{
|
|
continue;
|
|
continue;
|
|
@@ -5186,11 +5188,14 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
if(cs2.getEndClassTime().compareTo(cs1.getStartClassTime())<=0){
|
|
if(cs2.getEndClassTime().compareTo(cs1.getStartClassTime())<=0){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- if(courseRepeatIdMap.containsKey(cs2.getCourseId())&&courseRepeatIdMap.get(cs2.getCourseId()).contains(cs1.getCourseId())){
|
|
|
|
|
|
+
|
|
|
|
+ if(courseRepeatIdMap.containsKey(cs2.getCourseId())
|
|
|
|
+ &&((List<Long>)courseRepeatIdMap.get(cs2.getCourseId()).get("repeatCourseId")).contains(cs1.getCourseId())){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
if(cs2.getStartClassTime().compareTo(cs1.getEndClassTime())>=0){
|
|
if(cs2.getStartClassTime().compareTo(cs1.getEndClassTime())>=0){
|
|
- if(CollectionUtils.isEmpty(courseRepeatIdMap.get(cs1.getCourseId()))){
|
|
|
|
|
|
+ List<Long> repeatCourseId = (List<Long>) courseRepeatIdMap.get(cs1.getCourseId()).get("repeatCourseId");
|
|
|
|
+ if(CollectionUtils.isEmpty(((List<Long>)courseRepeatIdMap.get(cs1.getCourseId()).get("repeatCourseId")))){
|
|
courseRepeatIdMap.remove(cs1.getCourseId());
|
|
courseRepeatIdMap.remove(cs1.getCourseId());
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
@@ -5198,23 +5203,23 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
if(cs1.getStartClassTime().compareTo(cs2.getEndClassTime())>=0||cs1.getEndClassTime().compareTo(cs2.getStartClassTime())<=0){
|
|
if(cs1.getStartClassTime().compareTo(cs2.getEndClassTime())>=0||cs1.getEndClassTime().compareTo(cs2.getStartClassTime())<=0){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- long repeatTeacherNums = cs1.getTeacherIds().stream().filter(teacherId -> cs2.getTeacherIds().contains(teacherId)).count();
|
|
|
|
- if(repeatTeacherNums>0){
|
|
|
|
- System.out.println(cs1.getCourseId() + "," + cs2.getCourseId());
|
|
|
|
- courseRepeatIdMap.get(cs1.getCourseId()).add(cs2.getCourseId());
|
|
|
|
|
|
+ Set<Integer> repeatTeacherIds = cs1.getTeacherIds().stream().filter(teacherId -> cs2.getTeacherIds().contains(teacherId)).collect(Collectors.toSet());
|
|
|
|
+ if(repeatTeacherIds.size()>0){
|
|
|
|
+ courseRepeatIdMap.get(cs1.getCourseId()).put("cause", "冲突教师编号:"+StringUtils.join(repeatTeacherIds));
|
|
|
|
+ ((List<Long>)courseRepeatIdMap.get(cs1.getCourseId()).get("repeatCourseId")).add(cs2.getCourseId());
|
|
needAdjustCourseNum++;
|
|
needAdjustCourseNum++;
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- long repeatStudentNums = cs1.getStudentIds().stream().filter(studentId -> cs2.getStudentIds().contains(studentId)).count();
|
|
|
|
- if(repeatStudentNums>0){
|
|
|
|
- System.out.println(cs1.getCourseId() + "," + cs2.getCourseId());
|
|
|
|
- courseRepeatIdMap.get(cs1.getCourseId()).add(cs2.getCourseId());
|
|
|
|
|
|
+ Set<Integer> repeatStudentIds = cs1.getStudentIds().stream().filter(studentId -> cs2.getStudentIds().contains(studentId)).collect(Collectors.toSet());
|
|
|
|
+ if(repeatStudentIds.size()>0){
|
|
|
|
+ courseRepeatIdMap.get(cs1.getCourseId()).put("cause", "学生冲突:"+StringUtils.join(repeatStudentIds));
|
|
|
|
+ ((List<Long>)courseRepeatIdMap.get(cs1.getCourseId()).get("repeatCourseId")).add(cs2.getCourseId());
|
|
needAdjustCourseNum++;
|
|
needAdjustCourseNum++;
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(CollectionUtils.isEmpty(courseRepeatIdMap.get(cs1.getCourseId()))){
|
|
|
|
|
|
+ if(courseRepeatIdMap.containsKey(cs1.getCourseId())&&CollectionUtils.isEmpty(((List<Long>)courseRepeatIdMap.get(cs1.getCourseId()).get("repeatCourseId")))){
|
|
courseRepeatIdMap.remove(cs1.getCourseId());
|
|
courseRepeatIdMap.remove(cs1.getCourseId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -5223,6 +5228,18 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
|
|
System.out.println("重复课程数量:" + courseRepeatIdMap.size());
|
|
System.out.println("重复课程数量:" + courseRepeatIdMap.size());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+ CourseRepeatCheckDto c = new CourseRepeatCheckDto();
|
|
|
|
+ c.setCourseId((long) 1);
|
|
|
|
+ Map<Long, Map<String, Object>> courseRepeatIdMap = new HashMap<>();
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
+ result.put("repeatCourseId", new ArrayList<>());
|
|
|
|
+ courseRepeatIdMap.put(c.getCourseId(), result);
|
|
|
|
+ if(CollectionUtils.isEmpty(((List<Long>)courseRepeatIdMap.get(c.getCourseId()).get("repeatCourseId")))){
|
|
|
|
+ courseRepeatIdMap.remove(c.getCourseId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public void courseMerge(CourseMergeDto courseMergeInfo) {
|
|
public void courseMerge(CourseMergeDto courseMergeInfo) {
|