浏览代码

!5 修复bug
Merge pull request !5 from 削梨非DAO/master

xiwa 2 年之前
父节点
当前提交
48f98e1595

+ 5 - 4
iot-rule-engine/src/main/java/cc/iotkit/ruleengine/rule/RuleManager.java

@@ -60,9 +60,13 @@ public class RuleManager {
 
     @SneakyThrows
     public void initRules() {
-        int idx = 0;
+        int idx = 1;
         while (true) {
             Paging<RuleInfo> rules = ruleInfoData.findAll(idx, 1000);
+            // 如果记录为空,直接跳出循环
+            if (rules.getData() == null || rules.getData().isEmpty()) {
+                break;
+            }
             rules.getData().forEach(rule -> {
                 try {
                     //不添加停止的规则
@@ -76,9 +80,6 @@ public class RuleManager {
                 }
             });
             idx++;
-            if (rules.getTotal() == 0) {
-                break;
-            }
         }
     }
 

+ 5 - 4
iot-rule-engine/src/main/java/cc/iotkit/ruleengine/task/TaskManager.java

@@ -48,9 +48,13 @@ public class TaskManager implements ApplicationContextAware {
     }
 
     public void initTask() {
-        int idx = 0;
+        int idx = 1;
         while (true) {
             Paging<TaskInfo> tasks = taskInfoData.findAll(idx, 1000);
+            // 如果记录为空,直接跳出循环
+            if (tasks.getData() == null || tasks.getData().isEmpty()) {
+                break;
+            }
             tasks.getData().forEach(task -> {
                 try {
                     if (!TaskInfo.STATE_RUNNING.equals(task.getState())) {
@@ -63,9 +67,6 @@ public class TaskManager implements ApplicationContextAware {
                 }
             });
             idx++;
-            if (tasks.getTotal() == 0) {
-                break;
-            }
         }
     }