|
@@ -1,12 +1,13 @@
|
|
|
-package com.gyee.wisdom.dao.golden;
|
|
|
+package com.gyee.gaia.dao.golden;
|
|
|
|
|
|
+import com.gyee.gaia.dao.timeseries.GoldenDao;
|
|
|
+import com.gyee.gaia.dao.timeseries.IDataChangeDao;
|
|
|
import com.gyee.wisdom.common.data.timeseries.*;
|
|
|
import com.gyee.wisdom.common.exception.WisdomException;
|
|
|
-import com.gyee.wisdom.dao.timeseries.GoldenDao;
|
|
|
-import com.gyee.wisdom.dao.timeseries.IDataChangeDao;
|
|
|
-import com.gyee.wisdom.dao.timeseries.ILatestDao;
|
|
|
-import com.rtdb.enums.Quality;
|
|
|
-import com.rtdb.model.*;
|
|
|
+import com.rtdb.model.DoubleData;
|
|
|
+import com.rtdb.model.Entity;
|
|
|
+import com.rtdb.model.IntData;
|
|
|
+import com.rtdb.model.MinPoint;
|
|
|
import com.rtdb.service.impl.BaseImpl;
|
|
|
import com.rtdb.service.impl.ServerImpl;
|
|
|
import com.rtdb.service.impl.SnapshotImpl;
|
|
@@ -14,7 +15,10 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.util.*;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Optional;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Component
|
|
@@ -27,13 +31,13 @@ public class GoldenDataChangeDao implements IDataChangeDao {
|
|
|
|
|
|
private HashMap<String, HashMap<TsDataType, CacheData>> topicMap;
|
|
|
|
|
|
- public void registerTopic(String topic, List<TsPoint> tsPoints) {
|
|
|
+ public void registerTopic(String topic, List<TsPoint> tsPoints) {
|
|
|
if (topicMap == null) {
|
|
|
topicMap = new HashMap<>();
|
|
|
}
|
|
|
HashMap<TsDataType, CacheData> tsDataTypeHashMap;
|
|
|
if (topicMap.containsKey(topic)) {
|
|
|
- tsDataTypeHashMap = topicMap.get(topic);
|
|
|
+ tsDataTypeHashMap = topicMap.get(topic);
|
|
|
tsDataTypeHashMap.clear();
|
|
|
} else {
|
|
|
tsDataTypeHashMap = new HashMap<>();
|
|
@@ -85,7 +89,7 @@ public class GoldenDataChangeDao implements IDataChangeDao {
|
|
|
result.putAll(getLongTsDataChanges(topic, tagIds));
|
|
|
} else if (entry.getKey() == TsDataType.BOOLEAN) {
|
|
|
result.putAll(getBooleanTsDataChanges(topic, tagIds));
|
|
|
- } else {
|
|
|
+ } else {
|
|
|
throw new WisdomException("不支持数据类型:" + entry.getKey());
|
|
|
}
|
|
|
}
|
|
@@ -93,7 +97,7 @@ public class GoldenDataChangeDao implements IDataChangeDao {
|
|
|
return result;
|
|
|
} catch (Exception ex) {
|
|
|
log.error(ex.getMessage());
|
|
|
- return null;
|
|
|
+ return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -139,7 +143,7 @@ public class GoldenDataChangeDao implements IDataChangeDao {
|
|
|
CacheData cacheData = topicMap.get(topic).get(TsDataType.LONG);
|
|
|
Entity<IntData> entityD = snap.getIntSnapshots(tagIds);
|
|
|
Map<String, TsData> tsDataMap = new HashMap<>();
|
|
|
- for (int i = 0; i < tagIds.length; i++) {
|
|
|
+ for (int i = 0; i < tagIds.length; i++) {
|
|
|
if (cacheData.getData()[i] == null || cacheData.getData()[i].getDoubleValue().isPresent() == false) {
|
|
|
cacheData.getData()[i] = new GeneralTsData();
|
|
|
cacheData.getData()[i].setTs(entityD.getList().get(i).getDateTime().getTime());
|
|
@@ -155,7 +159,7 @@ public class GoldenDataChangeDao implements IDataChangeDao {
|
|
|
tsDataMap.put(cacheData.getTagNames()[i],
|
|
|
new LongTsData(entityD.getList().get(i).getDateTime().getTime(),
|
|
|
entityD.getList().get(i).getQuality(),
|
|
|
- (long)entityD.getList().get(i).getValue()));
|
|
|
+ (long) entityD.getList().get(i).getValue()));
|
|
|
}
|
|
|
}
|
|
|
return tsDataMap;
|