浏览代码

studentStartRealExam 改造。

tom 1 周之前
父节点
当前提交
d6eb9894fe

+ 54 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/constant/ArBuilder.java

@@ -0,0 +1,54 @@
+package com.ruoyi.sim.constant;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+
+import java.util.Objects;
+
+public class ArBuilder {
+
+    /**
+     *
+     * @param code not null.
+     * @param msg  not null.
+     * @param data could be null.
+     * @return
+     */
+    public static AjaxResult success(final Integer code, final String msg, final Object data) {
+        Objects.requireNonNull(code, "code is null!");
+        Objects.requireNonNull(msg, "msg is null!");
+        StringBuilder f = new StringBuilder();
+        f.append("[").append(code).append("]").append(msg);
+        if (Objects.isNull(data)) {
+            return AjaxResult.success(f.toString());
+        } else {
+            return AjaxResult.success(f.toString(), data);
+        }
+    }
+
+    public static AjaxResult success(final Integer code, final String msg) {
+        return success(code, msg, null);
+    }
+
+    /**
+     *
+     * @param code not null.
+     * @param msg  not null.
+     * @param data could be null.
+     * @return
+     */
+    public static AjaxResult error(final Integer code, final String msg, final Object data) {
+        Objects.requireNonNull(code, "code is null!");
+        Objects.requireNonNull(msg, "msg is null!");
+        StringBuilder f = new StringBuilder();
+        f.append("[").append(code).append("]").append(msg);
+        if (Objects.isNull(data)) {
+            return AjaxResult.error(f.toString());
+        } else {
+            return AjaxResult.error(f.toString(), data);
+        }
+    }
+
+    public static AjaxResult error(final Integer code, final String msg) {
+        return error(code, msg, null);
+    }
+}

+ 13 - 1
ruoyi-sim/src/main/java/com/ruoyi/sim/constant/CommConst.java

@@ -28,7 +28,7 @@ public interface CommConst {
 
     String CMD_DATA_PLACE_HOLDER = "00000000";
 
-    String BLANK_CONTENT = "00000000";
+    String CONTENT_BLANK = "00000000";
 
     /**
      * 故障下发
@@ -58,9 +58,21 @@ public interface CommConst {
 
     String ANSWER_LAST_RIGHT_MSG = "00";
     String ANSWER_LAST_WRONG_MSG = "01";
+
+    /**
+     * 可换件不存在
+     */
     String WHG_MSG_EXIT_NO = "00";
+
+    /**
+     * 可换件存在
+     */
     String WHG_MSG_EXIST_YES = "01";
 
+    int ID_MAX = Integer.parseInt("2A", 16);
+
+    int ID_MIN = Integer.parseInt("00", 16);
+
     int LENGTH_2 = 2;
     int LENGTH_8 = 8;
     /**

+ 182 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/constant/ErrorConst.java

@@ -0,0 +1,182 @@
+package com.ruoyi.sim.constant;
+
+/**
+ * 错误功能码。
+ */
+public interface ErrorConst {
+
+    /** 10xxx 连接状态相关 **/
+
+    /**
+     *
+     * 连接线按钮没有打开。
+     */
+    Integer SWITCH_OFF = 10100;
+
+    /**
+     * 路由器ping不通。
+     */
+    Integer ROUTER_PING_LOST = 10101;
+
+    /**
+     * RS485网关ping不通。
+     */
+    Integer RS_485_GATEWAY_PING_LOST = 10102;
+
+    Integer STUDENT_PC_PING_LOST = 10103;
+
+    /**
+     * 数据库虚拟服务器ping不通。
+     */
+    Integer DB_SERVER_PING_LOST = 10104;
+
+    /**
+     * 后端调用接口失败
+     */
+    Integer BACK_END_SERVER_LOST = 10105;
+
+
+    /**
+     * 20xxx 模拟器状态相关
+     **/
+    Integer T_20001 = 20001;
+
+    String M_20001 = "座号[{0}]-模拟器[{1}]型[{2}]在线";
+    ;
+
+    Integer T_20002 = 20002;
+
+    String M_20002 = "座号[{0}]-没有连接任何接模拟器,检查线缆开关和线缆连接!";
+
+    /** 201xx 0001型模拟器状态相关 **/
+    /**
+     * 模拟器类型错误
+     */
+    Integer T_20003 = 20003;
+
+    String M_20003 = "连接模拟器类型或序列号不正确!<br>应该连接模拟器型号:<br>";
+
+    /**
+     * 充电时间不足。
+     */
+    Integer T20004 = 20004;
+
+    String M20004 = "";
+
+    /**
+     * 可换件 全0
+     */
+    Integer T20005 = 20005;
+
+    /**
+     * 可换件 ID小于MIN
+     */
+    Integer T20011 = 20011;
+
+    String M20011 = "可换件id异常";
+
+    /**
+     * 可换件 ID超过MAX
+     */
+    Integer T20012 = 20012;
+
+    String M20012 = "可换件id异常";
+
+    /**
+     * 其他情况 通过报文内容 逻辑判断 可换件不存在
+     */
+    Integer T20007 = 20007;
+
+    /**
+     * 0002型 09
+     **/
+    Integer T22009 = 22009;
+
+    /**
+     * 0003型 07
+     **/
+    Integer T23007 = 23007;
+
+    Integer T24001 = 24001;
+
+    String M24001 = "请检查 显控报警板与主板连接线 连接情况!";
+
+    /**
+     * 40xxx 基础数据问题
+     **/
+    Integer T_40001 = 40001;
+
+    String M_40001 = "IP地址无效";
+
+    Integer T_40002 = 40002;
+
+    String M_40002 = "没有IP对应座次数据!";
+
+    Integer T_40003 = 40003;
+
+    Integer T_40004 = 40004;
+
+    Integer T_40005 = 40005;
+
+    Integer T_40006 = 40006;
+
+    Integer T_40007 = 40007;
+
+    Integer T_40008 = 40008;
+
+    Integer T_40009 = 40009;
+
+    Integer T_40010 = 40010;
+
+    String M_40010 = "座次数据空!<br/>请向教员说明情况。";
+
+    Integer T_40011 = 40011;
+
+    String M_40011 = "模拟器数据空!<br/>请向教员说明情况。";
+
+    /** 50xxx 报文内容问题 **/
+
+    /**
+     * 60xxx 考试相关问题
+     **/
+
+    Integer T_60001 = 60001;
+
+    String M_60001 = "存在打开的考试,无法开启训练!<br/>请向教员说明情况。";
+
+    Integer T_60002 = 60002;
+
+    String M_60002 = "存在打开的考试,无法开启练习!<br/>请向教员说明情况。";
+
+    Integer T_60003 = 60003;
+
+    String M_60003 = "存在打开的训练,无法开启练习!<br/>请向教员说明情况。";
+
+    Integer T_60004 = 60004;
+
+    String M_60004 = "对应考试Id不存在!";
+
+    Integer T_60005 = 60005;
+
+    String M_60005 = "已经交卷,禁止重复开始考试!";
+
+    Integer T_60006 = 60006;
+
+    String M_60006 = "考试集合数据不存在!";
+
+    Integer T_60007 = 60007;
+
+    String M_60007 = "教师端对应考试/训练尚未打开!<br/>请向教员说明情况。";
+
+    Integer T_60008 = 60008;
+
+    String M_60008 = "考试集合类型不对应!";
+
+    Integer T60009 = 60009;
+
+    String M60009 = "开始考试失败,<br/>请重新尝试开始考试!";
+
+    Integer T60010 = 60010;
+
+    String M60010 = "考试数据空!<br/>请向教员说明情况。";
+}

+ 0 - 25
ruoyi-sim/src/main/java/com/ruoyi/sim/constant/ErrorMsgBuilder.java

@@ -1,25 +0,0 @@
-package com.ruoyi.sim.constant;
-
-import com.ruoyi.common.core.domain.AjaxResult;
-
-import java.util.Objects;
-
-public class ErrorMsgBuilder {
-
-    /**
-     *
-     * @param code
-     * @param msg
-     * @param data
-     * @return
-     */
-    public static AjaxResult errorMsg(Integer code, String msg, Object data) {
-        StringBuilder f = new StringBuilder();
-        f.append("[").append(code).append("]").append(msg);
-        if (Objects.isNull(data)) {
-            return AjaxResult.error(f.toString());
-        } else {
-            return AjaxResult.error(f.toString(), data);
-        }
-    }
-}

+ 3 - 2
ruoyi-sim/src/main/java/com/ruoyi/sim/constant/FaultConst.java

@@ -1,13 +1,14 @@
 package com.ruoyi.sim.constant;
 
 import java.util.HashSet;
+import java.util.Set;
 
 public class FaultConst {
 
     /**
      * 跳过的开始考试检查故障部位 集合。
      */
-    public static HashSet<String> FAULT_SET_CHECK_PASS = new HashSet<>();
+    public static Set<String> FAULT_SET_CHECK_PASS = new HashSet<>();
 
     /**
      * 判分 暂时没有使用
@@ -18,7 +19,7 @@ public class FaultConst {
     /**
      * 是否是 2型,3型 的 检测干燥管
      */
-    public static HashSet<String> FAULT_SET_GAN_ZAO_GUAN = new HashSet<>();
+    public static Set<String> FAULT_SET_GAN_ZAO_GUAN = new HashSet<>();
 
     static {
         {

+ 0 - 77
ruoyi-sim/src/main/java/com/ruoyi/sim/constant/FunCodeConst.java

@@ -1,77 +0,0 @@
-package com.ruoyi.sim.constant;
-
-/**
- * 功能码。
- */
-public interface FunCodeConst {
-
-    /** 10xxx 连接状态相关 **/
-
-    /**
-     *
-     * 连接线按钮没有打开。
-     */
-    Integer SWITCH_OFF = 10100;
-
-    /**
-     * 路由器ping不通。
-     */
-    Integer ROUTER_PING_LOST = 10101;
-
-    /**
-     * RS485网关ping不通。
-     */
-    Integer RS_485_GATEWAY_PING_LOST = 10102;
-
-    Integer STUDENT_PC_PING_LOST = 10103;
-
-    /**
-     * 数据库虚拟服务器ping不通。
-     */
-    Integer DB_SERVER_PING_LOST = 10104;
-
-    /**
-     * 后端调用接口失败
-     */
-    Integer BACK_END_SERVER_LOST = 10105;
-
-    /**
-     * 模拟器类型错误
-     */
-    Integer SIM_TYPE_ERROR = 10201;
-
-    /** 20xxx 模拟器状态相关 **/
-
-
-    /** 201xx 0001型模拟器状态相关 **/
-
-    /**
-     * 0001型 缺少可换件
-     */
-    Integer T_0001_LACK_OF_REPLACE_PARTS = 20100;
-
-    Integer T_0001_BATTERY_COMPARTMENT_COVER_OPENED = 20130;
-
-    /** 202xx 0002型模拟器状态相关 **/
-
-
-    /**
-     * 0002型 缺少可换件
-     */
-    Integer T_0002_LACK_OF_REPLACE_PARTS = 20200;
-    /**
-     * 0002型模拟器,充电时间不足。
-     */
-    Integer T_0002_INSUFFICIENT_CHARGING_TIME = 20230;
-
-    /** 203xx 0003型模拟器状态相关 **/
-
-    /**
-     * 0003型 缺少可换件
-     */
-    Integer T_0003_LACK_OF_REPLACE_PARTS = 20300;
-
-    /** 40xxx 基础数据问题 **/
-
-    /** 50xxx 报文内容问题 **/
-}

+ 12 - 13
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommCheckService.java

@@ -1,8 +1,9 @@
 package com.ruoyi.sim.service.impl;
 
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.sim.constant.ArBuilder;
 import com.ruoyi.sim.constant.CommConst;
-import com.ruoyi.sim.constant.FunCodeConst;
+import com.ruoyi.sim.constant.ErrorConst;
 import com.ruoyi.sim.domain.RealExamCollection;
 import com.ruoyi.sim.domain.Seat;
 import com.ruoyi.sim.domain.Sim;
@@ -23,6 +24,7 @@ import java.util.Objects;
 
 import static com.ruoyi.sim.constant.CommConst.RETRY_COUNT_0;
 import static com.ruoyi.sim.constant.CommConst.RETRY_COUNT_QUERY_SN_IMPORTANT;
+import static com.ruoyi.sim.constant.ErrorConst.*;
 
 @Service
 public class CommCheckService {
@@ -153,11 +155,10 @@ public class CommCheckService {
             // 查询出最新的Sim对象
             sim = simService.uniqueBySimNum(simNum);
             //
-            String msgTemp = "座号[{0}]-模拟器[{1}]型[{2}]在线";
-            String msg = MessageFormat.format(msgTemp, seat.getSeatNum(), Sim.TYPE_NAME_MAP.get(sim.getSimType()), sim.getSimNum());
+            String msg = MessageFormat.format(M_20001, seat.getSeatNum(), Sim.TYPE_NAME_MAP.get(sim.getSimType()), sim.getSimNum());
             String msgSpec = checkOneSeatStateSpecBySimType(sim);
             // 成功的话,Obj为Sim对象。
-            return AjaxResult.success(msg + msgSpec, sim);
+            return ArBuilder.success(T_20001, msg + msgSpec, sim);
         } else if (Objects.equals(result, SimMsg.Result.READ_TIMEOUT_EXCEPTION)) { // 正常情况:模拟器离线
             // 更新Sim状态 更新当前座上sim的状态。
             if (!seat.getCurrentSimId().equals(Sim.ID_0)) {
@@ -166,13 +167,12 @@ public class CommCheckService {
             }
             // 更新座上SimId
             seatService.updateCurrentSimIdBySeatNum(seat.getSeatNum(), Sim.ID_0);
-            String msgTemp = "座号[{0}]-没有连接任何接模拟器,检查线缆开关和线缆连接!";
-            String msg = MessageFormat.format(msgTemp, seat.getSeatNum());
+            String msg = MessageFormat.format(M_20002, seat.getSeatNum());
             // 构造一个假的Sim对象,用来返回结果。不知道之前模拟器的状态。
             Sim simFake = new Sim();
             simFake.setSimState(Sim.State.OFFLINE);
             // 成功的话,Obj为虚拟构建Sim对象。
-            return AjaxResult.success(msg, simFake);
+            return ArBuilder.success(T_20002, msg, simFake);
         } else if (Objects.equals(result, SimMsg.Result.RECEIVE_CHECK_FAIL)) {
             return smR.getDefaultErrorAR();
         } else if (Objects.equals(result, SimMsg.Result.RECEIVE_NOT_MATCH)) {
@@ -182,7 +182,7 @@ public class CommCheckService {
     }
 
     /**
-     * 针对 特定模拟器 型号 的特殊处理。
+     * 针对 特定模拟器 型号 的特殊处理。目前只有2型有电量。
      *
      * @param sim
      * @return
@@ -263,7 +263,6 @@ public class CommCheckService {
             return AjaxResult.error("模拟器ID[" + seat.getCurrentSimId() + "]不存在!");
         }
         //
-        final String msgErrorTemp = "[错误码-" + FunCodeConst.SIM_TYPE_ERROR + "]" + "连接模拟器类型或序列号不正确!<br>应该连接模拟器型号:<br>";
         final String msgOk = "连接模拟器类型或序列号正确!";
         int retryTotalCount;
         if (important) {
@@ -281,21 +280,21 @@ public class CommCheckService {
                     if (content.startsWith(CommConst.TYPE_0001_SN_PREFIX) && content.endsWith(sim.getSimNum())) {
                         return AjaxResult.success(msgOk);
                     } else {
-                        return AjaxResult.error(msgErrorTemp + Sim.TYPE_NAME_MAP.get(targetSimType));
+                        return ArBuilder.error(ErrorConst.T_20003, M_20003 + Sim.TYPE_NAME_MAP.get(targetSimType));
                     }
                 }
                 case Sim.TYPE_0002 -> {
                     if (content.startsWith(CommConst.TYPE_0002_SN_PREFIX) && content.endsWith(sim.getSimNum())) {
                         return AjaxResult.success(msgOk);
                     } else {
-                        return AjaxResult.error(msgErrorTemp + Sim.TYPE_NAME_MAP.get(targetSimType));
+                        return ArBuilder.error(ErrorConst.T_20003, M_20003 + Sim.TYPE_NAME_MAP.get(targetSimType));
                     }
                 }
                 case Sim.TYPE_0003 -> {
                     if (content.startsWith(CommConst.TYPE_0003_SN_PREFIX) && content.endsWith(sim.getSimNum())) {
                         return AjaxResult.success(msgOk);
                     } else {
-                        return AjaxResult.error(msgErrorTemp + Sim.TYPE_NAME_MAP.get(targetSimType));
+                        return ArBuilder.error(ErrorConst.T_20003, M_20003 + Sim.TYPE_NAME_MAP.get(targetSimType));
                     }
                 }
                 default -> throw new IllegalStateException("Unexpected value: " + targetSimType);
@@ -375,7 +374,7 @@ public class CommCheckService {
                                 .append("电量")
                                 .append(simService.getChargingCountPercentage(sim.getSimId()))
                                 .append("%;请等待充电完成再次尝试。");
-                        return AjaxResult.error(sb.toString());
+                        return ArBuilder.error(T20004, sb.toString());
                     }
                 }
             }

+ 23 - 2
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommParseUtils.java

@@ -1,6 +1,7 @@
 package com.ruoyi.sim.service.impl;
 
 
+import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.sim.constant.CommConst;
 import com.ruoyi.sim.domain.SimMsg;
 import org.apache.commons.lang3.StringUtils;
@@ -12,7 +13,7 @@ public class CommParseUtils {
      */
 
     /**
-     * 截取 内容报文
+     * 截取 接收报文内容
      *
      * @param
      * @return "01 02 03 04"
@@ -24,9 +25,29 @@ public class CommParseUtils {
         return StringUtils.substring(sm.getReceiveMsg(), 10, 18);
     }
 
+    /**
+     * 接收报文内容 第三个字节。
+     *
+     * @param sm
+     * @return
+     */
+    public static String receiveSubContentData46(SimMsg sm) {
+        return receiveSubContentData(sm).substring(4, 6);
+    }
+
+    /**
+     * 接收报文内容 第四个字节。
+     *
+     * @param sm
+     * @return
+     */
+    public static String receiveSubContentData68(SimMsg sm) {
+        return receiveSubContentData(sm).substring(6, 8);
+    }
+
     public static boolean isReceiveContentDataBlank(SimMsg sm) {
         String contentData = receiveSubContentData(sm);
-        return StringUtils.isBlank(contentData) || StringUtils.equals(contentData, CommConst.BLANK_CONTENT);
+        return StringUtils.isBlank(contentData) || StringUtils.equals(contentData, CommConst.CONTENT_BLANK);
     }
 
     public static String subSimNum(String msg) {

+ 32 - 9
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommReceiveService.java

@@ -1,8 +1,10 @@
 package com.ruoyi.sim.service.impl;
 
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.sim.constant.ArBuilder;
 import com.ruoyi.sim.constant.CommConst;
 import com.ruoyi.sim.constant.FaultConst;
+import com.ruoyi.sim.constant.FaultIdConst;
 import com.ruoyi.sim.domain.*;
 import com.ruoyi.sim.domain.vo.FaultCheckVo;
 import com.ruoyi.sim.util.CRC16Modbus;
@@ -14,8 +16,10 @@ import org.springframework.stereotype.Service;
 
 import java.util.Arrays;
 import java.util.HashSet;
+import java.util.Objects;
 
 import static com.ruoyi.sim.constant.CommConst.*;
+import static com.ruoyi.sim.constant.ErrorConst.*;
 
 @Service
 // 多实例
@@ -155,7 +159,7 @@ public class CommReceiveService {
         SimMsg sm = vo.getSimMsgReceive();
         Sim s = vo.getSim();
         Fault f = vo.getFault();
-        String checkValue = CommParseUtils.receiveSubContentData(sm);
+        String contentData = CommParseUtils.receiveSubContentData(sm);
         if (s == null) {
             return AjaxResult.error("没有对应模拟器!");
         }
@@ -190,23 +194,42 @@ public class CommReceiveService {
         // 3型的 检测干燥管
         if (FaultConst.FAULT_SET_GAN_ZAO_GUAN.contains(f.getFaultId())) {
             // 判断必须存在
-            String WHG_EXIST_MSG = checkValue.substring(4, 6);
+            String WHG_EXIST_MSG = CommParseUtils.receiveSubContentData46(sm);
             if (!WHG_MSG_EXIST_YES.equals(WHG_EXIST_MSG)) {
                 String eMsg = "[" + f.getReplaceName() + "]可换件异常;<br>" +
                         "请正确安装[" + f.getReplaceName() + "]后再次开始考试。<br>";
                 l.info(eMsg);
                 vo.setErrorMsg(eMsg);
                 vo.setCheckOk(false);
-                return AjaxResult.error(eMsg, vo);
+                if (Objects.equals(FaultIdConst.T0002.F09, f.getFaultId())) {
+                    return ArBuilder.error(T22009, eMsg, vo);
+                } else if (Objects.equals(FaultIdConst.T0003.F07, f.getFaultId())) {
+                    return ArBuilder.error(T23007, eMsg, vo);
+                } else {
+                    return ArBuilder.error(T20007, eMsg, vo);
+                }
             }
         }
         // 非空判断
-        if (StringUtils.equals(checkValue, BLANK_CONTENT)) {
-            String eMsg = "[" + f.getReplaceName() + "]可换件异常;<br>";
-            l.info(eMsg);
-            vo.setErrorMsg(eMsg);
-            vo.setCheckOk(false);
-            return AjaxResult.error(eMsg, vo);
+        {
+            if (StringUtils.equals(CONTENT_BLANK, contentData)) {
+                String eMsg = "[" + f.getReplaceName() + "]可换件异常;<br>";
+                l.info(eMsg);
+                vo.setErrorMsg(eMsg);
+                vo.setCheckOk(false);
+                return ArBuilder.error(T20005, eMsg, vo);
+            }
+        }
+        // 可换件id 最小值 最大值 判断
+        {
+            String id = CommParseUtils.receiveSubContentData68(sm);
+            int idDec = Integer.parseInt(id, 16);
+            if (idDec < CommConst.ID_MIN) {
+                return ArBuilder.error(T20011, M20011, vo);
+            }
+            if (idDec > CommConst.ID_MAX) {
+                return ArBuilder.error(T20012, M20012, vo);
+            }
         }
         // final ok.
         vo.setErrorMsg("");

+ 10 - 8
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommSendService.java

@@ -4,6 +4,7 @@ import cn.hutool.core.map.MapUtil;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.sim.config.SimConfig;
+import com.ruoyi.sim.constant.ArBuilder;
 import com.ruoyi.sim.constant.CommConst;
 import com.ruoyi.sim.constant.FaultIdConst;
 import com.ruoyi.sim.domain.*;
@@ -27,6 +28,7 @@ import java.net.Socket;
 import java.util.*;
 
 import static com.ruoyi.sim.constant.CommConst.*;
+import static com.ruoyi.sim.constant.ErrorConst.*;
 
 /**
  * 硬件通信
@@ -756,9 +758,9 @@ public class CommSendService {
         List<Fault> listF = faultService.selectFaultList(q);
         // 未正确安装可换件故障List
         // NG not good
-        List<FaultCheckVo> listNGVo = new ArrayList<>();
+        List<FaultCheckVo> nGVoList = new ArrayList<>();
         // not good fault_id HashSet
-        Set<String> setNG = new HashSet<>();
+        Set<String> nGSet = new HashSet<>();
         // 单一故障部位检查
         {
             for (Fault oneF : listF) {
@@ -774,8 +776,8 @@ public class CommSendService {
                         l.info("log 故障部位[{}][{}]安装ok;", oneF.getBindHardwareMsg(), oneF.getReplaceName());
                     } else {
                         l.info("log 故障部位[{}][{}]未正确安装;", oneF.getBindHardwareMsg(), oneF.getReplaceName());
-                        listNGVo.add(voReturn);
-                        setNG.add(oneF.getFaultId());
+                        nGVoList.add(voReturn);
+                        nGSet.add(oneF.getFaultId());
                     }
                 }
                 // 得出ar有问题直接返回,不执行后面检查。
@@ -786,15 +788,15 @@ public class CommSendService {
         }
         // 复核条件检查
         {
-            AjaxResult ar = readOneSimAllFaultStartGlobalCheck(sim, setNG);
+            AjaxResult ar = readOneSimAllFaultStartGlobalCheck(sim, nGSet);
             if (ar.isError()) {
                 return ar;
             }
         }
         //
-        if (!listNGVo.isEmpty()) {
+        if (!nGVoList.isEmpty()) {
             StringBuilder sb = new StringBuilder();
-            for (FaultCheckVo oneVo : listNGVo) {
+            for (FaultCheckVo oneVo : nGVoList) {
                 sb.append(oneVo.getErrorMsg());
             }
             sb.append("请正确安装可换件,检查后重新开始!");
@@ -885,7 +887,7 @@ public class CommSendService {
                     setNG.contains(FaultIdConst.T0003.F0B) &&
                     setNG.contains(FaultIdConst.T0003.F0E)
             ) {
-                return AjaxResult.error("请检查 显控报警板与主板连接线 连接情况!");
+                return ArBuilder.error(T24001, M24001);
             }
         }
         return AjaxResult.success("复合读取检查 成功。");

+ 23 - 18
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/RealExamService.java

@@ -6,6 +6,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.sim.config.SimConfig;
 import com.ruoyi.sim.config.SimDebugConfig;
+import com.ruoyi.sim.constant.ArBuilder;
 import com.ruoyi.sim.domain.*;
 import com.ruoyi.sim.domain.vo.*;
 import org.apache.commons.lang3.StringUtils;
@@ -17,6 +18,8 @@ import org.springframework.stereotype.Service;
 import com.ruoyi.sim.mapper.RealExamMapper;
 import org.springframework.transaction.annotation.Transactional;
 
+import static com.ruoyi.sim.constant.ErrorConst.*;
+
 /**
  * 考试Service业务层处理
  *
@@ -295,7 +298,7 @@ public class RealExamService {
         if (StringUtils.equals(RealExamCollection.Type.EXERCISE, examCollectionType)) {
             // 已经open的考试。
             if (realExamCollectionService.existOpenedByType(RealExamCollection.Type.EXAM)) {
-                return AjaxResult.error("存在打开的考试,无法开启训练!<br/>请向教员说明情况。");
+                return ArBuilder.error(T_60001, M_60001);
             }
         } else {
             l.info("type EXERCISE,没有打开的考试,校验正确");
@@ -304,13 +307,13 @@ public class RealExamService {
         if (StringUtils.equals(RealExamCollection.Type.SELF_EXERCISE, examCollectionType)) {
             // 已经open的考试。
             if (realExamCollectionService.existOpenedByType(RealExamCollection.Type.EXAM)) {
-                return AjaxResult.error("存在打开的考试,无法开启练习!<br/>请向教员说明情况。");
+                return ArBuilder.error(T_60002, M_60002);
             } else {
                 l.info("type SELF_EXERCISE,没有打开的考试,校验正确");
             }
             // 已经open的训练。
             if (realExamCollectionService.existOpenedByType(RealExamCollection.Type.EXERCISE)) {
-                return AjaxResult.error("存在打开的训练,无法开启练习!<br/>请向教员说明情况。");
+                return ArBuilder.error(T_60003, M_60003);
             } else {
                 l.info("type SELF_EXERCISE,没有打开的训练,校验正确");
             }
@@ -333,14 +336,14 @@ public class RealExamService {
         if (StringUtils.equals(re.getExamStatus(), RealExam.State.SUBMITTED) ||
                 StringUtils.equals(re.getExamStatus(), RealExam.State.CALCULATING_SCORE) ||
                 StringUtils.equals(re.getExamStatus(), RealExam.State.GOT_REPORT)) {
-            return AjaxResult.error("已经交卷,禁止重复开始考试!");
+            return ArBuilder.error(T_60005, M_60005);
         } else {
             l.info("没有重复交卷校验正确");
         }
         RealExamCollection rec = realExamCollectionService.selectRealExamCollectionByExamCollectionId(re.getExamCollectionId());
         // Check:考试集合数据有效性。
         if (rec == null) {
-            return AjaxResult.error("考试集合数据异常!");
+            return ArBuilder.error(T_60006, M_60006);
         } else {
             l.info("考试集合数据校验正确");
         }
@@ -348,26 +351,26 @@ public class RealExamService {
             if (StringUtils.equals(rec.getExamCollectionType(), RealExamCollection.Type.SELF_EXERCISE)) {
                 l.info("练习类型考试集合,不需要检查 考试集合 开关状态。");
             } else {
-                return AjaxResult.error("教师端对应考试/训练尚未打开!<br/>请向教员说明情况。");
+                return ArBuilder.error(T_60007, M_60007);
             }
         } else {
             l.info("考试集合开启校验正确");
         }
         // Check:检查参数examCollectionType有效性
         if (!StringUtils.equals(examCollectionType, rec.getExamCollectionType())) {
-            return AjaxResult.error("考试集合类型不对应!");
+            return ArBuilder.error(T_60008, M_60008);
         } else {
             l.info("考试集合类型校验正确");
         }
         // Check:检查参数studentBindIp有效性
         if (StringUtils.isBlank(ip)) {
-            return AjaxResult.error("IP地址无效");
+            return ArBuilder.error(T_40001, M_40001);
         } else {
             l.info("IP地址检验正确");
         }
         Seat seat = seatService.uniqueByBindIp(ip);
         if (seat == null) {
-            return AjaxResult.error("没有IP对应座次数据!");
+            return ArBuilder.error(T_40002, M_40002);
         } else {
             l.info("座次数据检验正确");
         }
@@ -424,7 +427,7 @@ public class RealExamService {
                 l.info("Who模拟器校验正确");
             }
             if (ar.isSuccess()) {
-
+                l.info("isSuccess {}", ar);
             } else if (ar.isError()) { // 其他的异常情况。
                 return ar;
             }
@@ -444,12 +447,14 @@ public class RealExamService {
         // Check: seat_id 和 current_sim_id
         {
             RealExam reF = selectRealExamByExamId(examId);
-            if (reF == null ||
-                    reF.getSeatId() == null ||
-                    reF.getSeatId() == 0L ||
-                    reF.getSimId() == null ||
-                    reF.getSimId() == 0) {
-                return AjaxResult.error("开始考试异常!<br/>请刷新页面重试!");
+            if (reF == null) {
+                return ArBuilder.error(T60010, M60010);
+            }
+            if (reF.getSeatId() == null || reF.getSeatId() == 0L) {
+                return ArBuilder.error(T_40010, M_40010);
+            }
+            if (reF.getSimId() == null || reF.getSimId() == 0) {
+                return ArBuilder.error(T_40011, M_40011);
             }
         }
         // Step:查询模拟器在线状态,纯DB查询。
@@ -524,7 +529,7 @@ public class RealExamService {
             l.info("开始考试成功");
             return AjaxResult.success("开始考试成功!");
         } else {
-            return AjaxResult.error("开始考试失败,<br/>请重新尝试开始考试!");
+            return ArBuilder.error(T60009, M60009);
         }
     }
 
@@ -556,7 +561,7 @@ public class RealExamService {
     public AjaxResult checkExamId(final Long examId) {
         // Check:检查 examId 是否正确存在
         if (!exist(examId)) {
-            return AjaxResult.error("对应考试Id不存在!");
+            return ArBuilder.error(T_60004, M_60004);
         } else {
             return AjaxResult.success();
         }