|  | @@ -75,6 +75,7 @@ import java.util.*;
 | 
											
												
													
														|  |  import java.util.function.Function;
 |  |  import java.util.function.Function;
 | 
											
												
													
														|  |  import java.util.stream.Collectors;
 |  |  import java.util.stream.Collectors;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +import static com.timevale.tgtext.text.html.b.i;
 | 
											
												
													
														|  |  import static com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType.MUSIC_NETWORK;
 |  |  import static com.ym.mec.biz.dal.entity.CourseSchedule.CourseScheduleType.MUSIC_NETWORK;
 | 
											
												
													
														|  |  import static com.ym.mec.biz.dal.enums.GroupType.*;
 |  |  import static com.ym.mec.biz.dal.enums.GroupType.*;
 | 
											
												
													
														|  |  import static com.ym.mec.biz.dal.enums.PracticeGroupType.FREE;
 |  |  import static com.ym.mec.biz.dal.enums.PracticeGroupType.FREE;
 | 
											
										
											
												
													
														|  | @@ -1642,12 +1643,12 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
											
												
													
														|  |  		List<Date> courseStartDates = new ArrayList<>();
 |  |  		List<Date> courseStartDates = new ArrayList<>();
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		Set<String> holidayDays = new HashSet<>();
 |  |  		Set<String> holidayDays = new HashSet<>();
 | 
											
												
													
														|  | -        Integer tenantId = TenantContextHolder.getTenantId();
 |  | 
 | 
											
												
													
														|  | -        if (courseAdjustInfo.isHoliday()) {
 |  | 
 | 
											
												
													
														|  | -            String holidaySetting = sysTenantConfigService.getTenantConfigValue(SysConfigService.HOLIDAY_SETTING,tenantId);
 |  | 
 | 
											
												
													
														|  | -            if(StringUtils.isNotBlank(holidaySetting)){
 |  | 
 | 
											
												
													
														|  | -                holidayDays = new HashSet<>(JSON.parseArray(holidaySetting, String.class));
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | 
 |  | +		Integer tenantId = TenantContextHolder.getTenantId();
 | 
											
												
													
														|  | 
 |  | +		if (courseAdjustInfo.isHoliday()) {
 | 
											
												
													
														|  | 
 |  | +			String holidaySetting = sysTenantConfigService.getTenantConfigValue(SysConfigService.HOLIDAY_SETTING,tenantId);
 | 
											
												
													
														|  | 
 |  | +			if(StringUtils.isNotBlank(holidaySetting)){
 | 
											
												
													
														|  | 
 |  | +				holidayDays = new HashSet<>(JSON.parseArray(holidaySetting, String.class));
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		Map<String, List<CourseSchedule>> result = new HashMap<String, List<CourseSchedule>>(){{
 |  |  		Map<String, List<CourseSchedule>> result = new HashMap<String, List<CourseSchedule>>(){{
 | 
											
										
											
												
													
														|  | @@ -2323,37 +2324,37 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  |      @Transactional(rollbackFor = Exception.class)
 |  |      @Transactional(rollbackFor = Exception.class)
 | 
											
												
													
														|  |      public void vipCourseAdjust(VipGroupCourseAdjustInfoDto vipGroupCourseAdjustInfo) {
 |  |      public void vipCourseAdjust(VipGroupCourseAdjustInfoDto vipGroupCourseAdjustInfo) {
 | 
											
												
													
														|  | -        SysUser user = sysUserService.getUser();
 |  | 
 | 
											
												
													
														|  | -        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 (StringUtils.isBlank(vipGroupCourseAdjustInfo.getCourseScheduleIds())) {
 |  | 
 | 
											
												
													
														|  | -            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("排课起始时间不能小于当前时间");
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | 
 |  | +		SysUser user = sysUserService.getUser();
 | 
											
												
													
														|  | 
 |  | +		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 (StringUtils.isBlank(vipGroupCourseAdjustInfo.getCourseScheduleIds())) {
 | 
											
												
													
														|  | 
 |  | +			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("排课起始时间不能小于当前时间");
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        boolean needSchoolId = Objects.nonNull(vipGroupCourseAdjustInfo.getTeachMode()) && vipGroupCourseAdjustInfo.getTeachMode().equals(TeachModeEnum.OFFLINE) && Objects.isNull(vipGroupCourseAdjustInfo.getSchoolId());
 |  | 
 | 
											
												
													
														|  | -        if (needSchoolId) {
 |  | 
 | 
											
												
													
														|  | -            throw new BizException("请设置教学点");
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | 
 |  | +		boolean needSchoolId = Objects.nonNull(vipGroupCourseAdjustInfo.getTeachMode()) && vipGroupCourseAdjustInfo.getTeachMode().equals(TeachModeEnum.OFFLINE) && Objects.isNull(vipGroupCourseAdjustInfo.getSchoolId());
 | 
											
												
													
														|  | 
 |  | +		if (needSchoolId) {
 | 
											
												
													
														|  | 
 |  | +			throw new BizException("请设置教学点");
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        int singleClassMinutes = 0;
 |  | 
 | 
											
												
													
														|  | -        int courseNum = 0;
 |  | 
 | 
											
												
													
														|  | -        Date coursesExpireDate = null;
 |  | 
 | 
											
												
													
														|  | -        Date coursesStartDate = null;
 |  | 
 | 
											
												
													
														|  | -        GroupType groupType = vipGroupCourseAdjustInfo.getGroupType();
 |  | 
 | 
											
												
													
														|  | 
 |  | +		int singleClassMinutes = 0;
 | 
											
												
													
														|  | 
 |  | +		int courseNum = 0;
 | 
											
												
													
														|  | 
 |  | +		Date coursesExpireDate = null;
 | 
											
												
													
														|  | 
 |  | +		Date coursesStartDate = null;
 | 
											
												
													
														|  | 
 |  | +		GroupType groupType = vipGroupCourseAdjustInfo.getGroupType();
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		VipGroup vipGroup=null;
 |  |  		VipGroup vipGroup=null;
 | 
											
												
													
														|  |  		VipGroupActivity vipGroupActivity = null;
 |  |  		VipGroupActivity vipGroupActivity = null;
 | 
											
										
											
												
													
														|  | @@ -2366,116 +2367,116 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
											
												
													
														|  |  			vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId());
 |  |  			vipGroupActivity = vipGroupActivityDao.get(vipGroup.getVipGroupActivityId());
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        switch (vipGroupCourseAdjustInfo.getGroupType()){
 |  | 
 | 
											
												
													
														|  | -            case PRACTICE:
 |  | 
 | 
											
												
													
														|  | -                PracticeGroup practiceGroup = practiceGroupDao.get(vipGroupCourseAdjustInfo.getVipGroupId().longValue());
 |  | 
 | 
											
												
													
														|  | -                if (Objects.isNull(practiceGroup)) {
 |  | 
 | 
											
												
													
														|  | -                    throw new BizException("指定课程不存在");
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | -                singleClassMinutes = practiceGroup.getSingleClassMinutes();
 |  | 
 | 
											
												
													
														|  | -                courseNum = courseScheduleDao.countVipGroupCourses(practiceGroup.getId().intValue(),groupType.getCode());
 |  | 
 | 
											
												
													
														|  | -                coursesExpireDate = practiceGroup.getCoursesExpireDate();
 |  | 
 | 
											
												
													
														|  | -                coursesStartDate = practiceGroup.getCoursesStartDate();
 |  | 
 | 
											
												
													
														|  | -                break;
 |  | 
 | 
											
												
													
														|  | -            default:
 |  | 
 | 
											
												
													
														|  | -                if (Objects.isNull(vipGroup)) {
 |  | 
 | 
											
												
													
														|  | -                    throw new BizException("指定课程不存在");
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | 
 |  | +		switch (vipGroupCourseAdjustInfo.getGroupType()){
 | 
											
												
													
														|  | 
 |  | +			case PRACTICE:
 | 
											
												
													
														|  | 
 |  | +				PracticeGroup practiceGroup = practiceGroupDao.get(vipGroupCourseAdjustInfo.getVipGroupId().longValue());
 | 
											
												
													
														|  | 
 |  | +				if (Objects.isNull(practiceGroup)) {
 | 
											
												
													
														|  | 
 |  | +					throw new BizException("指定课程不存在");
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				singleClassMinutes = practiceGroup.getSingleClassMinutes();
 | 
											
												
													
														|  | 
 |  | +				courseNum = courseScheduleDao.countVipGroupCourses(practiceGroup.getId().intValue(),groupType.getCode());
 | 
											
												
													
														|  | 
 |  | +				coursesExpireDate = practiceGroup.getCoursesExpireDate();
 | 
											
												
													
														|  | 
 |  | +				coursesStartDate = practiceGroup.getCoursesStartDate();
 | 
											
												
													
														|  | 
 |  | +				break;
 | 
											
												
													
														|  | 
 |  | +			default:
 | 
											
												
													
														|  | 
 |  | +				if (Objects.isNull(vipGroup)) {
 | 
											
												
													
														|  | 
 |  | +					throw new BizException("指定课程不存在");
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  |  				if(Objects.nonNull(vipGroup)
 |  |  				if(Objects.nonNull(vipGroup)
 | 
											
												
													
														|  |  						&&!VipGroupStatusEnum.PROGRESS.equals(vipGroup.getStatus())
 |  |  						&&!VipGroupStatusEnum.PROGRESS.equals(vipGroup.getStatus())
 | 
											
												
													
														|  |  						&&!VipGroupStatusEnum.FINISHED.equals(vipGroup.getStatus())){
 |  |  						&&!VipGroupStatusEnum.FINISHED.equals(vipGroup.getStatus())){
 | 
											
												
													
														|  |  					throw new BizException("非进行中课程组不允许进行此操作");
 |  |  					throw new BizException("非进行中课程组不允许进行此操作");
 | 
											
												
													
														|  |  				}
 |  |  				}
 | 
											
												
													
														|  | -                singleClassMinutes = vipGroup.getSingleClassMinutes();
 |  | 
 | 
											
												
													
														|  | -                courseNum = courseScheduleDao.countVipGroupCourses(vipGroup.getId().intValue(),groupType.getCode());
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -        if (courseNum == 0) {
 |  | 
 | 
											
												
													
														|  | -            throw new BizException("未排课的课程不能进行调整");
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | 
 |  | +				singleClassMinutes = vipGroup.getSingleClassMinutes();
 | 
											
												
													
														|  | 
 |  | +				courseNum = courseScheduleDao.countVipGroupCourses(vipGroup.getId().intValue(),groupType.getCode());
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +		if (courseNum == 0) {
 | 
											
												
													
														|  | 
 |  | +			throw new BizException("未排课的课程不能进行调整");
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        ClassGroup classGroup = classGroupDao.findByGroupAndType(vipGroupCourseAdjustInfo.getVipGroupId().toString(),groupType.getCode());
 |  | 
 | 
											
												
													
														|  | -        if (Objects.isNull(classGroup)) {
 |  | 
 | 
											
												
													
														|  | -            throw new BizException("对应班级不存在");
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | 
 |  | +		ClassGroup classGroup = classGroupDao.findByGroupAndType(vipGroupCourseAdjustInfo.getVipGroupId().toString(),groupType.getCode());
 | 
											
												
													
														|  | 
 |  | +		if (Objects.isNull(classGroup)) {
 | 
											
												
													
														|  | 
 |  | +			throw new BizException("对应班级不存在");
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        //所有课程编号
 |  | 
 | 
											
												
													
														|  | -        List<Long> courseScheduleIds = Arrays.asList(vipGroupCourseAdjustInfo.getCourseScheduleIds().split(","))
 |  | 
 | 
											
												
													
														|  | -                .stream().map(Long::parseLong).collect(Collectors.toList());
 |  | 
 | 
											
												
													
														|  | -        //所有的课程
 |  | 
 | 
											
												
													
														|  | -        List<CourseSchedule> courseSchedules = courseScheduleDao.findByCourseScheduleIds(courseScheduleIds);
 |  | 
 | 
											
												
													
														|  | 
 |  | +		//所有课程编号
 | 
											
												
													
														|  | 
 |  | +		List<Long> courseScheduleIds = Arrays.asList(vipGroupCourseAdjustInfo.getCourseScheduleIds().split(","))
 | 
											
												
													
														|  | 
 |  | +				.stream().map(Long::parseLong).collect(Collectors.toList());
 | 
											
												
													
														|  | 
 |  | +		//所有的课程
 | 
											
												
													
														|  | 
 |  | +		List<CourseSchedule> courseSchedules = courseScheduleDao.findByCourseScheduleIds(courseScheduleIds);
 | 
											
												
													
														|  |  		//校验可排课时间
 |  |  		//校验可排课时间
 | 
											
												
													
														|  |  		this.checkLiveAdjust(courseSchedules);
 |  |  		this.checkLiveAdjust(courseSchedules);
 | 
											
												
													
														|  |  		//校验机构线上课人数上限
 |  |  		//校验机构线上课人数上限
 | 
											
												
													
														|  |  		this.checkOnlineCategory(courseSchedules,vipGroupCourseAdjustInfo.getTeachMode());
 |  |  		this.checkOnlineCategory(courseSchedules,vipGroupCourseAdjustInfo.getTeachMode());
 | 
											
												
													
														|  | -        courseSchedules.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
 |  | 
 | 
											
												
													
														|  | 
 |  | +		courseSchedules.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
 | 
											
												
													
														|  |  		//拷贝历史直播课
 |  |  		//拷贝历史直播课
 | 
											
												
													
														|  |  		List<CourseSchedule> liveCourseSchedules = JSON.parseArray(JSON.toJSONString(courseSchedules),CourseSchedule.class);
 |  |  		List<CourseSchedule> liveCourseSchedules = JSON.parseArray(JSON.toJSONString(courseSchedules),CourseSchedule.class);
 | 
											
												
													
														|  |  		//获取操作日志
 |  |  		//获取操作日志
 | 
											
												
													
														|  |  		List<CourseScheduleModifyLog> modifyLogs = getModifyLogs(courseScheduleIds, courseSchedules, user.getId(), now);
 |  |  		List<CourseScheduleModifyLog> modifyLogs = getModifyLogs(courseScheduleIds, courseSchedules, user.getId(), now);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        if (courseScheduleIds.size() != courseScheduleIds.size()) {
 |  | 
 | 
											
												
													
														|  | -            throw new BizException("部分课程不存在");
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | 
 |  | +		if (courseScheduleIds.size() != courseScheduleIds.size()) {
 | 
											
												
													
														|  | 
 |  | +			throw new BizException("部分课程不存在");
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        Calendar calendar = Calendar.getInstance();
 |  | 
 | 
											
												
													
														|  | -        calendar.setTime(courseCreateStartTime);
 |  | 
 | 
											
												
													
														|  | -        List<Date> courseStartDates = new ArrayList<>();
 |  | 
 | 
											
												
													
														|  | 
 |  | +		Calendar calendar = Calendar.getInstance();
 | 
											
												
													
														|  | 
 |  | +		calendar.setTime(courseCreateStartTime);
 | 
											
												
													
														|  | 
 |  | +		List<Date> courseStartDates = new ArrayList<>();
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  		Set<String> holidayDays = new HashSet<>();
 |  |  		Set<String> holidayDays = new HashSet<>();
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        Integer tenantId = TenantContextHolder.getTenantId();
 |  | 
 | 
											
												
													
														|  | -        if (vipGroupCourseAdjustInfo.isHoliday()) {
 |  | 
 | 
											
												
													
														|  | -            String holidaySetting = sysTenantConfigService.getTenantConfigValue(SysConfigService.HOLIDAY_SETTING,tenantId);
 |  | 
 | 
											
												
													
														|  | -            if(StringUtils.isNotBlank(holidaySetting)){
 |  | 
 | 
											
												
													
														|  | -                holidayDays = new HashSet<>(JSON.parseArray(holidaySetting, String.class));
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | 
 |  | +		Integer tenantId = TenantContextHolder.getTenantId();
 | 
											
												
													
														|  | 
 |  | +		if (vipGroupCourseAdjustInfo.isHoliday()) {
 | 
											
												
													
														|  | 
 |  | +			String holidaySetting = sysTenantConfigService.getTenantConfigValue(SysConfigService.HOLIDAY_SETTING,tenantId);
 | 
											
												
													
														|  | 
 |  | +			if(StringUtils.isNotBlank(holidaySetting)){
 | 
											
												
													
														|  | 
 |  | +				holidayDays = new HashSet<>(JSON.parseArray(holidaySetting, String.class));
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        while (true) {
 |  | 
 | 
											
												
													
														|  | -            if (vipGroupCourseAdjustInfo.isHoliday() && holidayDays.contains(DateUtil.format(calendar.getTime(), "yyyy-MM-dd"))) {
 |  | 
 | 
											
												
													
														|  | -                calendar.add(Calendar.DATE, 1);
 |  | 
 | 
											
												
													
														|  | -                continue;
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -            int i = calendar.get(Calendar.DAY_OF_WEEK);
 |  | 
 | 
											
												
													
														|  | -            if (i == 1) {
 |  | 
 | 
											
												
													
														|  | -                i = 7;
 |  | 
 | 
											
												
													
														|  | -            } else {
 |  | 
 | 
											
												
													
														|  | -                i = i - 1;
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -            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, singleClassMinutes);
 |  | 
 | 
											
												
													
														|  | -                    if(DateUtil.daysBetween(DateUtil.stringToDate(DateUtil.format(courseStartTime,DateUtil.DEFAULT_PATTERN),DateUtil.DEFAULT_PATTERN),
 |  | 
 | 
											
												
													
														|  | -                            DateUtil.stringToDate(DateUtil.format(courseEndTime,DateUtil.DEFAULT_PATTERN),DateUtil.DEFAULT_PATTERN)) > 0){
 |  | 
 | 
											
												
													
														|  | -                        throw new BizException("单节课时不允许跨天");
 |  | 
 | 
											
												
													
														|  | -                    }
 |  | 
 | 
											
												
													
														|  | -                    courseStartDates.add(DateUtil.stringToDate(dateYmdStr, DateUtil.EXPANDED_DATE_TIME_FORMAT));
 |  | 
 | 
											
												
													
														|  | 
 |  | +		while (true) {
 | 
											
												
													
														|  | 
 |  | +			if (vipGroupCourseAdjustInfo.isHoliday() && holidayDays.contains(DateUtil.format(calendar.getTime(), "yyyy-MM-dd"))) {
 | 
											
												
													
														|  | 
 |  | +				calendar.add(Calendar.DATE, 1);
 | 
											
												
													
														|  | 
 |  | +				continue;
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			int i = calendar.get(Calendar.DAY_OF_WEEK);
 | 
											
												
													
														|  | 
 |  | +			if (i == 1) {
 | 
											
												
													
														|  | 
 |  | +				i = 7;
 | 
											
												
													
														|  | 
 |  | +			} else {
 | 
											
												
													
														|  | 
 |  | +				i = i - 1;
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			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, singleClassMinutes);
 | 
											
												
													
														|  | 
 |  | +					if(DateUtil.daysBetween(DateUtil.stringToDate(DateUtil.format(courseStartTime,DateUtil.DEFAULT_PATTERN),DateUtil.DEFAULT_PATTERN),
 | 
											
												
													
														|  | 
 |  | +							DateUtil.stringToDate(DateUtil.format(courseEndTime,DateUtil.DEFAULT_PATTERN),DateUtil.DEFAULT_PATTERN)) > 0){
 | 
											
												
													
														|  | 
 |  | +						throw new BizException("单节课时不允许跨天");
 | 
											
												
													
														|  | 
 |  | +					}
 | 
											
												
													
														|  | 
 |  | +					courseStartDates.add(DateUtil.stringToDate(dateYmdStr, DateUtil.EXPANDED_DATE_TIME_FORMAT));
 | 
											
												
													
														|  |  					CourseSchedule courseSchedule = courseSchedules.get(courseStartDates.size() - 1);
 |  |  					CourseSchedule courseSchedule = courseSchedules.get(courseStartDates.size() - 1);
 | 
											
												
													
														|  |  					//校验课程是否结算
 |  |  					//校验课程是否结算
 | 
											
												
													
														|  |  					this.checkCourseIsSettlement(courseSchedule);
 |  |  					this.checkCourseIsSettlement(courseSchedule);
 | 
											
												
													
														|  | -                    int num = studentAttendanceDao.countStudentAttendenceNum(courseSchedule.getId().intValue());
 |  | 
 | 
											
												
													
														|  | -                    if (num > 0) {
 |  | 
 | 
											
												
													
														|  | -                        throw new BizException("{}[{}]{}-{}课程已点名",
 |  | 
 | 
											
												
													
														|  | 
 |  | +					int num = studentAttendanceDao.countStudentAttendenceNum(courseSchedule.getId().intValue());
 | 
											
												
													
														|  | 
 |  | +					if (num > 0) {
 | 
											
												
													
														|  | 
 |  | +						throw new BizException("{}[{}]{}-{}课程已点名",
 | 
											
												
													
														|  |  								courseSchedule.getName(),
 |  |  								courseSchedule.getName(),
 | 
											
												
													
														|  |  								courseSchedule.getId(),
 |  |  								courseSchedule.getId(),
 | 
											
												
													
														|  | -                                DateUtil.dateToString(courseSchedule.getStartClassTime(),
 |  | 
 | 
											
												
													
														|  | -                                        DateUtil.EXPANDED_DATE_TIME_FORMAT),
 |  | 
 | 
											
												
													
														|  | -                                DateUtil.dateToString(courseSchedule.getEndClassTime(),
 |  | 
 | 
											
												
													
														|  | -                                        DateUtil.EXPANDED_DATE_TIME_FORMAT));
 |  | 
 | 
											
												
													
														|  | -                    }
 |  | 
 | 
											
												
													
														|  | -                    courseSchedule.setStatus(CourseStatusEnum.NOT_START);
 |  | 
 | 
											
												
													
														|  | -                    courseSchedule.setClassDate(courseStartTime);
 |  | 
 | 
											
												
													
														|  | -                    courseSchedule.setStartClassTime(courseStartTime);
 |  | 
 | 
											
												
													
														|  | -                    courseSchedule.setEndClassTime(courseEndTime);
 |  | 
 | 
											
												
													
														|  | 
 |  | +								DateUtil.dateToString(courseSchedule.getStartClassTime(),
 | 
											
												
													
														|  | 
 |  | +										DateUtil.EXPANDED_DATE_TIME_FORMAT),
 | 
											
												
													
														|  | 
 |  | +								DateUtil.dateToString(courseSchedule.getEndClassTime(),
 | 
											
												
													
														|  | 
 |  | +										DateUtil.EXPANDED_DATE_TIME_FORMAT));
 | 
											
												
													
														|  | 
 |  | +					}
 | 
											
												
													
														|  | 
 |  | +					courseSchedule.setStatus(CourseStatusEnum.NOT_START);
 | 
											
												
													
														|  | 
 |  | +					courseSchedule.setClassDate(courseStartTime);
 | 
											
												
													
														|  | 
 |  | +					courseSchedule.setStartClassTime(courseStartTime);
 | 
											
												
													
														|  | 
 |  | +					courseSchedule.setEndClassTime(courseEndTime);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  					Integer allowOnlineToOffline = 0;
 |  |  					Integer allowOnlineToOffline = 0;
 | 
											
												
													
														|  |  					if(Objects.nonNull(vipGroupActivity)){
 |  |  					if(Objects.nonNull(vipGroupActivity)){
 | 
											
										
											
												
													
														|  | @@ -2489,13 +2490,13 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
											
												
													
														|  |  					}
 |  |  					}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  					if (Objects.nonNull(vipGroupCourseAdjustInfo.getTeachMode())) {
 |  |  					if (Objects.nonNull(vipGroupCourseAdjustInfo.getTeachMode())) {
 | 
											
												
													
														|  | -                    	boolean onlineToOffline = courseSchedule.getTeachMode().equals(TeachModeEnum.ONLINE)
 |  | 
 | 
											
												
													
														|  | 
 |  | +						boolean onlineToOffline = courseSchedule.getTeachMode().equals(TeachModeEnum.ONLINE)
 | 
											
												
													
														|  |  								&&vipGroupCourseAdjustInfo.getTeachMode().equals(TeachModeEnum.OFFLINE);
 |  |  								&&vipGroupCourseAdjustInfo.getTeachMode().equals(TeachModeEnum.OFFLINE);
 | 
											
												
													
														|  |  						boolean offlineToOnline = courseSchedule.getTeachMode().equals(TeachModeEnum.OFFLINE)
 |  |  						boolean offlineToOnline = courseSchedule.getTeachMode().equals(TeachModeEnum.OFFLINE)
 | 
											
												
													
														|  |  								&&vipGroupCourseAdjustInfo.getTeachMode().equals(TeachModeEnum.ONLINE);
 |  |  								&&vipGroupCourseAdjustInfo.getTeachMode().equals(TeachModeEnum.ONLINE);
 | 
											
												
													
														|  | -                        if(onlineToOffline && Objects.nonNull(vipGroupActivity) && (allowOnlineToOffline == 0 || allowOnlineToOffline == 3)){
 |  | 
 | 
											
												
													
														|  | -                            throw new BizException("此VIP课活动不支持线上课调整为线下课");
 |  | 
 | 
											
												
													
														|  | -                        }
 |  | 
 | 
											
												
													
														|  | 
 |  | +						if(onlineToOffline && Objects.nonNull(vipGroupActivity) && (allowOnlineToOffline == 0 || allowOnlineToOffline == 3)){
 | 
											
												
													
														|  | 
 |  | +							throw new BizException("此VIP课活动不支持线上课调整为线下课");
 | 
											
												
													
														|  | 
 |  | +						}
 | 
											
												
													
														|  |  						if(offlineToOnline&&Objects.nonNull(vipGroupActivity) && (allowOnlineToOffline == 2 || allowOnlineToOffline == 3)){
 |  |  						if(offlineToOnline&&Objects.nonNull(vipGroupActivity) && (allowOnlineToOffline == 2 || allowOnlineToOffline == 3)){
 | 
											
												
													
														|  |  							throw new BizException("此VIP课活动不支持线下课调整为线上课");
 |  |  							throw new BizException("此VIP课活动不支持线下课调整为线上课");
 | 
											
												
													
														|  |  						}
 |  |  						}
 | 
											
										
											
												
													
														|  | @@ -2503,45 +2504,45 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
											
												
													
														|  |  							throw new BizException("请选择教学点");
 |  |  							throw new BizException("请选择教学点");
 | 
											
												
													
														|  |  						}
 |  |  						}
 | 
											
												
													
														|  |  						courseSchedule.setTeachMode(vipGroupCourseAdjustInfo.getTeachMode());
 |  |  						courseSchedule.setTeachMode(vipGroupCourseAdjustInfo.getTeachMode());
 | 
											
												
													
														|  | -                        if (vipGroupCourseAdjustInfo.getTeachMode().equals(TeachModeEnum.OFFLINE)) {
 |  | 
 | 
											
												
													
														|  | -                            if(Objects.nonNull(vipGroupCourseAdjustInfo.getSchoolId())){
 |  | 
 | 
											
												
													
														|  | 
 |  | +						if (vipGroupCourseAdjustInfo.getTeachMode().equals(TeachModeEnum.OFFLINE)) {
 | 
											
												
													
														|  | 
 |  | +							if(Objects.nonNull(vipGroupCourseAdjustInfo.getSchoolId())){
 | 
											
												
													
														|  |  								courseSchedule.setSchoolId(vipGroupCourseAdjustInfo.getSchoolId());
 |  |  								courseSchedule.setSchoolId(vipGroupCourseAdjustInfo.getSchoolId());
 | 
											
												
													
														|  | -                            }
 |  | 
 | 
											
												
													
														|  | -                        } else {
 |  | 
 | 
											
												
													
														|  | 
 |  | +							}
 | 
											
												
													
														|  | 
 |  | +						} else {
 | 
											
												
													
														|  |  							courseSchedule.setSchoolId(null);
 |  |  							courseSchedule.setSchoolId(null);
 | 
											
												
													
														|  | -                        }
 |  | 
 | 
											
												
													
														|  | -                    }
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | -                if (courseStartDates.size() == courseScheduleIds.size()) {
 |  | 
 | 
											
												
													
														|  | -                    break;
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -            if (courseStartDates.size() == courseScheduleIds.size()) {
 |  | 
 | 
											
												
													
														|  | -                break;
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -            calendar.add(Calendar.DATE, 1);
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -        checkNewCourseSchedules(courseSchedules, false,false);
 |  | 
 | 
											
												
													
														|  | -        //如果是陪练课,调整时间不允许超过有效期
 |  | 
 | 
											
												
													
														|  | -        if(groupType == PRACTICE){
 |  | 
 | 
											
												
													
														|  | -            for (CourseSchedule e:courseSchedules) {
 |  | 
 | 
											
												
													
														|  | -                //已点名的不允许调整
 |  | 
 | 
											
												
													
														|  | -                List<StudentAttendance> studentAttendances = studentAttendanceDao.findByCourseId(e.getId());
 |  | 
 | 
											
												
													
														|  | -                if(studentAttendances != null && studentAttendances.size() > 0){
 |  | 
 | 
											
												
													
														|  | -                    throw new BizException("调整失败: 课程已点名");
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | -                String classDate = DateUtil.format(e.getClassDate(), DateUtil.DEFAULT_PATTERN);
 |  | 
 | 
											
												
													
														|  | -                String startClassTime = DateUtil.format(e.getStartClassTime(), DateUtil.EXPANDED_TIME_FORMAT);
 |  | 
 | 
											
												
													
														|  | -                Date startDateTime = DateUtil.stringToDate(classDate + " " + startClassTime, DateUtil.EXPANDED_DATE_TIME_FORMAT);
 |  | 
 | 
											
												
													
														|  | -                Date endDateTime = DateUtil.addMinutes(startDateTime,singleClassMinutes);
 |  | 
 | 
											
												
													
														|  | -                if(DateUtil.minutesBetween(startDateTime,coursesStartDate) > 0){
 |  | 
 | 
											
												
													
														|  | -                    throw new BizException("调整失败: 课程{}调整时间早于有效期",e.getId());
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | -                if(DateUtil.minutesBetween(coursesExpireDate,endDateTime) > 0){
 |  | 
 | 
											
												
													
														|  | -                    throw new BizException("调整失败: 课程{}截止时间超过课程有效期",e.getId());
 |  | 
 | 
											
												
													
														|  | -                }
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | 
 |  | +						}
 | 
											
												
													
														|  | 
 |  | +					}
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				if (courseStartDates.size() == courseScheduleIds.size()) {
 | 
											
												
													
														|  | 
 |  | +					break;
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			if (courseStartDates.size() == courseScheduleIds.size()) {
 | 
											
												
													
														|  | 
 |  | +				break;
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +			calendar.add(Calendar.DATE, 1);
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +		checkNewCourseSchedules(courseSchedules, false,false);
 | 
											
												
													
														|  | 
 |  | +		//如果是陪练课,调整时间不允许超过有效期
 | 
											
												
													
														|  | 
 |  | +		if(groupType == PRACTICE){
 | 
											
												
													
														|  | 
 |  | +			for (CourseSchedule e:courseSchedules) {
 | 
											
												
													
														|  | 
 |  | +				//已点名的不允许调整
 | 
											
												
													
														|  | 
 |  | +				List<StudentAttendance> studentAttendances = studentAttendanceDao.findByCourseId(e.getId());
 | 
											
												
													
														|  | 
 |  | +				if(studentAttendances != null && studentAttendances.size() > 0){
 | 
											
												
													
														|  | 
 |  | +					throw new BizException("调整失败: 课程已点名");
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				String classDate = DateUtil.format(e.getClassDate(), DateUtil.DEFAULT_PATTERN);
 | 
											
												
													
														|  | 
 |  | +				String startClassTime = DateUtil.format(e.getStartClassTime(), DateUtil.EXPANDED_TIME_FORMAT);
 | 
											
												
													
														|  | 
 |  | +				Date startDateTime = DateUtil.stringToDate(classDate + " " + startClassTime, DateUtil.EXPANDED_DATE_TIME_FORMAT);
 | 
											
												
													
														|  | 
 |  | +				Date endDateTime = DateUtil.addMinutes(startDateTime,singleClassMinutes);
 | 
											
												
													
														|  | 
 |  | +				if(DateUtil.minutesBetween(startDateTime,coursesStartDate) > 0){
 | 
											
												
													
														|  | 
 |  | +					throw new BizException("调整失败: 课程{}调整时间早于有效期",e.getId());
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +				if(DateUtil.minutesBetween(coursesExpireDate,endDateTime) > 0){
 | 
											
												
													
														|  | 
 |  | +					throw new BizException("调整失败: 课程{}截止时间超过课程有效期",e.getId());
 | 
											
												
													
														|  | 
 |  | +				}
 | 
											
												
													
														|  | 
 |  | +			}
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  |  		if(groupType == VIP || groupType == LIVE){
 |  |  		if(groupType == VIP || groupType == LIVE){
 | 
											
												
													
														|  |  			CourseSchedule courseSchedule = courseSchedules.stream().max(Comparator.comparing(CourseSchedule::getEndClassTime)).get();
 |  |  			CourseSchedule courseSchedule = courseSchedules.stream().max(Comparator.comparing(CourseSchedule::getEndClassTime)).get();
 | 
											
												
													
														|  |  			if(courseSchedule.getEndClassTime().compareTo(vipGroup.getCoursesExpireDate())>0){
 |  |  			if(courseSchedule.getEndClassTime().compareTo(vipGroup.getCoursesExpireDate())>0){
 | 
											
										
											
												
													
														|  | @@ -2562,12 +2563,12 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 | 
											
												
													
														|  |  			}
 |  |  			}
 | 
											
												
													
														|  |  		}
 |  |  		}
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        courseScheduleDao.batchUpdate(courseSchedules);
 |  | 
 | 
											
												
													
														|  | -        classGroupService.updateClassGroupInfo(classGroup.getId());
 |  | 
 | 
											
												
													
														|  | -        if(vipGroupCourseAdjustInfo.getCourseCreateStartTime().after(now)){
 |  | 
 | 
											
												
													
														|  | -            teacherAttendanceDao.batchCleanCourseTeacherSignInfo(courseScheduleIds);
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -        studentAttendanceDao.deleteByCourseSchedules(courseScheduleIds);
 |  | 
 | 
											
												
													
														|  | 
 |  | +		courseScheduleDao.batchUpdate(courseSchedules);
 | 
											
												
													
														|  | 
 |  | +		classGroupService.updateClassGroupInfo(classGroup.getId());
 | 
											
												
													
														|  | 
 |  | +		if(vipGroupCourseAdjustInfo.getCourseCreateStartTime().after(now)){
 | 
											
												
													
														|  | 
 |  | +			teacherAttendanceDao.batchCleanCourseTeacherSignInfo(courseScheduleIds);
 | 
											
												
													
														|  | 
 |  | +		}
 | 
											
												
													
														|  | 
 |  | +		studentAttendanceDao.deleteByCourseSchedules(courseScheduleIds);
 | 
											
												
													
														|  |  		//删除作业
 |  |  		//删除作业
 | 
											
												
													
														|  |  		courseHomeworkService.delHomwworkByCourseScheduleId(courseScheduleIds);
 |  |  		courseHomeworkService.delHomwworkByCourseScheduleId(courseScheduleIds);
 | 
											
												
													
														|  |  		//删除评论
 |  |  		//删除评论
 |