|  | @@ -82,6 +82,8 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
	
		
			
				|  |  |  	private ClassGroupTeacherSalaryDao classGroupTeacherSalaryDao;
 | 
	
		
			
				|  |  |  	@Autowired
 | 
	
		
			
				|  |  |  	private JiaRiFeignService jiaRiFeignService;
 | 
	
		
			
				|  |  | +	@Autowired
 | 
	
		
			
				|  |  | +	private VipGroupService vipGroupService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	@Override
 | 
	
		
			
				|  |  |  	public BaseDAO<Long, CourseSchedule> getDAO() {
 | 
	
	
		
			
				|  | @@ -976,6 +978,112 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	@Override
 | 
	
		
			
				|  |  | +	public void batchAppendVipGroupCourses(VipGroupCourseAdjustInfoDto vipGroupCourseAdjustInfo) {
 | 
	
		
			
				|  |  | +		if(Objects.isNull(vipGroupCourseAdjustInfo.getVipGroupId())){
 | 
	
		
			
				|  |  | +			throw new BizException("请指定小课");
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		if(Objects.isNull(vipGroupCourseAdjustInfo.getCourseCreateStartTime())){
 | 
	
		
			
				|  |  | +			throw new BizException("请指定排课起始时间;");
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		if(CollectionUtils.isEmpty(vipGroupCourseAdjustInfo.getCourseTimes())){
 | 
	
		
			
				|  |  | +			throw new BizException("请指定排课周期");
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		if(Objects.isNull(vipGroupCourseAdjustInfo.getCourseCount())){
 | 
	
		
			
				|  |  | +			throw new BizException("请指定排课次数");
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		Date courseCreateStartTime = vipGroupCourseAdjustInfo.getCourseCreateStartTime();
 | 
	
		
			
				|  |  | +		Date now = new Date();
 | 
	
		
			
				|  |  | +		Date today = DateUtil.stringToDate(DateUtil.dateToString(now, DateUtil.ISO_EXPANDED_DATE_FORMAT),
 | 
	
		
			
				|  |  | +				DateUtil.ISO_EXPANDED_DATE_FORMAT);
 | 
	
		
			
				|  |  | +		if(courseCreateStartTime.before(today)){
 | 
	
		
			
				|  |  | +			throw new BizException("排课起始时间不能小于当前时间");
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		VipGroup vipGroup=vipGroupDao.get(vipGroupCourseAdjustInfo.getVipGroupId().longValue());
 | 
	
		
			
				|  |  | +		if(Objects.isNull(vipGroup)){
 | 
	
		
			
				|  |  | +			throw new BizException("指定课程不存在");
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		int courseNum = courseScheduleDao.countVipGroupCourses(vipGroup.getId().intValue());
 | 
	
		
			
				|  |  | +		if(courseNum==0){
 | 
	
		
			
				|  |  | +			throw new BizException("未排课的课程不能进行调整");
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		ClassGroup classGroup=classGroupDao.findByGroupAndType(vipGroupCourseAdjustInfo.getVipGroupId().toString(),GroupType.VIP.getCode());
 | 
	
		
			
				|  |  | +		if(Objects.isNull(classGroup)){
 | 
	
		
			
				|  |  | +			throw new BizException("对应班级不存在");
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		Calendar calendar = Calendar.getInstance();
 | 
	
		
			
				|  |  | +		calendar.setTime(courseCreateStartTime);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		Map<String, Integer> holidayDays = new HashMap<>();
 | 
	
		
			
				|  |  | +		Map<Integer, Map<String, Integer>> holiday = new HashMap<>();;
 | 
	
		
			
				|  |  | +		if (vipGroupCourseAdjustInfo.isHoliday()) {
 | 
	
		
			
				|  |  | +			holiday = jiaRiFeignService.query(calendar.get(Calendar.YEAR));
 | 
	
		
			
				|  |  | +			holidayDays = holiday.get(calendar.get(Calendar.YEAR));
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		List<CourseSchedule> courseSchedules=new ArrayList<>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		while (true) {
 | 
	
		
			
				|  |  | +			if(vipGroupCourseAdjustInfo.isHoliday() && !holiday.containsKey(calendar.get(Calendar.YEAR))){
 | 
	
		
			
				|  |  | +				holiday = jiaRiFeignService.query(calendar.get(Calendar.YEAR));
 | 
	
		
			
				|  |  | +				holidayDays = holiday.get(calendar.get(Calendar.YEAR));
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			if (vipGroupCourseAdjustInfo.isHoliday() && holidayDays.containsKey(DateUtil.format(calendar.getTime(),"MMdd"))) {
 | 
	
		
			
				|  |  | +				calendar.add(Calendar.DATE, 1);
 | 
	
		
			
				|  |  | +				continue;
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			int i = calendar.get(Calendar.DAY_OF_WEEK);
 | 
	
		
			
				|  |  | +			if(i==1){
 | 
	
		
			
				|  |  | +				i=7;
 | 
	
		
			
				|  |  | +			}else{
 | 
	
		
			
				|  |  | +				i=--i;
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			for (CourseTimeDto courseTime : vipGroupCourseAdjustInfo.getCourseTimes()) {
 | 
	
		
			
				|  |  | +				if(Objects.isNull(courseTime.getDayOfWeek())){
 | 
	
		
			
				|  |  | +					throw new BizException("排课循环周期错误");
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				if(courseTime.getDayOfWeek()<1||courseTime.getDayOfWeek()>7){
 | 
	
		
			
				|  |  | +					throw new BizException("排课循环周期错误");
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				if(courseTime.getDayOfWeek()==i){
 | 
	
		
			
				|  |  | +					String dateYmdStr = DateUtil.dateToString(calendar.getTime(), DateUtil.ISO_EXPANDED_DATE_FORMAT);
 | 
	
		
			
				|  |  | +					dateYmdStr = dateYmdStr + " " +courseTime.getStartClassTime();
 | 
	
		
			
				|  |  | +					Date courseStartTime = DateUtil.stringToDate(dateYmdStr, "yyyy-MM-dd HH:mm");
 | 
	
		
			
				|  |  | +					Date courseEndTime = DateUtil.addMinutes(courseStartTime,vipGroup.getSingleClassMinutes());
 | 
	
		
			
				|  |  | +					CourseSchedule courseSchedule=new CourseSchedule();
 | 
	
		
			
				|  |  | +					courseSchedule.setGroupType(GroupType.VIP);
 | 
	
		
			
				|  |  | +					courseSchedule.setMusicGroupId(vipGroup.getId().toString());
 | 
	
		
			
				|  |  | +					courseSchedule.setClassGroupId(classGroup.getId());
 | 
	
		
			
				|  |  | +					courseSchedule.setClassDate(courseStartTime);
 | 
	
		
			
				|  |  | +					courseSchedule.setStartClassTime(courseStartTime);
 | 
	
		
			
				|  |  | +					courseSchedule.setEndClassTime(courseEndTime);
 | 
	
		
			
				|  |  | +					courseSchedule.setSchoolId(vipGroup.getTeacherSchoolId());
 | 
	
		
			
				|  |  | +					courseSchedule.setStatus(CourseStatusEnum.NOT_START);
 | 
	
		
			
				|  |  | +					courseSchedule.setTeachMode(vipGroupCourseAdjustInfo.getTeachMode());
 | 
	
		
			
				|  |  | +					courseSchedules.add(courseSchedule);
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +				if(courseSchedules.size()==vipGroupCourseAdjustInfo.getCourseCount()){
 | 
	
		
			
				|  |  | +					break;
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			if(courseSchedules.size()==vipGroupCourseAdjustInfo.getCourseCount()){
 | 
	
		
			
				|  |  | +				break;
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			calendar.add(Calendar.DATE, 1);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +//		checkNewCourseSchedules(courseSchedules,false);
 | 
	
		
			
				|  |  | +//		courseScheduleDao.batchUpdate(courseSchedules);
 | 
	
		
			
				|  |  | +		VipGroupApplyDto vipGroupApplyDto=new VipGroupApplyDto();
 | 
	
		
			
				|  |  | +		VipGroupApplyBaseInfoDto vipGroupApplyBaseInfoDto=new VipGroupApplyBaseInfoDto();
 | 
	
		
			
				|  |  | +		vipGroupApplyBaseInfoDto.setId(vipGroup.getId());
 | 
	
		
			
				|  |  | +		vipGroupApplyDto.setCourseSchedules(courseSchedules);
 | 
	
		
			
				|  |  | +		classGroupService.updateClassGroupInfo(classGroup.getId());
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	@Override
 | 
	
		
			
				|  |  |  	public void courseAdjust(List<CourseSchedule> newCourseSchedules) {
 | 
	
		
			
				|  |  |  		Date now=new Date();
 | 
	
		
			
				|  |  |  		//课程信息处理
 |