|
|
@ -1,20 +1,18 @@
|
|
|
|
package com.xydl.cac.transform;
|
|
|
|
package com.xydl.cac.transform;
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.util.StringUtils;
|
|
|
|
import com.alibaba.excel.util.StringUtils;
|
|
|
|
import com.xydl.cac.entity.I2syncConfig;
|
|
|
|
import com.xydl.cac.entity.*;
|
|
|
|
import com.xydl.cac.entity.I2syncField;
|
|
|
|
|
|
|
|
import com.xydl.cac.entity.I2syncRecord;
|
|
|
|
|
|
|
|
import com.xydl.cac.entity.NSensor;
|
|
|
|
|
|
|
|
import com.xydl.cac.model.i2sync.Attr;
|
|
|
|
import com.xydl.cac.model.i2sync.Attr;
|
|
|
|
import com.xydl.cac.model.i2sync.Datanode;
|
|
|
|
import com.xydl.cac.model.i2sync.Datanode;
|
|
|
|
import com.xydl.cac.model.i2sync.Monitordata;
|
|
|
|
import com.xydl.cac.model.i2sync.Monitordata;
|
|
|
|
import com.xydl.cac.model.i2sync.Request;
|
|
|
|
import com.xydl.cac.model.i2sync.Request;
|
|
|
|
import com.xydl.cac.util.DataTable;
|
|
|
|
import com.xydl.cac.task.CacheTask;
|
|
|
|
import com.xydl.cac.util.DateUtil;
|
|
|
|
import com.xydl.cac.util.DateUtil;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
@ -25,6 +23,17 @@ public class I2DataTransformer {
|
|
|
|
public Request transform(NSensor sensor, I2syncRecord record, I2syncConfig config,
|
|
|
|
public Request transform(NSensor sensor, I2syncRecord record, I2syncConfig config,
|
|
|
|
List<I2syncField> fieldList, List<Map<String, Object>> dataList) throws Exception {
|
|
|
|
List<I2syncField> fieldList, List<Map<String, Object>> dataList) throws Exception {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查到可用规则
|
|
|
|
|
|
|
|
List<WarnRule> ruleList = new ArrayList<>();
|
|
|
|
|
|
|
|
Iterator<Integer> it = CacheTask.rule_Cache.keySet().iterator();
|
|
|
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
|
|
|
Integer key = it.next();
|
|
|
|
|
|
|
|
WarnRule rule = CacheTask.rule_Cache.get(key);
|
|
|
|
|
|
|
|
if (rule.canDo() && rule.getSensorId().equals(sensor.getId())) {
|
|
|
|
|
|
|
|
ruleList.add(rule);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<Datanode> nodeList = new ArrayList<>();
|
|
|
|
List<Datanode> nodeList = new ArrayList<>();
|
|
|
|
for (Map<String, Object> map : dataList) {
|
|
|
|
for (Map<String, Object> map : dataList) {
|
|
|
|
String date = (String) map.get("acquisitionTime");
|
|
|
|
String date = (String) map.get("acquisitionTime");
|
|
|
@ -44,7 +53,11 @@ public class I2DataTransformer {
|
|
|
|
attr = new Attr();
|
|
|
|
attr = new Attr();
|
|
|
|
attr.setName(field.getDestFieldName());
|
|
|
|
attr.setName(field.getDestFieldName());
|
|
|
|
attr.setValue(String.valueOf(value));
|
|
|
|
attr.setValue(String.valueOf(value));
|
|
|
|
attr.setAlarm("FALSE");
|
|
|
|
if (this.triggerRule(ruleList, field.getFieldName(), value)) {
|
|
|
|
|
|
|
|
attr.setAlarm("TRUE");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
attr.setAlarm("FALSE");
|
|
|
|
|
|
|
|
}
|
|
|
|
if (StringUtils.isBlank(node.getType())) {
|
|
|
|
if (StringUtils.isBlank(node.getType())) {
|
|
|
|
node.setType(config.getTypeCode());
|
|
|
|
node.setType(config.getTypeCode());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -64,4 +77,16 @@ public class I2DataTransformer {
|
|
|
|
request.setMonitordata(monitordata);
|
|
|
|
request.setMonitordata(monitordata);
|
|
|
|
return request;
|
|
|
|
return request;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean triggerRule(List<WarnRule> ruleList, String fieldName, Object value) {
|
|
|
|
|
|
|
|
for (WarnRule rule : ruleList) {
|
|
|
|
|
|
|
|
if (rule.getTypePoint().getField().equalsIgnoreCase(fieldName)) {
|
|
|
|
|
|
|
|
boolean r = rule.triggerRule(value);
|
|
|
|
|
|
|
|
if (r) {
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|