package com.keao.edu.user.service.impl; import com.alibaba.fastjson.JSONObject; 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.exception.BizException; import com.keao.edu.common.page.PageInfo; import com.keao.edu.common.service.IdGeneratorService; import com.keao.edu.common.service.impl.BaseServiceImpl; import com.keao.edu.common.tenant.TenantContextHolder; import com.keao.edu.im.api.client.ImFeignService; import com.keao.edu.im.api.entity.MemberChangedMessage; import com.keao.edu.im.api.entity.PublishMessageDto; import com.keao.edu.im.api.entity.ReqUserData; import com.keao.edu.user.api.entity.ExamRoom; import com.keao.edu.user.api.entity.ExamRoomStudentRelation; import com.keao.edu.user.api.enums.ExamModeEnum; import com.keao.edu.user.dao.*; import com.keao.edu.user.dto.ExamRoomStudentRelationDto; import com.keao.edu.user.dto.NeedCheckingDetailDto; import com.keao.edu.user.dto.RoomStudentListDto; import com.keao.edu.user.dto.StuRecordDetailDto; import com.keao.edu.user.entity.*; import com.keao.edu.user.page.ExamRoomStudentRelationQueryInfo; import com.keao.edu.user.service.*; import com.keao.edu.util.collection.MapUtil; import com.keao.edu.util.date.DateUtil; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import java.util.*; import java.util.stream.Collectors; @Service public class ExamRoomStudentRelationServiceImpl extends BaseServiceImpl implements ExamRoomStudentRelationService { @Autowired private ExamRoomStudentRelationDao examRoomStudentRelationDao; @Autowired private ExamRoomDao examRoomDao; @Autowired private OrganizationService organizationService; @Autowired private StudentExamResultDao studentExamResultDao; @Autowired private ExamCertificationService examCertificationService; @Autowired private ExamLocationDao examLocationDao; @Autowired private IdGeneratorService idGeneratorService; @Autowired private ExamRegistrationDao examRegistrationDao; @Autowired private ExamTeacherSalaryService examTeacherSalaryService; @Autowired private ImFeignService imFeignService; @Autowired private SysUserFeignService sysUserFeignService; @Autowired private SysConfigService sysConfigService; @Autowired private ExamOrganizationRelationDao examOrganizationRelationDao; @Override public BaseDAO getDAO() { return examRoomStudentRelationDao; } @Override public void switchClassRoom(Integer openFlag, Integer examinationBasicId, Integer studentId) { examRoomStudentRelationDao.switchClassRoom(openFlag,examinationBasicId,studentId); } @Override @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED) public void addStudentForRoom(Long examRoomId, String registIdsStr, Integer organId) { if(Objects.isNull(examRoomId)){ throw new BizException("请指定教室"); } if(StringUtils.isBlank(registIdsStr)){ throw new BizException("请指定学员报名编号"); } ExamRoom examRoom = examRoomDao.lockRoom(examRoomId); if(Objects.isNull(examRoom)){ throw new BizException("教室不存在"); } if(examRoom.getExamPlanPushFlag()==1){ throw new BizException("无法添加学员"); } ExamOrganizationRelation examOrganizationRelation = examOrganizationRelationDao.getExamOrganizationRelation(examRoom.getExaminationBasicId(), organId); if(Objects.isNull(examOrganizationRelation)||examOrganizationRelation.getIsAllowArrangeExam()==0){ throw new BizException("无权操作"); } ExamLocation examLocation = null; if(ExamModeEnum.OFFLINE.equals(examRoom.getExamMode())){ examLocation = examLocationDao.get(examRoom.getExamLocationId()); if(Objects.isNull(examLocation)){ throw new BizException("考点信息错误"); } } List studentsWithExamRoom = examRoomStudentRelationDao.findStudentsWithExamRoom(examRoomId); Set existRegistIds = studentsWithExamRoom.stream().map(ExamRoomStudentRelation::getExamRegistrationId).collect(Collectors.toSet()); Set existStudentIds = studentsWithExamRoom.stream().map(ExamRoomStudentRelation::getStudentId).collect(Collectors.toSet()); String[] registIds = registIdsStr.split(","); List examRegistrations = examRegistrationDao.getRegists(Arrays.asList(registIds).stream().map(e -> Long.valueOf(e)).collect(Collectors.toList())); Map studentRegistMap = examRegistrations.stream().collect(Collectors.toMap(ExamRegistration::getId, e -> e)); Set studentIds = examRegistrations.stream().map(ExamRegistration::getStudentId).collect(Collectors.toSet()); if(studentIds.size()!=registIds.length){ throw new BizException("学员重复"); } List examRoomStudentRelations=new ArrayList<>(); for (String registId : registIds) { if(existRegistIds.contains(Long.valueOf(registId))){ continue; } ExamRegistration examRegistration = studentRegistMap.get(Integer.valueOf(registId)); if(Objects.isNull(examRegistration)){ throw new BizException("学员信息错误"); } if(existStudentIds.contains(examRegistration.getStudentId())){ throw new BizException("学员重复"); } ExamRoomStudentRelation e=new ExamRoomStudentRelation(); e.setExamRegistrationId(Long.valueOf(registId)); e.setExaminationBasicId(examRoom.getExaminationBasicId()); e.setExamRoomId(examRoom.getId()); e.setStudentId(examRegistration.getStudentId()); e.setTenantId(TenantContextHolder.getTenantId()); examRoomStudentRelations.add(e); } if(!CollectionUtils.isEmpty(examRoomStudentRelations)){ examRoomStudentRelationDao.batchInsert(examRoomStudentRelations); examTeacherSalaryService.teacherSalarySettlementWithExam(examRoom.getExaminationBasicId()); examRoom.setExamRoomStudentNum(examRoomStudentRelationDao.countStudentsWithRoom(examRoom.getId())); examRoomDao.update(examRoom); } } @Override @Transactional(rollbackFor = Exception.class) public void changeStudentExamRoom(Long registId, Long examRoomId, Integer organId) { if(Objects.isNull(registId)){ throw new BizException("请指定报名信息"); } if(Objects.isNull(examRoomId)){ throw new BizException("请指定新考场"); } ExamRegistration examRegistration = examRegistrationDao.get(registId); if(Objects.isNull(examRegistration)){ throw new BizException("学员报名信息不存在"); } ExamRoom examRoom = examRoomDao.get(examRoomId); if(Objects.isNull(examRoom)){ throw new BizException("考场信息不存在"); } List studentsWithExamRoom = examRoomStudentRelationDao.findStudentsWithExamRoom(examRoomId); Set existRegistIds = studentsWithExamRoom.stream().map(ExamRoomStudentRelation::getExamRegistrationId).collect(Collectors.toSet()); Set existStudentIds = studentsWithExamRoom.stream().map(ExamRoomStudentRelation::getStudentId).collect(Collectors.toSet()); if(existRegistIds.contains(Long.valueOf(registId))){ throw new BizException("学员重复"); } if(existStudentIds.contains(examRegistration.getStudentId())){ throw new BizException("学员重复"); } ExamOrganizationRelation examOrganizationRelation = examOrganizationRelationDao.getExamOrganizationRelation(examRoom.getExaminationBasicId(), organId); if(Objects.isNull(examOrganizationRelation)||examOrganizationRelation.getIsAllowArrangeExam()==0){ throw new BizException("无权操作"); } ExamRoomStudentRelation studentExamRoom = examRoomStudentRelationDao.getStudentExamRoom(registId); if(Objects.isNull(studentExamRoom)){ studentExamRoom=new ExamRoomStudentRelation(); studentExamRoom.setExaminationBasicId(examRegistration.getExaminationBasicId()); studentExamRoom.setExamRoomId(examRoomId); studentExamRoom.setExamRegistrationId(examRegistration.getId().longValue()); studentExamRoom.setStudentId(examRegistration.getStudentId()); studentExamRoom.setClassroomSwitch(0); examRoomStudentRelationDao.insert(studentExamRoom); return; } studentExamRoom.setExamRoomId(examRoomId); examRoomStudentRelationDao.update(studentExamRoom); examRoom.setExamRoomStudentNum(examRoomStudentRelationDao.countStudentsWithRoom(examRoom.getId())); examRoomDao.update(examRoom); } @Override public PageInfo findExamRoomStudents(ExamRoomStudentRelationQueryInfo queryInfo) { if(Objects.nonNull(queryInfo.getInRoom())&&Objects.isNull(queryInfo.getExamRoomId())){ throw new BizException("请指定考场"); } PageInfo pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows()); Map params = new HashMap(); MapUtil.populateMap(params, queryInfo); if(Objects.nonNull(queryInfo.getExamRoomId())){ ExamRoom examRoom = examRoomDao.get(queryInfo.getExamRoomId()); if(Objects.isNull(examRoom)){ throw new BizException("考场不存在"); } if(!examRoom.getExaminationBasicId().equals(queryInfo.getExamId())){ throw new BizException("考场信息异常"); } params.put("subjectIds", examRoom.getSubjectIdList()); } List nextLevelOrganIds = organizationService.getChildOrganIds(queryInfo.getOrganId(), true); params.put("organIds", nextLevelOrganIds); List dataList = new ArrayList<>(); int count = examRoomStudentRelationDao.countExamRoomStudents(params); if (count > 0) { pageInfo.setTotal(count); params.put("offset", pageInfo.getOffset()); dataList = examRoomStudentRelationDao.findExamRoomStudents(params); List studentIds = dataList.stream().map(e->e.getExamRegistration().getStudentId()).collect(Collectors.toList()); List subjectIds = dataList.stream().map(e->e.getExamRegistration().getSubjectId()).collect(Collectors.toList()); Map studentIdNameMap = this.getMap("sys_user", "id_", "real_name_", studentIds, Integer.class, String.class); Map subjectIdNameMap = this.getMap("subject", "id_", "name_", subjectIds, Integer.class, String.class); for (ExamRoomStudentRelationDto e : dataList) { e.setStudentInfo(new SysUser(e.getStudentId(),studentIdNameMap.get(e.getExamRegistration().getStudentId()))); e.setSubject(new Subject(e.getExamRegistration().getSubjectId(), subjectIdNameMap.get(e.getExamRegistration().getSubjectId()))); } } pageInfo.setRows(dataList); return pageInfo; } @Override @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED) public void deleteStudentFromRoom(Long examRoomId, String registIdsStr, Integer organId) { if(Objects.isNull(examRoomId)){ throw new BizException("请指定教室"); } ExamRoom examRoom = examRoomDao.lockRoom(examRoomId); if(Objects.isNull(examRoom)){ throw new BizException("教室不存在"); } if(examRoom.getExamPlanPushFlag()==1){ throw new BizException("无法删除学员"); } ExamOrganizationRelation examOrganizationRelation = examOrganizationRelationDao.getExamOrganizationRelation(examRoom.getExaminationBasicId(), organId); if(Objects.isNull(examOrganizationRelation)||examOrganizationRelation.getIsAllowArrangeExam()==0){ throw new BizException("无权操作"); } if(StringUtils.isBlank(registIdsStr)){ return; } examRoom.setExamRoomStudentNum(examRoomStudentRelationDao.countStudentsWithRoom(examRoom.getId())); examRoomDao.update(examRoom); examTeacherSalaryService.teacherSalarySettlementWithExam(examRoom.getExaminationBasicId()); } @Override public ExamRoomStudentRelation getExamRoomStudentRelation(Long registrationId) { return examRoomStudentRelationDao.getStudentExamRoom(registrationId); } @Override @Transactional(rollbackFor = Exception.class) public void recorded(Long roomId) { List roomStudentListDtos = examRoomStudentRelationDao.queryStudentList(roomId); if(roomStudentListDtos != null && roomStudentListDtos.size() > 0){ SysUser sysUser = sysUserFeignService.queryUserInfo(); RoomStudentListDto roomStudentListDto = roomStudentListDtos.get(0); if(roomStudentListDto.getFinishedExam() != 0){ throw new BizException("操作失败:当前学员状态不支持录播"); } ExamRoomStudentRelation examRoomStudentRelation = examRoomStudentRelationDao.get(roomStudentListDto.getExamRoomStudentRelationId()); //修改学员考试状态 StudentExamResult studentExamResult = studentExamResultDao.findByRegistrationId(examRoomStudentRelation.getExamRegistrationId()); studentExamResult.setRecordFlag(1); studentExamResult.setIsFinishedExam(4); studentExamResultDao.update(studentExamResult); //关闭学员房间入口 examRoomStudentRelation.setClassroomSwitch(0); examRoomStudentRelationDao.update(examRoomStudentRelation); publishMessage(examRoomStudentRelation,MemberChangedMessage.Action_Recorded,true,sysUser.getId()); if(roomStudentListDtos.size() > 1){ RoomStudentListDto roomStudentListDto1 = roomStudentListDtos.get(1); if(roomStudentListDto1.getFinishedExam() == 2){ nextStudent(roomStudentListDto1.getExamRoomStudentRelationId(),false,sysUser.getId()); } } //将当前学员退踢出教室 // imFeignService.kickRoom(new ReqUserData(examRoomStudentRelation.getExamRegistrationId(),roomStudentListDto.getStudentId().toString())); } } @Override @Transactional(rollbackFor = Exception.class) public NeedCheckingDetailDto stuRecorded(Long examRegistrationId) { //修改考试状态为录播 /*StudentExamResult studentExamResult = studentExamResultDao.findByRegistrationId(examRegistrationId); studentExamResult.setRecordFlag(1); studentExamResult.setRecordStartTime(new Date()); studentExamResultDao.update(studentExamResult);*/ //返回详情数据 return examCertificationService.needCheckingDetail(examRegistrationId); } @Override @Transactional(rollbackFor = Exception.class) public NeedCheckingDetailDto againQueue(Long examRegistrationId) { //清除排队状态 examRoomStudentRelationDao.cleanSignInTime(examRegistrationId); //返回详情数据 return examCertificationService.needCheckingDetail(examRegistrationId); } @Override public List findStudentsWithExamRooms(List examRoomIds) { return examRoomStudentRelationDao.findStudentsWithExamRooms(examRoomIds); } @Override public void deleteWithExamRooms(List examRoomIds) { examRoomStudentRelationDao.deleteWithExamRooms(examRoomIds); } @Override public String getStudentIds(Long examRoomId) { return examRoomStudentRelationDao.getStudentIds(examRoomId); } @Override public List> getStuRegistrationMap(Long examRoomId) { return examRoomStudentRelationDao.getStuRegistrationMap(examRoomId); } @Override @Transactional(rollbackFor = Exception.class) public StuRecordDetailDto stuRecordDetail(Long examRegistrationId) { StudentExamResult studentExamResult = studentExamResultDao.findByRegistrationId(examRegistrationId); //当前学员是否完成考试 if(studentExamResult.getIsFinishedExam() != 4){ throw new BizException("操作失败:当前状态不允许录播"); } //是否允许录播 if(studentExamResult.getRecordStartTime() == null){ if(studentExamResult.getRecordFlag() == 0){ studentExamResult.setRecordFlag(1); studentExamResult.setRecordStartTime(new Date()); studentExamResultDao.update(studentExamResult); }else { studentExamResult.setRecordStartTime(new Date()); studentExamResultDao.update(studentExamResult); } } StuRecordDetailDto stuRecordDetailDto = examRegistrationDao.getStuRecordDetail(examRegistrationId); int recordMinutes = Integer.parseInt(sysConfigService.findByParamName("record_minutes").getParanValue()); Date date = DateUtil.addMinutes(stuRecordDetailDto.getRecordStartTime(),recordMinutes); stuRecordDetailDto.setExamEndTime(date); int secondsBetween = DateUtil.secondsBetween(new Date(),date); if(secondsBetween <= 0){ throw new BizException("操作失败:录制超时"); } stuRecordDetailDto.setSubTime(secondsBetween); stuRecordDetailDto.setRecordTime(recordMinutes); stuRecordDetailDto.setExamRegistrationId(examRegistrationId); stuRecordDetailDto.setSongJson(StringEscapeUtils.unescapeJavaScript(stuRecordDetailDto.getSongJson())); stuRecordDetailDto.setSingleSongRecordMinutes(Integer.parseInt(sysConfigService.findByParamName("single_song_record_minutes").getParanValue())); return stuRecordDetailDto; } @Override @Transactional(rollbackFor = Exception.class) public void stuEndRecord(Long examRegistrationId, String videoUrl) { StudentExamResult studentExamResult = studentExamResultDao.findByRegistrationId(examRegistrationId); //当前学员是否完成考试 if(studentExamResult.getIsFinishedExam() != 4){ throw new BizException("提交失败:当前考试状态不允许录播"); } studentExamResult.setVideoUrl(videoUrl); studentExamResult.setIsFinishedExam(5); studentExamResultDao.update(studentExamResult); ExamRoomStudentRelation roomStudentRelation = examRoomStudentRelationDao.getStudentExamRoom(examRegistrationId); publishMessage(roomStudentRelation,MemberChangedMessage.Student_Queue,true,studentExamResult.getStudentId()); } @Override @Transactional(rollbackFor = Exception.class) public void actionExam(Long roomId) { ExamRoom examRoom = examRoomDao.get(roomId); if(examRoom.getExamFlag() == 1){ throw new BizException("考试已开启,请勿重复操作"); } examRoom.setExamFlag(1); examRoomDao.update(examRoom); nextBit(null,roomId); } @Override public Integer countSignInNum(Long examRoomId) { return examRoomStudentRelationDao.countSignInNum(examRoomId); } @Override public ExamRoomStudentRelation getStudentExamRoom(Long examRegistrationId) { return examRoomStudentRelationDao.getStudentExamRoom(examRegistrationId); } @Override @Transactional(rollbackFor = Exception.class) public void nextBit(Integer examStatus,Long examRoomId) { List roomStudentListDtos = examRoomStudentRelationDao.queryStudentList(examRoomId); if(roomStudentListDtos != null && roomStudentListDtos.size() > 0){ RoomStudentListDto roomStudentListDto = roomStudentListDtos.get(0); SysUser sysUser = sysUserFeignService.queryUserInfo(); if(roomStudentListDto.getFinishedExam() == 0 || roomStudentListDto.getFinishedExam() == 1){ //考试中 currentStudent(roomStudentListDto.getExamRoomStudentRelationId(),true,examStatus,sysUser.getId()); if(roomStudentListDtos.size() > 1){ RoomStudentListDto roomStudentListDto1 = roomStudentListDtos.get(1); if(roomStudentListDto1.getFinishedExam() == 2){ nextStudent(roomStudentListDto1.getExamRoomStudentRelationId(),false,sysUser.getId()); } } }else if(roomStudentListDto.getFinishedExam() == 2){ //未开始 nextStudent(roomStudentListDto.getExamRoomStudentRelationId(),true,sysUser.getId()); }else { throw new BizException("操作失败:没有待考学员"); } } } private void currentStudent(Long examRoomStudentRelationId,Boolean isPush,Integer examStatus,Integer operator){ ExamRoomStudentRelation examRoomStudentRelation = examRoomStudentRelationDao.get(examRoomStudentRelationId); //将当前学员退出教室并添加参考状态,如果考试未完成,清除签到时间,重新签到 imFeignService.kickRoom(new ReqUserData(examRoomStudentRelation.getExamRegistrationId(),examRoomStudentRelation.getStudentId().toString())); if(examStatus != null && examStatus == 0){ //未完成 examRoomStudentRelationDao.cleanSignInTime(examRoomStudentRelation.getExamRegistrationId()); studentExamResultDao.updateFinishedExam(examRoomStudentRelation.getExamRegistrationId(),3); }else { //结束考试 studentExamResultDao.updateFinishedExam(examRoomStudentRelation.getExamRegistrationId(),5); } //关闭学员房间入口 examRoomStudentRelation.setClassroomSwitch(0); examRoomStudentRelationDao.update(examRoomStudentRelation); publishMessage(examRoomStudentRelation,MemberChangedMessage.Student_Queue,isPush,operator); } private void nextStudent(Long nextExamRoomStudentRelationId,Boolean isPush,Integer operator){ ExamRoomStudentRelation examRoomStudentRelation = examRoomStudentRelationDao.get(nextExamRoomStudentRelationId); //开启学员房间入口 examRoomStudentRelation.setClassroomSwitch(1); examRoomStudentRelationDao.update(examRoomStudentRelation); //状态变更为呼叫中 studentExamResultDao.updateFinishedExam(examRoomStudentRelation.getExamRegistrationId(),1); publishMessage(examRoomStudentRelation,MemberChangedMessage.Student_Queue,isPush,operator); } @Override public void publishMessage(ExamRoomStudentRelation examRoomStudentRelation,Integer action,Boolean isPush,Integer operator){ if (!isPush){ return; } PublishMessageDto publishMessageDto = new PublishMessageDto(); publishMessageDto.setUserId(operator.toString()); publishMessageDto.setRoomId(examRoomStudentRelation.getExamRoomId().toString()); MemberChangedMessage msg = new MemberChangedMessage(action, examRoomStudentRelation.getStudentId().toString(),3); /*if(action == 3 || action == 4){ msg = new MemberChangedMessage(action, examRoomStudentRelation.getStudentId().toString(),3); }else { msg = new MemberChangedMessage(action, examRoomStudentRelation.getStudentId(),3); }*/ // String jsonString = JSONObject.toJSONString(examCertificationService.needCheckingDetail(examRoomStudentRelation.getExamRegistrationId())); NeedCheckingDetailDto needCheckingDetailDto = examCertificationService.needCheckingDetail(examRoomStudentRelation.getExamRegistrationId()); msg.setWaitNum(needCheckingDetailDto.getWaitNum()); msg.setClassroomSwitch(needCheckingDetailDto.getClassroomSwitch()); msg.setOpenFlag(needCheckingDetailDto.getOpenFlag()); // msg.setAppParamJson(jsonString); Map paramMap = new HashMap<>(2); paramMap.put("studentQueue",this.queryNeedCheckingList(examRoomStudentRelation.getExamRoomId())); paramMap.put("examCertification",examCertificationService.findDetailByStudentId(examRoomStudentRelation.getExamRegistrationId())); msg.setWebParamJson(JSONObject.toJSONString(paramMap)); publishMessageDto.setMemberChangedMessage(msg); imFeignService.publishMessage(publishMessageDto); } public PublishMessageDto getPublishMessage(Long examRegistrationId){ SysUser sysUser = sysUserFeignService.queryUserInfo(); ExamRoomStudentRelation examRoomStudentRelation = examRoomStudentRelationDao.getStudentExamRoom(examRegistrationId); PublishMessageDto publishMessageDto = new PublishMessageDto(); String userId = sysUser.getId().toString(); publishMessageDto.setUserId(userId); publishMessageDto.setRoomId(examRoomStudentRelation.getExamRoomId().toString()); MemberChangedMessage msg = new MemberChangedMessage(MemberChangedMessage.Student_Queue, examRoomStudentRelation.getStudentId().toString(),3); // String jsonString = JSONObject.toJSONString(examCertificationService.needCheckingDetail(examRoomStudentRelation.getExamRegistrationId())); // msg.setAppParamJson(jsonString); NeedCheckingDetailDto needCheckingDetailDto = examCertificationService.needCheckingDetail(examRoomStudentRelation.getExamRegistrationId()); msg.setWaitNum(needCheckingDetailDto.getWaitNum()); msg.setClassroomSwitch(needCheckingDetailDto.getClassroomSwitch()); msg.setOpenFlag(needCheckingDetailDto.getOpenFlag()); Map paramMap = new HashMap<>(2); this.queryNeedCheckingList(examRoomStudentRelation.getExamRoomId()); paramMap.put("studentQueue",this.queryNeedCheckingList(examRoomStudentRelation.getExamRoomId())); paramMap.put("examCertification",examCertificationService.findDetailByStudentId(examRoomStudentRelation.getExamRegistrationId())); msg.setWebParamJson(JSONObject.toJSONString(paramMap)); publishMessageDto.setMemberChangedMessage(msg); return publishMessageDto; } @Override public List queryStudentList(Long roomId) { return examRoomStudentRelationDao.queryStudentList(roomId); } @Override public Map queryNeedCheckingList(Long roomId) { List roomStudentListDtos = examRoomStudentRelationDao.queryStudentList(roomId); Map resultMap = new HashMap<>(4); resultMap.put("studentList",roomStudentListDtos); resultMap.put("signTotalNum",examRoomStudentRelationDao.querySignTotalNum(roomId)); resultMap.put("noSignTotalNum",examRoomStudentRelationDao.queryNoSignTotalNum(roomId)); resultMap.put("surplusNum",examRoomStudentRelationDao.querySurplusNum(roomId)); return resultMap; } @Override @Transactional(rollbackFor = Exception.class) public synchronized void signIn(Long examRegistrationId) { ExamRoomStudentRelation studentExamRoom = examRoomStudentRelationDao.getStudentExamRoom(examRegistrationId); if(studentExamRoom.getSignInTime() != null){ throw new BizException("您已签到,请勿重复操作!"); } studentExamRoom.setSignInTime(new Date()); examRoomStudentRelationDao.update(studentExamRoom); SysUser sysUser = sysUserFeignService.queryUserInfo(); PublishMessageDto publishMessageDto = new PublishMessageDto(); String userId = sysUser.getId().toString(); publishMessageDto.setUserId(userId); publishMessageDto.setRoomId(studentExamRoom.getExamRoomId().toString()); MemberChangedMessage msg = new MemberChangedMessage(MemberChangedMessage.Student_Queue, userId,3); // String jsonString = JSONObject.toJSONString(examCertificationService.needCheckingDetail(examRegistrationId)); NeedCheckingDetailDto needCheckingDetailDto = examCertificationService.needCheckingDetail(examRegistrationId); // msg.setAppParamJson(needCheckingDetailDto.getWaitNum()); msg.setWaitNum(needCheckingDetailDto.getWaitNum()); msg.setClassroomSwitch(0); msg.setOpenFlag(needCheckingDetailDto.getOpenFlag()); publishMessageDto.setMemberChangedMessage(msg); //修改签到状态 studentExamResultDao.updateFinishedExam(examRegistrationId,2); imFeignService.publishMessage(publishMessageDto); } }