Parcourir la source

1、课表导出报错解决

dzx il y a 2 mois
Parent
commit
73d0d34a28

+ 33 - 32
src/main/java/com/xjrsoft/module/courseTable/service/impl/CourseTableServiceImpl.java

@@ -488,38 +488,39 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
             if (timePeriodListMap != null) {
                 List<CourseDetailVo> courseDetailVoList = timePeriodListMap.get(classTime.getNumber());
                 if (courseDetailVoList != null) {
-                    Map<Integer, CourseDetailVo> courseDetailVoByWeeksMap = courseDetailVoList.stream()
-                            .collect(Collectors.toMap(CourseDetailVo::getWeeks, item -> item));
-
-                    for (int i = 1; i <= 7; i++) {
-                        CourseDetailVo courseDetailVo = courseDetailVoByWeeksMap.get(i);
-                        if (courseDetailVo != null) {
-                            String courseInfo = courseDetailVo.getCourseName() + "\n" +
-                                    courseDetailVo.getTeacherName() + "\n" +
-                                    courseDetailVo.getClassName() + "\n" +
-                                    courseDetailVo.getClassroomName() + "\n";
-                            switch (i) {
-                                case 1:
-                                    scheduleWeekExportQueryVo.setMonday(courseInfo);
-                                    break;
-                                case 2:
-                                    scheduleWeekExportQueryVo.setTuesday(courseInfo);
-                                    break;
-                                case 3:
-                                    scheduleWeekExportQueryVo.setWednesday(courseInfo);
-                                    break;
-                                case 4:
-                                    scheduleWeekExportQueryVo.setThursday(courseInfo);
-                                    break;
-                                case 5:
-                                    scheduleWeekExportQueryVo.setFriday(courseInfo);
-                                    break;
-                                case 6:
-                                    scheduleWeekExportQueryVo.setSaturday(courseInfo);
-                                    break;
-                                case 7:
-                                    scheduleWeekExportQueryVo.setSunday(courseInfo);
-                                    break;
+                    for (CourseDetailVo courseDetailVo : courseDetailVoList) {
+                        for (int i = 1; i <= 7; i++) {
+                            if(courseDetailVo.getWeeks() != i){
+                                continue;
+                            }
+                            if (courseDetailVo != null) {
+                                String courseInfo = courseDetailVo.getCourseName() + "\n" +
+                                        courseDetailVo.getTeacherName() + "\n" +
+                                        courseDetailVo.getClassName() + "\n" +
+                                        courseDetailVo.getClassroomName() + "\n";
+                                switch (i) {
+                                    case 1:
+                                        scheduleWeekExportQueryVo.setMonday(courseInfo);
+                                        break;
+                                    case 2:
+                                        scheduleWeekExportQueryVo.setTuesday(courseInfo);
+                                        break;
+                                    case 3:
+                                        scheduleWeekExportQueryVo.setWednesday(courseInfo);
+                                        break;
+                                    case 4:
+                                        scheduleWeekExportQueryVo.setThursday(courseInfo);
+                                        break;
+                                    case 5:
+                                        scheduleWeekExportQueryVo.setFriday(courseInfo);
+                                        break;
+                                    case 6:
+                                        scheduleWeekExportQueryVo.setSaturday(courseInfo);
+                                        break;
+                                    case 7:
+                                        scheduleWeekExportQueryVo.setSunday(courseInfo);
+                                        break;
+                                }
                             }
                         }
                     }