规则监听问题修复
parent
4dbed12ac1
commit
edde8b16a6
|
@ -35,7 +35,7 @@ public class ThingModelMessageDao {
|
||||||
builder.must(QueryBuilders.matchPhraseQuery("identifier", identifier));
|
builder.must(QueryBuilders.matchPhraseQuery("identifier", identifier));
|
||||||
}
|
}
|
||||||
NativeSearchQuery query = new NativeSearchQueryBuilder().withQuery(builder)
|
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();
|
.build();
|
||||||
SearchHits<ThingModelMessage> result = template.search(query, ThingModelMessage.class);
|
SearchHits<ThingModelMessage> result = template.search(query, ThingModelMessage.class);
|
||||||
return new Paging<>(result.getTotalHits(), result.getSearchHits().stream()
|
return new Paging<>(result.getTotalHits(), result.getSearchHits().stream()
|
||||||
|
|
0
dao/src/main/java/cc/iotkit/dao/config/ElasticsearchConfiguration.java
Normal file → Executable file
0
dao/src/main/java/cc/iotkit/dao/config/ElasticsearchConfiguration.java
Normal file → Executable file
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
0
rule-engine/src/main/java/cc/iotkit/ruleengine/action/HttpService.java
Normal file → Executable file
0
rule-engine/src/main/java/cc/iotkit/ruleengine/action/HttpService.java
Normal file → Executable file
0
rule-engine/src/main/java/cc/iotkit/ruleengine/handler/DeviceMessageHandler.java
Normal file → Executable file
0
rule-engine/src/main/java/cc/iotkit/ruleengine/handler/DeviceMessageHandler.java
Normal file → Executable file
|
@ -47,10 +47,11 @@ public class DeviceCondition {
|
||||||
if ("*".equals(identifier)) {
|
if ("*".equals(identifier)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//任意匹配
|
//存在参数,值任意匹配
|
||||||
if ("*".equals(comparator)) {
|
if (parameter.containsKey(identifier) && "*".equals(comparator)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Object left = parameter.get(identifier);
|
Object left = parameter.get(identifier);
|
||||||
if (left == null) {
|
if (left == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -26,7 +26,22 @@ public class DeviceListener implements Listener<DeviceCondition> {
|
||||||
public boolean execute(ThingModelMessage message) {
|
public boolean execute(ThingModelMessage message) {
|
||||||
String identifier = message.getIdentifier();
|
String identifier = message.getIdentifier();
|
||||||
Map<String, Object> mapData = message.dataToMap();
|
Map<String, Object> mapData = message.dataToMap();
|
||||||
|
String pk = message.getProductKey();
|
||||||
|
String dn = message.getDeviceName();
|
||||||
for (DeviceCondition condition : this.conditions) {
|
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)) {
|
if (condition.matches(message.getType(), identifier, mapData)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,10 @@ public class RuleManager {
|
||||||
1000, Sort.by(Sort.Order.desc("createAt"))));
|
1000, Sort.by(Sort.Order.desc("createAt"))));
|
||||||
rules.get().forEach(rule -> {
|
rules.get().forEach(rule -> {
|
||||||
try {
|
try {
|
||||||
|
//不添加停止的规则
|
||||||
|
if (RuleInfo.STATE_STOPPED.equals(rule.getState())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
log.info("got rule {} to init", rule.getId());
|
log.info("got rule {} to init", rule.getId());
|
||||||
add(rule);
|
add(rule);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
|
0
standalone-package/src/main/resources/assemblies/standalone-package.xml
Normal file → Executable file
0
standalone-package/src/main/resources/assemblies/standalone-package.xml
Normal file → Executable file
Loading…
Reference in New Issue