Ver código fonte

feat:乐团排课调整

Joburgess 4 anos atrás
pai
commit
aa7e62d765

+ 10 - 8
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ClassGroupServiceImpl.java

@@ -2402,7 +2402,7 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 
         for (ClassGroup4MixDto classGroup4MixDto : classGroup4MixDtos) {
             //3、插入班级排课信息
-            LocalDateTime now = LocalDate.parse(classGroup4MixDto.getStartDate(), DateTimeFormatter.ofPattern("yyyy-MM-dd")).atStartOfDay();
+            LocalDateTime now = LocalDateTime.now();
 
             if (!courseTypeMinutesMap.containsKey(classGroup4MixDto.getCourseType().getCode())) {
                 throw new BizException("{}课程类型暂无剩余课程时长", classGroup4MixDto.getCourseType().getMsg());
@@ -2421,11 +2421,9 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
             }
 
             Set<String> holidayDays = new HashSet<>();
-            if (classGroup4MixDto.getHoliday()) {
-                SysConfig holidaySetting = sysConfigService.findByParamName(SysConfigService.HOLIDAY_SETTING);
-                if (Objects.nonNull(holidaySetting) && StringUtils.isNotBlank(holidaySetting.getParanValue())) {
-                    holidayDays = new HashSet<>(JSON.parseArray(holidaySetting.getParanValue(), String.class));
-                }
+            SysConfig holidaySetting = sysConfigService.findByParamName(SysConfigService.HOLIDAY_SETTING);
+            if (Objects.nonNull(holidaySetting) && StringUtils.isNotBlank(holidaySetting.getParanValue())) {
+                holidayDays = new HashSet<>(JSON.parseArray(holidaySetting.getParanValue(), String.class));
             }
 
             WhileNode:
@@ -2461,8 +2459,8 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
                     }
 
                     //课时长度
-                    long classCourseDuration = Duration.between(LocalDateTime.parse(classGroup4MixDto.getStartDate() + " " + courseTimeDto.getStartClassTime() + ":00", formatter),
-                            LocalDateTime.parse(classGroup4MixDto.getStartDate() + " " + courseTimeDto.getEndClassTime() + ":00", formatter))
+                    long classCourseDuration = Duration.between(LocalDateTime.parse(DateUtil.dateToString(courseTimeDto.getStartDate(), "yyyy-MM-dd") + " " + courseTimeDto.getStartClassTime() + ":00", formatter),
+                            LocalDateTime.parse(DateUtil.dateToString(courseTimeDto.getStartDate(), "yyyy-MM-dd") + " " + courseTimeDto.getEndClassTime() + ":00", formatter))
                             .toMinutes();
 
                     totalCourseDuration += classCourseDuration;
@@ -2530,6 +2528,10 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 
                 now = now.plusDays(1);
             }
+
+            if (totalCourseDuration > totalMinutes) {
+                throw new BizException("课程时长不足");
+            }
         }
 
         courseScheduleService.checkNewCourseSchedules(courseScheduleList, false, false);