Joburgess 5 years ago
parent
commit
3f4665fc26

+ 3 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/CourseScheduleDao.java

@@ -490,9 +490,11 @@ public interface CourseScheduleDao extends BaseDAO<Long, CourseSchedule> {
 	 * @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 获取指定日期的课程

+ 26 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/CourseScheduleServiceImpl.java

@@ -289,6 +289,12 @@ 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)
@@ -313,7 +319,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 				.stream()
 				.collect(Collectors.groupingBy(ClassGroupStudentMapper::getClassGroupId));
 
-		//根据班级获取助教id关联集合
+		//根据课程获取助教id关联集合
 		List<IntegerAndIntegerListDto> courseScheduleTeachingTeacherIdList = new ArrayList<>();
 		if(!CollectionUtils.isEmpty(existCourseScheduleIds)){
 			courseScheduleTeachingTeacherIdList = courseScheduleDao.findCourseScheduleIdAndUserIdsMap(existCourseScheduleIds, TeachTypeEnum.TEACHING.getCode());
@@ -321,6 +327,11 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
 		Map<Integer, IntegerAndIntegerListDto> courseScheduleTeachingTeacherMap = courseScheduleTeachingTeacherIdList.stream()
 				.collect(Collectors.toMap(IntegerAndIntegerListDto::getId, integerAndIntegerListDto -> integerAndIntegerListDto));
 
+		//班级助教关联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));
 		if(allCourseSchedules.size()>1){
@@ -335,7 +346,7 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                     if(!checkExistCourseSchedule
 						&&existCourseScheduleIds.contains(preCourseSchedule.getId())
 						&&existCourseScheduleIds.contains(backCourseSchedule.getId())){
-                    	return;
+                    	continue;
 					}
                     //判断前后两节课是否存在冲突
                     if(backCourseSchedule.getStartClassTime().before(preCourseSchedule.getEndClassTime())){
@@ -353,13 +364,23 @@ public class CourseScheduleServiceImpl extends BaseServiceImpl<Long, CourseSched
                             throw new BizException(errInfo.toString());
                         }
                         //助教冲突检测
-						if(existCourseScheduleIds.contains(preCourseSchedule.getId())){
+						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(existCourseScheduleIds.contains(backCourseSchedule.getId())){
+						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());
@@ -403,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;
                         }

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

@@ -1,5 +1,22 @@
 package com.ym.mec.biz.service.impl;
 
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Random;
+import java.util.Set;
+
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.SysMessageDao;
@@ -18,15 +35,6 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext.MessageSender;
 import com.ym.mec.util.string.MessageFormatter;
-import org.apache.commons.lang.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.stereotype.Service;
-
-import java.util.*;
-import java.util.Map.Entry;
 
 @Service
 public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> implements SysMessageService {
@@ -56,7 +64,7 @@ public class SysMessageServiceImpl extends BaseServiceImpl<Long, SysMessage> imp
 
 	private final int DEFAULT_CODE = 888888;
 
-//	@Value("${message.debugMode}")
+	@Value("${message.debugMode}")
 	private boolean debugMode;
 
 	@Override

+ 5 - 1
mec-biz/src/main/resources/config/mybatis/CourseScheduleMapper.xml

@@ -1143,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>

+ 3 - 3
mec-common/common-core/src/main/java/com/ym/mec/common/redis/config/RedisConfig.java

@@ -1,5 +1,7 @@
 package com.ym.mec.common.redis.config;
 
+import java.io.Serializable;
+
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -11,8 +13,6 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
 import org.springframework.data.redis.serializer.StringRedisSerializer;
 
-import java.io.Serializable;
-
 @Configuration
 public class RedisConfig {
 
@@ -41,7 +41,7 @@ public class RedisConfig {
 	}
 
 	@Bean
-	public RedisTemplate<String, Serializable> redisTemplate() {
+	public RedisTemplate<String, Serializable> redisTemplate(JedisConnectionFactory connectionFactory) {
 		RedisTemplate<String, Serializable> redisTemplate = new RedisTemplate<>();
 		redisTemplate.setKeySerializer(new StringRedisSerializer());
 		redisTemplate.setHashKeySerializer(new StringRedisSerializer());

+ 8 - 8
mec-common/common-core/src/main/java/com/ym/mec/common/service/impl/RedisIdGeneratorService.java

@@ -1,8 +1,9 @@
 package com.ym.mec.common.service.impl;
 
-import com.google.common.base.Strings;
-import com.ym.mec.common.redis.service.RedisCache;
-import com.ym.mec.common.service.IdGeneratorService;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.concurrent.TimeUnit;
+
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -12,9 +13,9 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.ValueOperations;
 import org.springframework.stereotype.Service;
 
-import java.util.Calendar;
-import java.util.Date;
-import java.util.concurrent.TimeUnit;
+import com.google.common.base.Strings;
+import com.ym.mec.common.redis.service.RedisCache;
+import com.ym.mec.common.service.IdGeneratorService;
 
 @Service
 public class RedisIdGeneratorService implements IdGeneratorService {
@@ -25,8 +26,7 @@ public class RedisIdGeneratorService implements IdGeneratorService {
 
 	@Autowired
 	private RedisCache<String,Object> redisCache;
-
-//	@Value("${message.debugMode}")
+	@Value("${message.debugMode}")
 	private boolean debugMode;
 
 	/**

+ 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);