Procházet zdrojové kódy

checkSpecialBySimType 模拟器特定类型检查。

tom před 2 týdny
rodič
revize
be5f001e73

+ 32 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommCheckService.java

@@ -332,4 +332,36 @@ public class CommCheckService {
         });
         return AjaxResult.success("检查完毕,成功!");
     }
+
+    /**
+     * 模拟器特定类型检查
+     *
+     * @param sim
+     * @return
+     */
+    public AjaxResult checkSpecialBySimType(Sim sim) {
+        String targetSimType = sim.getSimType();
+        switch (targetSimType) {
+            case Sim.TYPE_0001 -> {
+
+            }
+            case Sim.TYPE_0002 -> {
+                {
+                    // 是否充满电
+                    Boolean isFull = simService.isChargingCountFullBySimId(sim.getSimId());
+                    if (isFull == null || !isFull) {
+                        StringBuilder sb = new StringBuilder()
+                                .append("电量")
+                                .append(simService.getChargingCountPercentage(sim.getSimId()))
+                                .append("%;请等待充电完成再次尝试。");
+                        return AjaxResult.error(sb.toString());
+                    }
+                }
+            }
+            case Sim.TYPE_0003 -> {
+
+            }
+        }
+        return AjaxResult.success("检查完毕,成功!");
+    }
 }

+ 11 - 1
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/RealExamService.java

@@ -467,6 +467,15 @@ public class RealExamService {
                 l.info("模拟器类型校验正确");
             }
         }
+        // Check:针对特殊类型模拟器的检查。
+        {
+            AjaxResult ar = commCheckService.checkSpecialBySimType(sim);
+            if (ar.isError()) {
+                return ar;
+            } else {
+                l.info("模拟器特定类型检查正确");
+            }
+        }
         // Step:可换件检查,读取对应一台模拟器 所有故障部位值。
         //      检查模拟器所有的 真实的 故障部位 是否异常 或者 空值。特殊的故障部位要单独判断。
         if (SimDebugConfig.CHECK_REPLACE_EMPTY) {
@@ -765,7 +774,8 @@ public class RealExamService {
             if (StringUtils.equals(rec.getExamCollectionState(), RealExamCollection.State.OPENED)) { // 考试集合状态是OPENED
                 if (StringUtils.equalsAny(re.getExamStatus(),
                         RealExam.State.NOT_LOGGED_IN,
-                        RealExam.State.LOGGED_IN)) { // 初始化状态 或 已登录状态
+                        RealExam.State.LOGGED_IN)
+                ) { // 初始化状态 或 已登录状态
                     Seat seat = seatService.uniqueByBindIp(ip);
                     if (seat == null || seat.getSeatId() == 0L) {
                         return AjaxResult.error("没有座次信息");