|
@@ -215,7 +215,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
LocalDateTime applyExpireDateTime=LocalDateTime.parse("2020-03-01 00:00:00", DateUtil.dateTimeFormatter);
|
|
|
result.put("canApply", now.compareTo(applyExpireDateTime)<=0?1:0);
|
|
|
}else{
|
|
|
- LocalDateTime applyExpireDateTime=LocalDateTime.parse("2020-02-22 08:00:00", DateUtil.dateTimeFormatter);
|
|
|
+ LocalDateTime applyExpireDateTime=LocalDateTime.parse("2020-02-22 20:00:00", DateUtil.dateTimeFormatter);
|
|
|
result.put("canApply", now.compareTo(applyExpireDateTime)<=0?1:0);
|
|
|
}
|
|
|
|
|
@@ -1654,7 +1654,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
}
|
|
|
}else{
|
|
|
LocalDateTime nowDateTime=LocalDateTime.now();
|
|
|
- LocalDateTime applyExpireDateTime=LocalDateTime.parse("2020-02-22 08:00:00", DateUtil.dateTimeFormatter);
|
|
|
+ LocalDateTime applyExpireDateTime=LocalDateTime.parse("2020-02-22 20:00:00", DateUtil.dateTimeFormatter);
|
|
|
if(nowDateTime.compareTo(applyExpireDateTime)>0){
|
|
|
result.put("status", "APPLY_DATE_OVERFLOW");
|
|
|
result.put("info", "预约失败,超出可预约时间范围。");
|
|
@@ -2399,7 +2399,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
Date secondSunday = DateUtil.getWeekDayWithDate(applyEndDate, Calendar.SUNDAY);
|
|
|
|
|
|
Map<Integer, List<String>> weekNumApplyTimesMap = getEnableApplyDatesWithWeek();
|
|
|
- List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeacherCoursesWithDateRange(teacherId, applyStartDate, secondSunday);
|
|
|
+ List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeacherCoursesWithDateRange(teacherId, firstMonday, secondSunday);
|
|
|
allTeacherCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
|
|
|
|
|
|
JSONObject teacherLeaveData = null;
|
|
@@ -2439,7 +2439,15 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
} else if (checkTeacherLeaveDate) {
|
|
|
for (String dateStr : teacherLeaveData.keySet()) {
|
|
|
LocalDate parse = LocalDate.parse(dateStr, ddf);
|
|
|
+ Date tempDate = DateUtil.stringToDate(dateStr, "yyyy-MM-dd");
|
|
|
+ if (tempDate.compareTo(applyStartDate)<0
|
|
|
+ ||tempDate.compareTo(applyEndDate)>=0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
List<String> applyTimeStrs = weekNumApplyTimesMap.get(parse.getDayOfWeek().getValue());
|
|
|
+ if(CollectionUtils.isEmpty(applyTimeStrs)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
Iterator<String> iterator = applyTimeStrs.iterator();
|
|
|
JSONObject leaveDateData = teacherLeaveData.getJSONObject(dateStr);
|
|
|
LocalTime leaveStartTime = LocalDateTime.parse(leaveDateData.getString("leave_start_time"), ddtf).toLocalTime();
|
|
@@ -2448,13 +2456,17 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
while (iterator.hasNext()) {
|
|
|
defaultApplyTime = LocalTime.parse(iterator.next(), dtf);
|
|
|
LocalTime defaultApplyEndTime = defaultApplyTime.plusMinutes(practiceCourseMinutes);
|
|
|
- if (defaultApplyTime.compareTo(leaveStartTime) <= 0
|
|
|
- && defaultApplyEndTime.compareTo(leaveEndTime) >= 0) {
|
|
|
+ if (defaultApplyTime.compareTo(leaveEndTime) <= 0
|
|
|
+ && defaultApplyEndTime.compareTo(leaveStartTime) >= 0) {
|
|
|
iterator.remove();
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
- weekNumApplyTimesMap.put(parse.getDayOfWeek().getValue(), applyTimeStrs);
|
|
|
+ if(!CollectionUtils.isEmpty(applyTimeStrs)){
|
|
|
+ weekNumApplyTimesMap.put(parse.getDayOfWeek().getValue(), applyTimeStrs);
|
|
|
+ }else{
|
|
|
+ weekNumApplyTimesMap.remove(parse.getDayOfWeek().getValue());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2464,6 +2476,9 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
JSONArray teacherWeekDayFreeTimes = teacherFreeTimes.getJSONArray(String.valueOf(weekNum));
|
|
|
if(Objects.nonNull(teacherWeekDayFreeTimes)){
|
|
|
List<String> applyTimeStrs = weekNumApplyTimesMap.get(weekNum);
|
|
|
+ if(CollectionUtils.isEmpty(applyTimeStrs)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
Iterator<String> iterator = applyTimeStrs.iterator();
|
|
|
while (iterator.hasNext()) {
|
|
|
LocalTime enableApplyStartTime=LocalTime.parse(iterator.next(), dtf);
|
|
@@ -2483,7 +2498,11 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
iterator.remove();
|
|
|
}
|
|
|
}
|
|
|
- weekNumApplyTimesMap.put(weekNum,applyTimeStrs);
|
|
|
+ if(CollectionUtils.isEmpty(applyTimeStrs)){
|
|
|
+ weekNumApplyTimeIterator.remove();
|
|
|
+ }else{
|
|
|
+ weekNumApplyTimesMap.put(weekNum,applyTimeStrs);
|
|
|
+ }
|
|
|
}else{
|
|
|
weekNumApplyTimeIterator.remove();
|
|
|
}
|
|
@@ -2496,35 +2515,55 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
|
|
|
int courseWeekNum = 0;
|
|
|
int practiceCourseNum = 0;
|
|
|
- Set<Integer> disableApplyWeek = new HashSet<>();
|
|
|
+ Set<Integer> disableApplyWeekNum = new HashSet<>();
|
|
|
LocalDateTime tempClassDateTime;
|
|
|
for (int i = 0; i < allTeacherCourses.size(); i++) {
|
|
|
CourseSchedule teacherCourse = allTeacherCourses.get(i);
|
|
|
tempClassDateTime = LocalDateTime.ofInstant(teacherCourse.getClassDate().toInstant(), zoneId);
|
|
|
- if (i == 0 && teacherCourse.getGroupType().equals(GroupType.PRACTICE)) {
|
|
|
- practiceCourseNum += 1;
|
|
|
- courseWeekNum = tempClassDateTime.get(weekFields.weekOfYear());
|
|
|
- }
|
|
|
- if (Objects.nonNull(maxTeacherCourses) && practiceCourseNum >= maxTeacherCourses) {
|
|
|
- disableApplyWeek.add(courseWeekNum);
|
|
|
- }
|
|
|
if (tempClassDateTime.get(weekFields.weekOfYear()) != courseWeekNum) {
|
|
|
courseWeekNum = tempClassDateTime.get(weekFields.weekOfYear());
|
|
|
practiceCourseNum = 0;
|
|
|
- }
|
|
|
- if (teacherCourse.getGroupType().equals(GroupType.PRACTICE)) {
|
|
|
+ practiceCourseNum = 1;
|
|
|
+ }else if(teacherCourse.getGroupType().equals(GroupType.PRACTICE)){
|
|
|
practiceCourseNum += 1;
|
|
|
}
|
|
|
+ if (Objects.nonNull(maxTeacherCourses) && practiceCourseNum >= maxTeacherCourses) {
|
|
|
+ disableApplyWeekNum.add(courseWeekNum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(disableApplyWeekNum.size()>2){
|
|
|
+ result.put("teacherFreeDays", new HashMap<>());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ LocalDateTime applyStartDateTime=LocalDateTime.ofInstant(applyStartDate.toInstant(), DateUtil.zoneId);
|
|
|
+ int applyStartDateWeekNum = applyStartDateTime.get(weekFields.weekOfYear());
|
|
|
+ LocalDateTime applyEndDateTime = LocalDateTime.ofInstant(applyEndDate.toInstant(), DateUtil.zoneId);
|
|
|
+ int applyEndDateWeekNum = applyEndDateTime.get(weekFields.weekOfYear());
|
|
|
+
|
|
|
+ if(!CollectionUtils.isEmpty(disableApplyWeekNum)&&!disableApplyWeekNum.contains(applyStartDateWeekNum)&&!disableApplyWeekNum.contains(applyEndDateWeekNum)){
|
|
|
+ result.put("teacherFreeDays", new HashMap<>());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(disableApplyWeekNum.contains(applyStartDateWeekNum)){
|
|
|
+ LocalDateTime applyStartSunDay = applyStartDateTime.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.SUNDAY.getValue());
|
|
|
+ while (applyStartDateTime.compareTo(applyStartSunDay)<=0){
|
|
|
+ weekNumApplyTimesMap.remove(applyStartDateTime.getDayOfWeek().getValue());
|
|
|
+ applyStartDateTime=applyStartDateTime.plusDays(1);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- Iterator<Integer> weekNumApplyTimeIterator2 = weekNumApplyTimesMap.keySet().iterator();
|
|
|
- while (weekNumApplyTimeIterator2.hasNext()) {
|
|
|
- Integer weekNum=weekNumApplyTimeIterator2.next();
|
|
|
- if(disableApplyWeek.contains(weekNum)){
|
|
|
- weekNumApplyTimeIterator2.remove();
|
|
|
+ if(disableApplyWeekNum.contains(applyEndDateWeekNum)){
|
|
|
+ LocalDateTime applyEndMonDay = applyEndDateTime.with(DateUtil.weekFields.dayOfWeek(), DayOfWeek.MONDAY.getValue());
|
|
|
+ while (applyEndMonDay.compareTo(applyEndDateTime)<0){
|
|
|
+ weekNumApplyTimesMap.remove(applyEndMonDay.getDayOfWeek().getValue());
|
|
|
+ applyEndMonDay = applyEndMonDay.plusDays(1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
for (CourseSchedule teacherCourse : allTeacherCourses) {
|
|
|
if(teacherCourse.getEndClassTime().before(applyStartDate)||teacherCourse.getStartClassTime().after(applyEndDate)){
|
|
|
continue;
|