|
|
@@ -4,6 +4,9 @@ import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.usky.common.core.util.JsonUtils;
|
|
|
import com.usky.common.security.utils.SecurityUtils;
|
|
|
+import com.usky.demo.RemoteTsdbProxyService;
|
|
|
+import com.usky.demo.domain.LastInnerQueryVO;
|
|
|
+import com.usky.demo.domain.LastInnerResultVO;
|
|
|
import com.usky.rule.domain.RuleEngineDevice;
|
|
|
import com.usky.rule.mapper.RuleEngineDeviceMapper;
|
|
|
import com.usky.rule.util.DateTimeUtil;
|
|
|
@@ -34,11 +37,7 @@ import com.usky.rule.service.RuleEngineService;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.Duration;
|
|
|
import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import com.usky.rule.vo.log.BaseLog;
|
|
|
@@ -57,6 +56,8 @@ public class TriggerDeviceUtil {
|
|
|
private DeviceTriggerIncludeMinuteCache historyRecordCache;
|
|
|
@Autowired
|
|
|
private RuleEngineDeviceMapper ruleEngineDeviceMapper;
|
|
|
+ @Autowired
|
|
|
+ private RemoteTsdbProxyService remoteTsdbProxyService;
|
|
|
private static final Integer maxNumberOfReminders = 1;
|
|
|
private static final ExpressionParser parser = new SpelExpressionParser();
|
|
|
|
|
|
@@ -293,6 +294,7 @@ public class TriggerDeviceUtil {
|
|
|
label49:
|
|
|
for(DeviceConstraint deviceConstraint : deviceConstraints) {
|
|
|
String deviceId = ((SimpleVO)deviceConstraint.getDevices().get(0)).getId();
|
|
|
+ String deviceUuid = deviceConstraint.getDevices().get(0).getDeviceUuid();
|
|
|
DeviceTriggerLog deviceTriggerLog = new DeviceTriggerLog();
|
|
|
List<Condition> meetConstraintConditionList = new ArrayList();
|
|
|
deviceTriggerLog.setId(deviceId);
|
|
|
@@ -319,7 +321,21 @@ public class TriggerDeviceUtil {
|
|
|
}
|
|
|
|
|
|
String deviceIdentifier = identifierCondition.getIdentifier();
|
|
|
- BigDecimal currValue = this.getCurrDeviceIdentifierValue(deviceId, deviceIdentifier);
|
|
|
+ //BigDecimal currValue = this.getCurrDeviceIdentifierValue(deviceId, deviceIdentifier);
|
|
|
+ LastInnerQueryVO lastInnerQueryVO = new LastInnerQueryVO();
|
|
|
+ lastInnerQueryVO.setDeviceuuid(Collections.singletonList(deviceUuid));
|
|
|
+ lastInnerQueryVO.setMetrics(Collections.singletonList(deviceIdentifier));
|
|
|
+ List<LastInnerResultVO> currValueList = remoteTsdbProxyService.queryLastDeviceData(lastInnerQueryVO);
|
|
|
+ BigDecimal currValue = currValueList.stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(LastInnerResultVO::getMetrics)
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .flatMap(metrics -> metrics.values().stream())
|
|
|
+ .filter(Objects::nonNull)
|
|
|
+ .map(String::valueOf)
|
|
|
+ .map(BigDecimal::new)
|
|
|
+ .findFirst()
|
|
|
+ .orElse(null);
|
|
|
if (currValue == null) {
|
|
|
boolConstraintExp.append(false);
|
|
|
} else {
|