Browse Source

fix: 首页数据

Joburgess 4 years ago
parent
commit
92f1c1348e

+ 26 - 45
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServeServiceImpl.java

@@ -370,52 +370,33 @@ public class StudentServeServiceImpl implements StudentServeService {
             Map<CourseSchedule.CourseScheduleType, List<StudentServeCourseDto>> typeCourseMap = studentCourseMapEntry.getValue().stream().collect(Collectors.groupingBy(StudentServeCourseDto::getType));
 
             if(typeCourseMap.containsKey(CourseSchedule.CourseScheduleType.SINGLE)){
-
-//                List<StudentServeCourseDto> futureCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.SINGLE);
-//                List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.SINGLE).stream().filter(c -> c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList());
-//                if(CollectionUtils.isEmpty(weekCourseInfo)){
-//                    Map<String, List<StudentServeCourseDto>> groupCourseInfo = futureCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId));
-//
-//                    Map<Integer, Integer> teacherNumMap = new HashMap<>();
-//                    for (Map.Entry<String, List<StudentServeCourseDto>> groupCourseInfoEntry : groupCourseInfo.entrySet()) {
-//                        StudentServeCourseDto courseInfo = groupCourseInfoEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
-//
-//                        if(!teacherNumMap.containsKey(courseInfo.getActualTeacherId())){
-//                            teacherNumMap.put(courseInfo.getActualTeacherId(), 1);
-//                        }else{
-//                            teacherNumMap.put(courseInfo.getActualTeacherId(), teacherNumMap.get(courseInfo.getActualTeacherId())+1);
-//                        }
-//                    }
-//
-//                    for (Map.Entry<Integer, Integer> teacherNumMapEntry : teacherNumMap.entrySet()) {
-//                        StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
-//                                teacherNumMapEntry.getKey(),nowDate.get(DateUtil.weekFields.weekOfYear()),
-//                                DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"),
-//                                "EXERCISE", null);
-//                        studentExtracurricularExercisesSituation.setExpectExercisesNum(teacherNumMapEntry.getValue());
-//                        results.add(studentExtracurricularExercisesSituation);
-//                    }
-//                }else{
-//                    Map<String, List<StudentServeCourseDto>> groupCourseInfo = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId));
-//                    Map<Integer, Set<Long>> teacherServiceCourseIdMap = new HashMap<>();
-//                    for (Map.Entry<String, List<StudentServeCourseDto>> groupCourseInfoEntry : groupCourseInfo.entrySet()) {
-//                        StudentServeCourseDto courseInfo = groupCourseInfoEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
-//                        if(!teacherServiceCourseIdMap.containsKey(courseInfo.getActualTeacherId())){
-//                            teacherServiceCourseIdMap.put(courseInfo.getActualTeacherId(), new HashSet<>());
-//                        }
-//                        teacherServiceCourseIdMap.get(courseInfo.getActualTeacherId()).add(courseInfo.getCourseScheduleId());
-//                    }
-//                    for (Map.Entry<Integer, Set<Long>> teacherServiceCourseIdMapEntry : teacherServiceCourseIdMap.entrySet()) {
-//                        StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
-//                                teacherServiceCourseIdMapEntry.getKey(),nowDate.get(DateUtil.weekFields.weekOfYear()),
-//                                DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"),
-//                                "HOMEWORK", StringUtils.join(teacherServiceCourseIdMapEntry.getValue(), ","));
-//                        studentExtracurricularExercisesSituation.setExpectExercisesNum(teacherServiceCourseIdMapEntry.getValue().size());
-//                        results.add(studentExtracurricularExercisesSituation);
-//                    }
-//                }
-
                 Set<String> musicGroupIds = noCourseStudentMusicIdsMap.get(studentCourseMapEntry.getKey());
+                if(Objects.isNull(musicGroupIds)){
+                    musicGroupIds = new HashSet<>();
+                }
+
+                List<StudentServeCourseDto> weekCourseInfo = typeCourseMap.get(CourseSchedule.CourseScheduleType.SINGLE).stream().filter(c -> c.getCourseStartTime().compareTo(nextMonday) < 0).collect(Collectors.toList());
+                if(!CollectionUtils.isEmpty(weekCourseInfo)){
+                    Map<String, List<StudentServeCourseDto>> groupCourseInfo = weekCourseInfo.stream().collect(Collectors.groupingBy(StudentServeCourseDto::getMusicGroupId));
+                    Map<Integer, Set<Long>> teacherServiceCourseIdMap = new HashMap<>();
+                    for (Map.Entry<String, List<StudentServeCourseDto>> groupCourseInfoEntry : groupCourseInfo.entrySet()) {
+                        if(musicGroupIds.contains(groupCourseInfoEntry.getKey()))
+                            musicGroupIds.remove(groupCourseInfoEntry.getKey());
+                        StudentServeCourseDto courseInfo = groupCourseInfoEntry.getValue().stream().min(Comparator.comparing(StudentServeCourseDto::getCourseStartTime)).get();
+                        if(!teacherServiceCourseIdMap.containsKey(courseInfo.getActualTeacherId())){
+                            teacherServiceCourseIdMap.put(courseInfo.getActualTeacherId(), new HashSet<>());
+                        }
+                        teacherServiceCourseIdMap.get(courseInfo.getActualTeacherId()).add(courseInfo.getCourseScheduleId());
+                    }
+                    for (Map.Entry<Integer, Set<Long>> teacherServiceCourseIdMapEntry : teacherServiceCourseIdMap.entrySet()) {
+                        StudentExtracurricularExercisesSituation studentExtracurricularExercisesSituation=new StudentExtracurricularExercisesSituation(studentCourseMapEntry.getKey(),
+                                teacherServiceCourseIdMapEntry.getKey(),nowDate.get(DateUtil.weekFields.weekOfYear()),
+                                DateUtil.stringToDate(monDayDate.toString(), "yyyy-MM-dd"), DateUtil.stringToDate(sunDayDate.toString(), "yyyy-MM-dd"),
+                                "HOMEWORK", StringUtils.join(teacherServiceCourseIdMapEntry.getValue(), ","));
+                        studentExtracurricularExercisesSituation.setExpectExercisesNum(teacherServiceCourseIdMapEntry.getValue().size());
+                        results.add(studentExtracurricularExercisesSituation);
+                    }
+                }
                 if(CollectionUtils.isEmpty(musicGroupIds)){
                     continue;
                 }