Pārlūkot izejas kodu

读取协议配置表存放到缓存

‘xugp 2 gadi atpakaļ
vecāks
revīzija
29eb330ac0
35 mainītis faili ar 488 papildinājumiem un 768 dzēšanām
  1. 2 20
      common/utils/src/main/java/com/gyee/edge/common/utils/BytesUtils.java
  2. 3 4
      gateway/src/main/java/com/gyee/edge/gateway/ApplicationEventListener.java
  3. 4 1
      gateway/src/main/java/com/gyee/edge/gateway/bridge/rocketmq/producter/AsyncProducter.java
  4. 2 2
      gateway/src/main/java/com/gyee/edge/gateway/bridge/rocketmq/producter/Gyfp2Protocol.java
  5. 1 1
      gateway/src/main/java/com/gyee/edge/gateway/client/IClient.java
  6. 1 1
      gateway/src/main/java/com/gyee/edge/gateway/client/IEC102SerialClient.java
  7. 1 1
      gateway/src/main/java/com/gyee/edge/gateway/client/IEC102TcpClient.java
  8. 39 0
      gateway/src/main/java/com/gyee/edge/gateway/client/IEC102TcpMaster.java
  9. 274 2
      gateway/src/main/java/com/gyee/edge/gateway/config/cache/CacheService.java
  10. 0 25
      gateway/src/main/java/com/gyee/edge/gateway/config/cache/PointCache.java
  11. 14 0
      gateway/src/main/java/com/gyee/edge/gateway/config/point/BachmanPoint.java
  12. 15 0
      gateway/src/main/java/com/gyee/edge/gateway/config/point/BfPoint.java
  13. 17 0
      gateway/src/main/java/com/gyee/edge/gateway/config/point/DjlPoint.java
  14. 18 0
      gateway/src/main/java/com/gyee/edge/gateway/config/point/FglPoint.java
  15. 16 0
      gateway/src/main/java/com/gyee/edge/gateway/config/point/GdupcPoint.java
  16. 16 0
      gateway/src/main/java/com/gyee/edge/gateway/config/point/Iec102Point.java
  17. 21 0
      gateway/src/main/java/com/gyee/edge/gateway/config/point/Iec104Point.java
  18. 17 0
      gateway/src/main/java/com/gyee/edge/gateway/config/point/ModbusPoint.java
  19. 0 14
      gateway/src/main/java/com/gyee/edge/gateway/config/point/Point102Mapper.java
  20. 0 45
      gateway/src/main/java/com/gyee/edge/gateway/config/read/ReadPoint102SqliteData.java
  21. 0 47
      gateway/src/main/java/com/gyee/edge/gateway/config/read/ReadPointCSVData.java
  22. 0 44
      gateway/src/main/java/com/gyee/edge/gateway/config/read/ReadPointSqLiteData.java
  23. 0 364
      gateway/src/main/java/com/gyee/edge/gateway/config/sqlite/DB.java
  24. 4 19
      gateway/src/main/java/com/gyee/edge/gateway/config/sqlite/Database.java
  25. 0 33
      gateway/src/main/java/com/gyee/edge/gateway/config/sqlite/EndPoint.java
  26. 0 12
      gateway/src/main/java/com/gyee/edge/gateway/config/sqlite/ProtocolType.java
  27. 0 27
      gateway/src/main/java/com/gyee/edge/gateway/data/GeneralTsData.java
  28. 0 15
      gateway/src/main/java/com/gyee/edge/gateway/data/TsData.java
  29. 0 15
      gateway/src/main/java/com/gyee/edge/gateway/data/TsDataType.java
  30. 0 56
      gateway/src/main/java/com/gyee/edge/gateway/data/TsPointData.java
  31. 3 2
      gateway/src/main/resources/application.yaml
  32. BIN
      gateway/src/main/resources/keytable.db
  33. BIN
      gateway/src/main/resources/keytable.sqlite3
  34. 12 10
      protocol/gyfp2/src/main/java/com/gyee/protocol/gyfp2/message/MessageData.java
  35. 8 8
      protocol/gyfp2/src/main/java/com/gyee/protocol/gyfp2/message/MessageMutable.java

+ 2 - 20
common/utils/src/main/java/com/gyee/edge/common/utils/BytesUtils.java

@@ -23,24 +23,6 @@ public class BytesUtils {
 
             '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
 
-    public static byte[] intToByte2(int myInt){
-        byte[] bytes = new byte[3];
-        byte b1,b2,b3;
-        b3 = (byte)(myInt & 0xFF);
-        b2 = (byte)((myInt >> 8) & 0xFF);
-        b1 = (byte)((myInt >> 16) & 0xFF);
-        bytes[0] = b3;
-        bytes[1] = b2;
-        bytes[2] = b1;
-        return bytes;
-    }
-
-    public static int BytesToInt(byte[] bytes, int index){
-        byte[] bytes1 = bytes;
-        int r = (bytes1[index] & 0xFF) | ((bytes1[index+1] & 0xFF) << 8) | ((bytes1[index+2] & 0x0F) << 16);
-        return r;
-    }
-
     /**
 
      * 将short整型数值转换为字节数组
@@ -1351,11 +1333,11 @@ public class BytesUtils {
 
      */
 
-    public static int bytesToInt(byte[] arr) {
+    public static int bytesToInt(byte[] arr,int t) {
 
         int mask = 0xFF;
 
-        int temp = 0;
+        int temp = t;
 
         int result = 0;
 

+ 3 - 4
gateway/src/main/java/com/gyee/edge/gateway/ApplicationEventListener.java

@@ -1,9 +1,7 @@
 package com.gyee.edge.gateway;
 
 import com.gyee.edge.gateway.bridge.rocketmq.producter.AsyncProducter;
-import com.gyee.edge.gateway.config.cache.PointCache;
-import com.gyee.edge.gateway.config.read.ReadPoint102SqliteData;
-import com.gyee.edge.gateway.config.read.ReadPointSqLiteData;
+import com.gyee.edge.gateway.config.cache.CacheService;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,12 +16,13 @@ public class ApplicationEventListener implements
 
     @Autowired
     private AsyncProducter asyncProducter;
+
+
     @SneakyThrows
     @Override
     public void onApplicationEvent(ApplicationReadyEvent event) {
         log.info("ApplicationEvent  rised!");
         log.info("listener: " + event.toString());
-
         asyncProducter.dataSendProducter();
     }
 

+ 4 - 1
gateway/src/main/java/com/gyee/edge/gateway/bridge/rocketmq/producter/AsyncProducter.java

@@ -18,6 +18,9 @@ public class AsyncProducter {
     @Value("${rocketmq.namesrvaddr}")
     String nameSrvAddr;
 
+    @Value("${rocketmq.tags}")
+    String tags;
+
     @Autowired
     private Gyfp2Protocol gyfp2Protocol;
     public  void dataSendProducter() throws Exception {
@@ -32,7 +35,7 @@ public class AsyncProducter {
         byte[] bytes = gyfp2Protocol.toBytes();
             //创建消息
             Message message = new Message("keyMessage"/*Topic*/,
-                    "TagA"/* Tag*/, "OrderID888", bytes);
+                    tags/* Tag*/, "OrderID888", bytes);
             producer.send(message, new SendCallback() {
                 @Override
                 public void onSuccess(SendResult sendResult) {

+ 2 - 2
gateway/src/main/java/com/gyee/edge/gateway/bridge/rocketmq/producter/Gyfp2Protocol.java

@@ -34,14 +34,14 @@ public class Gyfp2Protocol {
 //        }
 
         MessageData messageData = new MessageData();
-        messageData.setDataKey(1002);
+        messageData.setDataKey(4500000);
         messageData.setDataType((byte) 0);
         messageData.setTs(new Date().getTime());
         messageData.setGYFP2_TYPE_BOOLEAN(java.util.Optional.of(false));
         list.add(messageData);
 
         MessageData messageData1 = new MessageData();
-        messageData1.setDataKey(1002);
+        messageData1.setDataKey(4500000);
         messageData1.setDataType((byte) 11);
         messageData1.setTs(new Date().getTime());
         double d = 1 + Math.random() * (80 - 1);

+ 1 - 1
gateway/src/main/java/com/gyee/edge/gateway/client/IClient.java

@@ -1,6 +1,6 @@
 package com.gyee.edge.gateway.client;
 
-import com.gyee.edge.gateway.message.GYMessage;
+import com.gyee.protocol.gyfp2.message.GYMessage;
 import io.netty.channel.EventLoopGroup;
 import io.netty.util.concurrent.Future;
 

+ 1 - 1
gateway/src/main/java/com/gyee/edge/gateway/client/IEC102SerialClient.java

@@ -1,6 +1,6 @@
 package com.gyee.edge.gateway.client;
 
-import com.gyee.edge.gateway.message.GYMessage;
+import com.gyee.protocol.gyfp2.message.GYMessage;
 import io.netty.bootstrap.Bootstrap;
 import io.netty.channel.*;
 import io.netty.channel.oio.OioEventLoopGroup;

+ 1 - 1
gateway/src/main/java/com/gyee/edge/gateway/client/IEC102TcpClient.java

@@ -1,7 +1,7 @@
 package com.gyee.edge.gateway.client;
 
 
-import com.gyee.edge.gateway.message.GYMessage;
+import com.gyee.protocol.gyfp2.message.GYMessage;
 import io.netty.channel.EventLoopGroup;
 import io.netty.util.concurrent.Future;
 

+ 39 - 0
gateway/src/main/java/com/gyee/edge/gateway/client/IEC102TcpMaster.java

@@ -1,6 +1,10 @@
 package com.gyee.edge.gateway.client;
 
 
+import com.gyee.protocol.gyfp2.message.GYMessage;
+import io.netty.channel.EventLoopGroup;
+import io.netty.util.concurrent.Future;
+
 public class IEC102TcpMaster implements IClient {
 
     private EndPoint endPoint;
@@ -15,6 +19,41 @@ public class IEC102TcpMaster implements IClient {
         return endPoint;
     }
 
+    @Override
+    public Future<Integer> connect() {
+        return null;
+    }
+
+    @Override
+    public Future<Integer> reconnect() {
+        return null;
+    }
+
+    @Override
+    public void disconnect() {
+
+    }
+
+    @Override
+    public boolean isConnected() {
+        return false;
+    }
+
+    @Override
+    public EventLoopGroup getEventLoop() {
+        return null;
+    }
+
+    @Override
+    public Future<Integer> sendMessage(GYMessage gyMessage) {
+        return null;
+    }
+
+    @Override
+    public Future<Integer> send(Byte[] bytes) {
+        return null;
+    }
+
     public int getStatus() {
         return status;
     }

+ 274 - 2
gateway/src/main/java/com/gyee/edge/gateway/config/cache/CacheService.java

@@ -1,16 +1,37 @@
 package com.gyee.edge.gateway.config.cache;
 
 import com.gyee.edge.gateway.client.EndPoint;
+import com.gyee.edge.gateway.config.point.*;
+import com.gyee.edge.gateway.config.sqlite.Database;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
 import java.util.ArrayList;
 import java.util.List;
 
 @Component
 public class CacheService {
 
+    @Autowired
+    private Database db;
+
     private List<EndPoint> endPointList;
 
+    private List<Iec102Point> iec102PointList;
+
+    private List<Iec104Point> iec104PointList;
+
+    private List<ModbusPoint> modbusPointList;
+
+    private List<BfPoint> bfPointList;
+
+    private List<BachmanPoint> bachmanPointList;
+
+    private List<GdupcPoint> gdupcPointList;
+
     public List<EndPoint> getEndPointList() {
         if (endPointList == null) {
             endPointList = loadEndPoints();
@@ -19,10 +40,261 @@ public class CacheService {
         return endPointList;
     }
 
+    public List<Iec102Point> getIec102PointList(){
+        if (iec102PointList == null){
+            iec102PointList = loadIec102Points();
+        }
+
+        return iec102PointList;
+    }
+
+    public List<Iec104Point> getIec104PointList(){
+        if (iec104PointList == null){
+            iec104PointList = loadIec104Points();
+        }
+
+        return iec104PointList;
+    }
+
+    public List<ModbusPoint> getIModbusPointList(){
+        if (modbusPointList == null){
+            modbusPointList = loadmodbusPoints();
+        }
+
+        return modbusPointList;
+    }
+
+    public List<BfPoint> getBfPointList(){
+        if (bfPointList == null){
+            bfPointList = loadBfPoints();
+        }
+
+        return bfPointList;
+    }
+
+    public List<BachmanPoint> getBachmanPointList(){
+        if (bachmanPointList == null){
+            bachmanPointList = loadBachmanPoints();
+        }
+
+        return bachmanPointList;
+    }
+
+    public List<GdupcPoint> getGdupcPointList(){
+        if (gdupcPointList == null){
+            gdupcPointList = loadGdupcPoints();
+        }
+
+        return gdupcPointList;
+    }
+
     private List<EndPoint> loadEndPoints() {
-        //todo: 从数据库中加载endpoint
-        return new ArrayList<>();
+        // DONE: 从数据库中加载endpoint
+        List<EndPoint> endPointList = new ArrayList<>();
+        try {
+            Connection conn = db.getConnection();
+            String sql = "select * from endpoint";
+            PreparedStatement ps = conn.prepareStatement(sql);
+            ResultSet rs = ps.executeQuery();
+            while (rs.next()) {
+                EndPoint endPoint = new EndPoint();
+                endPoint.setId(rs.getInt("id"));
+                endPoint.setConnectionType(rs.getString("connectionType"));
+                endPoint.setDirection(rs.getInt("direction"));
+                endPoint.setProtocol(rs.getString("protocol"));
+                endPoint.setHost(rs.getString("host"));
+                endPoint.setPort(rs.getInt("port"));
+                endPoint.setSerialPort(rs.getString("serialPort"));
+                endPoint.setBaudRate(rs.getInt("baudRate"));
+                endPoint.setStartBit(rs.getInt("startBit"));
+                endPoint.setStopBit(rs.getInt("stopBit"));
+                endPoint.setCheckBit(rs.getInt("checkBit"));
+                endPoint.setUserName(rs.getString("username"));
+                endPoint.setPassword(rs.getString("password"));
+                endPoint.setToken(rs.getString("token"));
+                endPoint.setConnectionString(rs.getString("connectionString"));
+                endPoint.setPath(rs.getString("path"));
+                endPoint.setEnabled(rs.getBoolean("enabled"));
+                endPointList.add(endPoint);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }finally {
+            db.releaseResource();
+        }
+        return endPointList;
+    }
+
+    private List<Iec102Point> loadIec102Points() {
+        //DONE: 从数据库中加载Iec102Point
+        List<Iec102Point> iec102PointList = new ArrayList<>();
+        try {
+            Connection conn = db.getConnection();
+            String sql = "select * from iec102";
+            PreparedStatement ps = conn.prepareStatement(sql);
+            ResultSet rs = ps.executeQuery();
+            while (rs.next()) {
+                Iec102Point iec102Point = new Iec102Point();
+                iec102Point.setEndpointid(rs.getInt("endpointid"));
+                iec102Point.setGyfp2_base(rs.getFloat("gyfp2_base"));
+                iec102Point.setGyfp2_addr(rs.getInt("gyfp2_addr"));
+                iec102Point.setGyfp2_coeff(rs.getInt("gyfp2_coeff"));
+                iec102Point.setIec102_addr(rs.getInt("iec102_addr"));
+                iec102Point.setIec102_base(rs.getFloat("iec102_base"));
+                iec102Point.setIec102_coeff(rs.getFloat("iec102_coeff"));
+                iec102Point.setGyfp2_valid(rs.getInt("gyfp2_valid"));
+                iec102PointList.add(iec102Point);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }finally {
+            db.releaseResource();
+        }
+        return iec102PointList;
+    }
+
+    private List<Iec104Point> loadIec104Points() {
+        //DONE: 从数据库中加载Iec104Point
+        List<Iec104Point> iec104PointList = new ArrayList<>();
+        try {
+            Connection conn = db.getConnection();
+            String sql = "select * from iec104";
+            PreparedStatement ps = conn.prepareStatement(sql);
+            ResultSet rs = ps.executeQuery();
+            while (rs.next()) {
+                Iec104Point iec104Point = new Iec104Point();
+                iec104Point.setEndpointid(rs.getInt("endpointid"));
+                iec104Point.setIec104_addr(rs.getInt("iec104_addr"));
+                iec104Point.setIec104_xmax(rs.getFloat("iec104_xmax"));
+                iec104Point.setIec104_xmin(rs.getFloat("iec104_xmin"));
+                iec104Point.setIec104_base(rs.getFloat("iec104_base"));
+                iec104Point.setIec104_coeff(rs.getFloat("iec104_coeff"));
+                iec104Point.setGyfp2_base(rs.getFloat("gyfp2_base"));
+                iec104Point.setGyfp2_addr(rs.getInt("gyfp2_addr"));
+                iec104Point.setGyfp2_coeff(rs.getInt("gyfp2_coeff"));
+                iec104Point.setGyfp2_valid(rs.getInt("gyfp2_valid"));
+                iec104PointList.add(iec104Point);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }finally {
+            db.releaseResource();
+        }
+        return iec104PointList;
     }
 
+    private List<ModbusPoint> loadmodbusPoints() {
+        //DONE: 从数据库中加载ModbusPoint
+        List<ModbusPoint> modbusPointList = new ArrayList<>();
+        try {
+            Connection conn = db.getConnection();
+            String sql = "select * from modbus";
+            PreparedStatement ps = conn.prepareStatement(sql);
+            ResultSet rs = ps.executeQuery();
+            while (rs.next()) {
+                ModbusPoint modbusPoint = new ModbusPoint();
+                modbusPoint.setEndpointid(rs.getInt("endpointid"));
+                modbusPoint.setModbus_uid(rs.getInt("modbusPoint"));
+                modbusPoint.setModbus_addr(rs.getInt("modbus_addr"));
+                modbusPoint.setModbus_fun(rs.getInt("modbus_fun"));
+                modbusPoint.setModbus_swap(rs.getInt("modbus_swap"));
+                modbusPoint.setModbus_type(rs.getInt("modbus_type"));
+                modbusPoint.setGyfp2_base(rs.getFloat("gyfp2_base"));
+                modbusPoint.setGyfp2_addr(rs.getInt("gyfp2_addr"));
+                modbusPoint.setGyfp2_coeff(rs.getInt("gyfp2_coeff"));
+                modbusPoint.setGyfp2_valid(rs.getInt("gyfp2_valid"));
+                modbusPointList.add(modbusPoint);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }finally {
+            db.releaseResource();
+        }
+        return modbusPointList;
+    }
+
+    private List<BfPoint> loadBfPoints() {
+        //DONE: 从数据库中加载BfPoint
+        List<BfPoint> bfPointList = new ArrayList<>();
+        try {
+            Connection conn = db.getConnection();
+            String sql = "select * from bf";
+            PreparedStatement ps = conn.prepareStatement(sql);
+            ResultSet rs = ps.executeQuery();
+            while (rs.next()) {
+                BfPoint bfPoint = new BfPoint();
+                bfPoint.setEndpointid(rs.getInt("endpointid"));
+                bfPoint.setBf_netid(rs.getString("bf_netid"));
+                bfPoint.setBf_key(rs.getString("bf_key"));
+                bfPoint.setGyfp2_base(rs.getFloat("gyfp2_base"));
+                bfPoint.setGyfp2_addr(rs.getInt("gyfp2_addr"));
+                bfPoint.setGyfp2_coeff(rs.getInt("gyfp2_coeff"));
+                bfPoint.setGyfp2_valid(rs.getInt("gyfp2_valid"));
+                bfPointList.add(bfPoint);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }finally {
+            db.releaseResource();
+        }
+        return bfPointList;
+    }
+
+    private List<BachmanPoint> loadBachmanPoints() {
+        //DONE: 从数据库中加载BachmanPoint
+        List<BachmanPoint> bachmanPointList = new ArrayList<>();
+        try {
+            Connection conn = db.getConnection();
+            String sql = "select * from bachman";
+            PreparedStatement ps = conn.prepareStatement(sql);
+            ResultSet rs = ps.executeQuery();
+            while (rs.next()) {
+                BachmanPoint bachmanPoint = new BachmanPoint();
+                bachmanPoint.setEndpointid(rs.getInt("endpointid"));
+                bachmanPoint.setIp(rs.getString("ip"));
+                bachmanPoint.setBachman(rs.getString("bachman"));
+                bachmanPoint.setGyfp2_base(rs.getFloat("gyfp2_base"));
+                bachmanPoint.setGyfp2_addr(rs.getInt("gyfp2_addr"));
+                bachmanPoint.setGyfp2_coeff(rs.getInt("gyfp2_coeff"));
+                bachmanPoint.setGyfp2_valid(rs.getInt("gyfp2_valid"));
+                bachmanPointList.add(bachmanPoint);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        finally {
+            db.releaseResource();
+        }
+        return bachmanPointList;
+    }
+
+    private List<GdupcPoint> loadGdupcPoints() {
+        //DONE: 从数据库中加载GdupcPoint
+        List<GdupcPoint> gdupcPointList = new ArrayList<>();
+        try {
+            Connection conn = db.getConnection();
+            String sql = "select * from gdupc";
+            PreparedStatement ps = conn.prepareStatement(sql);
+            ResultSet rs = ps.executeQuery();
+            while (rs.next()) {
+                GdupcPoint gdupcPoint = new GdupcPoint();
+                gdupcPoint.setEndpointid(rs.getInt("endpointid"));
+                gdupcPoint.setGdupc_ip(rs.getString("gdupc_ip"));
+                gdupcPoint.setGdupc_tag(rs.getString("gdupc_tag"));
+                gdupcPoint.setGdupc_type(rs.getString("gdupc_type"));
+                gdupcPoint.setGdupc_len(rs.getInt("gdupc_len"));
+                gdupcPoint.setGyfp2_base(rs.getFloat("gyfp2_base"));
+                gdupcPoint.setGyfp2_addr(rs.getInt("gyfp2_addr"));
+                gdupcPoint.setGyfp2_coeff(rs.getInt("gyfp2_coeff"));
+                gdupcPoint.setGyfp2_valid(rs.getInt("gyfp2_valid"));
+                gdupcPointList.add(gdupcPoint);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }finally {
+            db.releaseResource();
+        }
+        return gdupcPointList;
+    }
 
 }

+ 0 - 25
gateway/src/main/java/com/gyee/edge/gateway/config/cache/PointCache.java

@@ -1,25 +0,0 @@
-package com.gyee.edge.gateway.config.cache;
-
-import com.gyee.edge.gateway.config.point.PointMapper;
-import com.gyee.edge.gateway.config.read.ReadPointCSVData;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-
-import java.util.ArrayList;
-
-@Component
-public class PointCache {
-    private ArrayList<PointMapper> strList = new ArrayList<>();
-
-    @Value("${filePath}")
-    String filePath;
-
-    public ArrayList<PointMapper> getPointMapper(){
-        if (strList.size() <= 0){
-            strList = ReadPointCSVData.readConfig(filePath);
-            return strList;
-        }
-        else
-            return strList;
-    }
-}

+ 14 - 0
gateway/src/main/java/com/gyee/edge/gateway/config/point/BachmanPoint.java

@@ -0,0 +1,14 @@
+package com.gyee.edge.gateway.config.point;
+
+import lombok.Data;
+
+@Data
+public class BachmanPoint {
+    private int endpointid;
+    private String ip;
+    private String bachman;
+    private int gyfp2_addr;
+    private int gyfp2_valid;
+    private float gyfp2_coeff;
+    private float gyfp2_base;
+}

+ 15 - 0
gateway/src/main/java/com/gyee/edge/gateway/config/point/BfPoint.java

@@ -0,0 +1,15 @@
+package com.gyee.edge.gateway.config.point;
+
+import lombok.Data;
+
+
+@Data
+public class BfPoint {
+    private int endpointid;
+    private String bf_netid;
+    private String bf_key;
+    private int gyfp2_addr;
+    private int gyfp2_valid;
+    private float gyfp2_coeff;
+    private float gyfp2_base;
+}

+ 17 - 0
gateway/src/main/java/com/gyee/edge/gateway/config/point/DjlPoint.java

@@ -0,0 +1,17 @@
+package com.gyee.edge.gateway.config.point;
+
+import lombok.Data;
+
+
+@Data
+public class DjlPoint {
+    private int endpointid;
+    private int address;
+    private int valite;
+    private float coeff;
+    private float base;
+    private int gyfp2_addr;
+    private int gyfp2_valid;
+    private float gyfp2_coeff;
+    private float gyfp2_base;
+}

+ 18 - 0
gateway/src/main/java/com/gyee/edge/gateway/config/point/FglPoint.java

@@ -0,0 +1,18 @@
+package com.gyee.edge.gateway.config.point;
+
+import lombok.Data;
+
+
+@Data
+public class FglPoint {
+    private int endpointid;
+    private int modbus_uid;
+    private int modbus_addr;
+    private int modbus_fun;
+    private int modbus_type;
+    private int modbus_swap;
+    private int gyfp2_addr;
+    private int gyfp2_valid;
+    private float gyfp2_coeff;
+    private float gyfp2_base;
+}

+ 16 - 0
gateway/src/main/java/com/gyee/edge/gateway/config/point/GdupcPoint.java

@@ -0,0 +1,16 @@
+package com.gyee.edge.gateway.config.point;
+
+import lombok.Data;
+
+@Data
+public class GdupcPoint {
+    private int endpointid;
+    private String gdupc_ip;
+    private String gdupc_tag;
+    private String gdupc_type;
+    private int gdupc_len;
+    private int gyfp2_addr;
+    private int gyfp2_valid;
+    private float gyfp2_coeff;
+    private float gyfp2_base;
+}

+ 16 - 0
gateway/src/main/java/com/gyee/edge/gateway/config/point/Iec102Point.java

@@ -0,0 +1,16 @@
+package com.gyee.edge.gateway.config.point;
+
+import lombok.Data;
+
+@Data
+public class Iec102Point {
+
+    private int endpointid;
+    private int iec102_addr;
+    private float iec102_coeff;
+    private float iec102_base;
+    private int gyfp2_addr;
+    private int gyfp2_valid;
+    private float gyfp2_coeff;
+    private float gyfp2_base;
+}

+ 21 - 0
gateway/src/main/java/com/gyee/edge/gateway/config/point/Iec104Point.java

@@ -0,0 +1,21 @@
+package com.gyee.edge.gateway.config.point;
+
+import lombok.Data;
+
+/**
+ *
+ */
+@Data
+public class Iec104Point {
+
+    private int endpointid;
+    private int iec104_addr;
+    private float iec104_xmax;
+    private float iec104_xmin;
+    private float iec104_coeff;
+    private float iec104_base;
+    private int gyfp2_addr;
+    private int gyfp2_valid;
+    private float gyfp2_coeff;
+    private float gyfp2_base;
+}

+ 17 - 0
gateway/src/main/java/com/gyee/edge/gateway/config/point/ModbusPoint.java

@@ -0,0 +1,17 @@
+package com.gyee.edge.gateway.config.point;
+
+import lombok.Data;
+
+@Data
+public class ModbusPoint {
+    private int endpointid;
+    private int modbus_uid;
+    private int modbus_addr;
+    private int modbus_fun;
+    private int modbus_type;
+    private int modbus_swap;
+    private int gyfp2_addr;
+    private int gyfp2_valid;
+    private float gyfp2_coeff;
+    private float gyfp2_base;
+}

+ 0 - 14
gateway/src/main/java/com/gyee/edge/gateway/config/point/Point102Mapper.java

@@ -1,14 +0,0 @@
-package com.gyee.edge.gateway.config.point;
-
-import lombok.Data;
-
-@Data
-public class Point102Mapper {
-    private int iec102_addr;
-    private float iec102_coeff;
-    private float iec102_base;
-    private int gyfp_addr;
-    private int gyfp_valid;
-    private float gyfp_coeff;
-    private float gyfp_base;
-}

+ 0 - 45
gateway/src/main/java/com/gyee/edge/gateway/config/read/ReadPoint102SqliteData.java

@@ -1,45 +0,0 @@
-package com.gyee.edge.gateway.config.read;
-
-
-import com.gyee.edge.gateway.config.point.Point102Mapper;
-import com.gyee.edge.gateway.config.point.PointMapper;
-import com.gyee.edge.gateway.config.sqlite.Database;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.ArrayList;
-import java.util.List;
-
-@Component
-public class ReadPoint102SqliteData {
-    @Autowired
-    private Database db;
-
-    public List<Point102Mapper> readData() {
-        List<Point102Mapper> point102MapperList = new ArrayList<>();
-        try {
-            Connection conn = db.getConnection();
-            String sql = "select * from key_table";
-            PreparedStatement ps = conn.prepareStatement(sql);
-            ResultSet rs = ps.executeQuery();
-            while (rs.next()) {
-                Point102Mapper point102Mapper = new Point102Mapper();
-                point102Mapper.setGyfp_base(rs.getFloat("gyfp_base"));
-                point102Mapper.setGyfp_addr(rs.getInt("gyfp_addr"));
-                point102Mapper.setGyfp_coeff(rs.getInt("gyfp_coeff"));
-                point102Mapper.setIec102_addr(rs.getInt("iec102_addr"));
-                point102Mapper.setIec102_base(rs.getFloat("iec102_base"));
-                point102Mapper.setIec102_coeff(rs.getFloat("iec102_coeff"));
-                point102Mapper.setGyfp_valid(rs.getInt("gyfp_valid"));
-                point102MapperList.add(point102Mapper);
-            }
-            db.releaseResource();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return point102MapperList;
-    }
-}

+ 0 - 47
gateway/src/main/java/com/gyee/edge/gateway/config/read/ReadPointCSVData.java

@@ -1,47 +0,0 @@
-package com.gyee.edge.gateway.config.read;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import com.csvreader.CsvReader;
-import com.gyee.edge.gateway.config.point.PointMapper;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
-
-@Slf4j
-@Component
-public class ReadPointCSVData {
-    public static ArrayList<PointMapper> readConfig(String filePath)  {
-        //默认路径
-        if (filePath.length()>0) {
-            return readCsvByCsvReader(filePath);
-        }
-        else{
-            return null;
-        }
-    }
-
-    public static ArrayList<PointMapper> readCsvByCsvReader(String filePath) {
-        ArrayList<PointMapper> strList = null;
-        try {
-            ArrayList<String[]> arrList = new ArrayList<String[]>();
-            strList = new ArrayList<PointMapper>();
-            CsvReader reader = new CsvReader(filePath, ',', Charset.forName("UTF-8"));
-            while (reader.readRecord()) {
-                arrList.add(reader.getValues());
-            }
-            reader.close();
-            for (int row = 0; row < arrList.size(); row++) {
-                PointMapper pointMapper = new PointMapper();
-                pointMapper.setDataSource(arrList.get(row)[0]);
-                pointMapper.setProtocolSource(arrList.get(row)[1]);
-                pointMapper.setSourceAddress(Integer.valueOf(arrList.get(row)[2]));
-                pointMapper.setRatio(Double.valueOf(arrList.get(row)[3]));
-                pointMapper.setMessageKey(Integer.valueOf(arrList.get(row)[4]));
-                pointMapper.setMessageId(arrList.get(row)[5]);
-                strList.add(pointMapper);
-            }
-        } catch (Exception e) {
-            log.error("读取csv文件发生错误",e);
-        }
-        return strList;
-    }
-}

+ 0 - 44
gateway/src/main/java/com/gyee/edge/gateway/config/read/ReadPointSqLiteData.java

@@ -1,44 +0,0 @@
-package com.gyee.edge.gateway.config.read;
-
-
-import com.gyee.edge.gateway.config.point.PointMapper;
-import com.gyee.edge.gateway.config.sqlite.Database;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.util.ArrayList;
-import java.util.List;
-
-@Component
-public class ReadPointSqLiteData {
-    @Autowired
-    private Database db;
-
-    public List<PointMapper> readData() {
-        List<PointMapper> pointMapperList = new ArrayList<>();
-        try {
-            Connection conn = db.getConnection();
-            String sql = "select * from point";
-            PreparedStatement ps = conn.prepareStatement(sql);
-            ResultSet rs = ps.executeQuery();
-            while (rs.next()) {
-                PointMapper pointMapper = new PointMapper();
-                pointMapper.setRatio(rs.getDouble("ratio"));
-                pointMapper.setDataSource(rs.getString("datasource"));
-                pointMapper.setMessageKey(rs.getInt("messagekey"));
-                pointMapper.setSourceAddress(rs.getInt("sourceaddress"));
-                pointMapper.setMessageId(rs.getString("messageid"));
-                pointMapper.setProtocolSource(rs.getString("protocolsource"));
-                pointMapperList.add(pointMapper);
-            }
-            System.out.println(pointMapperList.get(0));
-            db.releaseResource();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return pointMapperList;
-    }
-}

+ 0 - 364
gateway/src/main/java/com/gyee/edge/gateway/config/sqlite/DB.java

@@ -1,364 +0,0 @@
-package com.gyee.edge.gateway.config.sqlite;
-
-import java.io.Reader;
-import java.io.StringReader;
-import java.sql.*;
-import java.text.MessageFormat;
-import java.util.*;
-
-public class DB {
-    //数据库驱动,默认为Oracle
-    public static String JDBC_DRIVER = "oracle.jdbc.driver.OracleDriver";
-
-    //数据库连接地址
-    public static String DB_URL = "";
-
-    public static String USER = "";
-
-    public static String PASS = "";
-
-    Connection CONN = null;
-
-    //PreparedStatement PSTM = null;
-
-    public DB(String url, String user, String pass) {
-        DB_URL = url;
-        USER = user;
-        PASS = pass;
-    }
-
-    public DB() {
-        /*Properties props = new Properties();
-        try {
-            String configFilePath = System.getProperty("antgis.web.oa.root")+"/WEB-INF/config.properties";
-            props.load(new FileInputStream(configFilePath));
-        }catch (FileNotFoundException e){
-
-        }catch (IOException e){
-
-        }*/
-
-
-//        JDBC_DRIVER = Config.DB_DRIVER;
-//        DB_URL = Config.DB_URL;
-//        USER = Config.DB_USER;
-//        PASS = Config.DB_PWD;
-    }
-
-    public Connection getConnection() {
-        try {
-            Class.forName(JDBC_DRIVER);
-            CONN = DriverManager.getConnection(DB_URL, USER, PASS);
-        } catch (ClassNotFoundException e) {
-
-        } catch (SQLException e) {
-
-        }
-        return CONN;
-    }
-
-    public ResultSet getResultSet(String sql) {
-        ResultSet resultSet = null;
-        //PreparedStatement pstm = null;
-        try {
-            CONN = getConnection();
-            PreparedStatement PSTM = CONN.prepareStatement(sql);
-            resultSet = PSTM.executeQuery();
-            return resultSet;
-        } catch (SQLException e) {
-            return resultSet;
-        } finally {
-
-        }
-    }
-
-    public void close() {
-        /*if(PSTM !=null) {
-            try {
-                PSTM.close();
-            } catch (SQLException e) {
-                e.printStackTrace();
-            }
-        }*/
-
-        try {
-            if (CONN != null && (!CONN.isClosed())) {
-                try {
-                    CONN.close();
-                } catch (SQLException e) {
-                    e.printStackTrace();
-                }
-            }
-        } catch (SQLException e) {
-            e.printStackTrace();
-        }
-    }
-
-    public List<Map<String, Object>> getList(String sql) {
-        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
-        ResultSet rs = getResultSet(sql);
-        list = convertToList(rs);
-        return list;
-    }
-
-    public List<Map<String, Object>> convertToList(ResultSet rs) {
-        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
-        try {
-            ResultSetMetaData md = rs.getMetaData(); //获得结果集结构信息,元数据
-            int columnCount = md.getColumnCount();   //获得列数
-            while (rs.next()) {
-                Map<String, Object> rowData = new HashMap<String, Object>();
-                for (int i = 1; i <= columnCount; i++) {
-                    rowData.put(md.getColumnName(i), rs.getObject(i));
-                }
-                list.add(rowData);
-            }
-        } catch (SQLException e) {
-
-        }
-
-        return list;
-    }
-
-    public ResultSet getResultSet(String tableName, String filter) {
-        String sql = MessageFormat.format("select * from {0} where {1}", tableName, filter);
-        return getResultSet(sql);
-    }
-
-    public ResultSet getResultSet(String tableName, String columnList, String filter) {
-        String sql = MessageFormat.format("select {2} from {0} where {1}", tableName, filter, columnList);
-        return getResultSet(sql);
-    }
-
-    public ResultSet getResultSet(String tableName, String columnList, String filter, String orderColumnList) {
-        String sql = MessageFormat.format("select {2} from {0} where {1} order by {3}", tableName, filter, columnList, orderColumnList);
-        return getResultSet(sql);
-    }
-
-    public Object getFirstColumn(String sql) {
-        ResultSet rs = getResultSet(sql);
-        try {
-            if (rs.next()) {
-                return rs.getObject(0);
-            }
-        } catch (SQLException e) {
-
-        }
-        return null;
-    }
-
-    public String getSqlForPageSize(String tableName, Integer pageSize, Integer pageIndex, String where, String order) {
-        return getSqlForPageSize(tableName, "*", pageSize, pageIndex, where, order);
-    }
-
-    public String getSqlForPageSize(String tableName, String sColumnList, int pageSize, int pageIndex, String where, String order) {
-        String sSql = "";
-        StringBuilder sb = new StringBuilder();
-        sb.append("select " + sColumnList + " from (select t.*,rownum rno ");
-        sb.append(" from (select * from " + tableName + " ");
-        sb.append(" where " + where);
-        sb.append(order);
-        sb.append(") t where rownum <= ");
-        sb.append((pageIndex + 1) * pageSize);
-        sb.append(" )");
-        sb.append(" where rno >= ");
-        sb.append(pageIndex * pageSize + 1);
-        sSql = sb.toString();
-        return sSql;
-    }
-
-    public boolean judgeRecordExist(String tableName, String filter) {
-        ResultSet rs = getResultSet(tableName, filter);
-        try {
-            if (rs.next())
-                return true;
-            else
-                return false;
-        } catch (SQLException e) {
-            return false;
-        }
-    }
-
-    public String formatTableName(String tableName) {
-        return tableName.replace("\"", "");
-    }
-
-    public boolean judgeTableOrViewExist(String tableName) {
-        String sql = "select count(*) from user_objects where object_type in ('TABLE','VIEW') AND upper(OBJECT_NAME)=upper('" + formatTableName(tableName) + "')";
-        ResultSet rs = getResultSet(sql);
-        return judgeCountValue(rs);
-    }
-
-    public boolean judgeColumnExist(String tableName, String columnName) {
-        String sql = "select count(*) from user_tab_cols where upper(table_name)=upper('" + formatTableName(tableName) + "') and upper(COLUMN_NAME)=upper('" + columnName + "') order by COLUMN_ID";
-        ResultSet rs = getResultSet(sql);
-        return judgeCountValue(rs);
-    }
-
-    private boolean judgeCountValue(ResultSet rs) {
-        try {
-            if (rs.next()) {
-                if (Integer.parseInt(rs.getObject(0).toString()) == 1)
-                    return true;
-                else
-                    return false;
-            } else {
-                return false;
-            }
-        } catch (SQLException e) {
-            return false;
-        }
-    }
-
-    public HashMap getTableColumnType(String tableName) {
-        String sql = "select COLUMN_NAME,DATA_TYPE,DATA_LENGTH,COLUMN_ID from user_tab_cols where upper(table_name)=upper('" + formatTableName(tableName) + "') order by COLUMN_ID";
-        ResultSet rs = getResultSet(sql);
-        HashMap hm = new HashMap();
-        try {
-            while (rs.next()) {
-                String name = rs.getString("COLUMN_NAME");
-                String value = rs.getString("DATA_TYPE");
-                hm.put(name, value);
-            }
-        } catch (SQLException e) {
-
-        }
-
-        return hm;
-    }
-
-    public boolean add(String tableName, LinkedHashMap<String, Object> hm) throws Exception {
-        if (tableName == null || tableName.equals("")) {
-            throw new Exception("表名不能为空字符串!");
-        }
-
-        String sColumns = "";
-        String sValues = "";
-
-        Iterator iter = hm.entrySet().iterator();
-        while (iter.hasNext()) {
-            Map.Entry entry = (Map.Entry) iter.next();
-            sColumns += entry.getKey().toString() + ",";
-            sValues += "?,";
-        }
-        /*for(String key:hm.keySet()){
-            sColumns += key +",";
-            sValues += "?,";
-        }*/
-
-        sColumns = sColumns.substring(0, sColumns.length() - 1);
-        sValues = sValues.substring(0, sValues.length() - 1);
-        String sql = MessageFormat.format("insert into {0} ({1}) values({2})", tableName, sColumns, sValues);
-
-        return executeSql(sql, tableName, hm);
-    }
-
-    public boolean update(String tableName, LinkedHashMap<String, Object> hm, String filterColumns) throws Exception {
-        if (tableName == null || tableName.equals("")) {
-            throw new Exception("表名不能为空字符串!");
-        }
-
-        String filter = getFilterString(tableName, hm, filterColumns);
-
-        return update2(tableName, hm, filter);
-    }
-
-    public boolean update2(String tableName, LinkedHashMap<String, Object> hm, String filter) throws Exception {
-        if (tableName == null || tableName.equals("")) {
-            throw new Exception("表名不能为空字符串!");
-        }
-
-        String str = "";
-        Iterator iter = hm.entrySet().iterator();
-        while (iter.hasNext()) {
-            Map.Entry entry = (Map.Entry) iter.next();
-            str += entry.getKey().toString() + "=?,";
-        }
-
-        str = str.substring(0, str.length() - 1);
-        String sql = MessageFormat.format("update {0} set {1} where {2}", tableName, str, filter);
-        return executeSql(sql, tableName, hm);
-    }
-
-    private String getFilterString(String tableName, LinkedHashMap<String, Object> hm, String filterColumns) {
-        String[] arr = filterColumns.split(",");
-        int length = arr.length;
-        HashMap columnsType = getTableColumnType(tableName);
-        String filter = "";
-        for (int ii = 0; ii < length; ii++) {
-            String columnType = columnsType.get(arr[ii]).toString();
-            switch (columnType) {
-                case "NUMBER":
-                    filter += "and " + arr[ii] + "=" + hm.get(arr[ii]) + " ";
-                    break;
-                case "DATE":
-                    filter += "and " + arr[ii] + "=to_date('" + hm.get(arr[ii]).toString() + "','yyyy-mm-dd hh24:mi:ss') ";
-                    break;
-                default:
-                    filter += "and " + arr[ii] + "='" + hm.get(arr[ii]).toString() + "' ";
-                    break;
-
-            }
-        }
-        filter = filter.substring(3);
-        return filter;
-    }
-
-
-    public boolean executeSql(String sql, String tableName, LinkedHashMap<String, Object> hm) {
-        boolean bl = false;
-        int i = 0;
-        try {
-            CONN = getConnection();
-            PreparedStatement pstm = CONN.prepareStatement(sql);
-            HashMap columnsType = getTableColumnType(tableName);
-
-            Iterator iter = hm.entrySet().iterator();
-            int index = 0;
-            while (iter.hasNext()) {
-                index += 1;
-                Map.Entry entry = (Map.Entry) iter.next();
-                String key = entry.getKey().toString();
-                Object val = entry.getValue();
-                String columnType = columnsType.get(key).toString();
-                switch (columnType) {
-                    case "NVARCHAR2":
-                    case "NCHAR":
-                    case "VARCHAR2":
-                    case "CHAR":
-                    case "NUMBER":
-                        pstm.setString(index, val.toString());
-                        break;
-                    case "DATE":
-                        Timestamp dateTime = Timestamp.valueOf(val.toString());
-                        pstm.setTimestamp(index, dateTime);
-                        break;
-                    /*case "BLOB":
-                        PSTM.setBlob(index,oracle.sql.BLOB.getEmptyBLOB());
-
-                        break;*/
-                    case "CLOB":
-                        String str = val.toString();
-                        Reader clobReader = new StringReader(str); // 将 text转成流形式
-                        pstm.setClob(index, clobReader, str.length());
-                        break;
-                    default:
-                        pstm.setString(index, val.toString());
-                        break;
-
-                }
-            }
-
-            i = pstm.executeUpdate();
-            if (i > 0)
-                bl = true;
-
-
-        } catch (SQLException e) {
-            String msg = e.getMessage();
-        }
-
-
-        return bl;
-    }
-}

+ 4 - 19
gateway/src/main/java/com/gyee/edge/gateway/config/sqlite/Database.java

@@ -14,13 +14,14 @@ public class Database {
     @Value("${spring.datasource.url}")
     private String url;
 
-    Connection connection = null;
+    private Connection connection = null;
 
-    PreparedStatement preparedStatement = null;
-    ResultSet rs = null;
 
 
     public Connection getConnection() throws Exception {
+//        if (connection == null || connection.isClosed()) {
+//
+//        }
         try{
             Class.forName(driver);
             connection = DriverManager.getConnection(url);
@@ -35,22 +36,6 @@ public class Database {
 
     //释放资源
     public void releaseResource(){
-        if(rs!=null){
-            try{
-                rs.close();
-            }catch (SQLException e){
-                e.printStackTrace();
-            }
-        }
-
-        if(preparedStatement!=null){
-            try{
-                preparedStatement.close();
-            }catch (SQLException e){
-                e.printStackTrace();
-            }
-        }
-
         if(connection!=null){
             try{
                 connection.close();

+ 0 - 33
gateway/src/main/java/com/gyee/edge/gateway/config/sqlite/EndPoint.java

@@ -1,33 +0,0 @@
-package com.gyee.edge.gateway.config.sqlite;
-
-import lombok.Data;
-
-@Data
-public class EndPoint {
-    String ipAddress;
-
-    int ipPort;
-
-    ProtocolType protocolType;
-
-    //串口端口
-    String serialPort;
-
-    //波特率
-    int baudRate;
-
-    //开始位
-    int startBit;
-
-    //停止位
-    int stopBit;
-
-    //校验位
-    int checkBit;
-
-    String username;
-
-    String password;
-
-    String token;
-}

+ 0 - 12
gateway/src/main/java/com/gyee/edge/gateway/config/sqlite/ProtocolType.java

@@ -1,12 +0,0 @@
-package com.gyee.edge.gateway.config.sqlite;
-
-
-//协议类型
-public enum ProtocolType {
-    MODBUS,
-    IEC104,
-    IEC102,
-    GYFP2,
-    CDT,
-    GLYC
-}

+ 0 - 27
gateway/src/main/java/com/gyee/edge/gateway/data/GeneralTsData.java

@@ -1,27 +0,0 @@
-package com.gyee.edge.gateway.data;
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-import java.util.Optional;
-
-/**
- * @author songwb<songwb@aliyun.com>
- */
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-public class GeneralTsData implements TsData {
-
-    private long ts;
-    private short status;
-    private Optional<Double> doubleValue;
-    private Optional<Long> longValue;
-    private Optional<Boolean> booleanValue;
-    private Optional<String> stringValue;
-    private Optional<String> blobValue;
-
-
-}
-

+ 0 - 15
gateway/src/main/java/com/gyee/edge/gateway/data/TsData.java

@@ -1,15 +0,0 @@
-package com.gyee.edge.gateway.data;
-
-/**
- * @author songwb<songwb@aliyun.com>
- */
-public interface TsData {
-
-    long getTs();
-
-    short getStatus();
-
-    //double getValue();
-
-}
-

+ 0 - 15
gateway/src/main/java/com/gyee/edge/gateway/data/TsDataType.java

@@ -1,15 +0,0 @@
-package com.gyee.edge.gateway.data;
-
-/**
- * @author songwb<songwb@aliyun.com>
- */
-public enum TsDataType {
-    LONG,
-    DOUBLE,
-    BOOLEAN,
-    STRING,
-    BLOB,
-    COORDINATE
-
-}
-

+ 0 - 56
gateway/src/main/java/com/gyee/edge/gateway/data/TsPointData.java

@@ -1,56 +0,0 @@
-package com.gyee.edge.gateway.data;
-
-
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.NoArgsConstructor;
-
-/**
- * @author songwb<songwb@aliyun.com>
- */
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-public class TsPointData {
-
-    private String tagName;
-    private GeneralTsData tsData;
-
-    public TsDataType findDataType() {
-        if (tsData.getDoubleValue().isPresent()){
-            return TsDataType.DOUBLE;
-        }
-        else if (tsData.getBooleanValue().isPresent()){
-            return TsDataType.BOOLEAN;
-        }
-        else if (tsData.getLongValue().isPresent()){
-            return TsDataType.LONG;
-        }
-
-        else if (tsData.getStringValue().isPresent()){
-            return TsDataType.STRING;
-        }
-
-        else if (tsData.getBlobValue().isPresent()){
-            return TsDataType.BLOB;
-        }
-
-
-        return TsDataType.DOUBLE;
-    }
-    /**
-     * 获取 double 类型值
-     * @return
-     */
-    public double getValue() {
-        if (tsData.getDoubleValue().isPresent()) {
-            return tsData.getDoubleValue().get();
-        } else if (tsData.getBooleanValue().isPresent()) {
-            return tsData.getBooleanValue().get() ? 1.0 : 0.0;
-        } else if (tsData.getLongValue().isPresent()) {
-            return tsData.getLongValue().get();
-        }
-        return 0.0;
-    }
-}
-

+ 3 - 2
gateway/src/main/resources/application.yaml

@@ -1,16 +1,17 @@
 server:
-  port: 8012
+  port: 8013
 spring:
   application:
   name: gateway
   datasource:
     driver-class-name: org.sqlite.JDBC
 #    F:\\colud_ideaspace\\edge\\gateway\\src\\main\\resources\\myDb
-    url: jdbc:sqlite::resource:keytable.sqlite3
+    url: jdbc:sqlite::resource:keytable.db
     username:
     password:
 
 rocketmq:
   namesrvaddr: 127.0.0.1:9876
+  tags: MHS
 filePath: D:\\data.csv
 

BIN
gateway/src/main/resources/keytable.db


BIN
gateway/src/main/resources/keytable.sqlite3


+ 12 - 10
protocol/gyfp2/src/main/java/com/gyee/protocol/gyfp2/message/MessageData.java

@@ -75,13 +75,15 @@ public class MessageData implements Serializable {
         return bytes;
     }
 
-    //MessageData对象转字节数组   messagetype决定实际长度类型
-    // mutable中有值则采用mutable中type的值,mutable中无值则采用messagedata中的datatype。
+    /** MessageData对象转字节数组   messagetype决定实际长度类型
+        mutable中有值则采用mutable中type的值,
+       mutable中无值则采用messagedata中的datatype。
+     */
     public byte[] toBytes(int attribute,byte messagetype){
         ByteBuf buffer = Unpooled.buffer(10);
         if (attribute==0){
             buffer.writeByte(getDataType());
-            buffer.writeBytes(BytesUtils.intToByte2(getDataKey()));
+            buffer.writeBytes(BytesUtils.intToBytes(getDataKey(),3));
             buffer.writeLong(getTs());
             buffer.writeBytes(ValuetoBytes(getDataType()));
         }else if(attribute==1){
@@ -89,7 +91,7 @@ public class MessageData implements Serializable {
             buffer.writeLong(getTs());
             buffer.writeBytes(ValuetoBytes(getDataType()));
         }else if(attribute==2) {
-            buffer.writeBytes(BytesUtils.intToByte2(getDataKey()));
+            buffer.writeBytes(BytesUtils.intToBytes(getDataKey(),3));
             buffer.writeLong(getTs());
             buffer.writeBytes(ValuetoBytes(messagetype));
         }else if(attribute==3){
@@ -97,13 +99,13 @@ public class MessageData implements Serializable {
             buffer.writeBytes(ValuetoBytes(messagetype));
         }else if(attribute==4){
             buffer.writeByte(getDataType());
-            buffer.writeBytes(BytesUtils.intToByte2(getDataKey()));
+            buffer.writeBytes(BytesUtils.intToBytes(getDataKey(),3));
             buffer.writeBytes(ValuetoBytes(getDataType()));
         }else if (attribute==5){
             buffer.writeByte(getDataType());
             buffer.writeBytes(ValuetoBytes(getDataType()));
         }else if (attribute==6){
-            buffer.writeBytes(BytesUtils.intToByte2(getDataKey()));
+            buffer.writeBytes(BytesUtils.intToBytes(getDataKey(),3));
             buffer.writeBytes(ValuetoBytes(messagetype));
         }else if (attribute==7){
             buffer.writeBytes(ValuetoBytes(messagetype));
@@ -124,7 +126,7 @@ public class MessageData implements Serializable {
             for (int i = 0; i < bytes1.length;) {
                 MessageData messageData = new MessageData();
                 messageData.setDataType(bytes1[i]);
-                messageData.setDataKey(BytesUtils.BytesToInt(bytes1,i+1));
+                messageData.setDataKey(BytesUtils.bytesToInt(bytes1,i+1));
                 messageData.setTs(BytesUtils.getLong2(bytes1,i+4));
                 if (bytes1[i]==0){
                     messageData.setGYFP2_TYPE_BOOLEAN(BytesUtils.getBoolean(bytes1,i+12));
@@ -171,7 +173,7 @@ public class MessageData implements Serializable {
             System.arraycopy(bytes, 16 + bytes2.length, bytes1, 0, bytes1.length);
             for (int i = 0; i < bytes1.length;) {
                 MessageData messageData = new MessageData();
-                messageData.setDataKey(BytesUtils.BytesToInt(bytes1,i));
+                messageData.setDataKey(BytesUtils.bytesToInt(bytes1,i));
                 messageData.setTs(BytesUtils.getLong2(bytes1,i+3));
                 if (bytes2[0]==0){
                     messageData.setGYFP2_TYPE_BOOLEAN(BytesUtils.getBoolean(bytes1,i+11));
@@ -218,7 +220,7 @@ public class MessageData implements Serializable {
             for (int i = 0; i < bytes1.length;) {
                 MessageData messageData = new MessageData();
                 messageData.setDataType(bytes1[i]);
-                messageData.setDataKey(BytesUtils.BytesToInt(bytes1,i+1));
+                messageData.setDataKey(BytesUtils.bytesToInt(bytes1,i+1));
                 if (bytes1[i]==0){
                     messageData.setGYFP2_TYPE_BOOLEAN(BytesUtils.getBoolean(bytes1,i+4));
                     i = i + 5;
@@ -263,7 +265,7 @@ public class MessageData implements Serializable {
             System.arraycopy(bytes, 16 + bytes2.length, bytes1, 0, bytes1.length);
             for (int i = 0; i < bytes1.length;) {
                 MessageData messageData = new MessageData();
-                messageData.setDataKey(BytesUtils.BytesToInt(bytes1,i));
+                messageData.setDataKey(BytesUtils.bytesToInt(bytes1,i));
                 if (bytes2[0]==0){
                     messageData.setGYFP2_TYPE_BOOLEAN(BytesUtils.getBoolean(bytes1,i+3));
                     i = i + 4;

+ 8 - 8
protocol/gyfp2/src/main/java/com/gyee/protocol/gyfp2/message/MessageMutable.java

@@ -22,23 +22,23 @@ public class MessageMutable implements Serializable {
     public byte[] toBytes(int attribute){
         ByteBuf buffer = Unpooled.buffer(4);
         if(attribute==1){
-            buffer.writeBytes(BytesUtils.intToByte2(getKey()));
+            buffer.writeBytes(BytesUtils.intToBytes(getKey(),3));
         }else if(attribute==2){
             buffer.writeByte(getMessageType());
         }else if(attribute==3){
             buffer.writeByte(getMessageType());
-            buffer.writeBytes(BytesUtils.intToByte2(getKey()));
+            buffer.writeBytes(BytesUtils.intToBytes(getKey(),3));
         }else if(attribute==4){
             buffer.writeLong(getTs());
         }else if(attribute==5){
-            buffer.writeBytes(BytesUtils.intToByte2(getKey()));
+            buffer.writeBytes(BytesUtils.intToBytes(getKey(),3));
             buffer.writeLong(getTs());
         }else if (attribute==6){
             buffer.writeByte(getMessageType());
             buffer.writeLong(getTs());
         }else if(attribute==7){
             buffer.writeByte(getMessageType());
-            buffer.writeBytes(BytesUtils.intToByte2(getKey()));
+            buffer.writeBytes(BytesUtils.intToBytes(getKey(),3));
             buffer.writeLong(getTs());
         }
         byte[] bytes = ByteBufUtil.getBytes(buffer);
@@ -53,7 +53,7 @@ public class MessageMutable implements Serializable {
                 //获取header头部字节大小
                 byte[] bytes1 = new byte[3];
                 System.arraycopy(bytes, 16, bytes1, 0, 3);
-                int i = BytesUtils.BytesToInt(bytes1, 0);
+                int i = BytesUtils.bytesToInt(bytes1, 0);
                 messageMutable.setKey(i);
             }else if (attribute == 2) {
                 byte[] bytes1 = new byte[1];
@@ -63,7 +63,7 @@ public class MessageMutable implements Serializable {
                 byte[] bytes1 = new byte[4];
                 System.arraycopy(bytes, 16, bytes1, 0, 4);
                 messageMutable.setMessageType(bytes1[0]);
-                int i = BytesUtils.BytesToInt(bytes1, 1);
+                int i = BytesUtils.bytesToInt(bytes1, 1);
                 messageMutable.setKey(i);
             }else if (attribute == 4) {
                 byte[] bytes1 = new byte[8];
@@ -72,7 +72,7 @@ public class MessageMutable implements Serializable {
             }else if (attribute == 5) {
                 byte[] bytes1 = new byte[11];
                 System.arraycopy(bytes, 16, bytes1, 0, 11);
-                int i = BytesUtils.BytesToInt(bytes1, 0);
+                int i = BytesUtils.bytesToInt(bytes1, 0);
                 messageMutable.setKey(i);
                 messageMutable.setTs(BytesUtils.getLong2(bytes1, 3));
             }else if (attribute == 6) {
@@ -84,7 +84,7 @@ public class MessageMutable implements Serializable {
                 byte[] bytes1 = new byte[12];
                 System.arraycopy(bytes, 16, bytes1, 0, 12);
                 messageMutable.setMessageType(bytes1[0]);
-                int i = BytesUtils.BytesToInt(bytes1, 1);
+                int i = BytesUtils.bytesToInt(bytes1, 1);
                 messageMutable.setKey(i);
                 messageMutable.setTs(BytesUtils.getLong2(bytes1, 4));
             }