瀏覽代碼

1、存在毫秒导致的日期判断错误

Joburgess 5 年之前
父節點
當前提交
c4e1d844e8
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java

+ 7 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PracticeGroupServiceImpl.java

@@ -195,6 +195,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         calendar.set(Calendar.HOUR_OF_DAY, 0);
         calendar.set(Calendar.MINUTE, 0);
         calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
         List<Integer> firstTeacherIds = new ArrayList<>();
         List<Integer> secondTeacherIds = new ArrayList<>();
         while (calendar.getTime().before(activityEndDate)) {
@@ -385,6 +386,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         calendar.set(Calendar.HOUR_OF_DAY, 0);
         calendar.set(Calendar.MINUTE, 0);
         calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
         List<Integer> firstTeacherIds = new ArrayList<>();
         List<Integer> secondTeacherIds = new ArrayList<>();
         while (calendar.getTime().before(activityEndDate)) {
@@ -609,6 +611,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         calendar.set(Calendar.HOUR_OF_DAY, 0);
         calendar.set(Calendar.MINUTE, 0);
         calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
         while (calendar.getTime().before(activityEndDate)) {
             calendar.add(Calendar.DATE, 1);
             Date applyStartDay = calendar.getTime();
@@ -653,7 +656,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
                     } else {
                         secondWeekCourses.add(teacherCours);
                     }
-                    if (!teacherCours.getClassDate().before(applyStartDay)
+                    if ((!teacherCours.getClassDate().before(applyStartDay))
                             && (teacherCours.getClassDate().before(applyEndDay) || DateUtil.isSameDay(teacherCours.getClassDate(), applyEndDay))) {
                         applyDateRangeCourses.add(teacherCours);
                     }
@@ -751,6 +754,8 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
             result.put("teacherFreeDays", days);
             allTeacherFreeDates = allTeacherFreeDates.stream().sorted().collect(Collectors.toSet());
             result.put("teacherFreeDates", allTeacherFreeDates);
+        }else{
+            result.put("teacherFreeDays", new ArrayList<>());
         }
         return result;
     }
@@ -762,6 +767,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
         calendar.setTime(startDay);
         calendar.add(Calendar.DATE, -1);
         calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
         SysConfig practiceApplyStartTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_START_TIME);
         SysConfig practiceApplyEndTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_END_TIME);
         SysConfig practiceApplyIntervalTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_INTERVAL_TIME);