Bläddra i källkod

测点重复问题、历史数量的庚顿不一致、点名里带.问题处理

xushili 10 månader sedan
förälder
incheckning
fe7436dfd3

+ 3 - 3
timeseries/dao-sql/src/main/java/com/gyee/gaia/dao/sql/things/JpaThingsPointDao.java

@@ -26,9 +26,9 @@ public class JpaThingsPointDao implements IThingsPointDao {
 
     @Override
     public TsPoint findTsPointById(String tagName) {
-        Optional<TsPointEntity> obj = tsPointRepository.findById(tagName);
-        if (obj.isPresent())
-            return obj.get().toData();
+        List<TsPointEntity> allByIdIn = tsPointRepository.findAllByIdIn(tagName);
+        if (allByIdIn.size()>0)
+            return allByIdIn.get(0).toData();
 
         return null;
     }

+ 1 - 1
timeseries/dao-taoscz/src/main/java/com/gyee/gaia/dao/taoscz/TaosHistoryDao.java

@@ -235,7 +235,7 @@ public class TaosHistoryDao implements IHistoryDao {
                 sb.append("select interp(val) from ");
                 sb.append(taosConfig.getTableName(point));
                 sb.append(" range(").append(tsQuery.getStartTs());
-                sb.append(",").append(tsQuery.getEndTs());
+                sb.append(",").append(tsQuery.getEndTs()-1);
                 sb.append(") every(").append(tsQuery.getInterval()).append("s) fill(prev)");
             } else {
                 throw new WisdomException("无效的查询条件!");

+ 10 - 5
timeseries/dao-taoscz/src/main/java/com/gyee/gaia/dao/taoscz/TaosLatestDao.java

@@ -34,7 +34,7 @@ public class TaosLatestDao implements ILatestDao {
         Map<String, TsData> result = new HashMap<>();
         Map<TsDataType, List<TsPoint>> pointGroup = tsPoints.stream().collect(Collectors.groupingBy(TsPoint::getTsDataType));
         for (Map.Entry<TsDataType, List<TsPoint>> entry : pointGroup.entrySet()) {
-            String[] tagNames = entry.getValue().stream().map(TsPoint::getId).toArray(String[]::new);
+            String[] tagNames = entry.getValue().stream().map(tp -> tp.getId().replaceFirst("\\.", "__")).toArray(String[]::new);
             if (entry.getKey() == TsDataType.DOUBLE) {
                 result.putAll(getDoubleTsDataSnapshots(tagNames));
             } else if (entry.getKey() == TsDataType.BOOLEAN) {
@@ -45,8 +45,11 @@ public class TaosLatestDao implements ILatestDao {
                 throw new WisdomException("Taos不支持数据类型:" + entry.getKey());
             }
         }
-
-        return result;
+        Map<String, TsData> result2 = new HashMap<>();
+        for (Map.Entry<String, TsData> entry : result.entrySet()) {
+            result2.put(entry.getKey().replaceFirst("__", "."), entry.getValue());
+        }
+        return result2;
     }
 
 
@@ -60,7 +63,9 @@ public class TaosLatestDao implements ILatestDao {
             String point = config.getTableName(obj.getTagName());
             double value = obj.getTsData().getDoubleValue().get();
             // sb.append(TaosCovertUtil.coverStationPrefix(point)).append(".");
-            sb.append(point).append(" VALUES (");
+            sb.append(point).append(" USING ").append(config.getDbName())
+                    .append(".").append(config.getAIStableName())
+                    .append(" TAGS ('','','','','') VALUES (");
             sb.append(time).append(",").append(value).append(") ");
         }
         sb.append(";");
@@ -144,7 +149,7 @@ public class TaosLatestDao implements ILatestDao {
     @Override
     public boolean writeLatest(List<TsPointData> dataList) throws Exception {
         int writeCount = 0;
-
+        dataList = dataList.stream().peek(tpd -> tpd.setTagName(tpd.getTagName().replaceFirst("\\.", "__"))).collect(Collectors.toList());
         Map<TsDataType, List<TsPointData>> pointGroup = dataList.stream().collect(Collectors.groupingBy(TsPointData::findDataType));
         for (Map.Entry<TsDataType, List<TsPointData>> entry : pointGroup.entrySet()) {
             List<TsPointData> pointDataList = entry.getValue();

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 47203 - 0
资源文件/sql/hf.sql