浏览代码

hash2binary

xushili 3 周之前
父节点
当前提交
4feeae5bab
共有 35 个文件被更改,包括 590 次插入41 次删除
  1. 0 2
      clientside/src/main/java/com/gyee/clientside/controller/TaosController.java
  2. 14 7
      clientside/src/main/resources/application.yml
  3. 0 1
      clientside/src/main/resources/static/assets/axios.1f49b28e.js
  4. 1 0
      clientside/src/main/resources/static/assets/axios.e4e8b213.js
  5. 1 1
      clientside/src/main/resources/static/assets/index.6dee49c0.css
  6. 0 1
      clientside/src/main/resources/static/assets/index.2db0316f.js
  7. 1 0
      clientside/src/main/resources/static/assets/index.346322ab.js
  8. 1 0
      clientside/src/main/resources/static/assets/index.36561025.js
  9. 1 0
      clientside/src/main/resources/static/assets/index.4b07e2e5.js
  10. 0 1
      clientside/src/main/resources/static/assets/index.516d4e34.js
  11. 0 1
      clientside/src/main/resources/static/assets/index.5e19ab78.js
  12. 1 1
      clientside/src/main/resources/static/assets/index.da732290.js
  13. 0 1
      clientside/src/main/resources/static/assets/index.bcb96acb.js
  14. 1 1
      clientside/src/main/resources/static/assets/index.665f04fc.css
  15. 1 0
      clientside/src/main/resources/static/assets/index.fc26a1d9.js
  16. 1 0
      clientside/src/main/resources/static/assets/routerViewss.10b58024.js
  17. 0 1
      clientside/src/main/resources/static/assets/routerViewss.379c9691.js
  18. 1 0
      clientside/src/main/resources/static/assets/tree.vue_vue&type=script&setup=true&name=search&lang.102d2073.js
  19. 0 1
      clientside/src/main/resources/static/assets/tree.vue_vue&type=script&setup=true&name=search&lang.a44512a1.js
  20. 1 1
      clientside/src/main/resources/static/assets/vendor.e280aae7.js
  21. 33 0
      clientside/src/main/resources/static/static/config/config.js
  22. 1 0
      clientside/src/main/resources/static/static/config/modeConfig.js
  23. 5 5
      clientside/src/main/resources/templates/index.html
  24. 6 1
      gateway/build.gradle
  25. 2 0
      gateway/src/main/java/com/gyee/gateway/GatewayApp.java
  26. 45 0
      gateway/src/main/resources/application.yml
  27. 1 1
      gradle/wrapper/gradle-wrapper.properties
  28. 43 0
      redisread/src/main/java/com/gyee/redisread/entity/PointData.java
  29. 58 10
      redisread/src/main/java/com/gyee/redisread/task/TaskRedisRead.java
  30. 311 0
      redisread/src/main/java/com/gyee/redisread/util/ByteUtil.java
  31. 2 2
      redisread/src/main/java/com/gyee/redisread/util/ChangedSave.java
  32. 28 0
      redisread/src/test/java/1.txt
  33. 27 0
      redisread/src/test/java/2.txt
  34. 1 1
      settings.gradle
  35. 2 1
      taoswrite/build.gradle

+ 0 - 2
clientside/src/main/java/com/gyee/clientside/controller/TaosController.java

@@ -1,7 +1,5 @@
 package com.gyee.clientside.controller;
 
-import cn.hutool.poi.excel.ExcelReader;
-import cn.hutool.poi.excel.ExcelUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

+ 14 - 7
clientside/src/main/resources/application.yml

@@ -2,6 +2,10 @@ server:
   port: 5087
 
 spring:
+  thymeleaf:
+    prefix: classpath:/templates/
+    mode: HTML5
+    cache: false
   servlet:
     multipart:
       max-file-size: 100MB
@@ -33,19 +37,22 @@ spring:
 
 #适配器链接taos数据库配置信息
 taoscz:
-  server_ip: 192.168.126.128
-  #server_ip: 192.168.10.13
-  server_port: 6030
+  #server_ip: 192.168.126.128
+#  server_ip: 192.168.10.28
+  server_ip: 123.60.219.66
+#  server_port: 6030
+  server_port: 6041
   #数据库名
-  db_name: nxxny
+#  db_name: nxxny
+  db_name: jsfw_db
   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测点的超级表名
-  ai_stable_name: pointai
+  ai_stable_name: pointci
   #taos中di测点的超级表名
   di_stable_name: pointdi
 

文件差异内容过多而无法显示
+ 0 - 1
clientside/src/main/resources/static/assets/axios.1f49b28e.js


文件差异内容过多而无法显示
+ 1 - 0
clientside/src/main/resources/static/assets/axios.e4e8b213.js


文件差异内容过多而无法显示
+ 1 - 1
clientside/src/main/resources/static/assets/index.6dee49c0.css


文件差异内容过多而无法显示
+ 0 - 1
clientside/src/main/resources/static/assets/index.2db0316f.js


文件差异内容过多而无法显示
+ 1 - 0
clientside/src/main/resources/static/assets/index.346322ab.js


文件差异内容过多而无法显示
+ 1 - 0
clientside/src/main/resources/static/assets/index.36561025.js


文件差异内容过多而无法显示
+ 1 - 0
clientside/src/main/resources/static/assets/index.4b07e2e5.js


文件差异内容过多而无法显示
+ 0 - 1
clientside/src/main/resources/static/assets/index.516d4e34.js


文件差异内容过多而无法显示
+ 0 - 1
clientside/src/main/resources/static/assets/index.5e19ab78.js


文件差异内容过多而无法显示
+ 1 - 1
clientside/src/main/resources/static/assets/index.da732290.js


文件差异内容过多而无法显示
+ 0 - 1
clientside/src/main/resources/static/assets/index.bcb96acb.js


文件差异内容过多而无法显示
+ 1 - 1
clientside/src/main/resources/static/assets/index.665f04fc.css


文件差异内容过多而无法显示
+ 1 - 0
clientside/src/main/resources/static/assets/index.fc26a1d9.js


+ 1 - 0
clientside/src/main/resources/static/assets/routerViewss.10b58024.js

@@ -0,0 +1 @@
+import{f as s,h as a,k as t,w as e,b as n,r as o,o as r,c as u,P as c,j as l,Q as i}from"./vendor.6869158f.js";const d={class:"content"},m={__name:"routerViewss",setup(m){const p=n(),f=s((()=>p.state.tagsList.map((s=>s.name))));return s((()=>p.state.collapse)),(s,n)=>{const m=o("router-view");return r(),a("div",d,[t(m,null,{default:e((({Component:s})=>[(r(),u(i,{includes:l(f)},[(r(),u(c(s)))],1032,["includes"]))])),_:1})])}}};export default m;

+ 0 - 1
clientside/src/main/resources/static/assets/routerViewss.379c9691.js

@@ -1 +0,0 @@
-import{g as s,i as a,l as e,w as t,b as n,r as o,o as r,c as l,Q as u,k as c,R as i}from"./vendor.e280aae7.js";const d={class:"content"},m={__name:"routerViewss",setup(m){const p=n(),f=s((()=>p.state.tagsList.map((s=>s.name))));return s((()=>p.state.collapse)),(s,n)=>{const m=o("router-view");return r(),a("div",d,[e(m,null,{default:t((({Component:s})=>[(r(),l(i,{includes:c(f)},[(r(),l(u(s)))],1032,["includes"]))])),_:1})])}}};export default m;

文件差异内容过多而无法显示
+ 1 - 0
clientside/src/main/resources/static/assets/tree.vue_vue&type=script&setup=true&name=search&lang.102d2073.js


文件差异内容过多而无法显示
+ 0 - 1
clientside/src/main/resources/static/assets/tree.vue_vue&type=script&setup=true&name=search&lang.a44512a1.js


文件差异内容过多而无法显示
+ 1 - 1
clientside/src/main/resources/static/assets/vendor.e280aae7.js


+ 33 - 0
clientside/src/main/resources/static/static/config/config.js

@@ -0,0 +1,33 @@
+
+const config = {
+    baseURL: 'http://192.168.10.28:6041',
+    socketURL: 'ws://192.168.10.28:6041',
+    redisURL: 'http://192.168.10.9:5087',
+    redisetURL: 'ws://192.168.10.9:5087',
+    taosURL: 'http://192.168.10.9:5085',
+    taosetURL: 'ws://192.168.10.9:5085'
+}
+// const config = {
+//     baseURL: 'http://10.0.118.76:6041',
+//     socketURL: 'ws://10.0.118.76:6041',
+//     redisURL: 'http://10.0.118.76:5087',
+//     redisetURL: 'ws://10.0.118.76:5087',
+//     taosURL: 'http://10.0.118.76:5085',
+//     taosetURL: 'ws://10.0.118.76:5085'
+// }
+
+// const config = {
+//     baseURL: 'http://192.168.10.28:5087',
+//     socketURL: 'ws://192.168.10.28:5087'
+// }
+
+
+// const config = {
+//     baseURL: 'http://192.168.10.28:5085',
+//     socketURL: 'ws://192.168.10.28:5085'
+// }
+
+
+export default config;
+export const baseURL = config.baseURL
+export const socketURL = config.socketURL

+ 1 - 0
clientside/src/main/resources/static/static/config/modeConfig.js

@@ -1,3 +1,4 @@
+
 // 本地联调开关
 const localTest = false;
 

+ 5 - 5
clientside/src/main/resources/templates/index.html

@@ -1,16 +1,16 @@
 <!DOCTYPE html>
-<html lang="zh">
+<html lang="en">
 
 <head>
     <meta charset="UTF-8" />
     <link rel="icon" href="./favicon.ico" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title>发电能力分析平台</title>
+    <title>taos管理</title>
     <script src="./static/config/modeConfig.js"></script>
-<script type="module" crossorigin src="./assets/index.2db0316f.js"></script>
-  <link rel="modulepreload" href="./assets/vendor.e280aae7.js">
+<script type="module" crossorigin src="./assets/index.fc26a1d9.js"></script>
+  <link rel="modulepreload" href="./assets/vendor.6869158f.js">
   <link rel="stylesheet" href="./assets/vendor.8596e0db.css">
-  <link rel="stylesheet" href="./assets/index.665f04fc.css">
+  <link rel="stylesheet" href="./assets/index.f825c6fc.css">
 </head>
 
 <body>

+ 6 - 1
gateway/build.gradle

@@ -1 +1,6 @@
-version '1.0'
+version '1.0'
+
+dependencies {
+    implementation 'org.springframework.cloud:spring-cloud-starter-gateway:3.1.7'
+    implementation 'com.alibaba.cloud:spring-cloud-starter-alibaba-nacos-discovery:2021.1'
+}

+ 2 - 0
gateway/src/main/java/com/gyee/gateway/GatewayApp.java

@@ -2,7 +2,9 @@ package com.gyee.gateway;
 
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
+//import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 
+//@EnableDiscoveryClient
 @SpringBootApplication
 public class GatewayApp {
     public static void main(String[] args) {

+ 45 - 0
gateway/src/main/resources/application.yml

@@ -0,0 +1,45 @@
+
+server:
+  port: 1080
+
+spring:
+  application:
+    name: gateway
+#  cloud:
+#    nacos:
+#      server-addr: 192.168.1.66:8848,192.168.1.67:8848,192.168.1.68:8848
+    gateway:
+      globalcors: # 全局的跨域处理
+        add-to-simple-url-handler-mapping: true # 解决options请求被拦截问题
+        corsConfigurations:
+          '[/**]':
+            allowedOrigins: # 允许哪些网站的跨域请求
+              - "http://localhost:80"
+            allowedMethods: # 允许的跨域ajax的请求方式
+              - "GET"
+              - "POST"
+              - "DELETE"
+              - "PUT"
+              - "OPTIONS"
+            allowedHeaders: "*" # 允许在请求中携带的头信息
+            allowCredentials: true # 是否允许携带cookie
+            maxAge: 360000 # 这次跨域检测的有效期
+      routes:
+        - id: nacos-1
+          uri: http://192.168.1.66:8848
+          predicates:
+            - Path=/**
+          filters:
+            - StripPrefix=1
+        - id: nacos-2
+          uri: http://192.168.1.67:8848
+          predicates:
+            - Path=/**
+          filters:
+            - StripPrefix=1
+        - id: nacos-3
+          uri: http://192.168.1.68:8848
+          predicates:
+            - Path=/**
+          filters:
+            - StripPrefix=1

+ 1 - 1
gradle/wrapper/gradle-wrapper.properties

@@ -1,5 +1,5 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists

+ 43 - 0
redisread/src/main/java/com/gyee/redisread/entity/PointData.java

@@ -0,0 +1,43 @@
+package com.gyee.redisread.entity;
+
+import lombok.Data;
+
+/**
+ * 测点数据
+ */
+@Data
+public class PointData {
+    /**
+     * 时间戳
+     */
+    private long ts;
+    private String tagName;
+    /**
+     * 数据
+     */
+    private double doubleValue;
+    /**
+     * boolean 数据
+     */
+    private boolean booleanValue;
+
+    private long longValue;
+
+    public PointData() {
+    }
+
+    public PointData(long ts, double val, String tagName) {
+        this.ts = ts;
+        this.doubleValue = doubleValue;
+        this.tagName = tagName;
+    }
+
+    public double getValue() {
+        if (booleanValue) {
+            return 1;
+        } else if (longValue != 0) {
+            doubleValue = longValue;
+        }
+        return doubleValue;
+    }
+}

+ 58 - 10
redisread/src/main/java/com/gyee/redisread/task/TaskRedisRead.java

@@ -2,6 +2,8 @@ package com.gyee.redisread.task;
 
 import com.gyee.feign.api.Redis2TaosApi;
 import com.gyee.redisread.config.RedisConfig;
+import com.gyee.redisread.entity.PointData;
+import com.gyee.redisread.util.ByteUtil;
 import com.gyee.redisread.util.ChangedSave;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -10,6 +12,7 @@ import redis.clients.jedis.Jedis;
 import redis.clients.jedis.Pipeline;
 
 import java.net.URI;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 
@@ -28,6 +31,38 @@ public class TaskRedisRead implements Runnable {
         this.redis2TaosApi = redis2TaosApi;
     }
 
+    private byte[] binaryStringToByteArray(String binaryString) {
+        byte[] byteArray = new byte[binaryString.length() / 8];
+        for (int i = 0; i < byteArray.length; i++) {
+            String byteString = binaryString.substring(i * 8, i * 8 + 8);
+            byteArray[i] = (byte) Integer.parseInt(byteString, 2);
+        }
+        return byteArray;
+    }
+
+    private void getPointData(List<Object> objects, StringBuilder sb) {
+        boolean b = "bool".equals(dataType);  // 提前计算,只判断一次
+        for (int i = 0; i < objects.size(); i++) {
+            String response = (String) objects.get(i);
+            String key = keys.get(i);
+            byte[] bytes = binaryStringToByteArray(response);
+            double val = ByteUtil.getDouble(bytes, 0);
+            long ts = ByteUtil.getLong2(bytes, 8);
+            Long ts0 = ChangedSave.map.get(key);
+
+            if (ts0 == null || ts != ts0) {
+                ChangedSave.map.put(key, ts);
+                if (ts0 != null) {  // 只有在 ts0 != null 时才追加字符串
+                    if (b) {
+                        sb.append(key).append(" VALUES (").append(ts).append(",").append(val != 0).append(") ");
+                    } else {
+                        sb.append(key).append(" VALUES (").append(ts).append(",").append(val).append(") ");
+                    }
+                }
+            }
+        }
+    }
+
     @Override
     public void run() {
 
@@ -39,7 +74,8 @@ public class TaskRedisRead implements Runnable {
 
             for (String key : keys) {
                 //pipelined.hscan(key, "0");
-                pipelined.hmget(key, "pointid", "value", "timestamp");
+                //pipelined.hmget(key, "pointid", "value", "timestamp");
+                pipelined.mget(key);
             }
             //redis批量获取接收为Object
             objects = pipelined.syncAndReturnAll();
@@ -54,8 +90,21 @@ public class TaskRedisRead implements Runnable {
             boolean bl;
             List<String> response;
             String sb2str;
+            getPointData(objects, sb);
+            for (Object obj : objects) {
+                if (b) {
+                    getPointData(response, sb);
+                } else {
+                    getPointData(response, sb);
+                }
+            }
+            sb2str = sb.toString();
+            if ("INSERT INTO ".equals(sb2str)) return;
+            for (String taosUrl : redisConfig.getTaosUrls().split(",")) {
+                redis2TaosApi.putSql(URI.create(taosUrl), sb2str);
+            }
 
-            if ("bool".equals(dataType)) {
+            /*if ("bool".equals(dataType)) {
                 for (int i = 0; i < objects.size(); i++) {
                     response = (List<String>) objects.get(i);
 
@@ -77,10 +126,9 @@ public class TaskRedisRead implements Runnable {
                     } else {
                         ChangedSave.map.put(pointid, datetime);
                     }
-
-                    /*ts = Long.valueOf(datetime) * 1000;
-                    bl = Double.valueOf(value) == 1;
-                    sb.append(pointid).append(" VALUES (").append(ts).append(",").append(bl).append(") ");*/
+                    //ts = Long.valueOf(datetime) * 1000;
+                    //bl = Double.valueOf(value) == 1;
+                    //sb.append(pointid).append(" VALUES (").append(ts).append(",").append(bl).append(") ");
                 }
                 sb2str = sb.toString();
                 if ("INSERT INTO ".equals(sb2str)) return;
@@ -110,16 +158,16 @@ public class TaskRedisRead implements Runnable {
                     } else {
                         ChangedSave.map.put(pointid, datetime);
                     }
-                    /*ts = Long.valueOf(datetime) * 1000;
-                    val = Double.valueOf(value);
-                    sb.append(pointid).append(" VALUES (").append(ts).append(",").append(val).append(") ");*/
+                    //ts = Long.valueOf(datetime) * 1000;
+                    //val = Double.valueOf(value);
+                    //sb.append(pointid).append(" VALUES (").append(ts).append(",").append(val).append(") ");
                 }
                 sb2str = sb.toString();
                 if ("INSERT INTO ".equals(sb2str)) return;
                 for (String taosUrl : redisConfig.getTaosUrls().split(",")) {
                     redis2TaosApi.putSql(URI.create(taosUrl), sb2str);
                 }
-            }
+            }*/
         } catch (Exception e) {
             e.printStackTrace();
             log.error(pointid + "------写请求超时或读取redis出错!");

+ 311 - 0
redisread/src/main/java/com/gyee/redisread/util/ByteUtil.java

@@ -0,0 +1,311 @@
+package com.gyee.redisread.util;
+
+public class ByteUtil {
+    /**
+     * 转换short为byte
+     *
+     * @param b
+     * @param s
+     *            需要转换的short
+     * @param index
+     */
+    public static void putShort(byte b[], short s, int index) {
+        b[index + 1] = (byte) (s >> 8);
+        b[index + 0] = (byte) (s >> 0);
+    }
+
+    /**
+     * 通过byte数组取到short
+     *
+     * @param b
+     * @param index
+     *            第几位开始取
+     * @return
+     */
+    public static short getShort(byte[] b, int index) {
+        return (short) (((b[index + 1] << 8) | b[index + 0] & 0xff));
+    }
+
+    /**
+     * 转换int为byte数组
+     *
+     * @param bb
+     * @param x
+     * @param index
+     */
+    public static void putInt(byte[] bb, int x, int index) {
+        bb[index + 3] = (byte) (x >> 24);
+        bb[index + 2] = (byte) (x >> 16);
+        bb[index + 1] = (byte) (x >> 8);
+        bb[index + 0] = (byte) (x >> 0);
+    }
+
+    /**
+     * 通过byte数组取到int
+     *
+     * @param bb
+     * @param index
+     *            第几位开始
+     * @return
+     */
+    public static int getInt(byte[] bb, int index) {
+        return (int) ((((bb[index + 3] & 0xff) << 24)
+                | ((bb[index + 2] & 0xff) << 16)
+                | ((bb[index + 1] & 0xff) << 8) | ((bb[index + 0] & 0xff) << 0)));
+    }
+
+    /**
+     * 转换long型为byte数组
+     *
+     * @param b
+     * @param x
+     * @param index
+     */
+    public static byte[] putLong(byte[] b, long x, int index) {
+        byte[] bb = new byte[8];
+        for (int i = 0; i < 8; i++) {
+            int offset = 64 - (i + 1) * 8;
+            bb[i] = (byte) ((x >> offset) & 0xff);
+        }
+        return bb;
+    }
+
+    /**
+     * 通过byte数组取到long
+     *
+     * @param bb
+     * @param index
+     * @return
+     */
+    public static long getLong(byte[] bb, int index) {
+        return ((((long) bb[index + 7] & 0xff) << 56)
+                | (((long) bb[index + 6] & 0xff) << 48)
+                | (((long) bb[index + 5] & 0xff) << 40)
+                | (((long) bb[index + 4] & 0xff) << 32)
+                | (((long) bb[index + 3] & 0xff) << 24)
+                | (((long) bb[index + 2] & 0xff) << 16)
+                | (((long) bb[index + 1] & 0xff) << 8) | (((long) bb[index + 0] & 0xff) << 0));
+    }
+
+    /**
+     * 通过byte数组取到long
+     *
+     * @param bb
+     * @param index
+     * @return
+     */
+    public static long getLong2(byte[] bb, int index) {
+        return ((((long) bb[index + 0] & 0xff) << 56)
+                | (((long) bb[index + 1] & 0xff) << 48)
+                | (((long) bb[index + 2] & 0xff) << 40)
+                | (((long) bb[index + 3] & 0xff) << 32)
+                | (((long) bb[index + 4] & 0xff) << 24)
+                | (((long) bb[index + 5] & 0xff) << 16)
+                | (((long) bb[index + 6] & 0xff) << 8)
+                | (((long) bb[index + 7] & 0xff) << 0) );
+    }
+
+    /**
+     * 字符到字节转换
+     *
+     * @param ch
+     * @return
+     */
+    public static void putChar(byte[] bb, char ch, int index) {
+        int temp = (int) ch;
+        // byte[] b = new byte[2];
+        for (int i = 0; i < 2; i ++ ) {
+            bb[index + i] = new Integer(temp & 0xff).byteValue(); // 将最高位保存在最低位
+            temp = temp >> 8; // 向右移8位
+        }
+    }
+
+    /**
+     * 字节到字符转换
+     *
+     * @param b
+     * @return
+     */
+    public static char getChar(byte[] b, int index) {
+        int s = 0;
+        if (b[index + 1] > 0)
+            s += b[index + 1];
+        else
+            s += 256 + b[index + 0];
+        s *= 256;
+        if (b[index + 0] > 0)
+            s += b[index + 1];
+        else
+            s += 256 + b[index + 0];
+        char ch = (char) s;
+        return ch;
+    }
+
+    /**
+     * float转换byte
+     *
+     * @param bb
+     * @param x
+     * @param index
+     */
+    public static void putFloat(byte[] bb, float x, int index) {
+        // byte[] b = new byte[4];
+        int l = Float.floatToIntBits(x);
+        for (int i = 0; i < 4; i++) {
+            bb[index + i] = new Integer(l).byteValue();
+            l = l >> 8;
+        }
+    }
+
+    /**
+     * 通过byte数组取得float
+     *
+     * @param b
+     * @param index
+     * @return
+     */
+    public static float getFloat(byte[] b, int index) {
+        int l;
+        l = b[index + 0];
+        l &= 0xff;
+        l |= ((long) b[index + 1] << 8);
+        l &= 0xffff;
+        l |= ((long) b[index + 2] << 16);
+        l &= 0xffffff;
+        l |= ((long) b[index + 3] << 24);
+        return Float.intBitsToFloat(l);
+    }
+
+    /**
+     * double转换byte
+     *
+     * @param bb
+     * @param x
+     * @param index
+     */
+    public static byte[] putDouble(byte[] bb, double x, int index) {
+        byte[] b = new byte[8];
+        long l = Double.doubleToLongBits(x);
+        for (int i = 0; i < 8; i++) {
+            b[index + i] = new Long(l).byteValue();
+            l = l >> 8;
+        }
+        return b;
+    }
+
+    /**
+     * 通过byte数组取得double
+     *
+     * @param b
+     * @param index
+     * @return
+     */
+    public static double getDouble(byte[] b, int index) {
+        long l;
+        l = b[0];
+        l &= 0xff;
+        l |= ((long) b[1] << 8);
+        l &= 0xffff;
+        l |= ((long) b[2] << 16);
+        l &= 0xffffff;
+        l |= ((long) b[3] << 24);
+        l &= 0xffffffffl;
+        l |= ((long) b[4] << 32);
+        l &= 0xffffffffffl;
+        l |= ((long) b[5] << 40);
+        l &= 0xffffffffffffl;
+        l |= ((long) b[6] << 48);
+        l &= 0xffffffffffffffl;
+        l |= ((long) b[7] << 56);
+        return Double.longBitsToDouble(l);
+    }
+
+    public static void putHexString(byte[] bb, String s, int index){
+        for (int i = 0; i < s.length(); i+=2) {
+            byte c= (byte)( charToByte(s.charAt(i))<<4 | charToByte(s.charAt(i+1)));
+            bb[index+(i>>1)] = c;
+        }
+    }
+
+    private static byte charToByte(char c) {
+        return (byte) "0123456789ABCDEF".indexOf(c);
+    }
+
+    public static String getHexString(byte[] b, int index, int count){
+        StringBuilder stringBuilder = new StringBuilder("");
+        if (b == null || index < 0 || b.length < index + count ) {
+            return null;
+        }
+        for (int i = index; i < count + index; i++) {
+            int v = b[i] & 0xFF;
+            String hv = Integer.toHexString(v);
+            if (hv.length() < 2) {
+                stringBuilder.append(0);
+            }
+            stringBuilder.append(hv);
+        }
+        return stringBuilder.toString();
+    }
+
+    public static String getBinaryString(int d,int length){
+        StringBuilder stringBuilder = new StringBuilder("");
+        String hv = Integer.toBinaryString(d);
+        for (int j = 0; j < length - hv.length(); j++) {
+            stringBuilder.append(0);
+        }
+        stringBuilder.append(hv);
+        return stringBuilder.toString();
+    }
+
+    public static String getBinaryReverseString(int d,int length){
+        StringBuilder stringBuilder = new StringBuilder("");
+        String hv = Integer.toBinaryString(d);
+        for (int j = 0; j < length - hv.length(); j++) {
+            stringBuilder.append(0);
+        }
+        stringBuilder.append(hv);
+        stringBuilder.reverse();
+
+        return stringBuilder.toString();
+    }
+
+
+    //网络字节逆序
+    public static byte[] ReversEndian(byte b[],int count, boolean big)
+    {
+        byte by;
+        byte data[] = new byte[count];
+        for(int i=0;i<count;i++)
+        {
+            data[i] = b[i];
+        }
+        if(big==false)
+        {
+            for(int i=0;i<count;i++)
+            {
+                by = b[i];
+                data[count-i-1] = by;
+            }
+        }
+        return data;
+    }
+
+    public static short htons(short s){
+        short rslt = 0;
+        byte [] bs1 = new byte[2];
+        ByteUtil.putShort(bs1, s, 0);
+        byte[] bs2 = ReversEndian(bs1, 2, false);
+        rslt = ByteUtil.getShort(bs2, 0);
+        return rslt;
+    }
+
+    public static int htonl(int d){
+        int rslt = 0;
+        byte [] bs1 = new byte[4];
+        ByteUtil.putInt(bs1, d, 0);
+        byte[] bs2 = ReversEndian(bs1, 4, false);
+        rslt = ByteUtil.getInt(bs2, 0);
+        return rslt;
+    }
+
+}

+ 2 - 2
redisread/src/main/java/com/gyee/redisread/util/ChangedSave.java

@@ -3,6 +3,6 @@ package com.gyee.redisread.util;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-public class ChangedSave {
-    public static Map<String, String> map = new ConcurrentHashMap<>();
+public class  ChangedSave {
+    public static Map<String, Long> map = new ConcurrentHashMap<>();
 }

+ 28 - 0
redisread/src/test/java/1.txt

@@ -0,0 +1,28 @@
+for (int i = 0; i < objects.size(); i++) {
+                    response = (List<String>) objects.get(i);
+
+                    value = response.get(1);
+                    if (value == null || "".equals(value) || value.contains("-nan")) continue;
+                    datetime = response.get(2);
+                    if (StringUtils.isEmpty(datetime)) continue;
+                    pointid = response.get(0);
+                    if (StringUtils.isEmpty(pointid)) continue;
+
+                    if (ChangedSave.map.containsKey(pointid)) {
+                        if (!Objects.equals(ChangedSave.map.get(pointid), datetime)) {
+                            ChangedSave.map.put(pointid, datetime);
+                            ts = Long.valueOf(datetime) * 1000;
+                            val = Double.valueOf(value);
+
+                            //j++;
+                            sb.append(pointid).append(" VALUES (").append(ts).append(",").append(val).append(") ");
+                        }
+                    } else {
+                        ChangedSave.map.put(pointid, datetime);
+                    }
+                }
+                sb2str = sb.toString();
+                if ("INSERT INTO ".equals(sb2str)) return;
+                for (String taosUrl : redisConfig.getTaosUrls().split(",")) {
+                    redis2TaosApi.putSql(URI.create(taosUrl), sb2str);
+                }

+ 27 - 0
redisread/src/test/java/2.txt

@@ -0,0 +1,27 @@
+for (int i = 0; i < objects.size(); i++) {
+                    response = (List<String>) objects.get(i);
+
+                    value = response.get(1);
+                    if (value == null || "".equals(value) || value.contains("-nan")) continue;
+                    datetime = response.get(2);
+                    if (StringUtils.isEmpty(datetime)) continue;
+                    pointid = response.get(0);
+                    if (StringUtils.isEmpty(pointid)) continue;
+
+                    if (ChangedSave.map.containsKey(pointid)) {
+                        if (!Objects.equals(ChangedSave.map.get(pointid), datetime)) {
+                            ChangedSave.map.put(pointid, datetime);
+                            ts = Long.valueOf(datetime) * 1000;
+                            bl = Double.valueOf(value) == 1;
+                            //j++;
+                            sb.append(pointid).append(" VALUES (").append(ts).append(",").append(bl).append(") ");
+                        }
+                    } else {
+                        ChangedSave.map.put(pointid, datetime);
+                    }
+                }
+                sb2str = sb.toString();
+                if ("INSERT INTO ".equals(sb2str)) return;
+                for (String taosUrl : redisConfig.getTaosUrls().split(",")) {
+                    redis2TaosApi.putSql(URI.create(taosUrl), sb2str);
+                }

+ 1 - 1
settings.gradle

@@ -1,6 +1,6 @@
 rootProject.name = 'taos'
 include 'feign'
-//include 'gateway'
+include 'gateway'
 include 'redisread'
 include 'taoswrite'
 include 'clientside'

+ 2 - 1
taoswrite/build.gradle

@@ -4,6 +4,7 @@ dependencies {
     implementation 'org.springframework.boot:spring-boot-starter-web'
 
     implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.2'
-    implementation 'com.taosdata.jdbc:taos-jdbcdriver:3.1.0'
+//    implementation 'com.taosdata.jdbc:taos-jdbcdriver:3.1.0'
+    implementation 'com.taosdata.jdbc:taos-jdbcdriver:2.0.42'
     implementation 'com.alibaba:druid:1.2.16'
 }