Browse Source

taos3.0.3.0 adapter测通

xushili 1 year atrás
parent
commit
a5995984a8

+ 1 - 1
dao/dao-redis/src/main/java/com/gyee/wisdom/dao/redis/RedisLatestDao.java

@@ -30,7 +30,7 @@ public class RedisLatestDao implements ILatestDao {
         Map<String, TsData> resultTest = new HashMap<>();
         try {
             List<String> collect = tsPoints.stream().map(s -> s.getId()).collect(Collectors.toList());
-            List<byte[]> bytesList = redisValUtil.getBytesList(Integer.parseInt(tsPoints.get(0).getTag()), collect);
+            List<byte[]> bytesList = redisValUtil.getBytesList(0, collect);
             for (int i = 0; i < bytesList.size(); i++) {
                 double val = ByteUtil.getDouble(bytesList.get(i), 0);
                 long ts = ByteUtil.getLong2(bytesList.get(i), 8);

+ 1 - 1
dao/dao-taoscz/src/main/java/com/gyee/wisdom/dao/taoscz/TaosConfig.java

@@ -71,7 +71,7 @@ public class TaosConfig {
     }
 
     public String getTableName(String tagName) {
-        return dbName + "." + tagName;
+        return dbName + "." + tagName.toLowerCase();
     }
 
     public String getDbName() {

+ 9 - 9
dao/dao-taoscz/src/main/java/com/gyee/wisdom/dao/taoscz/TaosHistoryDao.java

@@ -60,14 +60,14 @@ public class TaosHistoryDao implements IHistoryDao {
         StringBuilder sb = new StringBuilder();
         sb.append("select avg(val),max(val),min(val) from ");
         sb.append(taosConfig.getTableName(tsQuery.getTsPoint().getId()));
-        sb.append(" where ts between").append(tsQuery.getStartTs());
+        sb.append(" where ts between ").append(tsQuery.getStartTs());
         sb.append(" and ").append(tsQuery.getEndTs());
-        sb.append(" interval(").append(tsQuery.getInterval()).append("s)");
+        //sb.append(" interval(").append(tsQuery.getInterval()).append("s)");
         ResultSet rs = st.executeQuery(sb.toString());
         while (rs.next()) {
-            DoubleTsData avgData = new DoubleTsData(rs.getLong(1), (short) 1, rs.getDouble(2));
-            DoubleTsData maxData = new DoubleTsData(rs.getLong(1), (short) 1, rs.getDouble(3));
-            DoubleTsData minData = new DoubleTsData(rs.getLong(1), (short) 1, rs.getDouble(4));
+            DoubleTsData avgData = new DoubleTsData(tsQuery.getStartTs(), (short) 1, rs.getDouble(1));
+            DoubleTsData maxData = new DoubleTsData(tsQuery.getStartTs(), (short) 1, rs.getDouble(2));
+            DoubleTsData minData = new DoubleTsData(tsQuery.getStartTs(), (short) 1, rs.getDouble(3));
             DoubleStatData statData = new DoubleStatData(avgData, maxData, minData);
             result.add(statData);
         }
@@ -227,11 +227,11 @@ public class TaosHistoryDao implements IHistoryDao {
             sb.append(" and ").append(tsQuery.getEndTs());
         } else if (tsQuery.getInterpolation() == Interpolation.SNAP) {
             if (tsQuery.getDateArray() != null && tsQuery.getDateArray().length > 0) {
-                sb.append("select interp(val) from ");
+                sb.append("select _irowts,interp(val) from ");
                 sb.append(taosConfig.getTableName(point));
-                sb.append(" where ts between ").append(tsQuery.getStartTs());
-                sb.append(" and ").append(tsQuery.getEndTs());
-                sb.append(" every(").append(tsQuery.getInterval()).append("s) fill(prev)");
+                sb.append(" range(").append(tsQuery.getStartTs());
+                sb.append(",").append(tsQuery.getEndTs());
+                sb.append(") every(").append(tsQuery.getInterval()).append("s) fill(prev)");
             } else {
                 throw new WisdomException("无效的查询条件!");
             }

+ 5 - 4
dao/dao-taoscz/src/main/java/com/gyee/wisdom/dao/taoscz/TaosLatestDao.java

@@ -178,7 +178,7 @@ public class TaosLatestDao implements ILatestDao {
         Map<String, TsData> tsDataMap = new HashMap<>();
         Statement st = config.getInstance().createStatement();
 
-        String inString = Arrays.stream(tagNames).map(s -> "'" + s + "'").collect(Collectors.joining(","));
+        String inString = Arrays.stream(tagNames).map(s -> "'" + s.toLowerCase() + "'").collect(Collectors.joining(","));
         inString = "select last_row(*),tbname from " + config.getDbName() + "." + config.getAIStableName()
                 + " where tbname in (" + inString + ") group by tbname;";
         ResultSet rs = st.executeQuery(inString);
@@ -206,9 +206,10 @@ public class TaosLatestDao implements ILatestDao {
         Map<String, TsData> tsDataMap = new HashMap<>();
         Statement st = config.getInstance().createStatement();
 
-        String inString = Arrays.stream(tagNames).map(s -> "'" + s + "'").collect(Collectors.joining(","));
-        ResultSet rs = st.executeQuery("select last_row(*),tbname from " + config.getDbName() + "." + config.getDIStableName() +
-                " where tbname in (" + inString + ") group by tbname;");
+        String inString = Arrays.stream(tagNames).map(s -> "'" + s.toLowerCase() + "'").collect(Collectors.joining(","));
+        inString = "select last_row(*),tbname from " + config.getDbName() + "." + config.getDIStableName() +
+                " where tbname in (" + inString + ") group by tbname;";
+        ResultSet rs = st.executeQuery(inString);
 
         while (rs.next()) {
             tsDataMap.put(rs.getString(3).toUpperCase(), new BooleanTsData(rs.getTimestamp(1).getTime(), (short) 0, rs.getBoolean(2)));

+ 1 - 1
dao/dao-taoscz/src/main/java/com/gyee/wisdom/dao/taoscz/TaskCallable.java

@@ -50,7 +50,7 @@ public class TaskCallable implements Callable<Map<String, TsData>> {
 //            String tableName = dbName+ "." + this.tagName;
             StringBuilder sb = new StringBuilder();
             sb.append("select last_row(*) from ").append(taosConfig.getDbName()).append(".")
-                    .append(tagName).append(" where ts>=").append(time);
+                    .append(tagName).append(" where ts<=").append(time);
             //log.info(sql);
             rs = st.executeQuery(sb.toString());
             if (rs.next()) {

+ 7 - 7
data-adapter/src/main/resources/application-hf.yaml

@@ -50,10 +50,10 @@ knife4j:
   redis:
     # 是否采用json序列化方式,若不采用jackson序列化
     jsonSerialType: 'Fastjson'
-    host: 10.0.118.70
-    password: wanghs123
+    host: 10.0.118.76
+    password:
     port: 6379
-    databases: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15] # 要使用的库,会根据此处填写的库生成redisTemplate
+    databases: [0] # 要使用的库,会根据此处填写的库生成redisTemplate
     timeout: 60s
     lettuce: # lettuce基于netty,线程安全,支持并发
       pool:
@@ -105,15 +105,15 @@ taos:
 
 #适配器链接taos数据库配置信息
 taoscz:
-  server_ip: 192.168.2.10
-  server_port: 6041
+  server_ip: 10.0.118.76
+  server_port: 6030
   db_name: hfxny
   user_name: root
   password: taosdata
   pool_size: 10
   max_pool_size: 100
-  driver_type: com.taosdata.jdbc.rs.RestfulDriver
-  #driver_type: com.taosdata.jdbc.TSDBDriver
+  #driver_type: com.taosdata.jdbc.rs.RestfulDriver
+  driver_type: com.taosdata.jdbc.TSDBDriver
   #taos中ai测点的超级表名
   di_stable_name: pointdi
   #taos中di测点的超级表名

+ 67 - 0
transport/redis2taos/src/main/resources/application-hf.yaml

@@ -0,0 +1,67 @@
+server:
+  port: 8085
+
+spring:
+  datasource:
+    driver-class-name: oracle.jdbc.OracleDriver
+    url: jdbc:oracle:thin:@10.0.118.71:1521:gdsj
+    username: gdprod
+    password: gd123
+    type: com.alibaba.druid.pool.DruidDataSource
+    druid:
+      max-active: 20
+      initial-size: 1
+      min-idle: 3
+      max-wait: 60000
+      time-between-eviction-runs-millis: 60000
+      min-evictable-idle-time-millis: 300000
+      test-while-idle: true
+      test-on-borrow: false
+      test-on-return: false
+  application:
+    name: transport
+  jpa:
+    show-sql: false
+  cache:
+    type: SIMPLE
+
+knife4j:
+  redis:
+    # 是否采用json序列化方式,若不采用jackson序列化
+    jsonSerialType: 'Fastjson'
+    host: 10.0.118.76
+    password:
+    port: 6379
+    databases: [0] # 要使用的库,会根据此处填写的库生成redisTemplate
+    timeout: 60s
+    lettuce: # lettuce基于netty,线程安全,支持并发
+      pool:
+        max-active: 50
+        max-wait: -1ms
+        max-idle: 8
+        min-idle: 0
+  cache:
+    type: Simple
+timeseries:
+  db-type: redis
+#taoscz场站数据 数据连接方式分为两种 JDBC-JNI和JDBC-RESTful
+#JDBC-JNI方式驱动为com.taosdata.jdbc.TSDBDriver 端口为6030
+#JDBC-RESTful方式驱动为com.taosdata.jdbc.rs.RestfulDriver 端口为6041
+taoscz:
+  server_ip: 10.0.118.76
+  server_port: 6030
+  db_name: hfxny
+  user_name: root
+  password: taosdata
+  pool_size: 10
+  max_pool_size: 100
+  driver_type: com.taosdata.jdbc.TSDBDriver
+
+#是否缓存所有风机测点
+isLoadAllTag: true
+
+
+
+
+
+