|  | @@ -166,13 +166,7 @@ public class RealExamService {
 | 
											
												
													
														|  |       * @param state
 |  |       * @param state
 | 
											
												
													
														|  |       * @return
 |  |       * @return
 | 
											
												
													
														|  |       */
 |  |       */
 | 
											
												
													
														|  | -    @Transactional
 |  | 
 | 
											
												
													
														|  |      public int updateOneState(long examId, final String state) {
 |  |      public int updateOneState(long examId, final String state) {
 | 
											
												
													
														|  | -        if (false) {
 |  | 
 | 
											
												
													
														|  | -            // php项目维护exam_status字段。java这边不操作。
 |  | 
 | 
											
												
													
														|  | -            // 屏蔽
 |  | 
 | 
											
												
													
														|  | -            return 0;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  |          RealExam q = selectRealExamByExamId(examId);
 |  |          RealExam q = selectRealExamByExamId(examId);
 | 
											
												
													
														|  |          // todo:屏蔽
 |  |          // todo:屏蔽
 | 
											
												
													
														|  |          if (false && RealExam.State.SUBMITTED.equals(state)) {
 |  |          if (false && RealExam.State.SUBMITTED.equals(state)) {
 | 
											
										
											
												
													
														|  | @@ -298,10 +292,6 @@ public class RealExamService {
 | 
											
												
													
														|  |       * @return
 |  |       * @return
 | 
											
												
													
														|  |       */
 |  |       */
 | 
											
												
													
														|  |      public AjaxResult studentStartRealExam(final Long examId, final String studentBindIp, final String examCollectionType) {
 |  |      public AjaxResult studentStartRealExam(final Long examId, final String studentBindIp, final String examCollectionType) {
 | 
											
												
													
														|  | -        // todo: 暂时没有解决方案 检查 考试的sim和seat,是否正确对应。
 |  | 
 | 
											
												
													
														|  | -        // Step :检查参数studentBindIp有效性
 |  | 
 | 
											
												
													
														|  | -        // Step :检查参数examCollectionType有效性
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |          // Check:检查参数examId有效性
 |  |          // Check:检查参数examId有效性
 | 
											
												
													
														|  |          {
 |  |          {
 | 
											
												
													
														|  |              AjaxResult ar = checkExamId(examId);
 |  |              AjaxResult ar = checkExamId(examId);
 | 
											
										
											
												
													
														|  | @@ -309,36 +299,36 @@ public class RealExamService {
 | 
											
												
													
														|  |                  return ar;
 |  |                  return ar;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        // Check:检查studentBindIp有效性
 |  | 
 | 
											
												
													
														|  | 
 |  | +        RealExam re = selectRealExamByExamId(examId);
 | 
											
												
													
														|  | 
 |  | +        RealExamCollection rec = realExamCollectionService.selectRealExamCollectionByExamCollectionId(re.getExamCollectionId());
 | 
											
												
													
														|  | 
 |  | +        // Check:检查参数studentBindIp有效性
 | 
											
												
													
														|  |          if (StringUtils.isBlank(studentBindIp)) {
 |  |          if (StringUtils.isBlank(studentBindIp)) {
 | 
											
												
													
														|  |              return AjaxResult.error("IP地址无效");
 |  |              return AjaxResult.error("IP地址无效");
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        // todo:examCollectionType 类型对应
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        RealExam re = selectRealExamByExamId(examId);
 |  | 
 | 
											
												
													
														|  |          Seat seat = seatService.uniqueByBindIp(studentBindIp);
 |  |          Seat seat = seatService.uniqueByBindIp(studentBindIp);
 | 
											
												
													
														|  | 
 |  | +        if (seat == null) {
 | 
											
												
													
														|  | 
 |  | +            return AjaxResult.error("没有IP对应座次数据!");
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        // Check:检查参数examCollectionType有效性
 | 
											
												
													
														|  | 
 |  | +        if (!StringUtils.equals(examCollectionType, rec.getExamCollectionType())) {
 | 
											
												
													
														|  | 
 |  | +            return AjaxResult.error("考试集合类型不对应!");
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        // Check:ping通 路由器。
 | 
											
												
													
														|  |          {
 |  |          {
 | 
											
												
													
														|  | -            if (seat == null) {
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -                throw new IllegalArgumentException("XXX");
 |  | 
 | 
											
												
													
														|  | 
 |  | +            AjaxResult ar = commCheckService.checkRouterState(simConfig.getRouterIp());
 | 
											
												
													
														|  | 
 |  | +            if (ar.isError()) {
 | 
											
												
													
														|  | 
 |  | +                return ar;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        // Step :ping通 路由器。
 |  | 
 | 
											
												
													
														|  | 
 |  | +        // Check:ping通 学员端电脑。
 | 
											
												
													
														|  |          if (false) {
 |  |          if (false) {
 | 
											
												
													
														|  | -            AjaxResult ar = commCheckService.checkRouterState(simConfig.getRouterIp());
 |  | 
 | 
											
												
													
														|  | 
 |  | +            AjaxResult ar = commCheckService.checkPingStudentPcState(studentBindIp);
 | 
											
												
													
														|  |              if (ar.isError()) {
 |  |              if (ar.isError()) {
 | 
											
												
													
														|  |                  return ar;
 |  |                  return ar;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        // Step :ping通 学员端电脑。
 |  | 
 | 
											
												
													
														|  | 
 |  | +        // Check:ping通 RS485。
 | 
											
												
													
														|  |          {
 |  |          {
 | 
											
												
													
														|  | -//            AjaxResult ar = commCheckService.checkPingStudentPcState(studentBindIp);
 |  | 
 | 
											
												
													
														|  | -//            if (ar.isError()) {
 |  | 
 | 
											
												
													
														|  | -//                return ar;
 |  | 
 | 
											
												
													
														|  | -//            }
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -        // Step :ping通 RS485。
 |  | 
 | 
											
												
													
														|  | -        if (false) {
 |  | 
 | 
											
												
													
														|  |              AjaxResult ar = commCheckService.checkPingRs485State(seat.getSeatRs485Ip());
 |  |              AjaxResult ar = commCheckService.checkPingRs485State(seat.getSeatRs485Ip());
 | 
											
												
													
														|  |              if (ar.isError()) {
 |  |              if (ar.isError()) {
 | 
											
												
													
														|  |                  // todo:重复
 |  |                  // todo:重复
 | 
											
										
											
												
													
														|  | @@ -351,21 +341,21 @@ public class RealExamService {
 | 
											
												
													
														|  |                  // Ping通不代表在线,Socket连接建立表示在线。
 |  |                  // Ping通不代表在线,Socket连接建立表示在线。
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        // Step :如果有缓存Socket并且可用,使用缓存Socket,检查并建立Socket连接;否则返回对应错误。
 |  | 
 | 
											
												
													
														|  | 
 |  | +        // Check:如果有缓存Socket并且可用,使用缓存Socket,检查并建立Socket连接;否则返回对应错误。
 | 
											
												
													
														|  |          {
 |  |          {
 | 
											
												
													
														|  |              AjaxResult ar = socketService.openOne(seat.toSimSocketParamVo(), true);
 |  |              AjaxResult ar = socketService.openOne(seat.toSimSocketParamVo(), true);
 | 
											
												
													
														|  |              if (ar.isError()) {
 |  |              if (ar.isError()) {
 | 
											
												
													
														|  |                  return ar;
 |  |                  return ar;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        // Step :发送通用询问指令,询问是连接的哪种型号的哪一台模拟器;否则返回对应错误。
 |  | 
 | 
											
												
													
														|  | 
 |  | +        // Check:发送通用询问指令,询问是连接的哪种型号的哪一台模拟器;否则返回对应错误。
 | 
											
												
													
														|  |          {
 |  |          {
 | 
											
												
													
														|  |              AjaxResult ar = commCheckService.checkOneSeatState(seat, true);
 |  |              AjaxResult ar = commCheckService.checkOneSeatState(seat, true);
 | 
											
												
													
														|  |              if (ar.isError()) {
 |  |              if (ar.isError()) {
 | 
											
												
													
														|  |                  return ar;
 |  |                  return ar;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        // 重新查询。已经确定simId了。
 |  | 
 | 
											
												
													
														|  | 
 |  | +        // Step:重新查询。已经确定simId和simState了。
 | 
											
												
													
														|  |          {
 |  |          {
 | 
											
												
													
														|  |              // 修改exam表对应examId的一条数据,填充并锁定seat_id和sim_id值。
 |  |              // 修改exam表对应examId的一条数据,填充并锁定seat_id和sim_id值。
 | 
											
												
													
														|  |              // 设置上seatId和simId
 |  |              // 设置上seatId和simId
 | 
											
										
											
												
													
														|  | @@ -373,10 +363,9 @@ public class RealExamService {
 | 
											
												
													
														|  |              seat = seatService.uniqueByBindIp(studentBindIp);
 |  |              seat = seatService.uniqueByBindIp(studentBindIp);
 | 
											
												
													
														|  |              re.setSeatId(seat.getSeatId());
 |  |              re.setSeatId(seat.getSeatId());
 | 
											
												
													
														|  |              re.setSimId(seat.getCurrentSimId());
 |  |              re.setSimId(seat.getCurrentSimId());
 | 
											
												
													
														|  | -            l.debug("re = {}", re);
 |  | 
 | 
											
												
													
														|  |              updateRealExam(re);
 |  |              updateRealExam(re);
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        // 查询模拟器在线状态,纯DB查询。
 |  | 
 | 
											
												
													
														|  | 
 |  | +        // Step:查询模拟器在线状态,纯DB查询。
 | 
											
												
													
														|  |          {
 |  |          {
 | 
											
												
													
														|  |              AjaxResult ar = commCheckService.checkOneSimOnlineState(seat.getCurrentSimId());
 |  |              AjaxResult ar = commCheckService.checkOneSimOnlineState(seat.getCurrentSimId());
 | 
											
												
													
														|  |              if (ar.isError()) {
 |  |              if (ar.isError()) {
 | 
											
										
											
												
													
														|  | @@ -384,7 +373,7 @@ public class RealExamService {
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          Sim sim = simService.selectSimBySimId(re.getSimId());
 |  |          Sim sim = simService.selectSimBySimId(re.getSimId());
 | 
											
												
													
														|  | -        // 检查模拟器类型
 |  | 
 | 
											
												
													
														|  | 
 |  | +        // Check:检查模拟器类型
 | 
											
												
													
														|  |          final String targetSimType = re.getSimType();
 |  |          final String targetSimType = re.getSimType();
 | 
											
												
													
														|  |          {
 |  |          {
 | 
											
												
													
														|  |              AjaxResult ar = commCheckService.checkOneSimType(seat, true, targetSimType);
 |  |              AjaxResult ar = commCheckService.checkOneSimType(seat, true, targetSimType);
 | 
											
										
											
												
													
														|  | @@ -392,34 +381,28 @@ public class RealExamService {
 | 
											
												
													
														|  |                  return ar;
 |  |                  return ar;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        // Step 5:
 |  | 
 | 
											
												
													
														|  | -        {
 |  | 
 | 
											
												
													
														|  | -//            AjaxResult arE3 = commSendService.checkOneSimStateActive(seat);
 |  | 
 | 
											
												
													
														|  | -//            if (arE3.isError()) {
 |  | 
 | 
											
												
													
														|  | -//                return arE3;
 |  | 
 | 
											
												
													
														|  | -//            }
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -        // Step :可换件检查,读取对应一台模拟器 所有故障部位值。检查模拟器所有的 真实的 故障部位 是否异常 或者 空值。特殊的故障部位要单独判断。
 |  | 
 | 
											
												
													
														|  | 
 |  | +        // Step:可换件检查,读取对应一台模拟器 所有故障部位值。
 | 
											
												
													
														|  | 
 |  | +        //      检查模拟器所有的 真实的 故障部位 是否异常 或者 空值。特殊的故障部位要单独判断。
 | 
											
												
													
														|  |          if (SimDebugConfig.CHECK_REPLACE_EMPTY) {
 |  |          if (SimDebugConfig.CHECK_REPLACE_EMPTY) {
 | 
											
												
													
														|  |              AjaxResult ar = commSendService.readOneSimAllFaultCheck(seat, sim);
 |  |              AjaxResult ar = commSendService.readOneSimAllFaultCheck(seat, sim);
 | 
											
												
													
														|  |              if (ar.isError()) {
 |  |              if (ar.isError()) {
 | 
											
												
													
														|  |                  return ar;
 |  |                  return ar;
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        // Step :清除对应一台模拟器 所有 真实的 故障部位故障。
 |  | 
 | 
											
												
													
														|  | 
 |  | +        // Step:清除对应一台模拟器 所有 真实的 故障部位故障。
 | 
											
												
													
														|  |          {
 |  |          {
 | 
											
												
													
														|  |              commSendService.clearOneSimAllFaultByExam(re);
 |  |              commSendService.clearOneSimAllFaultByExam(re);
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        // Step :下发对应一台模拟器 出题选中的 故障位置故障。
 |  | 
 | 
											
												
													
														|  | 
 |  | +        // Step:下发对应一台模拟器 出题选中的 故障位置故障。
 | 
											
												
													
														|  |          {
 |  |          {
 | 
											
												
													
														|  |              commSendService.writeOneSimAllSelectFaultByExam(re);
 |  |              commSendService.writeOneSimAllSelectFaultByExam(re);
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        // Step :读取对应一台模拟器 所有的 真实的 故障部位 电阻值代表值 作为出题值。
 |  | 
 | 
											
												
													
														|  | -        // 修改关联状态
 |  | 
 | 
											
												
													
														|  | 
 |  | +        // Step:读取对应一台模拟器 所有的 真实的 故障部位 电阻值代表值 作为出题值。
 | 
											
												
													
														|  |          {
 |  |          {
 | 
											
												
													
														|  |              commSendService.readOneSimAllFaultFirstTimeByExam(re);
 |  |              commSendService.readOneSimAllFaultFirstTimeByExam(re);
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | -        // Step :修改当前exam_id考试数据的状态。
 |  | 
 | 
											
												
													
														|  | 
 |  | +        // Step:修改当前exam_id的考试状态。
 | 
											
												
													
														|  | 
 |  | +        // 修改关联状态
 | 
											
												
													
														|  |          if (realExamFaultService.isType2ExamPrepareStartOk(re.getExamId())) {
 |  |          if (realExamFaultService.isType2ExamPrepareStartOk(re.getExamId())) {
 | 
											
												
													
														|  |              updateOneState(re.getExamId(), RealExam.State.SIM_PREPARE_OK);
 |  |              updateOneState(re.getExamId(), RealExam.State.SIM_PREPARE_OK);
 | 
											
												
													
														|  |              updateOneState(re.getExamId(), RealExam.State.ANSWERING);
 |  |              updateOneState(re.getExamId(), RealExam.State.ANSWERING);
 | 
											
										
											
												
													
														|  | @@ -428,7 +411,7 @@ public class RealExamService {
 | 
											
												
													
														|  |              updateRealExam(re);
 |  |              updateRealExam(re);
 | 
											
												
													
														|  |              return AjaxResult.success("开始考试成功!");
 |  |              return AjaxResult.success("开始考试成功!");
 | 
											
												
													
														|  |          } else {
 |  |          } else {
 | 
											
												
													
														|  | -            return AjaxResult.error("连接超时,请检查模拟器连接!");
 |  | 
 | 
											
												
													
														|  | 
 |  | +            return AjaxResult.error("执行超时!");
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -453,7 +436,7 @@ public class RealExamService {
 | 
											
												
													
														|  |              return AjaxResult.success();
 |  |              return AjaxResult.success();
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | -    
 |  | 
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      /**
 |  |      /**
 | 
											
												
													
														|  |       * [轮询][学生]正在考试界面。
 |  |       * [轮询][学生]正在考试界面。
 | 
											
												
													
														|  |       *
 |  |       *
 |