|
@@ -186,7 +186,8 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
calendar.set(Calendar.MINUTE, 0);
|
|
calendar.set(Calendar.MINUTE, 0);
|
|
calendar.set(Calendar.SECOND, 0);
|
|
calendar.set(Calendar.SECOND, 0);
|
|
- List<Integer> includeTeacherIds=new ArrayList<>();
|
|
|
|
|
|
+ List<Integer> firstTeacherIds=new ArrayList<>();
|
|
|
|
+ List<Integer> secondTeacherIds=new ArrayList<>();
|
|
while (calendar.getTime().before(activityEndDate)){
|
|
while (calendar.getTime().before(activityEndDate)){
|
|
calendar.add(Calendar.DATE,1);
|
|
calendar.add(Calendar.DATE,1);
|
|
Date applyStartDay = calendar.getTime();
|
|
Date applyStartDay = calendar.getTime();
|
|
@@ -195,14 +196,18 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
if(applyEndDay.after(activityEndDate)){
|
|
if(applyEndDay.after(activityEndDate)){
|
|
applyEndDay=activityEndDate;
|
|
applyEndDay=activityEndDate;
|
|
}
|
|
}
|
|
|
|
+
|
|
boolean excludeFirstTime=practiceGroup.getFirstCourseTime().before(applyStartDay)||(practiceGroup.getFirstCourseTime().after(applyEndDay)&&!DateUtil.isSameDay(practiceGroup.getFirstCourseTime(),applyEndDay));
|
|
boolean excludeFirstTime=practiceGroup.getFirstCourseTime().before(applyStartDay)||(practiceGroup.getFirstCourseTime().after(applyEndDay)&&!DateUtil.isSameDay(practiceGroup.getFirstCourseTime(),applyEndDay));
|
|
boolean excludeSecondTime=practiceGroup.getSecondCourseTime().before(applyStartDay)||(practiceGroup.getSecondCourseTime().after(applyEndDay)&&!DateUtil.isSameDay(practiceGroup.getFirstCourseTime(),applyEndDay));
|
|
boolean excludeSecondTime=practiceGroup.getSecondCourseTime().before(applyStartDay)||(practiceGroup.getSecondCourseTime().after(applyEndDay)&&!DateUtil.isSameDay(practiceGroup.getFirstCourseTime(),applyEndDay));
|
|
if(excludeFirstTime&&excludeSecondTime){
|
|
if(excludeFirstTime&&excludeSecondTime){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ Date firstMonday=DateUtil.getWeekDayWithDate(applyStartDay,Calendar.MONDAY);
|
|
|
|
+ Date secondMonday=DateUtil.getWeekDayWithDate(applyEndDay,Calendar.MONDAY);
|
|
|
|
+ Date secondSunday=DateUtil.getWeekDayWithDate(applyEndDay,Calendar.SUNDAY);
|
|
|
|
|
|
- List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeachersCoursesWithDateRange(teacherIds, applyStartDay, applyEndDay);
|
|
|
|
|
|
+ List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeachersCoursesWithDateRange(teacherIds, firstMonday, secondSunday);
|
|
|
|
|
|
Date firstClassEndTime = DateUtil.addMinutes(practiceGroup.getFirstCourseTime(), practiceCourseMinutes);
|
|
Date firstClassEndTime = DateUtil.addMinutes(practiceGroup.getFirstCourseTime(), practiceCourseMinutes);
|
|
Date secondClassEndTime = DateUtil.addMinutes(practiceGroup.getSecondCourseTime(), practiceCourseMinutes);
|
|
Date secondClassEndTime = DateUtil.addMinutes(practiceGroup.getSecondCourseTime(), practiceCourseMinutes);
|
|
@@ -211,20 +216,73 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
for (Integer teacherId : teacherIds) {
|
|
for (Integer teacherId : teacherIds) {
|
|
List<CourseSchedule> teacherCourses = teacherCoursesMap.get(teacherId);
|
|
List<CourseSchedule> teacherCourses = teacherCoursesMap.get(teacherId);
|
|
if(CollectionUtils.isEmpty(teacherCourses)){
|
|
if(CollectionUtils.isEmpty(teacherCourses)){
|
|
- includeTeacherIds.add(teacherId);
|
|
|
|
|
|
+ if(!excludeFirstTime){
|
|
|
|
+ firstTeacherIds.add(teacherId);
|
|
|
|
+ }
|
|
|
|
+ if(!excludeSecondTime){
|
|
|
|
+ secondTeacherIds.add(teacherId);
|
|
|
|
+ }
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- Map<GroupType, Long> groupTypeCountMap = teacherCourses.stream().collect(Collectors.groupingBy(CourseSchedule::getGroupType, Collectors.counting()));
|
|
|
|
- if(Objects.nonNull(groupTypeCountMap.get(GroupType.PRACTICE))&&groupTypeCountMap.get(GroupType.PRACTICE)>80){
|
|
|
|
|
|
+ List<CourseSchedule> firstWeekCourses=new ArrayList<>();
|
|
|
|
+ List<CourseSchedule> secondWeekCourses=new ArrayList<>();
|
|
|
|
+ List<CourseSchedule> applyDateRangeCourses=new ArrayList<>();
|
|
|
|
+ for (CourseSchedule teacherCours : teacherCourses) {
|
|
|
|
+ if(teacherCours.getClassDate().before(secondMonday)){
|
|
|
|
+ firstWeekCourses.add(teacherCours);
|
|
|
|
+ }else{
|
|
|
|
+ secondWeekCourses.add(teacherCours);
|
|
|
|
+ }
|
|
|
|
+ if(!teacherCours.getClassDate().before(applyStartDay)
|
|
|
|
+ &&(teacherCours.getClassDate().before(applyEndDay)||DateUtil.isSameDay(teacherCours.getClassDate(),applyEndDay))){
|
|
|
|
+ applyDateRangeCourses.add(teacherCours);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ boolean firstWeekEnableApply=true;
|
|
|
|
+ boolean secondWeekEnableApply=true;
|
|
|
|
+
|
|
|
|
+ if(!CollectionUtils.isEmpty(firstWeekCourses)){
|
|
|
|
+ Map<GroupType, Long> groupTypeCountFirstMap = firstWeekCourses.stream().collect(Collectors.groupingBy(CourseSchedule::getGroupType, Collectors.counting()));
|
|
|
|
+ if(Objects.nonNull(groupTypeCountFirstMap.get(GroupType.PRACTICE))&&groupTypeCountFirstMap.get(GroupType.PRACTICE)>80){
|
|
|
|
+ firstWeekEnableApply=false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!CollectionUtils.isEmpty(firstWeekCourses)){
|
|
|
|
+ Map<GroupType, Long> groupTypeCountSecondMap = secondWeekCourses.stream().collect(Collectors.groupingBy(CourseSchedule::getGroupType, Collectors.counting()));
|
|
|
|
+ if(Objects.nonNull(groupTypeCountSecondMap.get(GroupType.PRACTICE))&&groupTypeCountSecondMap.get(GroupType.PRACTICE)>80){
|
|
|
|
+ secondWeekEnableApply=false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Date enableApplyStartDate=applyStartDay;
|
|
|
|
+ Date enableApplyEndDate=secondSunday;
|
|
|
|
+ if(!firstWeekEnableApply){
|
|
|
|
+ enableApplyStartDate=secondMonday;
|
|
|
|
+ }
|
|
|
|
+ if(!secondWeekEnableApply){
|
|
|
|
+ enableApplyEndDate=secondMonday;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(DateUtil.isSameDay(enableApplyStartDate,enableApplyEndDate)){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
teacherCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
|
|
teacherCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
|
|
boolean enableCreateFirstCourse=true;
|
|
boolean enableCreateFirstCourse=true;
|
|
|
|
+ if(practiceGroup.getFirstCourseTime().before(enableApplyStartDate)
|
|
|
|
+ ||practiceGroup.getFirstCourseTime().after(enableApplyEndDate)){
|
|
|
|
+ enableCreateFirstCourse=false;
|
|
|
|
+ }
|
|
boolean enableCreateSecondCourse=true;
|
|
boolean enableCreateSecondCourse=true;
|
|
- for (int i=0;i<teacherCourses.size()-1;i++) {
|
|
|
|
- CourseSchedule preCourseSchedule = teacherCourses.get(i);
|
|
|
|
|
|
+ if(practiceGroup.getSecondCourseTime().before(enableApplyStartDate)
|
|
|
|
+ ||practiceGroup.getSecondCourseTime().after(enableApplyEndDate)){
|
|
|
|
+ enableCreateSecondCourse=false;
|
|
|
|
+ }
|
|
|
|
+ for (int i=0;i<applyDateRangeCourses.size()-1;i++) {
|
|
|
|
+ CourseSchedule preCourseSchedule = applyDateRangeCourses.get(i);
|
|
|
|
|
|
if(practiceGroup.getFirstCourseTime().before(preCourseSchedule.getEndClassTime())
|
|
if(practiceGroup.getFirstCourseTime().before(preCourseSchedule.getEndClassTime())
|
|
&&firstClassEndTime.after(preCourseSchedule.getStartClassTime())){
|
|
&&firstClassEndTime.after(preCourseSchedule.getStartClassTime())){
|
|
@@ -236,17 +294,27 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
enableCreateSecondCourse=false;
|
|
enableCreateSecondCourse=false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (enableCreateFirstCourse&&enableCreateSecondCourse){
|
|
|
|
- includeTeacherIds.add(teacherId);
|
|
|
|
|
|
+ if (enableCreateFirstCourse){
|
|
|
|
+ firstTeacherIds.add(teacherId);
|
|
|
|
+ }
|
|
|
|
+ if (enableCreateSecondCourse){
|
|
|
|
+ secondTeacherIds.add(teacherId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(!CollectionUtils.isEmpty(includeTeacherIds)){
|
|
|
|
|
|
+ if(!CollectionUtils.isEmpty(firstTeacherIds)&&!CollectionUtils.isEmpty(secondTeacherIds)){
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if(CollectionUtils.isEmpty(firstTeacherIds)||CollectionUtils.isEmpty(secondTeacherIds)){
|
|
|
|
+ throw new BizException("未找到符合条件的教师");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<Integer> includeTeacherIds = firstTeacherIds.stream().filter(firstTeacherId -> secondTeacherIds.contains(firstTeacherId)).collect(Collectors.toList());
|
|
|
|
+
|
|
if(CollectionUtils.isEmpty(includeTeacherIds)){
|
|
if(CollectionUtils.isEmpty(includeTeacherIds)){
|
|
throw new BizException("未找到符合条件的教师");
|
|
throw new BizException("未找到符合条件的教师");
|
|
}
|
|
}
|
|
|
|
+
|
|
List<CourseScheduleTeacherSalary> studentRelateTeachers = courseScheduleTeacherSalaryDao.findStudentRelateTeachers(practiceGroup.getStudentId(), includeTeacherIds);
|
|
List<CourseScheduleTeacherSalary> studentRelateTeachers = courseScheduleTeacherSalaryDao.findStudentRelateTeachers(practiceGroup.getStudentId(), includeTeacherIds);
|
|
Random random=new Random();
|
|
Random random=new Random();
|
|
if(!CollectionUtils.isEmpty(studentRelateTeachers)){
|
|
if(!CollectionUtils.isEmpty(studentRelateTeachers)){
|
|
@@ -300,7 +368,8 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
calendar.set(Calendar.MINUTE, 0);
|
|
calendar.set(Calendar.MINUTE, 0);
|
|
calendar.set(Calendar.SECOND, 0);
|
|
calendar.set(Calendar.SECOND, 0);
|
|
- List<Integer> includeTeacherIds=new ArrayList<>();
|
|
|
|
|
|
+ List<Integer> firstTeacherIds=new ArrayList<>();
|
|
|
|
+ List<Integer> secondTeacherIds=new ArrayList<>();
|
|
while (calendar.getTime().before(activityEndDate)){
|
|
while (calendar.getTime().before(activityEndDate)){
|
|
calendar.add(Calendar.DATE,1);
|
|
calendar.add(Calendar.DATE,1);
|
|
Date applyStartDay = calendar.getTime();
|
|
Date applyStartDay = calendar.getTime();
|
|
@@ -315,7 +384,11 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeachersCoursesWithDateRange(teacherIds, applyStartDay, applyEndDay);
|
|
|
|
|
|
+ Date firstMonday=DateUtil.getWeekDayWithDate(applyStartDay,Calendar.MONDAY);
|
|
|
|
+ Date secondMonday=DateUtil.getWeekDayWithDate(applyEndDay,Calendar.MONDAY);
|
|
|
|
+ Date secondSunday=DateUtil.getWeekDayWithDate(applyEndDay,Calendar.SUNDAY);
|
|
|
|
+
|
|
|
|
+ List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeachersCoursesWithDateRange(teacherIds, firstMonday, secondSunday);
|
|
|
|
|
|
Date firstClassEndTime = DateUtil.addMinutes(practiceGroup.getFirstCourseTime(), practiceCourseMinutes);
|
|
Date firstClassEndTime = DateUtil.addMinutes(practiceGroup.getFirstCourseTime(), practiceCourseMinutes);
|
|
Date secondClassEndTime = DateUtil.addMinutes(practiceGroup.getSecondCourseTime(), practiceCourseMinutes);
|
|
Date secondClassEndTime = DateUtil.addMinutes(practiceGroup.getSecondCourseTime(), practiceCourseMinutes);
|
|
@@ -324,20 +397,74 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
for (Integer teacherId : teacherIds) {
|
|
for (Integer teacherId : teacherIds) {
|
|
List<CourseSchedule> teacherCourses = teacherCoursesMap.get(teacherId);
|
|
List<CourseSchedule> teacherCourses = teacherCoursesMap.get(teacherId);
|
|
if(CollectionUtils.isEmpty(teacherCourses)){
|
|
if(CollectionUtils.isEmpty(teacherCourses)){
|
|
- includeTeacherIds.add(teacherId);
|
|
|
|
|
|
+ if(!excludeFirstTime){
|
|
|
|
+ firstTeacherIds.add(teacherId);
|
|
|
|
+ }
|
|
|
|
+ if(!excludeSecondTime){
|
|
|
|
+ secondTeacherIds.add(teacherId);
|
|
|
|
+ }
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- Map<GroupType, Long> groupTypeCountMap = teacherCourses.stream().collect(Collectors.groupingBy(CourseSchedule::getGroupType, Collectors.counting()));
|
|
|
|
- if(Objects.nonNull(groupTypeCountMap.get(GroupType.PRACTICE))&&groupTypeCountMap.get(GroupType.PRACTICE)>80){
|
|
|
|
|
|
+ List<CourseSchedule> firstWeekCourses=new ArrayList<>();
|
|
|
|
+ List<CourseSchedule> secondWeekCourses=new ArrayList<>();
|
|
|
|
+ List<CourseSchedule> applyDateRangeCourses=new ArrayList<>();
|
|
|
|
+ for (CourseSchedule teacherCours : teacherCourses) {
|
|
|
|
+ if(teacherCours.getClassDate().before(secondMonday)){
|
|
|
|
+ firstWeekCourses.add(teacherCours);
|
|
|
|
+ }else{
|
|
|
|
+ secondWeekCourses.add(teacherCours);
|
|
|
|
+ }
|
|
|
|
+ if(!teacherCours.getClassDate().before(applyStartDay)
|
|
|
|
+ &&(teacherCours.getClassDate().before(applyEndDay)||DateUtil.isSameDay(teacherCours.getClassDate(),applyEndDay))){
|
|
|
|
+ applyDateRangeCourses.add(teacherCours);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ boolean firstWeekEnableApply=true;
|
|
|
|
+ boolean secondWeekEnableApply=true;
|
|
|
|
+
|
|
|
|
+ if(!CollectionUtils.isEmpty(firstWeekCourses)){
|
|
|
|
+ Map<GroupType, Long> groupTypeCountFirstMap = firstWeekCourses.stream().collect(Collectors.groupingBy(CourseSchedule::getGroupType, Collectors.counting()));
|
|
|
|
+ if(Objects.nonNull(groupTypeCountFirstMap.get(GroupType.PRACTICE))&&groupTypeCountFirstMap.get(GroupType.PRACTICE)>80){
|
|
|
|
+ firstWeekEnableApply=false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!CollectionUtils.isEmpty(firstWeekCourses)){
|
|
|
|
+ Map<GroupType, Long> groupTypeCountSecondMap = secondWeekCourses.stream().collect(Collectors.groupingBy(CourseSchedule::getGroupType, Collectors.counting()));
|
|
|
|
+ if(Objects.nonNull(groupTypeCountSecondMap.get(GroupType.PRACTICE))&&groupTypeCountSecondMap.get(GroupType.PRACTICE)>80){
|
|
|
|
+ secondWeekEnableApply=false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Date enableApplyStartDate=applyStartDay;
|
|
|
|
+ Date enableApplyEndDate=secondSunday;
|
|
|
|
+ if(!firstWeekEnableApply){
|
|
|
|
+ enableApplyStartDate=secondMonday;
|
|
|
|
+ }
|
|
|
|
+ if(!secondWeekEnableApply){
|
|
|
|
+ enableApplyEndDate=secondMonday;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(DateUtil.isSameDay(enableApplyStartDate,enableApplyEndDate)){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
teacherCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
|
|
teacherCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
|
|
boolean enableCreateFirstCourse=true;
|
|
boolean enableCreateFirstCourse=true;
|
|
|
|
+ if(practiceGroup.getFirstCourseTime().before(enableApplyStartDate)
|
|
|
|
+ ||practiceGroup.getFirstCourseTime().after(enableApplyEndDate)){
|
|
|
|
+ enableCreateFirstCourse=false;
|
|
|
|
+ }
|
|
boolean enableCreateSecondCourse=true;
|
|
boolean enableCreateSecondCourse=true;
|
|
- for (int i=0;i<teacherCourses.size()-1;i++) {
|
|
|
|
- CourseSchedule preCourseSchedule = teacherCourses.get(i);
|
|
|
|
|
|
+ if(practiceGroup.getSecondCourseTime().before(enableApplyStartDate)
|
|
|
|
+ ||practiceGroup.getSecondCourseTime().after(enableApplyEndDate)){
|
|
|
|
+ enableCreateSecondCourse=false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (int i=0;i<applyDateRangeCourses.size()-1;i++) {
|
|
|
|
+ CourseSchedule preCourseSchedule = applyDateRangeCourses.get(i);
|
|
|
|
|
|
if(practiceGroup.getFirstCourseTime().before(preCourseSchedule.getEndClassTime())
|
|
if(practiceGroup.getFirstCourseTime().before(preCourseSchedule.getEndClassTime())
|
|
&&firstClassEndTime.after(preCourseSchedule.getStartClassTime())){
|
|
&&firstClassEndTime.after(preCourseSchedule.getStartClassTime())){
|
|
@@ -349,17 +476,27 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
enableCreateSecondCourse=false;
|
|
enableCreateSecondCourse=false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (enableCreateFirstCourse&&enableCreateSecondCourse){
|
|
|
|
- includeTeacherIds.add(teacherId);
|
|
|
|
|
|
+ if (enableCreateFirstCourse){
|
|
|
|
+ firstTeacherIds.add(teacherId);
|
|
|
|
+ }
|
|
|
|
+ if (enableCreateSecondCourse){
|
|
|
|
+ secondTeacherIds.add(teacherId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(!CollectionUtils.isEmpty(includeTeacherIds)){
|
|
|
|
|
|
+ if(!CollectionUtils.isEmpty(firstTeacherIds)&&!CollectionUtils.isEmpty(secondTeacherIds)){
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if(CollectionUtils.isEmpty(firstTeacherIds)||CollectionUtils.isEmpty(secondTeacherIds)){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<Integer> includeTeacherIds = firstTeacherIds.stream().filter(firstTeacherId -> secondTeacherIds.contains(firstTeacherId)).collect(Collectors.toList());
|
|
|
|
+
|
|
if(CollectionUtils.isEmpty(includeTeacherIds)){
|
|
if(CollectionUtils.isEmpty(includeTeacherIds)){
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
+
|
|
List<Map<Integer, Integer>> teacherCourseNumMaps = courseScheduleTeacherSalaryDao.countTeacherCourses(includeTeacherIds, GroupType.PRACTICE);
|
|
List<Map<Integer, Integer>> teacherCourseNumMaps = courseScheduleTeacherSalaryDao.countTeacherCourses(includeTeacherIds, GroupType.PRACTICE);
|
|
HashMap<Integer,Integer> teacherCourseNumMap= (HashMap<Integer, Integer>) MapUtil.convertIntegerMap(teacherCourseNumMaps);
|
|
HashMap<Integer,Integer> teacherCourseNumMap= (HashMap<Integer, Integer>) MapUtil.convertIntegerMap(teacherCourseNumMaps);
|
|
for (Integer includeTeacherId : includeTeacherIds) {
|
|
for (Integer includeTeacherId : includeTeacherIds) {
|
|
@@ -455,8 +592,12 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
if(applyEndDay.after(activityEndDate)){
|
|
if(applyEndDay.after(activityEndDate)){
|
|
applyEndDay=activityEndDate;
|
|
applyEndDay=activityEndDate;
|
|
}
|
|
}
|
|
|
|
+ Date firstMonday=DateUtil.getWeekDayWithDate(applyStartDay,Calendar.MONDAY);
|
|
|
|
+ Date secondMonday=DateUtil.getWeekDayWithDate(applyEndDay,Calendar.MONDAY);
|
|
|
|
+ Date secondSunday=DateUtil.getWeekDayWithDate(applyEndDay,Calendar.SUNDAY);
|
|
|
|
+
|
|
List<Date> enableApplyDates = getEnableApplyDates(applyStartDay,applyEndDay);
|
|
List<Date> enableApplyDates = getEnableApplyDates(applyStartDay,applyEndDay);
|
|
- List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeachersCoursesWithDateRange(teacherIds, applyStartDay, applyEndDay);
|
|
|
|
|
|
+ List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeachersCoursesWithDateRange(teacherIds, firstMonday, secondSunday);
|
|
HashSet<Integer> excludeTeacherIds=new HashSet<>();
|
|
HashSet<Integer> excludeTeacherIds=new HashSet<>();
|
|
if(Objects.nonNull(firstClassTime)){
|
|
if(Objects.nonNull(firstClassTime)){
|
|
Date firstClassEndTime = DateUtil.addMinutes(firstClassTime, practiceCourseMinutes);
|
|
Date firstClassEndTime = DateUtil.addMinutes(firstClassTime, practiceCourseMinutes);
|
|
@@ -477,34 +618,82 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
allTeacherFreeDates=new HashSet<>(enableApplyDates);
|
|
allTeacherFreeDates=new HashSet<>(enableApplyDates);
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- Map<GroupType, Long> groupTypeCountMap = teacherCourses.stream().collect(Collectors.groupingBy(CourseSchedule::getGroupType, Collectors.counting()));
|
|
|
|
- if(Objects.nonNull(groupTypeCountMap.get(GroupType.PRACTICE))&&groupTypeCountMap.get(GroupType.PRACTICE)>80){
|
|
|
|
|
|
+
|
|
|
|
+ List<CourseSchedule> firstWeekCourses=new ArrayList<>();
|
|
|
|
+ List<CourseSchedule> secondWeekCourses=new ArrayList<>();
|
|
|
|
+ List<CourseSchedule> applyDateRangeCourses=new ArrayList<>();
|
|
|
|
+ for (CourseSchedule teacherCours : teacherCourses) {
|
|
|
|
+ if(teacherCours.getClassDate().before(secondMonday)){
|
|
|
|
+ firstWeekCourses.add(teacherCours);
|
|
|
|
+ }else{
|
|
|
|
+ secondWeekCourses.add(teacherCours);
|
|
|
|
+ }
|
|
|
|
+ if(!teacherCours.getClassDate().before(applyStartDay)
|
|
|
|
+ &&(teacherCours.getClassDate().before(applyEndDay)||DateUtil.isSameDay(teacherCours.getClassDate(),applyEndDay))){
|
|
|
|
+ applyDateRangeCourses.add(teacherCours);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ boolean firstWeekEnableApply=true;
|
|
|
|
+ boolean secondWeekEnableApply=true;
|
|
|
|
+
|
|
|
|
+ if(!CollectionUtils.isEmpty(firstWeekCourses)){
|
|
|
|
+ Map<GroupType, Long> groupTypeCountFirstMap = firstWeekCourses.stream().collect(Collectors.groupingBy(CourseSchedule::getGroupType, Collectors.counting()));
|
|
|
|
+ if(Objects.nonNull(groupTypeCountFirstMap.get(GroupType.PRACTICE))&&groupTypeCountFirstMap.get(GroupType.PRACTICE)>80){
|
|
|
|
+ firstWeekEnableApply=false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!CollectionUtils.isEmpty(firstWeekCourses)){
|
|
|
|
+ Map<GroupType, Long> groupTypeCountSecondMap = secondWeekCourses.stream().collect(Collectors.groupingBy(CourseSchedule::getGroupType, Collectors.counting()));
|
|
|
|
+ if(Objects.nonNull(groupTypeCountSecondMap.get(GroupType.PRACTICE))&&groupTypeCountSecondMap.get(GroupType.PRACTICE)>80){
|
|
|
|
+ secondWeekEnableApply=false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Date enableApplyStartDate=applyStartDay;
|
|
|
|
+ Date enableApplyEndDate=secondSunday;
|
|
|
|
+ if(!firstWeekEnableApply){
|
|
|
|
+ enableApplyStartDate=secondMonday;
|
|
|
|
+ }
|
|
|
|
+ if(!secondWeekEnableApply){
|
|
|
|
+ enableApplyEndDate=secondMonday;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(DateUtil.isSameDay(enableApplyStartDate,enableApplyEndDate)){
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ List<Date> tempEnableApplyDates=new ArrayList<>();
|
|
|
|
+ for (Date enableApplyDate : enableApplyDates) {
|
|
|
|
+ if(!enableApplyDate.before(enableApplyStartDate)){
|
|
|
|
+ tempEnableApplyDates.add(enableApplyDate);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
teacherCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
|
|
teacherCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
|
|
- for (int j=0;j<teacherCourses.size()-1;j++) {
|
|
|
|
- CourseSchedule preCourseSchedule = teacherCourses.get(j);
|
|
|
|
- CourseSchedule backCourseSchedule = teacherCourses.get(j+1);
|
|
|
|
|
|
+ for (int j=0;j<applyDateRangeCourses.size()-1;j++) {
|
|
|
|
+ CourseSchedule preCourseSchedule = applyDateRangeCourses.get(j);
|
|
|
|
+ CourseSchedule backCourseSchedule = applyDateRangeCourses.get(j+1);
|
|
if(preCourseSchedule.getEndClassTime().after(backCourseSchedule.getEndClassTime())){
|
|
if(preCourseSchedule.getEndClassTime().after(backCourseSchedule.getEndClassTime())){
|
|
backCourseSchedule.setEndClassTime(preCourseSchedule.getEndClassTime());
|
|
backCourseSchedule.setEndClassTime(preCourseSchedule.getEndClassTime());
|
|
}
|
|
}
|
|
if(j==0){
|
|
if(j==0){
|
|
- for (Date enableApplyDate : enableApplyDates) {
|
|
|
|
|
|
+ for (Date enableApplyDate : tempEnableApplyDates) {
|
|
Date enableApplyDateCourseEndTime = DateUtil.addMinutes(enableApplyDate, practiceCourseMinutes);
|
|
Date enableApplyDateCourseEndTime = DateUtil.addMinutes(enableApplyDate, practiceCourseMinutes);
|
|
if(!enableApplyDateCourseEndTime.after(preCourseSchedule.getStartClassTime())){
|
|
if(!enableApplyDateCourseEndTime.after(preCourseSchedule.getStartClassTime())){
|
|
allTeacherFreeDates.add(enableApplyDate);
|
|
allTeacherFreeDates.add(enableApplyDate);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (j==teacherCourses.size()-2){
|
|
|
|
- for (Date enableApplyDate : enableApplyDates) {
|
|
|
|
|
|
+ if (j==applyDateRangeCourses.size()-2){
|
|
|
|
+ for (Date enableApplyDate : tempEnableApplyDates) {
|
|
if(!enableApplyDate.before(backCourseSchedule.getEndClassTime())){
|
|
if(!enableApplyDate.before(backCourseSchedule.getEndClassTime())){
|
|
allTeacherFreeDates.add(enableApplyDate);
|
|
allTeacherFreeDates.add(enableApplyDate);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- for (Date enableApplyDate : enableApplyDates) {
|
|
|
|
|
|
+ for (Date enableApplyDate : tempEnableApplyDates) {
|
|
Date enableApplyDateCourseEndTime = DateUtil.addMinutes(enableApplyDate, practiceCourseMinutes);
|
|
Date enableApplyDateCourseEndTime = DateUtil.addMinutes(enableApplyDate, practiceCourseMinutes);
|
|
if(!enableApplyDate.before(preCourseSchedule.getEndClassTime())
|
|
if(!enableApplyDate.before(preCourseSchedule.getEndClassTime())
|
|
&&!enableApplyDateCourseEndTime.after(backCourseSchedule.getStartClassTime())){
|
|
&&!enableApplyDateCourseEndTime.after(backCourseSchedule.getStartClassTime())){
|