|
@@ -77,13 +77,18 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
private static final Set<Integer> GUANGZHOU_SUBJECTIDS=new HashSet<Integer>(Arrays.asList(new Integer[]{2,4,5,12,13,15,23}));
|
|
|
//广州分部编号
|
|
|
private static final Integer GUANGZHOU_ORGAN_ID=3;
|
|
|
+ //大连分部编号
|
|
|
+ private static final Integer DALIAN_ORGAN_ID=27;
|
|
|
+ //沈阳分部编号
|
|
|
+ private static final Integer SHENYANG_ORGAN_ID=6;
|
|
|
|
|
|
private static Map<Integer,String> subjectSubjectsMap=new HashMap<>();
|
|
|
|
|
|
- private static Date activityStartDate,activityEndDate;
|
|
|
+ private static Date activityStartDate,activityEndDate,applyStartDay;
|
|
|
|
|
|
static{
|
|
|
- activityStartDate=DateUtil.stringToDate("2020-02-01 00:00:00");
|
|
|
+ applyStartDay=DateUtil.stringToDate("2020-02-08 00:00:00");
|
|
|
+ activityStartDate=DateUtil.stringToDate("2020-02-09 00:00:00");
|
|
|
activityEndDate=DateUtil.stringToDate("2020-03-25 00:00:00");
|
|
|
|
|
|
schoolSubjectTeachersMap=new HashMap<>();
|
|
@@ -167,6 +172,8 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
if(Objects.nonNull(teacherId)){
|
|
|
return teacherId;
|
|
|
}
|
|
|
+ }else if(sysUser.getOrganId().equals(DALIAN_ORGAN_ID)){
|
|
|
+ sysUser.setOrganId(SHENYANG_ORGAN_ID);
|
|
|
}
|
|
|
|
|
|
List<TeacherBasicDto> organAndSubjectTeachers = teacherDao.findTeaTeachersByOrganAndSubject(sysUser.getOrganId(), subjectSubjectsMap.get(practiceGroup.getSubjectId()));
|
|
@@ -178,50 +185,142 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
List<Integer> teacherIds = organAndSubjectTeachers.stream().map(TeacherBasicDto::getId).collect(Collectors.toList());
|
|
|
Date now = new Date();
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
+ if(now.before(applyStartDay)){
|
|
|
+ now=applyStartDay;
|
|
|
+ }
|
|
|
calendar.setTime(now);
|
|
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
calendar.set(Calendar.MINUTE, 0);
|
|
|
calendar.set(Calendar.SECOND, 0);
|
|
|
- calendar.add(Calendar.DATE,1);
|
|
|
- Date applyStartDay = calendar.getTime();
|
|
|
- calendar.add(Calendar.DATE,7);
|
|
|
- Date applyEndDay = calendar.getTime();
|
|
|
- List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeachersCoursesWithDateRange(teacherIds, applyStartDay, applyEndDay);
|
|
|
- List<Integer> includeTeacherIds=new ArrayList<>();
|
|
|
-
|
|
|
- Date firstClassEndTime = DateUtil.addMinutes(practiceGroup.getFirstCourseTime(), practiceCourseMinutes);
|
|
|
- Date secondClassEndTime = DateUtil.addMinutes(practiceGroup.getSecondCourseTime(), practiceCourseMinutes);
|
|
|
-
|
|
|
- Map<Integer, List<CourseSchedule>> teacherCoursesMap = allTeacherCourses.stream().collect(Collectors.groupingBy(CourseSchedule::getActualTeacherId));
|
|
|
- for (Integer teacherId : teacherIds) {
|
|
|
- List<CourseSchedule> teacherCourses = teacherCoursesMap.get(teacherId);
|
|
|
- if(CollectionUtils.isEmpty(teacherCourses)){
|
|
|
- includeTeacherIds.add(teacherId);
|
|
|
+ List<Integer> firstTeacherIds=new ArrayList<>();
|
|
|
+ List<Integer> secondTeacherIds=new ArrayList<>();
|
|
|
+ while (calendar.getTime().before(activityEndDate)){
|
|
|
+ calendar.add(Calendar.DATE,1);
|
|
|
+ Date applyStartDay = calendar.getTime();
|
|
|
+ calendar.add(Calendar.DATE,6);
|
|
|
+ Date applyEndDay = calendar.getTime();
|
|
|
+ if(applyEndDay.after(activityEndDate)){
|
|
|
+ applyEndDay=activityEndDate;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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));
|
|
|
+ if(excludeFirstTime&&excludeSecondTime){
|
|
|
continue;
|
|
|
}
|
|
|
- teacherCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
|
|
|
- boolean enableCreateFirstCourse=true;
|
|
|
- boolean enableCreateSecondCourse=true;
|
|
|
- for (int i=0;i<teacherCourses.size()-1;i++) {
|
|
|
- CourseSchedule preCourseSchedule = teacherCourses.get(i);
|
|
|
-
|
|
|
- if(practiceGroup.getFirstCourseTime().before(preCourseSchedule.getEndClassTime())
|
|
|
- &&firstClassEndTime.after(preCourseSchedule.getStartClassTime())){
|
|
|
- enableCreateFirstCourse=false;
|
|
|
+
|
|
|
+ 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 secondClassEndTime = DateUtil.addMinutes(practiceGroup.getSecondCourseTime(), practiceCourseMinutes);
|
|
|
+
|
|
|
+ Map<Integer, List<CourseSchedule>> teacherCoursesMap = allTeacherCourses.stream().collect(Collectors.groupingBy(CourseSchedule::getActualTeacherId));
|
|
|
+ for (Integer teacherId : teacherIds) {
|
|
|
+ List<CourseSchedule> teacherCourses = teacherCoursesMap.get(teacherId);
|
|
|
+ if(CollectionUtils.isEmpty(teacherCourses)){
|
|
|
+ if(!excludeFirstTime){
|
|
|
+ firstTeacherIds.add(teacherId);
|
|
|
+ }
|
|
|
+ if(!excludeSecondTime){
|
|
|
+ secondTeacherIds.add(teacherId);
|
|
|
+ }
|
|
|
+ continue;
|
|
|
}
|
|
|
|
|
|
- if(practiceGroup.getSecondCourseTime().before(preCourseSchedule.getEndClassTime())
|
|
|
- &&secondClassEndTime.after(preCourseSchedule.getStartClassTime())){
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ teacherCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
|
|
|
+ boolean enableCreateFirstCourse=true;
|
|
|
+ if(practiceGroup.getFirstCourseTime().before(enableApplyStartDate)
|
|
|
+ ||practiceGroup.getFirstCourseTime().after(enableApplyEndDate)){
|
|
|
+ enableCreateFirstCourse=false;
|
|
|
+ }
|
|
|
+ boolean enableCreateSecondCourse=true;
|
|
|
+ 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())
|
|
|
+ &&firstClassEndTime.after(preCourseSchedule.getStartClassTime())){
|
|
|
+ enableCreateFirstCourse=false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(practiceGroup.getSecondCourseTime().before(preCourseSchedule.getEndClassTime())
|
|
|
+ &&secondClassEndTime.after(preCourseSchedule.getStartClassTime())){
|
|
|
+ enableCreateSecondCourse=false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (enableCreateFirstCourse){
|
|
|
+ firstTeacherIds.add(teacherId);
|
|
|
+ }
|
|
|
+ if (enableCreateSecondCourse){
|
|
|
+ secondTeacherIds.add(teacherId);
|
|
|
+ }
|
|
|
}
|
|
|
- if (enableCreateFirstCourse&&enableCreateSecondCourse){
|
|
|
- includeTeacherIds.add(teacherId);
|
|
|
+ if(!CollectionUtils.isEmpty(firstTeacherIds)&&!CollectionUtils.isEmpty(secondTeacherIds)){
|
|
|
+ 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)){
|
|
|
throw new BizException("未找到符合条件的教师");
|
|
|
}
|
|
|
+
|
|
|
List<CourseScheduleTeacherSalary> studentRelateTeachers = courseScheduleTeacherSalaryDao.findStudentRelateTeachers(practiceGroup.getStudentId(), includeTeacherIds);
|
|
|
Random random=new Random();
|
|
|
if(!CollectionUtils.isEmpty(studentRelateTeachers)){
|
|
@@ -267,51 +366,143 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
Integer practiceCourseMinutes=practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
Date now = new Date();
|
|
|
+ if(now.before(applyStartDay)){
|
|
|
+ now=applyStartDay;
|
|
|
+ }
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.setTime(now);
|
|
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
calendar.set(Calendar.MINUTE, 0);
|
|
|
calendar.set(Calendar.SECOND, 0);
|
|
|
- calendar.add(Calendar.DATE,1);
|
|
|
- Date applyStartDay = calendar.getTime();
|
|
|
- calendar.add(Calendar.DATE,7);
|
|
|
- Date applyEndDay = calendar.getTime();
|
|
|
- List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeachersCoursesWithDateRange(teacherIds, applyStartDay, applyEndDay);
|
|
|
- List<Integer> includeTeacherIds=new ArrayList<>();
|
|
|
-
|
|
|
- Date firstClassEndTime = DateUtil.addMinutes(practiceGroup.getFirstCourseTime(), practiceCourseMinutes);
|
|
|
- Date secondClassEndTime = DateUtil.addMinutes(practiceGroup.getSecondCourseTime(), practiceCourseMinutes);
|
|
|
-
|
|
|
- Map<Integer, List<CourseSchedule>> teacherCoursesMap = allTeacherCourses.stream().collect(Collectors.groupingBy(CourseSchedule::getActualTeacherId));
|
|
|
- for (Integer teacherId : teacherIds) {
|
|
|
- List<CourseSchedule> teacherCourses = teacherCoursesMap.get(teacherId);
|
|
|
- if(CollectionUtils.isEmpty(teacherCourses)){
|
|
|
- includeTeacherIds.add(teacherId);
|
|
|
+ List<Integer> firstTeacherIds=new ArrayList<>();
|
|
|
+ List<Integer> secondTeacherIds=new ArrayList<>();
|
|
|
+ while (calendar.getTime().before(activityEndDate)){
|
|
|
+ calendar.add(Calendar.DATE,1);
|
|
|
+ Date applyStartDay = calendar.getTime();
|
|
|
+ calendar.add(Calendar.DATE,6);
|
|
|
+ Date applyEndDay = calendar.getTime();
|
|
|
+ if(applyEndDay.after(activityEndDate)){
|
|
|
+ applyEndDay=activityEndDate;
|
|
|
+ }
|
|
|
+ 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));
|
|
|
+ if(excludeFirstTime&&excludeSecondTime){
|
|
|
continue;
|
|
|
}
|
|
|
- teacherCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
|
|
|
- boolean enableCreateFirstCourse=true;
|
|
|
- boolean enableCreateSecondCourse=true;
|
|
|
- for (int i=0;i<teacherCourses.size()-1;i++) {
|
|
|
- CourseSchedule preCourseSchedule = teacherCourses.get(i);
|
|
|
-
|
|
|
- if(practiceGroup.getFirstCourseTime().before(preCourseSchedule.getEndClassTime())
|
|
|
- &&firstClassEndTime.after(preCourseSchedule.getStartClassTime())){
|
|
|
- enableCreateFirstCourse=false;
|
|
|
+
|
|
|
+ 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 secondClassEndTime = DateUtil.addMinutes(practiceGroup.getSecondCourseTime(), practiceCourseMinutes);
|
|
|
+
|
|
|
+ Map<Integer, List<CourseSchedule>> teacherCoursesMap = allTeacherCourses.stream().collect(Collectors.groupingBy(CourseSchedule::getActualTeacherId));
|
|
|
+ for (Integer teacherId : teacherIds) {
|
|
|
+ List<CourseSchedule> teacherCourses = teacherCoursesMap.get(teacherId);
|
|
|
+ if(CollectionUtils.isEmpty(teacherCourses)){
|
|
|
+ if(!excludeFirstTime){
|
|
|
+ firstTeacherIds.add(teacherId);
|
|
|
+ }
|
|
|
+ if(!excludeSecondTime){
|
|
|
+ secondTeacherIds.add(teacherId);
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ 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(practiceGroup.getSecondCourseTime().before(preCourseSchedule.getEndClassTime())
|
|
|
- &&secondClassEndTime.after(preCourseSchedule.getStartClassTime())){
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ teacherCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
|
|
|
+ boolean enableCreateFirstCourse=true;
|
|
|
+ if(practiceGroup.getFirstCourseTime().before(enableApplyStartDate)
|
|
|
+ ||practiceGroup.getFirstCourseTime().after(enableApplyEndDate)){
|
|
|
+ enableCreateFirstCourse=false;
|
|
|
+ }
|
|
|
+ boolean enableCreateSecondCourse=true;
|
|
|
+ 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())
|
|
|
+ &&firstClassEndTime.after(preCourseSchedule.getStartClassTime())){
|
|
|
+ enableCreateFirstCourse=false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(practiceGroup.getSecondCourseTime().before(preCourseSchedule.getEndClassTime())
|
|
|
+ &&secondClassEndTime.after(preCourseSchedule.getStartClassTime())){
|
|
|
+ enableCreateSecondCourse=false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (enableCreateFirstCourse){
|
|
|
+ firstTeacherIds.add(teacherId);
|
|
|
+ }
|
|
|
+ if (enableCreateSecondCourse){
|
|
|
+ secondTeacherIds.add(teacherId);
|
|
|
+ }
|
|
|
}
|
|
|
- if (enableCreateFirstCourse&&enableCreateSecondCourse){
|
|
|
- includeTeacherIds.add(teacherId);
|
|
|
+ if(!CollectionUtils.isEmpty(firstTeacherIds)&&!CollectionUtils.isEmpty(secondTeacherIds)){
|
|
|
+ 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)){
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
List<Map<Integer, Integer>> teacherCourseNumMaps = courseScheduleTeacherSalaryDao.countTeacherCourses(includeTeacherIds, GroupType.PRACTICE);
|
|
|
HashMap<Integer,Integer> teacherCourseNumMap= (HashMap<Integer, Integer>) MapUtil.convertIntegerMap(teacherCourseNumMaps);
|
|
|
for (Integer includeTeacherId : includeTeacherIds) {
|
|
@@ -343,12 +534,16 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
}else{
|
|
|
userDefaultSubjectIds=new ArrayList<>();
|
|
|
}
|
|
|
+
|
|
|
+ Integer applyTimes = practiceGroupDao.countUserPracticeApplyRecord(userId);
|
|
|
+
|
|
|
result.put("subjects", subjects);
|
|
|
result.put("practiceApplyStartTime", practiceApplyStartTimeConfig.getParanValue());
|
|
|
result.put("practiceApplyEndTime", practiceApplyEndTimeConfig.getParanValue());
|
|
|
result.put("userDefaultSubjectIds", StringUtils.join(userDefaultSubjectIds.toArray(),","));
|
|
|
result.put("practiceApplyIntervalMinutes", practiceApplyIntervalTimeConfig.getParanValue(Integer.class));
|
|
|
result.put("practiceCourseMinutes", practiceCourseMinutesConfig.getParanValue(Integer.class));
|
|
|
+ result.put("enableApply", applyTimes < 1 ? 1 : 0);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -365,32 +560,57 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
throw new BizException("未找到用户分部属性");
|
|
|
}
|
|
|
Map result = new HashMap();
|
|
|
- List<TeacherBasicDto> organAndSubjectTeachers = teacherDao.findTeaTeachersByOrganAndSubject(sysUser.getOrganId(), subjectSubjectsMap.get(subjectId));
|
|
|
- if (CollectionUtils.isEmpty(organAndSubjectTeachers)) {
|
|
|
- result.put("teacherFreeDates",new ArrayList<>());
|
|
|
- return result;
|
|
|
- }
|
|
|
Set<Date> allTeacherFreeDates=new HashSet<>();
|
|
|
SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
Integer practiceCourseMinutes=practiceCourseMinutesConfig.getParanValue(Integer.class);
|
|
|
- List<Integer> teacherIds = organAndSubjectTeachers.stream().map(TeacherBasicDto::getId).collect(Collectors.toList());
|
|
|
+ List<Integer> teacherIds=new ArrayList<>();
|
|
|
+
|
|
|
+ //如果是广州分部的,并且声部满足条件的需要特殊处理
|
|
|
+ if(sysUser.getOrganId().equals(GUANGZHOU_ORGAN_ID)&&GUANGZHOU_SUBJECTIDS.contains(subjectId)){
|
|
|
+ List<MusicGroup> userMusicGroups=musicGroupDao.findUserMusicGroups(userId);
|
|
|
+ if(!CollectionUtils.isEmpty(userMusicGroups)){
|
|
|
+ Collections.shuffle(userMusicGroups);
|
|
|
+ Integer schoolId = userMusicGroups.get(0).getSchoolId();
|
|
|
+ if(schoolSubjectTeachersMap.containsKey(schoolId)){
|
|
|
+ teacherIds = schoolSubjectTeachersMap.get(schoolId).get(subjectId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(sysUser.getOrganId().equals(DALIAN_ORGAN_ID)){
|
|
|
+ sysUser.setOrganId(SHENYANG_ORGAN_ID);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CollectionUtils.isEmpty(teacherIds)){
|
|
|
+ List<TeacherBasicDto> organAndSubjectTeachers = teacherDao.findTeaTeachersByOrganAndSubject(sysUser.getOrganId(), subjectSubjectsMap.get(subjectId));
|
|
|
+ if (CollectionUtils.isEmpty(organAndSubjectTeachers)) {
|
|
|
+ result.put("teacherFreeDates",new ArrayList<>());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ teacherIds = organAndSubjectTeachers.stream().map(TeacherBasicDto::getId).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
Date now = new Date();
|
|
|
+ if(now.before(applyStartDay)){
|
|
|
+ now=applyStartDay;
|
|
|
+ }
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.setTime(now);
|
|
|
- findTeacherFreeTimes:
|
|
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
calendar.set(Calendar.MINUTE, 0);
|
|
|
calendar.set(Calendar.SECOND, 0);
|
|
|
while (calendar.getTime().before(activityEndDate)){
|
|
|
calendar.add(Calendar.DATE,1);
|
|
|
Date applyStartDay = calendar.getTime();
|
|
|
- calendar.add(Calendar.DATE,7);
|
|
|
+ calendar.add(Calendar.DATE,6);
|
|
|
Date applyEndDay = calendar.getTime();
|
|
|
if(applyEndDay.after(activityEndDate)){
|
|
|
applyEndDay=activityEndDate;
|
|
|
}
|
|
|
- List<Date> enableApplyDates = getEnableApplyDates(7);
|
|
|
- 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<Date> enableApplyDates = getEnableApplyDates(applyStartDay,applyEndDay);
|
|
|
+ List<CourseSchedule> allTeacherCourses = courseScheduleDao.findTeachersCoursesWithDateRange(teacherIds, firstMonday, secondSunday);
|
|
|
HashSet<Integer> excludeTeacherIds=new HashSet<>();
|
|
|
if(Objects.nonNull(firstClassTime)){
|
|
|
Date firstClassEndTime = DateUtil.addMinutes(firstClassTime, practiceCourseMinutes);
|
|
@@ -411,26 +631,96 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
allTeacherFreeDates=new HashSet<>(enableApplyDates);
|
|
|
break;
|
|
|
}
|
|
|
- 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);
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Date> tempEnableApplyDates=new ArrayList<>();
|
|
|
+ for (Date enableApplyDate : enableApplyDates) {
|
|
|
+ if(!enableApplyDate.before(enableApplyStartDate)){
|
|
|
+ tempEnableApplyDates.add(enableApplyDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CollectionUtils.isEmpty(applyDateRangeCourses)){
|
|
|
+ allTeacherFreeDates=new HashSet<>(tempEnableApplyDates);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ applyDateRangeCourses.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
|
|
|
+ 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())){
|
|
|
+ backCourseSchedule.setEndClassTime(preCourseSchedule.getEndClassTime());
|
|
|
+ }
|
|
|
if(j==0){
|
|
|
- for (Date enableApplyDate : enableApplyDates) {
|
|
|
+ for (Date enableApplyDate : tempEnableApplyDates) {
|
|
|
+ if(Objects.nonNull(firstClassTime)&&DateUtil.isSameDay(enableApplyDate,firstClassTime)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
Date enableApplyDateCourseEndTime = DateUtil.addMinutes(enableApplyDate, practiceCourseMinutes);
|
|
|
if(!enableApplyDateCourseEndTime.after(preCourseSchedule.getStartClassTime())){
|
|
|
allTeacherFreeDates.add(enableApplyDate);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (j==teacherCourses.size()-1){
|
|
|
- for (Date enableApplyDate : enableApplyDates) {
|
|
|
+ if (j==applyDateRangeCourses.size()-2){
|
|
|
+ for (Date enableApplyDate : tempEnableApplyDates) {
|
|
|
+ if(Objects.nonNull(firstClassTime)&&DateUtil.isSameDay(enableApplyDate,firstClassTime)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
if(!enableApplyDate.before(backCourseSchedule.getEndClassTime())){
|
|
|
allTeacherFreeDates.add(enableApplyDate);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- for (Date enableApplyDate : enableApplyDates) {
|
|
|
+ for (Date enableApplyDate : tempEnableApplyDates) {
|
|
|
+ if(Objects.nonNull(firstClassTime)&&DateUtil.isSameDay(enableApplyDate,firstClassTime)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
Date enableApplyDateCourseEndTime = DateUtil.addMinutes(enableApplyDate, practiceCourseMinutes);
|
|
|
if(!enableApplyDate.before(preCourseSchedule.getEndClassTime())
|
|
|
&&!enableApplyDateCourseEndTime.after(backCourseSchedule.getStartClassTime())){
|
|
@@ -447,17 +737,18 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
Set<String> days = allTeacherFreeDates.stream()
|
|
|
.map(date -> DateUtil.dateToString(date,"yyyy-MM-dd")).collect(Collectors.toSet());
|
|
|
result.put("teacherFreeDays",days);
|
|
|
+ allTeacherFreeDates=allTeacherFreeDates.stream().sorted().collect(Collectors.toSet());
|
|
|
result.put("teacherFreeDates",allTeacherFreeDates);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Date> getEnableApplyDates(Integer days) {
|
|
|
+ public List<Date> getEnableApplyDates(Date startDay,Date endDay) {
|
|
|
List<Date> result=new ArrayList<>();
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
- Date now = new Date();
|
|
|
- calendar.setTime(now);
|
|
|
+ calendar.setTime(startDay);
|
|
|
+ calendar.add(Calendar.DATE, -1);
|
|
|
calendar.set(Calendar.SECOND, 0);
|
|
|
SysConfig practiceApplyStartTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_START_TIME);
|
|
|
SysConfig practiceApplyEndTimeConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_APPLY_END_TIME);
|
|
@@ -465,7 +756,7 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
String enableStartTimeStr = practiceApplyStartTimeConfig.getParanValue();
|
|
|
String enableEndTimeStr = practiceApplyEndTimeConfig.getParanValue();
|
|
|
Integer practiceApplyIntervalMinutes=practiceApplyIntervalTimeConfig.getParanValue(Integer.class);
|
|
|
- for (int i = 0; i < days; i++) {
|
|
|
+ while (!calendar.getTime().after(endDay)) {
|
|
|
calendar.add(Calendar.DATE, 1);
|
|
|
calendar.set(Calendar.HOUR_OF_DAY, Integer.valueOf(enableStartTimeStr.split(":")[0]));
|
|
|
calendar.set(Calendar.MINUTE, Integer.valueOf(enableStartTimeStr.split(":")[1]));
|
|
@@ -490,6 +781,10 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Map practiceApply(PracticeGroup practiceGroup) {
|
|
|
+ SysConfig practiceSubjectIdListConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_SUBJECT_ID_LIST);
|
|
|
+ if(!Arrays.asList(practiceSubjectIdListConfig.getParanValue().split(",")).contains(practiceGroup.getSubjectId().toString())){
|
|
|
+ throw new BizException("此声部不可预约");
|
|
|
+ }
|
|
|
Integer practiceCourseMinutes = 25;
|
|
|
SysConfig practiceCourseMinutesConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_MINUTES);
|
|
|
if (Objects.nonNull(practiceCourseMinutesConfig)) {
|
|
@@ -497,15 +792,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
}
|
|
|
SysConfig practiceCourseSalaryConfig = sysConfigService.findByParamName(SysConfigService.PRACTICE_COURSE_SALARY);
|
|
|
Date now = new Date();
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.setTime(now);
|
|
|
- calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
- calendar.set(Calendar.MINUTE, 0);
|
|
|
- calendar.set(Calendar.SECOND, 0);
|
|
|
- calendar.add(Calendar.DATE,1);
|
|
|
- Date applyStartDay = calendar.getTime();
|
|
|
- calendar.add(Calendar.DATE,8);
|
|
|
- Date applyEndDay = calendar.getTime();
|
|
|
if (practiceGroup.getFirstCourseTime().before(activityStartDate)
|
|
|
||practiceGroup.getFirstCourseTime().after(activityEndDate)) {
|
|
|
throw new BizException("预约时间超过范围");
|
|
@@ -514,6 +800,9 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
||practiceGroup.getSecondCourseTime().after(activityEndDate)) {
|
|
|
throw new BizException("预约时间超过范围");
|
|
|
}
|
|
|
+ if(DateUtil.isSameDay(practiceGroup.getFirstCourseTime(),practiceGroup.getSecondCourseTime())){
|
|
|
+ throw new BizException("两节课不可以在同一天");
|
|
|
+ }
|
|
|
|
|
|
List<Date> allCourseDates=new ArrayList<>();
|
|
|
allCourseDates.add(practiceGroup.getFirstCourseTime());
|