Parcourir la source

开始考试,添加 故障部位 白名单机制。下发故障可以正常运行。

tom il y a 1 semaine
Parent
commit
db6c4af6ed

+ 9 - 4
ruoyi-sim/src/main/java/com/ruoyi/sim/controller/HardwareCommDebugController.java

@@ -8,10 +8,7 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 @RestController
 @RequestMapping("/sim/debug")
@@ -78,4 +75,12 @@ public class HardwareCommDebugController extends BaseController {
     public AjaxResult debugWriteAllFault(@PathVariable("simNum") final String simNum) {
         return success(commSendService.debugWriteAllFault(simNum));
     }
+
+    @GetMapping(value = "/debugWriteSelectedFault/{simNum}/{faultIds}")
+    @ApiOperation("debug下发所选故障")
+    public AjaxResult debugWriteAllFault(@PathVariable("simNum") final String simNum,
+                                         @PathVariable("faultIds") final String[] faultIds,
+                                         @RequestParam final Boolean checkReplace) {
+        return success(commSendService.debugWriteSelectedFaultBySimNum(simNum, faultIds, checkReplace));
+    }
 }

+ 41 - 6
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommReceiveService.java

@@ -125,15 +125,16 @@ public class CommReceiveService {
     }
 
     /**
-     * 0002型 01故障部位进行特殊处理。
+     * 开始考试 检查 故障部位 检查
+     *
+     * @param sm
+     * @param s
+     * @param f
+     * @return
      */
-    public String FAULT_0002_GZBW_01 = "0002GZBW0001";
-
     public AjaxResult getOneFaultCheck(SimMsg sm, Sim s, Fault f) {
         String checkValue = parseGetData(sm.getReceiveMsg());
-        if (s != null &&
-                s.getSimType().equals(Sim.TYPE_0002) &&
-                f.getFaultId().equals(FAULT_0002_GZBW_01)) {
+        if (s != null && isFaultCheckPass(sm, s, f)) {
             return AjaxResult.success(f);
         }
         if (BLANK_CONTENT.equals(checkValue)) {
@@ -145,4 +146,38 @@ public class CommReceiveService {
             return AjaxResult.success(f);
         }
     }
+
+    /**
+     * 是否在故障部位白名单中。
+     *
+     * @param sm
+     * @param s
+     * @param f
+     * @return true 在白名单中。
+     */
+    public boolean isFaultCheckPass(SimMsg sm, Sim s, Fault f) {
+        String simType = s.getSimType();
+        String faultRealGZBWId = f.getFaultId();
+        if (Sim.TYPE_0001.equals(simType)) {
+
+        }
+        if (Sim.TYPE_0002.equals(simType)) {
+            // 0002型 01故障部位进行特殊处理。
+            if ("0002GZBW0001".equals(faultRealGZBWId)) {
+                return true;
+            }
+        }
+        if (Sim.TYPE_0003.equals(simType)) {
+            // 干燥管
+            if ("0003GZBW0007".equals(faultRealGZBWId)) {
+                return true;
+            }
+            // 检测剂
+            if ("0003GZBW0006".equals(faultRealGZBWId)) {
+                return true;
+            }
+        }
+        // finally
+        return false;
+    }
 }

+ 18 - 1
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommSendService.java

@@ -192,7 +192,7 @@ public class CommSendService {
      * 执行频率: 2min debug:30s
      */
     public void scheduledConnect() {
-        l.info("scheduled####Connect");
+        l.info("scheduled####Connect  连接情况 的 定时任务");
         if (!SimDebugConfig.SCHEDULED_CONNECT) {
             l.info("连接情况 的 定时任务被禁用!");
             return;
@@ -246,8 +246,10 @@ public class CommSendService {
      */
     public void checkAllSimState() {
         RealExamCollection ecF = realExamCollectionService.selectRealExamCollectionOpened();
+        l.info("ecF.getSimType() = {}", ecF.getSimType());
         if (ecF != null) {
             List<Sim> list = simService.listAllEnableBySimType(ecF.getSimType());
+            l.info("checkAllSimState list.size() = {}", list.size());
             list.forEach(this::checkOneSimState);
         }
     }
@@ -423,6 +425,20 @@ public class CommSendService {
         return list;
     }
 
+    /**
+     * todo:尚未实现
+     *
+     * @param simNum
+     * @param faultIds
+     * @return
+     */
+    public AjaxResult debugWriteSelectedFaultBySimNum(final String simNum,
+                                                      final String[] faultIds,
+                                                      final Boolean checkReplace) {
+
+        return null;
+    }
+
     private String[] getGZBWBySimType(String simType) {
         if (StringUtils.isBlank(simType)) {
             return new String[0];
@@ -500,6 +516,7 @@ public class CommSendService {
         return AjaxResult.error(sbNG.toString());
     }
 
+
     /**
      * 检查读取。
      *

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

@@ -162,7 +162,7 @@ public class RealExamService {
      */
     @Transactional
     public int updateOneState(long examId, final String state) {
-        if (true) {
+        if (false) {
             // php项目维护exam_status字段。java这边不操作。
             // 屏蔽
             return 0;