diff --git a/dao/src/main/java/cc/iotkit/dao/ThingModelMessageDao.java b/dao/src/main/java/cc/iotkit/dao/ThingModelMessageDao.java index 2b06157f..901712b4 100755 --- a/dao/src/main/java/cc/iotkit/dao/ThingModelMessageDao.java +++ b/dao/src/main/java/cc/iotkit/dao/ThingModelMessageDao.java @@ -35,7 +35,7 @@ public class ThingModelMessageDao { builder.must(QueryBuilders.matchPhraseQuery("identifier", identifier)); } NativeSearchQuery query = new NativeSearchQueryBuilder().withQuery(builder) - .withPageable(PageRequest.of(page, size, Sort.by(Sort.Order.desc("time")))) + .withPageable(PageRequest.of(page-1, size, Sort.by(Sort.Order.desc("time")))) .build(); SearchHits result = template.search(query, ThingModelMessage.class); return new Paging<>(result.getTotalHits(), result.getSearchHits().stream() diff --git a/dao/src/main/java/cc/iotkit/dao/config/ElasticsearchConfiguration.java b/dao/src/main/java/cc/iotkit/dao/config/ElasticsearchConfiguration.java old mode 100644 new mode 100755 diff --git a/doc/ma.png b/doc/ma.png old mode 100644 new mode 100755 diff --git a/rule-engine/src/main/java/cc/iotkit/ruleengine/action/HttpService.java b/rule-engine/src/main/java/cc/iotkit/ruleengine/action/HttpService.java old mode 100644 new mode 100755 diff --git a/rule-engine/src/main/java/cc/iotkit/ruleengine/handler/DeviceMessageHandler.java b/rule-engine/src/main/java/cc/iotkit/ruleengine/handler/DeviceMessageHandler.java old mode 100644 new mode 100755 diff --git a/rule-engine/src/main/java/cc/iotkit/ruleengine/listener/DeviceCondition.java b/rule-engine/src/main/java/cc/iotkit/ruleengine/listener/DeviceCondition.java index 8945ef7a..66693597 100755 --- a/rule-engine/src/main/java/cc/iotkit/ruleengine/listener/DeviceCondition.java +++ b/rule-engine/src/main/java/cc/iotkit/ruleengine/listener/DeviceCondition.java @@ -47,10 +47,11 @@ public class DeviceCondition { if ("*".equals(identifier)) { return true; } - //任意匹配 - if ("*".equals(comparator)) { + //存在参数,值任意匹配 + if (parameter.containsKey(identifier) && "*".equals(comparator)) { return true; } + Object left = parameter.get(identifier); if (left == null) { return false; diff --git a/rule-engine/src/main/java/cc/iotkit/ruleengine/listener/DeviceListener.java b/rule-engine/src/main/java/cc/iotkit/ruleengine/listener/DeviceListener.java index e4e8e064..c04f695e 100755 --- a/rule-engine/src/main/java/cc/iotkit/ruleengine/listener/DeviceListener.java +++ b/rule-engine/src/main/java/cc/iotkit/ruleengine/listener/DeviceListener.java @@ -26,7 +26,22 @@ public class DeviceListener implements Listener { public boolean execute(ThingModelMessage message) { String identifier = message.getIdentifier(); Map mapData = message.dataToMap(); + String pk = message.getProductKey(); + String dn = message.getDeviceName(); for (DeviceCondition condition : this.conditions) { + String condPkDn = condition.getDevice(); + String[] pkAndDn = condPkDn.split("/"); + String condPk = pkAndDn[0]; + String condDn = pkAndDn[1]; + //判断产品是否匹配 + if (!pk.equals(condPk)) { + continue; + } + //判断设备是否匹配 + if (!"#".equals(condDn) && !dn.equals(condDn)) { + continue; + } + if (condition.matches(message.getType(), identifier, mapData)) { return true; } diff --git a/rule-engine/src/main/java/cc/iotkit/ruleengine/rule/RuleManager.java b/rule-engine/src/main/java/cc/iotkit/ruleengine/rule/RuleManager.java index 0e56cb64..e1f38843 100755 --- a/rule-engine/src/main/java/cc/iotkit/ruleengine/rule/RuleManager.java +++ b/rule-engine/src/main/java/cc/iotkit/ruleengine/rule/RuleManager.java @@ -59,6 +59,10 @@ public class RuleManager { 1000, Sort.by(Sort.Order.desc("createAt")))); rules.get().forEach(rule -> { try { + //不添加停止的规则 + if (RuleInfo.STATE_STOPPED.equals(rule.getState())) { + return; + } log.info("got rule {} to init", rule.getId()); add(rule); } catch (Throwable e) { diff --git a/standalone-package/pom.xml b/standalone-package/pom.xml old mode 100644 new mode 100755 diff --git a/standalone-package/src/main/resources/assemblies/standalone-package.xml b/standalone-package/src/main/resources/assemblies/standalone-package.xml old mode 100644 new mode 100755