|  | @@ -523,7 +523,185 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	private String courseCheckInfo(CourseSchedule preCourseSchedule,CourseSchedule backCourseSchedule,List<Long> existCourseScheduleIds,Integer type){
 | 
	
		
			
				|  |  | +	@Override
 | 
	
		
			
				|  |  | +	public List<Long> checkSnapCourseShchedules(List<CourseSchedule> courseSchedules) {
 | 
	
		
			
				|  |  | +		List<Long> courseScheduleIds = new ArrayList<>();
 | 
	
		
			
				|  |  | +		if(CollectionUtils.isEmpty(courseSchedules)){
 | 
	
		
			
				|  |  | +			return courseScheduleIds;
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		//第一节课
 | 
	
		
			
				|  |  | +		CourseSchedule firstCourseSchedule;
 | 
	
		
			
				|  |  | +		//最后一节课
 | 
	
		
			
				|  |  | +		CourseSchedule latestCourseSchedule;
 | 
	
		
			
				|  |  | +		if(courseSchedules.size()==1){
 | 
	
		
			
				|  |  | +			firstCourseSchedule = courseSchedules.get(0);
 | 
	
		
			
				|  |  | +			latestCourseSchedule = courseSchedules.get(0);
 | 
	
		
			
				|  |  | +		}else{
 | 
	
		
			
				|  |  | +			firstCourseSchedule = courseSchedules.stream().min(Comparator.comparing(CourseSchedule::getStartClassTime)).get();
 | 
	
		
			
				|  |  | +			latestCourseSchedule = courseSchedules.stream().max(Comparator.comparing(CourseSchedule::getEndClassTime)).get();
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		//获取第一节课和最后一节课所包含的时间段内已存在的课程
 | 
	
		
			
				|  |  | +		List<CourseSchedule> existCourseSchedules = courseScheduleDao
 | 
	
		
			
				|  |  | +				.findAllCourseByDateZone(firstCourseSchedule.getStartClassTime(), latestCourseSchedule.getEndClassTime());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		//只需要调整课程信息的课程编号列表
 | 
	
		
			
				|  |  | +		List<Long> updateCourseScheduleIds = courseSchedules
 | 
	
		
			
				|  |  | +				.stream()
 | 
	
		
			
				|  |  | +				.filter(courseSchedule -> Objects.nonNull(courseSchedule.getId()))
 | 
	
		
			
				|  |  | +				.map(CourseSchedule::getId)
 | 
	
		
			
				|  |  | +				.collect(Collectors.toList());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		//排除只需调整的课程
 | 
	
		
			
				|  |  | +		existCourseSchedules=existCourseSchedules.stream()
 | 
	
		
			
				|  |  | +				.filter(courseSchedule -> !updateCourseScheduleIds.contains(courseSchedule.getId()))
 | 
	
		
			
				|  |  | +				.collect(Collectors.toList());
 | 
	
		
			
				|  |  | +		//新课程对应的班级编号列表
 | 
	
		
			
				|  |  | +		List<Integer> newCourseScheduleClassGroupIds = courseSchedules
 | 
	
		
			
				|  |  | +				.stream()
 | 
	
		
			
				|  |  | +				.map(CourseSchedule::getClassGroupId)
 | 
	
		
			
				|  |  | +				.distinct()
 | 
	
		
			
				|  |  | +				.collect(Collectors.toList());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		List<Long> existCourseScheduleIds = existCourseSchedules.stream()
 | 
	
		
			
				|  |  | +				.map(CourseSchedule::getId)
 | 
	
		
			
				|  |  | +				.collect(Collectors.toList());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		//合并新课程和已存在的课程
 | 
	
		
			
				|  |  | +		List<CourseSchedule> allCourseSchedules;
 | 
	
		
			
				|  |  | +		if(!CollectionUtils.isEmpty(existCourseSchedules)){
 | 
	
		
			
				|  |  | +			allCourseSchedules = ListUtils.sum(courseSchedules, existCourseSchedules);
 | 
	
		
			
				|  |  | +		}else{
 | 
	
		
			
				|  |  | +			allCourseSchedules = courseSchedules;
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		//所有课程的班级编号
 | 
	
		
			
				|  |  | +		List<Integer> classGroupIds = allCourseSchedules
 | 
	
		
			
				|  |  | +				.stream()
 | 
	
		
			
				|  |  | +				.map(CourseSchedule::getClassGroupId)
 | 
	
		
			
				|  |  | +				.distinct()
 | 
	
		
			
				|  |  | +				.collect(Collectors.toList());
 | 
	
		
			
				|  |  | +		//班级与学生的关联记录
 | 
	
		
			
				|  |  | +		List<ClassGroupStudentMapper> classGroupStudentMappers = classGroupStudentMapperDao.findByClassGroups(classGroupIds);
 | 
	
		
			
				|  |  | +		Map<Integer, List<ClassGroupStudentMapper>> classGroupStudentsMap = classGroupStudentMappers
 | 
	
		
			
				|  |  | +				.stream()
 | 
	
		
			
				|  |  | +				.collect(Collectors.groupingBy(ClassGroupStudentMapper::getClassGroupId));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		//根据课程获取教师id关联集合
 | 
	
		
			
				|  |  | +		List<IntegerAndIntegerListDto> courseScheduleTeachingTeacherIdList = new ArrayList<>();
 | 
	
		
			
				|  |  | +		if(!CollectionUtils.isEmpty(existCourseScheduleIds)){
 | 
	
		
			
				|  |  | +			courseScheduleTeachingTeacherIdList = courseScheduleDao.findCourseScheduleIdAndUserIdsMap(existCourseScheduleIds, null);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		Map<Integer, IntegerAndIntegerListDto> courseScheduleTeacherMap = courseScheduleTeachingTeacherIdList.stream()
 | 
	
		
			
				|  |  | +				.collect(Collectors.toMap(IntegerAndIntegerListDto::getId, integerAndIntegerListDto -> integerAndIntegerListDto));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		//将课程计划按照开课时间排序
 | 
	
		
			
				|  |  | +		allCourseSchedules.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
 | 
	
		
			
				|  |  | +		if(allCourseSchedules.size()>1){
 | 
	
		
			
				|  |  | +			//记录连续冲突的次数
 | 
	
		
			
				|  |  | +			Integer repeatTimes=1;
 | 
	
		
			
				|  |  | +			for (int i=1;i<allCourseSchedules.size();i++){
 | 
	
		
			
				|  |  | +				for(int j=1;j<=repeatTimes;j++){
 | 
	
		
			
				|  |  | +					//当前课程
 | 
	
		
			
				|  |  | +					CourseSchedule preCourseSchedule = allCourseSchedules.get(i-j);
 | 
	
		
			
				|  |  | +					//后面一节课程
 | 
	
		
			
				|  |  | +					CourseSchedule backCourseSchedule = allCourseSchedules.get(i);
 | 
	
		
			
				|  |  | +					//判断前后两节课是否存在冲突
 | 
	
		
			
				|  |  | +					if(preCourseSchedule.getEndClassTime().before(backCourseSchedule.getStartClassTime())){
 | 
	
		
			
				|  |  | +						repeatTimes=j;
 | 
	
		
			
				|  |  | +						continue;
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +					repeatTimes+=1;
 | 
	
		
			
				|  |  | +					if(existCourseScheduleIds.contains(preCourseSchedule.getId())
 | 
	
		
			
				|  |  | +							&&existCourseScheduleIds.contains(backCourseSchedule.getId())){
 | 
	
		
			
				|  |  | +						if(j==repeatTimes){
 | 
	
		
			
				|  |  | +							repeatTimes+=1;
 | 
	
		
			
				|  |  | +						}
 | 
	
		
			
				|  |  | +						continue;
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +					//教师冲突检测
 | 
	
		
			
				|  |  | +					if(Objects.isNull(preCourseSchedule.getId())){
 | 
	
		
			
				|  |  | +						IntegerAndIntegerListDto integerAndIntegerListDto = courseScheduleTeacherMap.get(preCourseSchedule.getId());
 | 
	
		
			
				|  |  | +						if(Objects.nonNull(integerAndIntegerListDto)){
 | 
	
		
			
				|  |  | +							preCourseSchedule.setTeachingTeacherIdList(integerAndIntegerListDto.getIds());
 | 
	
		
			
				|  |  | +						}
 | 
	
		
			
				|  |  | +					}else if(existCourseScheduleIds.contains(preCourseSchedule.getId())){
 | 
	
		
			
				|  |  | +						IntegerAndIntegerListDto integerAndIntegerListDto = courseScheduleTeacherMap.get(preCourseSchedule.getId());
 | 
	
		
			
				|  |  | +						if(Objects.nonNull(integerAndIntegerListDto)){
 | 
	
		
			
				|  |  | +							preCourseSchedule.setTeachingTeacherIdList(integerAndIntegerListDto.getIds());
 | 
	
		
			
				|  |  | +						}
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +					if(Objects.isNull(backCourseSchedule.getId())){
 | 
	
		
			
				|  |  | +						IntegerAndIntegerListDto integerAndIntegerListDto = courseScheduleTeacherMap.get(backCourseSchedule.getId());
 | 
	
		
			
				|  |  | +						if(Objects.nonNull(integerAndIntegerListDto)){
 | 
	
		
			
				|  |  | +							backCourseSchedule.setTeachingTeacherIdList(integerAndIntegerListDto.getIds());
 | 
	
		
			
				|  |  | +						}
 | 
	
		
			
				|  |  | +					}else if(existCourseScheduleIds.contains(backCourseSchedule.getId())){
 | 
	
		
			
				|  |  | +						IntegerAndIntegerListDto integerAndIntegerListDto = courseScheduleTeacherMap.get(backCourseSchedule.getId());
 | 
	
		
			
				|  |  | +						if(Objects.nonNull(integerAndIntegerListDto)){
 | 
	
		
			
				|  |  | +							backCourseSchedule.setTeachingTeacherIdList(integerAndIntegerListDto.getIds());
 | 
	
		
			
				|  |  | +						}
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +					boolean isRepeat = false;
 | 
	
		
			
				|  |  | +					if(!CollectionUtils.isEmpty(preCourseSchedule.getTeachingTeacherIdList())
 | 
	
		
			
				|  |  | +							&&!CollectionUtils.isEmpty(backCourseSchedule.getTeachingTeacherIdList())){
 | 
	
		
			
				|  |  | +						List<Integer> repeatIds = preCourseSchedule.getTeachingTeacherIdList()
 | 
	
		
			
				|  |  | +								.stream().filter(backCourseSchedule.getTeachingTeacherIdList()::contains)
 | 
	
		
			
				|  |  | +								.collect(Collectors.toList());
 | 
	
		
			
				|  |  | +						if(!CollectionUtils.isEmpty(repeatIds)){
 | 
	
		
			
				|  |  | +							isRepeat = true;
 | 
	
		
			
				|  |  | +						}
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +					//学生冲突检测
 | 
	
		
			
				|  |  | +					if(preCourseSchedule.getClassGroupId().equals(backCourseSchedule.getClassGroupId())){
 | 
	
		
			
				|  |  | +						//如果班级相同,则学生肯定存在冲突
 | 
	
		
			
				|  |  | +						isRepeat = true;
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +					//如果班级不同,则需要检测两个班级是否存在重复的学生
 | 
	
		
			
				|  |  | +					List<ClassGroupStudentMapper> preClassGroupStudents=classGroupStudentsMap.get(preCourseSchedule.getClassGroupId());
 | 
	
		
			
				|  |  | +					List<ClassGroupStudentMapper> backClassGroupStudents=classGroupStudentsMap.get(backCourseSchedule.getClassGroupId());
 | 
	
		
			
				|  |  | +					//当前课程所在班级的学生编号列表
 | 
	
		
			
				|  |  | +					List<Integer> preClassGroupStudentIds = preClassGroupStudents.stream()
 | 
	
		
			
				|  |  | +							.map(ClassGroupStudentMapper::getUserId)
 | 
	
		
			
				|  |  | +							.collect(Collectors.toList());
 | 
	
		
			
				|  |  | +					//后面一节课程所在班级的学生编号列表
 | 
	
		
			
				|  |  | +					List<Integer> backClassGroupStudentIds = backClassGroupStudents.stream()
 | 
	
		
			
				|  |  | +							.map(ClassGroupStudentMapper::getUserId)
 | 
	
		
			
				|  |  | +							.collect(Collectors.toList());
 | 
	
		
			
				|  |  | +					List<Integer> repeatStudentIds = preClassGroupStudentIds.stream()
 | 
	
		
			
				|  |  | +							.filter(backClassGroupStudentIds::contains)
 | 
	
		
			
				|  |  | +							.collect(Collectors.toList());
 | 
	
		
			
				|  |  | +					if(!CollectionUtils.isEmpty(repeatStudentIds)){
 | 
	
		
			
				|  |  | +						isRepeat = true;
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +					if(isRepeat){
 | 
	
		
			
				|  |  | +						if(preCourseSchedule.getClassGroupType().equals(ClassGroupTypeEnum.SNAP.getCode())
 | 
	
		
			
				|  |  | +								&&backCourseSchedule.getClassGroupType().equals(ClassGroupTypeEnum.SNAP.getCode())){
 | 
	
		
			
				|  |  | +							throw new BizException("教师冲突");
 | 
	
		
			
				|  |  | +						}else if(preCourseSchedule.getClassGroupType().equals(ClassGroupTypeEnum.SNAP.getCode())
 | 
	
		
			
				|  |  | +								&&backCourseSchedule.getClassGroupType().equals(ClassGroupTypeEnum.VIP.getCode())){
 | 
	
		
			
				|  |  | +							throw new BizException("教师冲突");
 | 
	
		
			
				|  |  | +						}else if(preCourseSchedule.getClassGroupType().equals(ClassGroupTypeEnum.VIP.getCode())
 | 
	
		
			
				|  |  | +								&&backCourseSchedule.getClassGroupType().equals(ClassGroupTypeEnum.SNAP.getCode())){
 | 
	
		
			
				|  |  | +							throw new BizException("教师冲突");
 | 
	
		
			
				|  |  | +						}else{
 | 
	
		
			
				|  |  | +							if(!preCourseSchedule.getClassGroupType().equals(ClassGroupTypeEnum.SNAP.getCode())
 | 
	
		
			
				|  |  | +								&&preCourseSchedule.getClassGroupType().equals(ClassGroupTypeEnum.VIP.getCode())){
 | 
	
		
			
				|  |  | +								courseScheduleIds.add(preCourseSchedule.getId());
 | 
	
		
			
				|  |  | +							}
 | 
	
		
			
				|  |  | +							if(!backCourseSchedule.getClassGroupType().equals(ClassGroupTypeEnum.SNAP.getCode())
 | 
	
		
			
				|  |  | +									&&backCourseSchedule.getClassGroupType().equals(ClassGroupTypeEnum.VIP.getCode())){
 | 
	
		
			
				|  |  | +								courseScheduleIds.add(backCourseSchedule.getId());
 | 
	
		
			
				|  |  | +							}
 | 
	
		
			
				|  |  | +						}
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return courseScheduleIds;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	private String courseCheckInfo(CourseSchedule preCourseSchedule, CourseSchedule backCourseSchedule, List<Long> existCourseScheduleIds, Integer type){
 | 
	
		
			
				|  |  |  		//提示信息
 | 
	
		
			
				|  |  |  		StringBuffer errInfo = new StringBuffer("在");
 | 
	
		
			
				|  |  |  		errInfo.append(DateUtil.dateToString(preCourseSchedule.getStartClassTime(),"yyyy-MM-dd HH:mm"));
 |