|
@@ -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();
|
|
@@ -2454,7 +2462,11 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
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);
|
|
@@ -2497,7 +2512,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
int courseWeekNum = 0;
|
|
|
int practiceCourseNum = 0;
|
|
|
Set<Integer> disableApplyWeekNum = new HashSet<>();
|
|
|
- Set<Integer> tempDisableApplyWeekNum = new HashSet<>();
|
|
|
LocalDateTime tempClassDateTime;
|
|
|
for (int i = 0; i < allTeacherCourses.size(); i++) {
|
|
|
CourseSchedule teacherCourse = allTeacherCourses.get(i);
|
|
@@ -2506,12 +2520,8 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
practiceCourseNum += 1;
|
|
|
courseWeekNum = tempClassDateTime.get(weekFields.weekOfYear());
|
|
|
}
|
|
|
- if(teacherCourse.getStartClassTime().compareTo(applyStartDate)>=0
|
|
|
- &&teacherCourse.getEndClassTime().compareTo(applyEndDate)<=0){
|
|
|
- tempDisableApplyWeekNum.add(tempClassDateTime.get(weekFields.dayOfWeek()));
|
|
|
- }
|
|
|
if (Objects.nonNull(maxTeacherCourses) && practiceCourseNum >= maxTeacherCourses) {
|
|
|
- disableApplyWeekNum.addAll(tempDisableApplyWeekNum);
|
|
|
+ disableApplyWeekNum.add(courseWeekNum);
|
|
|
}
|
|
|
if (tempClassDateTime.get(weekFields.weekOfYear()) != courseWeekNum) {
|
|
|
courseWeekNum = tempClassDateTime.get(weekFields.weekOfYear());
|
|
@@ -2522,14 +2532,33 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Iterator<Integer> weekNumApplyTimeIterator2 = weekNumApplyTimesMap.keySet().iterator();
|
|
|
- while (weekNumApplyTimeIterator2.hasNext()) {
|
|
|
- Integer weekNum=weekNumApplyTimeIterator2.next();
|
|
|
- if(disableApplyWeekNum.contains(weekNum)){
|
|
|
- weekNumApplyTimeIterator2.remove();
|
|
|
+ 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(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);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ 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;
|