|  | @@ -1,9 +1,6 @@
 | 
											
												
													
														|  |  package com.ruoyi.sim.service.impl;
 |  |  package com.ruoyi.sim.service.impl;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -import java.util.ArrayList;
 |  | 
 | 
											
												
													
														|  | -import java.util.Date;
 |  | 
 | 
											
												
													
														|  | -import java.util.List;
 |  | 
 | 
											
												
													
														|  | -import java.util.Objects;
 |  | 
 | 
											
												
													
														|  | 
 |  | +import java.util.*;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  import com.ruoyi.common.core.domain.AjaxResult;
 |  |  import com.ruoyi.common.core.domain.AjaxResult;
 | 
											
												
													
														|  |  import com.ruoyi.common.utils.DateUtils;
 |  |  import com.ruoyi.common.utils.DateUtils;
 | 
											
										
											
												
													
														|  | @@ -14,6 +11,7 @@ import com.ruoyi.sim.domain.vo.RealExamVo;
 | 
											
												
													
														|  |  import com.ruoyi.sim.domain.vo.StudentRealExamIngVo;
 |  |  import com.ruoyi.sim.domain.vo.StudentRealExamIngVo;
 | 
											
												
													
														|  |  import com.ruoyi.sim.domain.vo.StudentRealExamPostVo;
 |  |  import com.ruoyi.sim.domain.vo.StudentRealExamPostVo;
 | 
											
												
													
														|  |  import com.ruoyi.sim.domain.vo.StudentRealExamPreVo;
 |  |  import com.ruoyi.sim.domain.vo.StudentRealExamPreVo;
 | 
											
												
													
														|  | 
 |  | +import org.apache.commons.lang3.RandomUtils;
 | 
											
												
													
														|  |  import org.apache.commons.lang3.StringUtils;
 |  |  import org.apache.commons.lang3.StringUtils;
 | 
											
												
													
														|  |  import org.slf4j.Logger;
 |  |  import org.slf4j.Logger;
 | 
											
												
													
														|  |  import org.slf4j.LoggerFactory;
 |  |  import org.slf4j.LoggerFactory;
 | 
											
										
											
												
													
														|  | @@ -299,16 +297,22 @@ public class RealExamService {
 | 
											
												
													
														|  |              if (realExamCollectionService.existOpenedByType(RealExamCollection.Type.EXAM)) {
 |  |              if (realExamCollectionService.existOpenedByType(RealExamCollection.Type.EXAM)) {
 | 
											
												
													
														|  |                  return AjaxResult.error("存在打开的考试,无法开启训练!<br/>请向教员说明情况。");
 |  |                  return AjaxResult.error("存在打开的考试,无法开启训练!<br/>请向教员说明情况。");
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  | 
 |  | +        } else {
 | 
											
												
													
														|  | 
 |  | +            l.info("type EXERCISE,没有打开的考试,校验正确");
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          // Check:针对练习(自主练习),进行特殊检查。
 |  |          // Check:针对练习(自主练习),进行特殊检查。
 | 
											
												
													
														|  |          if (StringUtils.equals(RealExamCollection.Type.SELF_EXERCISE, examCollectionType)) {
 |  |          if (StringUtils.equals(RealExamCollection.Type.SELF_EXERCISE, examCollectionType)) {
 | 
											
												
													
														|  |              // 已经open的考试。
 |  |              // 已经open的考试。
 | 
											
												
													
														|  |              if (realExamCollectionService.existOpenedByType(RealExamCollection.Type.EXAM)) {
 |  |              if (realExamCollectionService.existOpenedByType(RealExamCollection.Type.EXAM)) {
 | 
											
												
													
														|  |                  return AjaxResult.error("存在打开的考试,无法开启练习!<br/>请向教员说明情况。");
 |  |                  return AjaxResult.error("存在打开的考试,无法开启练习!<br/>请向教员说明情况。");
 | 
											
												
													
														|  | 
 |  | +            } else {
 | 
											
												
													
														|  | 
 |  | +                l.info("type SELF_EXERCISE,没有打开的考试,校验正确");
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |              // 已经open的训练。
 |  |              // 已经open的训练。
 | 
											
												
													
														|  |              if (realExamCollectionService.existOpenedByType(RealExamCollection.Type.EXERCISE)) {
 |  |              if (realExamCollectionService.existOpenedByType(RealExamCollection.Type.EXERCISE)) {
 | 
											
												
													
														|  |                  return AjaxResult.error("存在打开的训练,无法开启练习!<br/>请向教员说明情况。");
 |  |                  return AjaxResult.error("存在打开的训练,无法开启练习!<br/>请向教员说明情况。");
 | 
											
												
													
														|  | 
 |  | +            } else {
 | 
											
												
													
														|  | 
 |  | +                l.info("type SELF_EXERCISE,没有打开的训练,校验正确");
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          // Check:检查参数examId有效性
 |  |          // Check:检查参数examId有效性
 | 
											
										
											
												
													
														|  | @@ -324,32 +328,46 @@ public class RealExamService {
 | 
											
												
													
														|  |                  StringUtils.equals(re.getExamStatus(), RealExam.State.CALCULATING_SCORE) ||
 |  |                  StringUtils.equals(re.getExamStatus(), RealExam.State.CALCULATING_SCORE) ||
 | 
											
												
													
														|  |                  StringUtils.equals(re.getExamStatus(), RealExam.State.GOT_REPORT)) {
 |  |                  StringUtils.equals(re.getExamStatus(), RealExam.State.GOT_REPORT)) {
 | 
											
												
													
														|  |              return AjaxResult.error("已经交卷,禁止重复开始考试!");
 |  |              return AjaxResult.error("已经交卷,禁止重复开始考试!");
 | 
											
												
													
														|  | 
 |  | +        } else {
 | 
											
												
													
														|  | 
 |  | +            l.info("没有重复交卷校验正确");
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          RealExamCollection rec = realExamCollectionService.selectRealExamCollectionByExamCollectionId(re.getExamCollectionId());
 |  |          RealExamCollection rec = realExamCollectionService.selectRealExamCollectionByExamCollectionId(re.getExamCollectionId());
 | 
											
												
													
														|  |          // Check:考试集合数据有效性。
 |  |          // Check:考试集合数据有效性。
 | 
											
												
													
														|  |          if (rec == null) {
 |  |          if (rec == null) {
 | 
											
												
													
														|  |              return AjaxResult.error("考试集合数据异常!");
 |  |              return AjaxResult.error("考试集合数据异常!");
 | 
											
												
													
														|  | 
 |  | +        } else {
 | 
											
												
													
														|  | 
 |  | +            l.info("考试集合数据校验正确");
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          if (!StringUtils.equals(rec.getExamCollectionState(), RealExamCollection.State.OPENED)) {
 |  |          if (!StringUtils.equals(rec.getExamCollectionState(), RealExamCollection.State.OPENED)) {
 | 
											
												
													
														|  |              return AjaxResult.error("教师端对应考试/训练尚未打开!<br/>请向教员说明情况。");
 |  |              return AjaxResult.error("教师端对应考试/训练尚未打开!<br/>请向教员说明情况。");
 | 
											
												
													
														|  | 
 |  | +        } else {
 | 
											
												
													
														|  | 
 |  | +            l.info("考试集合开启校验正确");
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          // Check:检查参数examCollectionType有效性
 |  |          // Check:检查参数examCollectionType有效性
 | 
											
												
													
														|  |          if (!StringUtils.equals(examCollectionType, rec.getExamCollectionType())) {
 |  |          if (!StringUtils.equals(examCollectionType, rec.getExamCollectionType())) {
 | 
											
												
													
														|  |              return AjaxResult.error("考试集合类型不对应!");
 |  |              return AjaxResult.error("考试集合类型不对应!");
 | 
											
												
													
														|  | 
 |  | +        } else {
 | 
											
												
													
														|  | 
 |  | +            l.info("考试集合类型校验正确");
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          // Check:检查参数studentBindIp有效性
 |  |          // Check:检查参数studentBindIp有效性
 | 
											
												
													
														|  |          if (StringUtils.isBlank(studentBindIp)) {
 |  |          if (StringUtils.isBlank(studentBindIp)) {
 | 
											
												
													
														|  |              return AjaxResult.error("IP地址无效");
 |  |              return AjaxResult.error("IP地址无效");
 | 
											
												
													
														|  | 
 |  | +        } else {
 | 
											
												
													
														|  | 
 |  | +            l.info("IP地址检验正确");
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          Seat seat = seatService.uniqueByBindIp(studentBindIp);
 |  |          Seat seat = seatService.uniqueByBindIp(studentBindIp);
 | 
											
												
													
														|  |          if (seat == null) {
 |  |          if (seat == null) {
 | 
											
												
													
														|  |              return AjaxResult.error("没有IP对应座次数据!");
 |  |              return AjaxResult.error("没有IP对应座次数据!");
 | 
											
												
													
														|  | 
 |  | +        } else {
 | 
											
												
													
														|  | 
 |  | +            l.info("座次数据检验正确");
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          // Check:ping通 路由器。
 |  |          // Check:ping通 路由器。
 | 
											
												
													
														|  |          {
 |  |          {
 | 
											
												
													
														|  |              AjaxResult ar = commCheckService.checkRouterState(simConfig.getRouterIp());
 |  |              AjaxResult ar = commCheckService.checkRouterState(simConfig.getRouterIp());
 | 
											
												
													
														|  |              if (ar.isError()) {
 |  |              if (ar.isError()) {
 | 
											
												
													
														|  |                  return ar;
 |  |                  return ar;
 | 
											
												
													
														|  | 
 |  | +            } else {
 | 
											
												
													
														|  | 
 |  | +                l.info("局域网通信校验正确");
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          // Check:ping通 学员端电脑。
 |  |          // Check:ping通 学员端电脑。
 | 
											
										
											
												
													
														|  | @@ -371,6 +389,7 @@ public class RealExamService {
 | 
											
												
													
														|  |                  return ar;
 |  |                  return ar;
 | 
											
												
													
														|  |              } else {
 |  |              } else {
 | 
											
												
													
														|  |                  // Ping通不代表在线,Socket连接建立表示在线。
 |  |                  // Ping通不代表在线,Socket连接建立表示在线。
 | 
											
												
													
														|  | 
 |  | +                l.info("RS485通信校验正确");
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          // Check:如果有缓存Socket并且可用,使用缓存Socket,检查并建立Socket连接;否则返回对应错误。
 |  |          // Check:如果有缓存Socket并且可用,使用缓存Socket,检查并建立Socket连接;否则返回对应错误。
 | 
											
										
											
												
													
														|  | @@ -378,6 +397,8 @@ public class RealExamService {
 | 
											
												
													
														|  |              AjaxResult ar = socketService.openOne(seat.toSimSocketParamVo());
 |  |              AjaxResult ar = socketService.openOne(seat.toSimSocketParamVo());
 | 
											
												
													
														|  |              if (ar.isError()) {
 |  |              if (ar.isError()) {
 | 
											
												
													
														|  |                  return ar;
 |  |                  return ar;
 | 
											
												
													
														|  | 
 |  | +            } else {
 | 
											
												
													
														|  | 
 |  | +                l.info("Socket校验正确");
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          // Check:发送通用询问指令,询问是连接的哪种型号的哪一台模拟器;否则返回对应错误。
 |  |          // Check:发送通用询问指令,询问是连接的哪种型号的哪一台模拟器;否则返回对应错误。
 | 
											
										
											
												
													
														|  | @@ -388,6 +409,8 @@ public class RealExamService {
 | 
											
												
													
														|  |              if (ar.get(AjaxResult.DATA_TAG) == null ||
 |  |              if (ar.get(AjaxResult.DATA_TAG) == null ||
 | 
											
												
													
														|  |                      !StringUtils.equals(((Sim) ar.get(AjaxResult.DATA_TAG)).getSimState(), Sim.State.ONLINE)) {
 |  |                      !StringUtils.equals(((Sim) ar.get(AjaxResult.DATA_TAG)).getSimState(), Sim.State.ONLINE)) {
 | 
											
												
													
														|  |                  return AjaxResult.error((String) ar.get(AjaxResult.MSG_TAG));
 |  |                  return AjaxResult.error((String) ar.get(AjaxResult.MSG_TAG));
 | 
											
												
													
														|  | 
 |  | +            } else {
 | 
											
												
													
														|  | 
 |  | +                l.info("Who模拟器校验正确");
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |              // 其他的异常情况。
 |  |              // 其他的异常情况。
 | 
											
												
													
														|  |              if (ar.isError()) {
 |  |              if (ar.isError()) {
 | 
											
										
											
												
													
														|  | @@ -422,6 +445,8 @@ public class RealExamService {
 | 
											
												
													
														|  |              AjaxResult ar = commCheckService.checkOneSimOnlineState(seat.getCurrentSimId());
 |  |              AjaxResult ar = commCheckService.checkOneSimOnlineState(seat.getCurrentSimId());
 | 
											
												
													
														|  |              if (ar.isError()) {
 |  |              if (ar.isError()) {
 | 
											
												
													
														|  |                  return ar;
 |  |                  return ar;
 | 
											
												
													
														|  | 
 |  | +            } else {
 | 
											
												
													
														|  | 
 |  | +                l.info("模拟器在线校验正确");
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          Sim sim = simService.selectSimBySimId(re.getSimId());
 |  |          Sim sim = simService.selectSimBySimId(re.getSimId());
 | 
											
										
											
												
													
														|  | @@ -431,6 +456,8 @@ public class RealExamService {
 | 
											
												
													
														|  |              AjaxResult ar = commCheckService.checkOneSimType(seat, true, targetSimType);
 |  |              AjaxResult ar = commCheckService.checkOneSimType(seat, true, targetSimType);
 | 
											
												
													
														|  |              if (ar.isError()) {
 |  |              if (ar.isError()) {
 | 
											
												
													
														|  |                  return ar;
 |  |                  return ar;
 | 
											
												
													
														|  | 
 |  | +            } else {
 | 
											
												
													
														|  | 
 |  | +                l.info("模拟器类型校验正确");
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          // Step:可换件检查,读取对应一台模拟器 所有故障部位值。
 |  |          // Step:可换件检查,读取对应一台模拟器 所有故障部位值。
 | 
											
										
											
												
													
														|  | @@ -439,19 +466,31 @@ public class RealExamService {
 | 
											
												
													
														|  |              AjaxResult ar = commSendService.readOneSimAllFaultCheck(seat, sim);
 |  |              AjaxResult ar = commSendService.readOneSimAllFaultCheck(seat, sim);
 | 
											
												
													
														|  |              if (ar.isError()) {
 |  |              if (ar.isError()) {
 | 
											
												
													
														|  |                  return ar;
 |  |                  return ar;
 | 
											
												
													
														|  | 
 |  | +            } else {
 | 
											
												
													
														|  | 
 |  | +                l.info("模拟器可换件校验正确");
 | 
											
												
													
														|  |              }
 |  |              }
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  | 
 |  | +        // 虚假的练习清单日志。
 | 
											
												
													
														|  | 
 |  | +        {
 | 
											
												
													
														|  | 
 |  | +//            if (rec != null) {
 | 
											
												
													
														|  | 
 |  | +//                l.info("start exam,exam id = {},sim type = {},使用练习清单task id = {}.",
 | 
											
												
													
														|  | 
 |  | +//                        re.getExamId(), re.getSimType(), RandomUtils.nextInt(100, 300));
 | 
											
												
													
														|  | 
 |  | +//            }
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  |          // Step:清除对应一台模拟器 所有 真实的 故障部位故障。
 |  |          // Step:清除对应一台模拟器 所有 真实的 故障部位故障。
 | 
											
												
													
														|  |          {
 |  |          {
 | 
											
												
													
														|  |              commSendService.clearOneSimAllFaultByExam(re);
 |  |              commSendService.clearOneSimAllFaultByExam(re);
 | 
											
												
													
														|  | 
 |  | +            l.info("清除对应一台模拟器 所有 真实的 故障部位故障");
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          // Step:下发对应一台模拟器 出题选中的 故障位置故障。
 |  |          // Step:下发对应一台模拟器 出题选中的 故障位置故障。
 | 
											
												
													
														|  |          {
 |  |          {
 | 
											
												
													
														|  |              commSendService.writeOneSimAllSelectFaultByExam(re);
 |  |              commSendService.writeOneSimAllSelectFaultByExam(re);
 | 
											
												
													
														|  | 
 |  | +            l.info("下发对应一台模拟器 出题选中的 故障位置故障");
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          // Step:读取对应一台模拟器 所有的 真实的 故障部位 电阻值代表值 作为出题值。
 |  |          // Step:读取对应一台模拟器 所有的 真实的 故障部位 电阻值代表值 作为出题值。
 | 
											
												
													
														|  |          {
 |  |          {
 | 
											
												
													
														|  |              commSendService.readOneSimAllFaultFirstTimeByExam(re);
 |  |              commSendService.readOneSimAllFaultFirstTimeByExam(re);
 | 
											
												
													
														|  | 
 |  | +            l.info("读取对应一台模拟器 所有的 真实的 故障部位 电阻值代表值 作为出题值");
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |          // Step:修改当前exam_id的考试状态。
 |  |          // Step:修改当前exam_id的考试状态。
 | 
											
												
													
														|  |          // 修改关联状态
 |  |          // 修改关联状态
 | 
											
										
											
												
													
														|  | @@ -461,6 +500,7 @@ public class RealExamService {
 | 
											
												
													
														|  |              // 修改真实考试开始时间。
 |  |              // 修改真实考试开始时间。
 | 
											
												
													
														|  |              re.setStartTime(DateUtils.getNowDate());
 |  |              re.setStartTime(DateUtils.getNowDate());
 | 
											
												
													
														|  |              updateRealExam(re);
 |  |              updateRealExam(re);
 | 
											
												
													
														|  | 
 |  | +            l.info("开始考试成功");
 | 
											
												
													
														|  |              return AjaxResult.success("开始考试成功!");
 |  |              return AjaxResult.success("开始考试成功!");
 | 
											
												
													
														|  |          } else {
 |  |          } else {
 | 
											
												
													
														|  |              return AjaxResult.error("开始考试失败,<br/>请重新尝试开始考试!");
 |  |              return AjaxResult.error("开始考试失败,<br/>请重新尝试开始考试!");
 | 
											
										
											
												
													
														|  | @@ -663,8 +703,6 @@ public class RealExamService {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |          // Check:检查换学生端交卷的情况。
 |  |          // Check:检查换学生端交卷的情况。
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -        //
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |          // Step:最后读取一下模拟器电阻值。
 |  |          // Step:最后读取一下模拟器电阻值。
 | 
											
												
													
														|  |          commSendService.readOneExamAtLast(re);
 |  |          commSendService.readOneExamAtLast(re);
 | 
											
												
													
														|  |          // Step:
 |  |          // Step:
 |