瀏覽代碼

双周排课

zouxuan 1 年之前
父節點
當前提交
1c809d12e5

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/CourseTimeDto.java

@@ -5,6 +5,7 @@ import com.ym.mec.biz.dal.entity.CourseSchedule;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.time.LocalDateTime;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
@@ -22,7 +23,7 @@ public class CourseTimeDto {
     @ApiModelProperty(value = "排课星期几")
     private Integer dayOfWeek;
 //    当前排课日期
-    private Calendar calendar;
+    private LocalDateTime calendar;
 
     @ApiModelProperty(value = "间隔天数(默认7)")
     private Integer intervalDays = 7;

+ 9 - 7
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -2680,8 +2680,10 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             while (true) {
 //                int dayOfWeek = now.getDayOfWeek().getValue();
                 for (CourseTimeDto courseTimeDto : classGroup4MixDto.getCourseTimeDtoList()) {
-                    //排课开始时间
-                    LocalDateTime now = courseTimeDto.getStartDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
+                    if(courseTimeDto.getCalendar() == null){
+                        //排课开始时间
+                        courseTimeDto.setCalendar(courseTimeDto.getStartDate().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
+                    }
                     List<ClassGroupTeacherMapper> newClassGroupTeacherMapperList = courseTimeDto.getClassGroupTeacherMapperList();
 
                     Set<Integer> noRepeatTeacherIds = newClassGroupTeacherMapperList.stream().map(ClassGroupTeacherMapper::getUserId).collect(Collectors.toSet());
@@ -2702,14 +2704,14 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                     }
 
                     //跳过节假日
-                    if (courseTimeDto.getHoliday() && holidayDays.contains(now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))) {
-                        now = now.plusDays(courseTimeDto.getIntervalDays());
+                    if (courseTimeDto.getHoliday() && holidayDays.contains(courseTimeDto.getCalendar().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")))) {
+                        courseTimeDto.setCalendar(courseTimeDto.getCalendar().plusDays(courseTimeDto.getIntervalDays()));
                         continue;
                     }
 
 //                    if (!courseTimeDto.getDayOfWeek().equals(dayOfWeek)) continue;
 
-                    Date classDate = DateConvertor.toDate(now);
+                    Date classDate = DateConvertor.toDate(courseTimeDto.getCalendar());
 
                     if (courseTimeDto.getStartDate().compareTo(classDate) > 0
                             || courseTimeDto.getEndDate().compareTo(classDate) < 0
@@ -2720,7 +2722,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                         if (totalCourseTimes <= generateCourseTimes) {
                             break WhileNode;
                         }
-                        now = now.plusDays(courseTimeDto.getIntervalDays());
+                        courseTimeDto.setCalendar(courseTimeDto.getCalendar().plusDays(courseTimeDto.getIntervalDays()));
                         continue;
                     }
 
@@ -2802,7 +2804,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                             return BaseController.failed(HttpStatus.MULTI_STATUS, "当前课程课酬预计为0,是否继续");
                         }
                     }
-                    now = now.plusDays(courseTimeDto.getIntervalDays());
+                    courseTimeDto.setCalendar(courseTimeDto.getCalendar().plusDays(courseTimeDto.getIntervalDays()));
                 }
             }