瀏覽代碼

完善debugClearAllSeatAllFault

tom 2 月之前
父節點
當前提交
2c5ef8d782

+ 12 - 2
ruoyi-sim/src/main/java/com/ruoyi/sim/controller/HardwareCommDebugController.java

@@ -75,10 +75,15 @@ public class HardwareCommDebugController extends BaseController {
         return commSendService.debugClearAllFaultBySeatId(seatId);
     }
 
+    /**
+     * 新版使用seatId
+     *
+     * @return
+     */
     @GetMapping(value = "/debugClearAllOnlineSimAllFault/")
-    @ApiOperation("debug清除所有在线的模拟器所有故障")
+    @ApiOperation("debug清除所有座次上连接的模拟器的所有故障")
     public AjaxResult debugClearAllOnlineSimAllFault() {
-        return commSendService.debugClearAllOnlineSimAllFault();
+        return commSendService.debugClearAllSeatAllFault();
     }
 
     @GetMapping(value = "/debugWriteOneFault/{seatId}/{bindHardwareMsg}")
@@ -101,6 +106,11 @@ public class HardwareCommDebugController extends BaseController {
         return commSendService.debugWriteSelectedFaultBySimNum(seatId, faultIds, checkReplace);
     }
 
+    /**
+     * 新版使用seatId
+     *
+     * @return
+     */
     @GetMapping(value = "/debugScanAllSeat/")
     @ApiOperation("debug扫描所有座次模拟器")
     public AjaxResult debugRefreshAllSeat() {

+ 25 - 7
ruoyi-sim/src/main/java/com/ruoyi/sim/service/impl/CommSendService.java

@@ -384,13 +384,31 @@ public class CommSendService {
         return send(sm, seat, sim, RETRY_COUNT_CLEAR_ONE_FAULT, commStrategy.getSleepLong());
     }
 
-    public AjaxResult debugClearAllOnlineSimAllFault() {
-        l.info("debugClearAllOnlineSimAllFault");
-        simService.listAllOnline().forEach(s -> {
-            // AjaxResult ar = debugClearAllFaultBySeatId(0);// todo:尚未实现
-        });
+    /**
+     * debug清除所有座次上的模拟器的所有故障
+     *
+     * @return
+     */
+    public AjaxResult debugClearAllSeatAllFault() {
         debugFaultService.deleteAll();
-        return AjaxResult.success("清除成功,清除所有在线模拟器所有故障!");
+        List<Seat> list = seatService.listAllEnable();
+        for (Seat seat : list) {
+            if (seat == null) {
+                AjaxResult.error("座次数据异常!");
+            }
+            //
+            commCheckService.checkOneSeatState(seat, true);
+            // 重新查询
+            seat = seatService.selectSeatBySeatId(seat.getSeatId());
+            if (seat.getCurrentSimId() == null || seat.getCurrentSimId() == 0L) {
+                continue;
+            }
+            AjaxResult ar = debugClearAllFaultBySeatId(seat.getSeatId());
+            if (ar.isError()) {
+                return ar;
+            }
+        }
+        return AjaxResult.success("清除成功,清除所有座次正确连接的模拟器的,所有的故障!");
     }
 
     /**
@@ -425,7 +443,7 @@ public class CommSendService {
             }
             list.add(sm);
         }
-        return AjaxResult.success("清除成功,清除当前模拟器所有故障!");
+        return AjaxResult.success("清除成功,清除当前模拟器所有故障!");
     }
 
     /**