Selaa lähdekoodia

Merge remote-tracking branch 'origin/master'

周箭河 5 vuotta sitten
vanhempi
commit
ec845cb437

+ 8 - 2
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java

@@ -479,18 +479,22 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
 	 * @author Joburgess
 	 * @date 2019/11/2
 	 * @param courseScheduleIds: 课程编号列表
+	 * @param teacherRole: 教师角色
 	 * @return java.util.List<com.ym.mec.biz.dal.dto.IntegerAndIntegerListDto>
 	 */
-	List<IntegerAndIntegerListDto> findCourseScheduleIdAndUserIdsMap(@Param("courseScheduleIds") List<Integer> courseScheduleIds);
+	List<IntegerAndIntegerListDto> findCourseScheduleIdAndUserIdsMap(@Param("courseScheduleIds") List<Long> courseScheduleIds,
+																	 @Param("teacherRole") String teacherRole);
 
 	/**
 	 * @describe 获取班级编号和与之对应的教师编号列表
 	 * @author Joburgess
 	 * @date 2019/11/3
 	 * @param classGroup: 班级编号列表
+	 * @param teacherRole: 教师角色
 	 * @return java.util.List<com.ym.mec.biz.dal.dto.IntegerAndIntegerListDto>
 	 */
-	List<IntegerAndIntegerListDto> findClassGroupAndUserIdsMap(@Param("classGroupIds") List<Integer> classGroup);
+	List<IntegerAndIntegerListDto> findClassGroupAndUserIdsMap(@Param("classGroupIds") List<Integer> classGroup,
+															   @Param("teacherRole") String teacherRole);
 
 	/**
 	 * @describe 获取指定日期的课程
@@ -525,4 +529,6 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
 	 * @return
 	 */
     List<Map<Integer, String>> findStudentMap(Integer courseScheduleId);
+
+    List<CourseSchedule> findAllCourseSches();
 }

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/CourseScheduleService.java

@@ -167,7 +167,7 @@ public interface CourseScheduleService extends BaseService<Long, CourseSchedule>
 	 * @param courseSchedules: 课程列表
 	 * @return void
 	 */
-	void checkNewCourseSchedules(List<CourseSchedule> courseSchedules);
+	void checkNewCourseSchedules(List<CourseSchedule> courseSchedules,boolean checkExistCourseSchedule);
 
 	/**
 	 * 获取班级未开始的课程计划

+ 73 - 15
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
@@ -145,7 +146,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		if(Objects.isNull(courseSchedules)&&courseSchedules.size()<=0){
 			throw new BizException("参数错误!");
 		}
-		checkNewCourseSchedules(courseSchedules);
+		checkNewCourseSchedules(courseSchedules,false);
         createCourseScheduleName(courseSchedules);
 		courseScheduleDao.batchAddCourseSchedules(courseSchedules);
 	}
@@ -158,7 +159,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		if(Objects.isNull(musicGroupID)){
 			throw new BizException("请指定乐团!");
 		}
-		checkNewCourseSchedules(courseSchedules);
+		checkNewCourseSchedules(courseSchedules,false);
         courseScheduleDao.deleteCourseSchedulesByMusicGroupID(musicGroupID);
         courseScheduleDao.batchAddCourseSchedules(courseSchedules);
 	}
@@ -268,13 +269,15 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 	}
 
 	@Override
-	public void checkNewCourseSchedules(List<CourseSchedule> courseSchedules){
+	public void checkNewCourseSchedules(List<CourseSchedule> courseSchedules,boolean checkExistCourseSchedule){
+		System.out.println(JSON.toJSONString(courseSchedules));
 		//第一节课
 		CourseSchedule firstCourseSchedule = courseSchedules.stream().min(Comparator.comparing(CourseSchedule::getStartClassTime)).get();
 		//最后一节课
 		CourseSchedule latestCourseSchedule = courseSchedules.stream().max(Comparator.comparing(CourseSchedule::getStartClassTime)).get();
 		//获取第一节课和最后一节课所包含的时间段内已存在的课程
 		List<CourseSchedule> existCourseSchedules = courseScheduleDao.findByDateZone(firstCourseSchedule.getStartClassTime(), latestCourseSchedule.getEndClassTime());
+
 		//只需要调整课程信息的课程编号列表
 		List<Long> updateCourseScheduleIds = courseSchedules
 				.stream()
@@ -286,6 +289,17 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		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)){
@@ -305,13 +319,18 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 				.stream()
 				.collect(Collectors.groupingBy(ClassGroupStudentMapper::getClassGroupId));
 
-//        allCourseSchedules
-//                    .stream()
-//                    .filter(courseSchedule -> Objects.nonNull(courseSchedule.getId()))
-//                    .map(CourseSchedule::getId)
-//                    .collect(Collectors.toList());
+		//根据课程获取助教id关联集合
+		List<IntegerAndIntegerListDto> courseScheduleTeachingTeacherIdList = new ArrayList<>();
+		if(!CollectionUtils.isEmpty(existCourseScheduleIds)){
+			courseScheduleTeachingTeacherIdList = courseScheduleDao.findCourseScheduleIdAndUserIdsMap(existCourseScheduleIds, TeachTypeEnum.TEACHING.getCode());
+		}
+		Map<Integer, IntegerAndIntegerListDto> courseScheduleTeachingTeacherMap = courseScheduleTeachingTeacherIdList.stream()
+				.collect(Collectors.toMap(IntegerAndIntegerListDto::getId, integerAndIntegerListDto -> integerAndIntegerListDto));
 
-//        courseScheduleDao.findCourseScheduleIdAndUserIdsMap(new ArrayList<>());
+		//班级助教关联ID集合
+		List<IntegerAndIntegerListDto> classGroupAndUserIdsMap = courseScheduleDao.findClassGroupAndUserIdsMap(newCourseScheduleClassGroupIds, TeachTypeEnum.TEACHING.getCode());
+		Map<Integer, IntegerAndIntegerListDto> classGroupTeachingTeacherMap = classGroupAndUserIdsMap.stream()
+				.collect(Collectors.toMap(IntegerAndIntegerListDto::getId, integerAndIntegerListDto -> integerAndIntegerListDto));
 
 		//将课程计划按照开课时间排序
 		allCourseSchedules.sort(Comparator.comparing(CourseSchedule::getStartClassTime));
@@ -324,21 +343,59 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                     CourseSchedule preCourseSchedule = allCourseSchedules.get(i-j);
                     //后面一节课程
                     CourseSchedule backCourseSchedule = allCourseSchedules.get(i);
+                    if(!checkExistCourseSchedule
+						&&existCourseScheduleIds.contains(preCourseSchedule.getId())
+						&&existCourseScheduleIds.contains(backCourseSchedule.getId())){
+                    	continue;
+					}
                     //判断前后两节课是否存在冲突
                     if(backCourseSchedule.getStartClassTime().before(preCourseSchedule.getEndClassTime())){
                         //提示信息
                         StringBuffer errInfo = new StringBuffer("在");
-                        errInfo.append(DateUtil.dateToString(preCourseSchedule.getStartClassTime(),DateUtil.EXPANDED_DATE_TIME_FORMAT));
+                        errInfo.append(DateUtil.dateToString(preCourseSchedule.getStartClassTime(),"yyyy-MM-dd HH:mm"));
                         errInfo.append("至");
-                        errInfo.append(DateUtil.dateToString(backCourseSchedule.getEndClassTime(),DateUtil.EXPANDED_DATE_TIME_FORMAT));
-                        errInfo.append("时间段内");
+                        errInfo.append(DateUtil.dateToString(backCourseSchedule.getEndClassTime(),"yyyy-MM-dd HH:mm"));
+                        errInfo.append("时间段内");
                         //如果存在时间重叠,则需要判断前后两节课的教师和学生是否存在冲突
-                        //教冲突检测
+                        //教冲突检测
                         if(Objects.nonNull(preCourseSchedule.getActualTeacherId())
                                 &&preCourseSchedule.getActualTeacherId().equals(backCourseSchedule.getActualTeacherId())){
-                            errInfo.append("安排的教有课程冲突");
+                            errInfo.append("安排的教有课程冲突");
                             throw new BizException(errInfo.toString());
                         }
+                        //助教冲突检测
+						if(Objects.isNull(preCourseSchedule.getId())){
+							IntegerAndIntegerListDto integerAndIntegerListDto = classGroupTeachingTeacherMap.get(preCourseSchedule.getClassGroupId());
+							if(Objects.nonNull(integerAndIntegerListDto)){
+								preCourseSchedule.setTeachingTeacherIdList(integerAndIntegerListDto.getIds());
+							}
+						}else if(existCourseScheduleIds.contains(preCourseSchedule.getId())){
+							IntegerAndIntegerListDto integerAndIntegerListDto = courseScheduleTeachingTeacherMap.get(preCourseSchedule.getId());
+							if(Objects.nonNull(integerAndIntegerListDto)){
+								preCourseSchedule.setTeachingTeacherIdList(integerAndIntegerListDto.getIds());
+							}
+						}
+						if(Objects.isNull(backCourseSchedule.getId())){
+							IntegerAndIntegerListDto integerAndIntegerListDto = classGroupTeachingTeacherMap.get(backCourseSchedule.getClassGroupId());
+							if(Objects.nonNull(integerAndIntegerListDto)){
+								backCourseSchedule.setTeachingTeacherIdList(integerAndIntegerListDto.getIds());
+							}
+						}else if(existCourseScheduleIds.contains(backCourseSchedule.getId())){
+							IntegerAndIntegerListDto integerAndIntegerListDto = courseScheduleTeachingTeacherMap.get(backCourseSchedule.getId());
+							if(Objects.nonNull(integerAndIntegerListDto)){
+								backCourseSchedule.setTeachingTeacherIdList(integerAndIntegerListDto.getIds());
+							}
+						}
+						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)){
+								errInfo.append("安排的助教存在冲突");
+								throw new BizException(errInfo.toString());
+							}
+						}
                         //学生冲突检测
                         if(preCourseSchedule.getClassGroupId().equals(backCourseSchedule.getClassGroupId())){
                             //如果班级相同,则学生肯定存在冲突
@@ -367,6 +424,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                             errInfo.append("安排的课程存在学生冲突");
                             throw new BizException(errInfo.toString());
                         }
+						System.out.println(j==repeatTimes);
                         if(j==repeatTimes){
                             repeatTimes+=1;
                         }
@@ -457,7 +515,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 
 	@Override
 	public void courseAdjust(List<CourseSchedule> newCourseSchedules) {
-		checkNewCourseSchedules(newCourseSchedules);
+		checkNewCourseSchedules(newCourseSchedules,false);
 		classStartDateAdjust(newCourseSchedules);
 	}
 

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/DemoGroupServiceImpl.java

@@ -224,7 +224,7 @@ public class DemoGroupServiceImpl extends BaseServiceImpl<Long, DemoGroup>  impl
 		courseScheduleByDemoGroup.setName(className.toString());
 		List<CourseSchedule> courseSchedules=new ArrayList<>();
 		courseSchedules.add(courseScheduleByDemoGroup);
-		courseScheduleService.checkNewCourseSchedules(courseSchedules);
+		courseScheduleService.checkNewCourseSchedules(courseSchedules,false);
 		courseScheduleDao.insert(courseScheduleByDemoGroup);
 
 		CourseScheduleStudentPayment courseScheduleStudentPayment = new CourseScheduleStudentPayment();

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/SysMessageServiceImpl.java

@@ -376,4 +376,4 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 	public int updateOneStatus(Long id, int status) {
 		return sysMessageDao.updateOneStatus(id, status);
 	}
-}
+}

+ 11 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/VipGroupServiceImpl.java

@@ -98,6 +98,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 	private TeacherDao teacherDao;
 	@Autowired
 	private TeacherAttendanceDao teacherAttendanceDao;
+	@Autowired
+	private ContractService contractService;
 
 	@Override
 	public BaseDAO<Long, VipGroup> getDAO() {
@@ -325,7 +327,7 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		}
 
 		//检测课程信息是否存在冲突
-		courseScheduleService.checkNewCourseSchedules(courseSchedules);
+		courseScheduleService.checkNewCourseSchedules(courseSchedules,false);
 		//只需要更新的课程走课程调整流程
 		courseScheduleService.classStartDateAdjust(updateCourseSchedules);
 
@@ -737,7 +739,12 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		if(Objects.isNull(classGroup)){
 			throw new BizException("未找到关联班级");
 		}
-		classGroup.setStudentNum(classGroup.getStudentNum()+num);
+		if(classGroup.getStudentNum()+num<0){
+			classGroup.setStudentNum(0);
+		}else{
+			classGroup.setStudentNum(classGroup.getStudentNum()+num);
+		}
+
 		if(classGroup.getStudentNum().equals(classGroup.getExpectStudentNum())&&updateVipStatus){
 			vipGroup.setStatus(VipGroupStatusEnum.FINISH);
 			vipGroupDao.update(vipGroup);
@@ -899,6 +906,8 @@ public class VipGroupServiceImpl extends BaseServiceImpl<Long, VipGroup> impleme
 		String organIdsString = StringUtils.join(hashSet, ",");
 		vipGroup.setOrganIdList(organIdsString);
 		vipGroupDao.update(vipGroup);
+
+		contractService.transferVipGroupCoursesContract(userId,vipGroupId);
 	}
 
 	@Transactional(rollbackFor = Exception.class)

+ 88 - 8
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -14,6 +14,8 @@
         <result column="class_date_" property="classDate"/>
         <result column="start_class_time_" property="startClassTime"/>
         <result column="end_class_time_" property="endClassTime"/>
+        <result column="start_class_time_str_" property="startClassTimeStr"/>
+        <result column="end_class_time_str_" property="endClassTimeStr"/>
         <result column="teacher_id_" property="teacherId"/>
         <result column="actual_teacher_id_" property="actualTeacherId"/>
         <result column="create_time_" property="createTime"/>
@@ -881,7 +883,7 @@
         <result property="startClassTime" column="start_class_time_"/>
         <result property="endClassTime" column="end_class_time_"/>
         <result property="actualTeacherId" column="actual_teacher_id_"/>
-        <result property="actualTeacherName" column="actual_teacher_id_"/>
+        <result property="actualTeacherName" column="username_"/>
         <result property="type" column="type_"/>
         <result property="studentNum" column="student_num_"/>
         <result property="leaveStudentNum" column="leave_student_num_"/>
@@ -1102,7 +1104,8 @@
             cs.schoole_id_
         FROM
             course_schedule cs
-            WHERE cs.class_date_ BETWEEN DATE_FORMAT(#{startTime},'%Y%m%d') AND DATE_FORMAT(#{endTime},'%Y%m%d')
+            WHERE (cs.class_date_ BETWEEN DATE_FORMAT(#{startTime},'%Y%m%d') AND DATE_FORMAT(#{endTime},'%Y%m%d'))
+            AND cs.status_='NOT_START'
     </select>
     
     <select id="queryStudentCoursesTimesOfTomorrow" resultMap="Mapper">
@@ -1116,7 +1119,7 @@
     <resultMap id="IntegerAndIntegerListDto" type="com.ym.mec.biz.dal.dto.IntegerAndIntegerListDto">
         <result property="id" column="id_"/>
         <collection property="ids" ofType="string" javaType="list">
-            <result column="relate_id"/>
+            <result column="relate_ids"/>
         </collection>
     </resultMap>
 
@@ -1125,7 +1128,11 @@
           course_schedule_id_ id_,
           user_id_ relate_ids
         from course_schedule_teacher_salary
-        where course_schedule_id_ IN
+        where 1=1
+        <if test="teacherRole!=null and teacherRole!=''">
+            AND teacher_role_=#{teacherRole}
+        </if>
+        AND course_schedule_id_ IN
         <foreach collection="courseScheduleIds" item="courseScheduleId" open="(" close=")" separator=",">
             #{courseScheduleId}
         </foreach>
@@ -1136,7 +1143,11 @@
             user_id_ relate_ids
         FROM
             class_group_teacher_mapper
-        WHERE class_group_id_ IN
+        WHERE 1=1
+        <if test="teacherRole!=null and teacherRole!=''">
+            AND teacher_role_=#{teacherRole}
+        </if>
+        AND class_group_id_ IN
         <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
             #{classGroupId}
         </foreach>
@@ -1151,7 +1162,7 @@
             CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
             CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
             cs.teacher_id_,
-            csts.actual_teacher_id_,
+            csts.user_id_ actual_teacher_id_,
             cs.create_time_,
             cs.update_time_,
             cs.teach_mode_,
@@ -1162,14 +1173,59 @@
             cs.schoole_id_
         FROM
             course_schedule cs
+            LEFT JOIN course_schedule_teacher_salary csts ON cs.id_=csts.course_schedule_id_
         WHERE cs.class_date_=DATE_FORMAT(#{date},'%Y-%m-%d %H:%i:%s')
         AND cs.type_!='VIP'
     </select>
     <select id="findByClassGroup" resultMap="CourseSchedule">
-      select * from  course_schedule where class_group_id_=#{classGroupId}
+      select
+        cs.id_,
+        cs.class_group_id_,
+        cs.status_,
+        cs.subsidy_,
+        cs.class_date_,
+        CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
+        CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
+        cs.start_class_time_ start_class_time_str_,
+        cs.end_class_time_ end_class_time_str_,
+        cs.teacher_id_,
+        csts.user_id_ actual_teacher_id_,
+        cs.create_time_,
+        cs.update_time_,
+        cs.teach_mode_,
+        cs.type_,
+        cs.name_,
+        cs.student_num_,
+        cs.leave_student_num_,
+        cs.schoole_id_
+      from  course_schedule cs
+        LEFT JOIN course_schedule_teacher_salary csts ON cs.id_=csts.course_schedule_id_
+      where cs.class_group_id_=#{classGroupId}
     </select>
     <select id="findByClassGroups" resultMap="CourseSchedule">
-        select * from  course_schedule where class_group_id_ IN
+        select
+            cs.id_,
+            cs.class_group_id_,
+            cs.status_,
+            cs.subsidy_,
+            cs.class_date_,
+            CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
+            CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
+            cs.start_class_time_ start_class_time_str_,
+            cs.end_class_time_ end_class_time_str_,
+            cs.teacher_id_,
+            csts.user_id_ actual_teacher_id_,
+            cs.create_time_,
+            cs.update_time_,
+            cs.teach_mode_,
+            cs.type_,
+            cs.name_,
+            cs.student_num_,
+            cs.leave_student_num_,
+            cs.schoole_id_
+        from  course_schedule cs
+          LEFT JOIN course_schedule_teacher_salary csts ON cs.id_=csts.course_schedule_id_
+        where cs.class_group_id_ IN
         <foreach collection="classGroupIds" item="classGroupId" open="(" close=")" separator=",">
             #{classGroupId}
         </foreach>
@@ -1179,4 +1235,28 @@
         WHERE cs.course_schedule_id_ = #{courseScheduleId}
         GROUP BY user_id_
     </select>
+
+    <select id="findAllCourseSches" resultMap="CourseSchedule">
+        select
+            cs.id_,
+            cs.class_group_id_,
+            cs.status_,
+            cs.subsidy_,
+            cs.class_date_,
+            CONCAT(cs.class_date_,' ',cs.start_class_time_) start_class_time_,
+            CONCAT(cs.class_date_,' ',cs.end_class_time_) end_class_time_,
+            cs.start_class_time_ start_class_time_str_,
+            cs.end_class_time_ end_class_time_str_,
+            cs.teacher_id_,
+            cs.actual_teacher_id_,
+            cs.create_time_,
+            cs.update_time_,
+            cs.teach_mode_,
+            cs.type_,
+            cs.name_,
+            cs.student_num_,
+            cs.leave_student_num_,
+            cs.schoole_id_
+        from course_schedule cs
+    </select>
 </mapper>

+ 11 - 3
mec-biz/src/main/resources/config/mybatis/TeacherLeaveRecordMapper.xml

@@ -98,9 +98,17 @@
 
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="TeacherLeaveRecord" parameterType="map">
-		SELECT tlr.create_time_,tlr.start_time_,tlr.end_time_,tlr.remark_,tlr.id_,
-		lc.name_ leave_category_name_,lc.id_ leave_category_id_
-		FROM teacher_leave_record tlr
+		SELECT
+			tlr.create_time_,
+			tlr.start_time_,
+			tlr.end_time_,
+			tlr.status_,
+			tlr.remark_,
+			tlr.id_,
+			lc.name_ leave_category_name_,
+			lc.id_ leave_category_id_
+		FROM
+		teacher_leave_record tlr
 		LEFT JOIN leave_category lc ON tlr.leave_category_id_ = lc.id_
 		<include refid="queryLeavePage"/>
 		ORDER BY tlr.create_time_ DESC

+ 10 - 0
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TeacherCourseScheduleController.java

@@ -9,6 +9,7 @@ import com.ym.mec.biz.dal.enums.StudentAttendanceStatusEnum;
 import com.ym.mec.biz.dal.page.CourseHomeworkQueryInfo;
 import com.ym.mec.biz.dal.page.CourseScheduleQueryInfo;
 import com.ym.mec.biz.dal.page.StudentAttendanceQueryInfo;
+import com.ym.mec.biz.service.ClassGroupService;
 import com.ym.mec.biz.service.CourseScheduleService;
 import com.ym.mec.biz.service.StudentAttendanceService;
 import com.ym.mec.common.controller.BaseController;
@@ -37,6 +38,8 @@ public class TeacherCourseScheduleController extends BaseController {
     private StudentAttendanceService studentAttendanceService;
     @Autowired
     private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private ClassGroupService classGroupService;
 
     @ApiOperation(value = "根据月份获取该月有课的日期")
     @GetMapping("/getCourseScheduleDateByMonth")
@@ -106,6 +109,13 @@ public class TeacherCourseScheduleController extends BaseController {
         if(classDateAdjustDto.getStartClassTime().before(new Date())){
             return failed("课程开始时间不能小于当前时间");
         }
+        CourseSchedule oldCourseSchedule = scheduleService.get(classDateAdjustDto.getId());
+        if(Objects.isNull(oldCourseSchedule)){
+            return failed("未找到指定课程");
+        }
+        if(Objects.isNull(classDateAdjustDto.getClassGroupId())){
+            classDateAdjustDto.setClassGroupId(oldCourseSchedule.getClassGroupId());
+        }
         List<CourseSchedule> courseSchedules=new ArrayList<>();
         courseSchedules.add(classDateAdjustDto);
         scheduleService.courseAdjust(courseSchedules);

+ 20 - 25
mec-web/src/main/java/com/ym/mec/web/controller/CourseScheduleController.java

@@ -1,30 +1,5 @@
 package com.ym.mec.web.controller;
 
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.MediaType;
-import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.ui.ModelMap;
-import org.springframework.util.CollectionUtils;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.ClassGroupTeacherMapperDao;
@@ -41,6 +16,19 @@ import com.ym.mec.biz.service.MusicGroupService;
 import com.ym.mec.biz.service.StudentAttendanceService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.exception.BizException;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.CollectionUtils;
+import org.springframework.web.bind.annotation.*;
+
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @Author Joburgess
@@ -139,6 +127,13 @@ public class CourseScheduleController extends BaseController {
     @PreAuthorize("@pcs.hasPermissions('courseSchedule/classStartDateAdjust')")
     @PostMapping(value = "/classStartDateAdjust",consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
     public Object classStartDateAdjust(CourseSchedule courseSchedule){
+        CourseSchedule oldCourseSchedule = scheduleService.get(courseSchedule.getId());
+        if(Objects.isNull(oldCourseSchedule)){
+            return failed("未找到指定课程");
+        }
+        if(Objects.isNull(courseSchedule.getClassGroupId())){
+            courseSchedule.setClassGroupId(oldCourseSchedule.getClassGroupId());
+        }
         List<CourseSchedule> courseSchedules=new ArrayList<>();
         courseSchedules.add(courseSchedule);
         scheduleService.courseAdjust(courseSchedules);