فهرست منبع

是否运行 连接情况 的 定时任务。添加开关。

tom 2 هفته پیش
والد
کامیت
1cb7c61ef8

+ 16 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/config/SimDebugConfig.java

@@ -0,0 +1,16 @@
+package com.ruoyi.sim.config;
+
+public class SimDebugConfig {
+
+    public static final String KEY_CHECK_REPLACE_EMPTY = "CHECK_REPLACE_EMPTY";
+    /**
+     * 是否考试开始前进行可换件检查。
+     */
+    public static boolean CHECK_REPLACE_EMPTY = true;
+
+    public static final String KEY_SCHEDULED_CONNECT = "SCHEDULED_CONNECT";
+    /**
+     * 是否运行 连接情况 的 定时任务。
+     */
+    public static boolean SCHEDULED_CONNECT = true;
+}

+ 53 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/controller/ConfigController.java

@@ -0,0 +1,53 @@
+package com.ruoyi.sim.controller;
+
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.sim.config.SimDebugConfig;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+
+@RestController
+@RequestMapping("/sim/config")
+@Api("ConfigController")
+public class ConfigController {
+
+    /**
+     * http://192.168.1.60:8080/sim/config/set?key=CHECK_REPLACE_EMPTY&value=false
+     * http://192.168.1.60:8080/sim/config/set?key=SCHEDULED_CONNECT&value=false
+     *
+     * @param key
+     * @param value
+     * @return
+     */
+    @GetMapping(value = "/set")
+    @ApiOperation("set config")
+    public AjaxResult set(@RequestParam final String key, @RequestParam final String value) {
+        if (SimDebugConfig.KEY_CHECK_REPLACE_EMPTY.equals(key.toUpperCase())) {
+            SimDebugConfig.CHECK_REPLACE_EMPTY = Boolean.valueOf(value);
+            return AjaxResult.success(SimDebugConfig.CHECK_REPLACE_EMPTY);
+        }
+        if (SimDebugConfig.KEY_SCHEDULED_CONNECT.equals(key.toUpperCase())) {
+            SimDebugConfig.SCHEDULED_CONNECT = Boolean.valueOf(value);
+            return AjaxResult.success(SimDebugConfig.SCHEDULED_CONNECT);
+        }
+        return AjaxResult.error("no match key.");
+    }
+
+    /**
+     * http://192.168.1.110:8080/sim/config/get?key=CHECK_REPLACE_EMPTY
+     * http://192.168.1.60:8080/sim/config/get?key=SCHEDULED_CONNECT
+     * @param key
+     * @return
+     */
+    @GetMapping(value = "/get")
+    @ApiOperation("get config")
+    public AjaxResult get(@RequestParam final String key) {
+        if (SimDebugConfig.KEY_CHECK_REPLACE_EMPTY.equals(key.toUpperCase())) {
+            return AjaxResult.success(SimDebugConfig.CHECK_REPLACE_EMPTY);
+        }
+        if (SimDebugConfig.KEY_SCHEDULED_CONNECT.equals(key.toUpperCase())) {
+            return AjaxResult.success(SimDebugConfig.SCHEDULED_CONNECT);
+        }
+        return AjaxResult.error("no match key.");
+    }
+}

+ 5 - 0
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommSendService.java

@@ -3,6 +3,7 @@ package com.ruoyi.sim.service.impl;
 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.domain.*;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.LoggerFactory;
@@ -192,6 +193,10 @@ public class CommSendService {
      */
     public void scheduledConnect() {
         l.info("scheduled####Connect");
+        if (!SimDebugConfig.SCHEDULED_CONNECT) {
+            l.info("连接情况 的 定时任务被禁用!");
+            return;
+        }
         if (!realExamCollectionService.existOpened()) {
             l.info("没有open的考试集合");
             return;

+ 7 - 2
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/RealExamService.java

@@ -115,6 +115,12 @@ public class RealExamService {
     @Autowired
     private SimConfig simConfig;
 
+    /**
+     * examId 是否有效。
+     *
+     * @param examId
+     * @return
+     */
     public boolean exist(Long examId) {
         if (examId == null) {
             return false;
@@ -207,7 +213,7 @@ public class RealExamService {
         }
         // todo: 日期,不可进入考试。
         //
-        // todo: 验证学生登录身份
+        // todo: 验证学生登录身份`
         Objects.requireNonNull(re);
         RealExamCollection collection =
                 realExamCollectionService.selectRealExamCollectionByExamCollectionId(re.getExamCollectionId());
@@ -288,7 +294,6 @@ public class RealExamService {
             // l.info("fake re = {}", re);
         }
         // check part.
-        l.info("CHECK_REPLACE_EMPTY = {}", SimDebugConfig.CHECK_REPLACE_EMPTY);
         {
             AjaxResult arE1 = checkExamId(examId);
             if (arE1.isError()) {