|
|
|
@ -116,23 +116,30 @@ public class IEDCollectService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void collectAndSaveValue(String paramindexNew, String paramindexT, String fc, Rptparamindex rpt) throws Exception {
|
|
|
|
|
String value = iecClient.getValue(paramindexNew, fc);
|
|
|
|
|
String time = iecClient.getValue(paramindexT, fc);
|
|
|
|
|
// 更新关联关系缓存
|
|
|
|
|
String key = paramindexNew + "_" + fc;
|
|
|
|
|
String value = rpt.getEqmid() + "," + rpt.getColname();
|
|
|
|
|
StaticVariable.paramRelationMap.put(key, value);
|
|
|
|
|
key = paramindexT + "_" + fc;
|
|
|
|
|
value = rpt.getEqmid() + ",acquisitionTime";
|
|
|
|
|
StaticVariable.paramRelationMap.put(key, value);
|
|
|
|
|
|
|
|
|
|
// 采集数据
|
|
|
|
|
BasicDataAttribute valueNode = iecClient.getNode(paramindexNew, fc);
|
|
|
|
|
BasicDataAttribute timeNode = iecClient.getNode(paramindexT, fc);
|
|
|
|
|
value = valueNode.getValueString();
|
|
|
|
|
String time = timeNode.getValueString();
|
|
|
|
|
log.info("采集到" + fc + " " + paramindexNew + "=" + value + ", t=" + time);
|
|
|
|
|
time = DateUtil.fromZoneUTCToLocal(time);
|
|
|
|
|
time = this.makeSameTime(rpt.getEqmid(), time);
|
|
|
|
|
_dataService.insertData(rpt.getTablename(), rpt.getEqmid(), time, rpt.getColname(), value);
|
|
|
|
|
|
|
|
|
|
// 更新最新数据缓存
|
|
|
|
|
updateLastData(rpt.getEqmid(), rpt.getColname(), value, time);
|
|
|
|
|
StaticVariable.updateLastData(rpt.getEqmid(), rpt.getColname(), value, time);
|
|
|
|
|
|
|
|
|
|
// 更新关联关系缓存
|
|
|
|
|
String key = paramindexNew + "_" + fc;
|
|
|
|
|
value = rpt.getEqmid() + "," + rpt.getColname();
|
|
|
|
|
StaticVariable.paramRelationMap.put(key, value);
|
|
|
|
|
key = paramindexT + "_" + fc;
|
|
|
|
|
value = rpt.getEqmid() + ",acquisitionTime";
|
|
|
|
|
StaticVariable.paramRelationMap.put(key, value);
|
|
|
|
|
// 更新服务端
|
|
|
|
|
StaticVariable.updateServerNodeValue(valueNode);
|
|
|
|
|
StaticVariable.updateServerNodeValue(timeNode);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String makeSameTime(Integer eqmid, String time) {
|
|
|
|
@ -229,34 +236,4 @@ public class IEDCollectService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void updateLastData(Integer eqmid, String colname, String value, String time) {
|
|
|
|
|
HashMap<String, String> map = StaticVariable.sensorLastDataMap.get(eqmid);
|
|
|
|
|
if (map == null) {
|
|
|
|
|
map = new HashMap<>();
|
|
|
|
|
StaticVariable.sensorLastDataMap.put(eqmid, map);
|
|
|
|
|
}
|
|
|
|
|
map.put(colname, value);
|
|
|
|
|
if (time != null) {
|
|
|
|
|
map.put("acquisitionTime", time);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void updateLastData(BasicDataAttribute bda) {
|
|
|
|
|
try {
|
|
|
|
|
String ref = bda.getReference().toString();
|
|
|
|
|
String key = ref + "_" + bda.getFc().toString();
|
|
|
|
|
if (StaticVariable.paramRelationMap.containsKey(key)) {
|
|
|
|
|
String value = StaticVariable.paramRelationMap.get(key);
|
|
|
|
|
String[] str = value.split(",");
|
|
|
|
|
Integer eqmid = Integer.parseInt(str[0]);
|
|
|
|
|
String colname = str[1];
|
|
|
|
|
value = bda.getValueString();
|
|
|
|
|
if ("acquisitionTime".equals(colname)) {
|
|
|
|
|
value = DateUtil.fromZoneUTCToLocal(value);
|
|
|
|
|
}
|
|
|
|
|
updateLastData(eqmid, colname, value, null);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ignore) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|