|  | @@ -7,7 +7,6 @@ import com.keao.edu.auth.api.client.SysUserFeignService;
 | 
	
		
			
				|  |  |  import com.keao.edu.auth.api.entity.SysUser;
 | 
	
		
			
				|  |  |  import com.keao.edu.common.dal.BaseDAO;
 | 
	
		
			
				|  |  |  import com.keao.edu.common.enums.MessageTypeEnum;
 | 
	
		
			
				|  |  | -import com.keao.edu.common.enums.YesOrNoEnum;
 | 
	
		
			
				|  |  |  import com.keao.edu.common.exception.BizException;
 | 
	
		
			
				|  |  |  import com.keao.edu.common.page.PageInfo;
 | 
	
		
			
				|  |  |  import com.keao.edu.common.service.SysMessageService;
 | 
	
	
		
			
				|  | @@ -34,7 +33,6 @@ import com.keao.edu.user.service.OrganizationService;
 | 
	
		
			
				|  |  |  import com.keao.edu.util.collection.MapUtil;
 | 
	
		
			
				|  |  |  import com.keao.edu.util.date.DateUtil;
 | 
	
		
			
				|  |  |  import org.apache.commons.beanutils.BeanUtils;
 | 
	
		
			
				|  |  | -import org.apache.commons.collections.MapUtils;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang.time.DateUtils;
 | 
	
		
			
				|  |  |  import org.apache.commons.lang3.StringUtils;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
	
		
			
				|  | @@ -166,7 +164,7 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		examRoom.setTenantId(TenantContextHolder.getTenantId());
 | 
	
		
			
				|  |  | -		examRoom.setExamPlanPushFlag(YesOrNoEnum.NO);
 | 
	
		
			
				|  |  | +		examRoom.setExamPlanPushFlag(0);
 | 
	
		
			
				|  |  |  		examRoom.setExamRoomStudentNum(0);
 | 
	
		
			
				|  |  |  		if(StringUtils.isBlank(examRoom.getExamTimeJson())){
 | 
	
		
			
				|  |  |  			examRoomDao.insert(examRoom);
 | 
	
	
		
			
				|  | @@ -321,6 +319,14 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 | 
	
		
			
				|  |  |  	@Override
 | 
	
		
			
				|  |  |  	@Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |  	public void sendExamPlan(Integer organId, Integer examId, Integer operatorId) {
 | 
	
		
			
				|  |  | +		if(Objects.isNull(examId)){
 | 
	
		
			
				|  |  | +			throw new BizException("请指定考级项目");
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		ExaminationBasic exam = examinationBasicDao.get(examId.longValue());
 | 
	
		
			
				|  |  | +		if(Objects.isNull(exam)){
 | 
	
		
			
				|  |  | +			throw new BizException("考级项目不存在");
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  		int withoutExamRoomStudentNum = examRegistrationDao.countWithoutExamRoomStudentNum(null, examId);
 | 
	
		
			
				|  |  |  		if(withoutExamRoomStudentNum>0){
 | 
	
		
			
				|  |  |  			throw new BizException("存在未安排教室的学员");
 | 
	
	
		
			
				|  | @@ -328,9 +334,6 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 | 
	
		
			
				|  |  |  		examLifecycleLogDao.insert(new ExamLifecycleLog(examId, "确认考试安排", operatorId));
 | 
	
		
			
				|  |  |  		List<ExamRoomStudentRelation> examRoomStudentWithOrgans = examRoomStudentRelationDao.getNoSendExamPlanRooms(examId.longValue(), null);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		Set<Long> examIds = examRoomStudentWithOrgans.stream().map(ExamRoomStudentRelation::getExaminationBasicId).collect(Collectors.toSet());
 | 
	
		
			
				|  |  | -		Map<Integer, String> idExamNameMap = this.getMap("examination_basic", "id_", "name_", new ArrayList(examIds), Integer.class, String.class);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  		Set<Integer> locationIds = examRoomStudentWithOrgans.stream().filter(e -> Objects.nonNull(e.getExamLocationId())).map(ExamRoomStudentRelation::getExamLocationId).collect(Collectors.toSet());
 | 
	
		
			
				|  |  |  		Map<Integer, String> idLocationMap = this.getMap("exam_location", "id_", "name_", new ArrayList(locationIds), Integer.class, String.class);
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -338,6 +341,11 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 | 
	
		
			
				|  |  |  		Map<Integer, String> idPhoneMap = this.getMap("sys_user", "id_", "phone_", new ArrayList(AllStudentIds), Integer.class, String.class);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		Map<Long, List<ExamRoomStudentRelation>> examRoomStudentMap = examRoomStudentWithOrgans.stream().collect(Collectors.groupingBy(ExamRoomStudentRelation::getExamRoomId));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		Map<Integer, List<ExamRoom>> teacherExamRoomsMap = new HashMap<>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		List<ExamRoom> needUpdateExamRooms = new ArrayList<>();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  		for (Map.Entry<Long, List<ExamRoomStudentRelation>> examRoomStudentEntry : examRoomStudentMap.entrySet()) {
 | 
	
		
			
				|  |  |  			List<ExamRoomStudentRelation> students = examRoomStudentEntry.getValue();
 | 
	
		
			
				|  |  |  			Set<Integer> studentIds = students.stream().map(ExamRoomStudentRelation::getStudentId).collect(Collectors.toSet());
 | 
	
	
		
			
				|  | @@ -345,13 +353,31 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 | 
	
		
			
				|  |  |  				continue;
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			ExamRoom examRoom=students.get(0);
 | 
	
		
			
				|  |  | +			examRoom.setId(students.get(0).getExamRoomId());
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			needUpdateExamRooms.add(new ExamRoom(examRoom.getId(), 1));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			if(!teacherExamRoomsMap.containsKey(examRoom.getMainTeacherUserId())){
 | 
	
		
			
				|  |  | +				teacherExamRoomsMap.put(examRoom.getMainTeacherUserId(), new ArrayList<>());
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			teacherExamRoomsMap.get(examRoom.getMainTeacherUserId()).add(examRoom);
 | 
	
		
			
				|  |  | +			if(StringUtils.isNotBlank(examRoom.getAssistantTeacherUserIdList())){
 | 
	
		
			
				|  |  | +				Set<Integer> ateacherIds = Arrays.stream(examRoom.getAssistantTeacherUserIdList().split(",")).map(e -> Integer.valueOf(e)).collect(Collectors.toSet());
 | 
	
		
			
				|  |  | +				for (Integer ateacherId : ateacherIds) {
 | 
	
		
			
				|  |  | +					if(!teacherExamRoomsMap.containsKey(ateacherId)){
 | 
	
		
			
				|  |  | +						teacherExamRoomsMap.put(ateacherId, new ArrayList<>());
 | 
	
		
			
				|  |  | +					}
 | 
	
		
			
				|  |  | +					teacherExamRoomsMap.get(ateacherId).add(examRoom);
 | 
	
		
			
				|  |  | +				}
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  			Map<Integer, String> receiverMap = studentIds.stream().collect(Collectors.toMap(e->e, e->e.toString()));
 | 
	
		
			
				|  |  |  			Map<Integer, String> phoneMap = idPhoneMap.entrySet().stream().filter(e->studentIds.contains(e.getKey())).collect(Collectors.toMap(e->e.getKey(), e->e.getValue()));
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  			MessageTypeEnum pushMessageType = MessageTypeEnum.EXAM_ROOM_CONFIRM_ONLINE_STUDENT_PUSH;
 | 
	
		
			
				|  |  |  			MessageTypeEnum smsMessageType = MessageTypeEnum.EXAM_ROOM_CONFIRM_ONLINE_STUDENT_SMS;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -			String examName = idExamNameMap.get(examRoom.getExaminationBasicId());
 | 
	
		
			
				|  |  | +			String examName = exam.getName();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  			String examDayStr = DateUtil.dateToString(examRoom.getExamStartTime(), "MM月dd日");
 | 
	
		
			
				|  |  |  			StringBuffer examTimeStr = new StringBuffer();
 | 
	
	
		
			
				|  | @@ -372,6 +398,28 @@ public class ExamRoomServiceImpl extends BaseServiceImpl<Long, ExamRoom> impleme
 | 
	
		
			
				|  |  |  					phoneMap, null, 0, null, YimeiSmsPlugin.PLUGIN_NAME,
 | 
	
		
			
				|  |  |  					examName, examDayStr, examTimeStr, locationName);
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		Map<Integer, String> idTeacherPhoneMap = this.getMap("sys_user", "id_", "real_name_", new ArrayList(teacherExamRoomsMap.keySet()), Integer.class, String.class);
 | 
	
		
			
				|  |  | +		for (Map.Entry<Integer, List<ExamRoom>> teacherRoomEntry : teacherExamRoomsMap.entrySet()) {
 | 
	
		
			
				|  |  | +			String teacherPhone = idTeacherPhoneMap.get(teacherRoomEntry.getKey());
 | 
	
		
			
				|  |  | +			Date examStartTime = teacherRoomEntry.getValue().stream().min(Comparator.comparing(ExamRoom::getExamStartTime)).get().getExamStartTime();
 | 
	
		
			
				|  |  | +			String examStartTimeStr = DateUtil.dateToString(examStartTime, "MM月dd日 HH时mm分");
 | 
	
		
			
				|  |  | +			int examRoomNum = teacherRoomEntry.getValue().size();
 | 
	
		
			
				|  |  | +			Map<Integer, String> phoneMap = new HashMap<>();
 | 
	
		
			
				|  |  | +			phoneMap.put(teacherRoomEntry.getKey(), teacherPhone);
 | 
	
		
			
				|  |  | +			sysMessageService.batchSendMessage(MessageTypeEnum.EXAM_ROOM_CONFIRM_TEACHER_SMS,
 | 
	
		
			
				|  |  | +												phoneMap, null, 0, null, YimeiSmsPlugin.PLUGIN_NAME,
 | 
	
		
			
				|  |  | +												exam.getName(), examStartTimeStr, examRoomNum);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		if(!CollectionUtils.isEmpty(needUpdateExamRooms)){
 | 
	
		
			
				|  |  | +			examRoomDao.batchUpdate(needUpdateExamRooms);
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	@Override
 | 
	
		
			
				|  |  | +	public void tomorrowExamPlanRemind() {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	@Override
 |