Explorar o código

Merge remote-tracking branch 'origin/test' into test

周箭河 %!s(int64=4) %!d(string=hai) anos
pai
achega
ac3572ec19

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

@@ -2404,7 +2404,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());
@@ -2423,11 +2423,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:
@@ -2463,8 +2461,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;
@@ -2532,6 +2530,10 @@ public class ClassGroupServiceImpl extends BaseServiceImpl<Integer, ClassGroup>
 
                 now = now.plusDays(1);
             }
+
+            if (totalCourseDuration > totalMinutes) {
+                throw new BizException("课程时长不足");
+            }
         }
 
         courseScheduleService.checkNewCourseSchedules(courseScheduleList, false, false);