From 233c0e20548cadafb77efdcb3418f38c6658bbad Mon Sep 17 00:00:00 2001
From: jiazx0107@163.com <jiazx0107@163.com>
Date: 星期四, 26 十月 2023 14:20:57 +0800
Subject: [PATCH] 四川省网关接口相关7

---
 src/main/java/com/fzzy/api/data/PushProtocol.java                           |   24 +
 src/main/java/com/fzzy/gateway/service/GatewayDeviceService.java            |   39 -
 src/main/java/com/fzzy/gateway/GatewayUtils.java                            |   66 +++
 src/main/java/com/fzzy/gateway/hx2023/ScConstant.java                       |   23 -
 src/main/java/com/fzzy/gateway/view/GatewayDevice.view.xml                  |   76 ++
 pom.xml                                                                     |    8 
 src/main/java/com/fzzy/api/data/GatewayDeviceType.java                      |   34 +
 src/main/java/com/fzzy/gateway/api/GatewaySyncWeightService.java            |    1 
 src/main/java/com/fzzy/gateway/entity/GatewayDevice.java                    |   18 
 src/main/java/com/fzzy/gateway/api/GatewayRemoteManager.java                |   17 
 src/main/java/com/fzzy/api/data/GatewayProtocol.java                        |   14 
 src/main/java/com/fzzy/gateway/hx2023/websocket/WebSocketDeviceLed.java     |    8 
 src/main/java/com/fzzy/api/utils/ContextUtil.java                           |   11 
 src/main/java/com/fzzy/gateway/hx2023/service/DeviceReportServiceImpl.java  |   56 ++
 src/main/java/com/fzzy/api/service/ApiTriggerService.java                   |   57 --
 src/main/java/com/fzzy/gateway/api/DeviceReportService.java                 |   24 +
 src/main/java/com/fzzy/protocol/weightyh/SessionListener.java               |   31 +
 src/main/java/com/fzzy/protocol/weightyh/MessageConsumer.java               |  114 +++++
 src/main/java/com/fzzy/gateway/hx2023/data/WebSocketPacketHeader.java       |    6 
 src/main/java/com/fzzy/api/utils/BytesUtil.java                             |  404 +++++++++++++++++++
 src/main/java/com/fzzy/gateway/hx2023/websocket/WebSocketDeviceReport.java  |   22 
 src/main/java/com/fzzy/protocol/weightyh/YhScaleServerEngine.java           |   43 ++
 src/main/java/com/fzzy/gateway/hx2023/service/HxGatewaySyncWeightImpl1.java |   19 
 src/main/java/com/fzzy/gateway/view/GatewayConf.view.xml                    |   33 +
 src/main/java/com/fzzy/api/utils/SpringUtil.java                            |   58 ++
 src/main/java/com/fzzy/api/data/GatewayDeviceProtocol.java                  |   19 
 src/main/java/com/fzzy/api/data/SyncProtocol.java                           |   18 
 src/main/java/com/fzzy/gateway/GatewayRunner.java                           |    1 
 src/main/java/com/fzzy/protocol/package-info.java                           |    4 
 29 files changed, 1,108 insertions(+), 140 deletions(-)

diff --git a/pom.xml b/pom.xml
index f060457..342e6a8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -170,6 +170,14 @@
 		<!-- </dependency> -->
 
 
+		<!-- 寮曞叆IO鍖� -->
+		<dependency>
+			<groupId>com.ld.base.io</groupId>
+			<artifactId>base-io-netty</artifactId>
+			<version>1.0.0-SNAPSHOT</version>
+		</dependency>
+
+
 		<!-- mysql杩炴帴 -->
 		<dependency>
 			<groupId>mysql</groupId>
diff --git a/src/main/java/com/fzzy/api/data/GatewayDeviceProtocol.java b/src/main/java/com/fzzy/api/data/GatewayDeviceProtocol.java
index 93dec3a..e87c538 100644
--- a/src/main/java/com/fzzy/api/data/GatewayDeviceProtocol.java
+++ b/src/main/java/com/fzzy/api/data/GatewayDeviceProtocol.java
@@ -1,6 +1,11 @@
 package com.fzzy.api.data;
 
 
+import com.fzzy.api.entity.ApiTrigger;
+
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * 缃戝叧涓庤澶囩洿鎺ョ殑閫氳鍗忚
  */
@@ -12,12 +17,24 @@
     DEVICE_IDCARD_HTTP("DEVICE_IDCARD_HTTP", "韬唤璇�-HTTP鍗忚"),
     DEVICE_LED_HTTP("DEVICE_LED_HTTP", "LED-HTTP鍗忚"),
     DEVICE_LPR_SDK_HK("DEVICE_LPR_SDK_HK", "杞︾墝璇嗗埆-SDK娴峰悍"),
-    DEVICE_TEST("DEVICE_TEST", "娴嬭瘯鍗忚");
+    DEVICE_TEST("DEVICE_TEST", "绌哄崗璁�");
 
 
     private String code;
     private String name;
 
+    public static List<ApiTrigger> listTrigger() {
+        List<ApiTrigger> list = new ArrayList<>();
+        list.add(new ApiTrigger(GRAIN_FZZY_ZH_2023.getCode(), GRAIN_FZZY_ZH_2023.getName()));
+        list.add(new ApiTrigger(DEVICE_WEIGHT_HTTP.getCode(), DEVICE_WEIGHT_HTTP.getName()));
+        list.add(new ApiTrigger(DEVICE_WEIGHT_TCP_YH.getCode(), DEVICE_WEIGHT_TCP_YH.getName()));
+        list.add(new ApiTrigger(DEVICE_IDCARD_HTTP.getCode(), DEVICE_IDCARD_HTTP.getName()));
+        list.add(new ApiTrigger(DEVICE_LED_HTTP.getCode(), DEVICE_LED_HTTP.getName()));
+        list.add(new ApiTrigger(DEVICE_LPR_SDK_HK.getCode(), DEVICE_LPR_SDK_HK.getName()));
+        list.add(new ApiTrigger(DEVICE_TEST.getCode(), DEVICE_TEST.getName()));
+        return list;
+    }
+
 
     public String getCode() {
         return code;
diff --git a/src/main/java/com/fzzy/api/data/GatewayDeviceType.java b/src/main/java/com/fzzy/api/data/GatewayDeviceType.java
index c4d65f4..afbafce 100644
--- a/src/main/java/com/fzzy/api/data/GatewayDeviceType.java
+++ b/src/main/java/com/fzzy/api/data/GatewayDeviceType.java
@@ -1,24 +1,44 @@
 package com.fzzy.api.data;
 
 
+import com.fzzy.api.entity.ApiTrigger;
+
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * 缃戝叧璁惧绫诲瀷
  */
 public enum GatewayDeviceType {
 
-    GRAIN_FZZY_ZH_2023("GRAIN_FZZY_ZH_2023", "绮儏-椋庢鑷磋繙鎺у埗鏌滃崗璁�2023"),
-    DEVICE_WEIGHT_HTTP("DEVICE_WEIGHT_HTTP", "鍦扮-HTTP鍗忚"),
-    DEVICE_WEIGHT_TCP_YH("DEVICE_WEIGHT_TCP_YH", "鍦扮-鑰�鍗嶵CP鍗忚"),
-    DEVICE_IDCARD_HTTP("DEVICE_IDCARD_HTTP", "韬唤璇�-HTTP鍗忚"),
-    DEVICE_LED_HTTP("DEVICE_LED_HTTP", "LED-HTTP鍗忚"),
-    DEVICE_LPR_SDK_HK("DEVICE_LPR_SDK_HK", "杞︾墝璇嗗埆-SDK娴峰悍"),
-    DEVICE_TEST("DEVICE_TEST", "娴嬭瘯鍗忚");
+    TYPE_01("TYPE_01", "鍦扮"),
+    TYPE_02("TYPE_02", "杞︾墝璇嗗埆"),
+    TYPE_03("TYPE_03", "閬撻椄"),
+    TYPE_04("TYPE_04", "LED"),
+    TYPE_05("TYPE_05", "鎵︽牱鏈�"),
+    TYPE_06("TYPE_06", "鎽勫儚澶�"),
+    TYPE_07("TYPE_07", "绮儏鍒嗘満"),
+    TYPE_99("TYPE_99", "鐙珛IOT");
 
 
     private String code;
     private String name;
 
 
+    public static List<ApiTrigger> listTrigger() {
+        List<ApiTrigger> list = new ArrayList<>();
+        list.add(new ApiTrigger(TYPE_01.getCode(), TYPE_01.getName()));
+        list.add(new ApiTrigger(TYPE_02.getCode(), TYPE_02.getName()));
+        list.add(new ApiTrigger(TYPE_03.getCode(), TYPE_03.getName()));
+        list.add(new ApiTrigger(TYPE_04.getCode(), TYPE_04.getName()));
+        list.add(new ApiTrigger(TYPE_05.getCode(), TYPE_05.getName()));
+        list.add(new ApiTrigger(TYPE_06.getCode(), TYPE_06.getName()));
+        list.add(new ApiTrigger(TYPE_07.getCode(), TYPE_07.getName()));
+        list.add(new ApiTrigger(TYPE_99.getCode(), TYPE_99.getName()));
+        return list;
+    }
+
+
     public String getCode() {
         return code;
     }
diff --git a/src/main/java/com/fzzy/api/data/GatewayProtocol.java b/src/main/java/com/fzzy/api/data/GatewayProtocol.java
index 4948379..44e65ba 100644
--- a/src/main/java/com/fzzy/api/data/GatewayProtocol.java
+++ b/src/main/java/com/fzzy/api/data/GatewayProtocol.java
@@ -1,6 +1,11 @@
 package com.fzzy.api.data;
 
 
+import com.fzzy.api.entity.ApiTrigger;
+
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * 绯荤粺涓庣綉鍏充箣闂寸殑閫氳鍗忚
  */
@@ -15,6 +20,15 @@
     private String code;
     private String name;
 
+    public static List<ApiTrigger> listTrigger() {
+        List<ApiTrigger> list = new ArrayList<>();
+        list.add(new ApiTrigger(GATE_WEBSOCKET.getCode(), GATE_WEBSOCKET.getName()));
+        list.add(new ApiTrigger(GATE_MQTT.getCode(), GATE_MQTT.getName()));
+        list.add(new ApiTrigger(GATE_HTTP.getCode(), GATE_HTTP.getName()));
+        list.add(new ApiTrigger(GATE_TEST.getCode(), GATE_TEST.getName()));
+        return list;
+    }
+
 
     public String getCode() {
         return code;
diff --git a/src/main/java/com/fzzy/api/data/PushProtocol.java b/src/main/java/com/fzzy/api/data/PushProtocol.java
index b9bc2bd..5b1bed0 100644
--- a/src/main/java/com/fzzy/api/data/PushProtocol.java
+++ b/src/main/java/com/fzzy/api/data/PushProtocol.java
@@ -1,6 +1,11 @@
 package com.fzzy.api.data;
 
 
+import com.fzzy.api.entity.ApiTrigger;
+
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * @Desc: 绯荤粺鏀寔宸茬粡瀹炵幇鐨勫崗璁�
  * @author: andy.jia
@@ -26,6 +31,25 @@
     private String name;
 
 
+    public static List<ApiTrigger> listTrigger() {
+        List<ApiTrigger> list = new ArrayList<>();
+        list.add(new ApiTrigger(GB_DEFAULT.getCode(), GB_DEFAULT.getName()));
+        list.add(new ApiTrigger(GB_2022.getCode(), GB_2022.getName()));
+        list.add(new ApiTrigger(SB_SH_2021.getCode(), SB_SH_2021.getName()));
+        list.add(new ApiTrigger(SB_GD_2022.getCode(), SB_GD_2022.getName()));
+        list.add(new ApiTrigger(SB_GD_2020.getCode(), SB_GD_2020.getName()));
+        list.add(new ApiTrigger(SB_HN_2022.getCode(), SB_HN_2022.getName()));
+        list.add(new ApiTrigger(SB_WHJL_2023.getCode(), SB_WHJL_2023.getName()));
+        list.add(new ApiTrigger(HB_FZZY_JG_2022.getCode(), HB_FZZY_JG_2022.getName()));
+        list.add(new ApiTrigger(SB_SHJdJW_2023.getCode(), SB_SHJdJW_2023.getName()));
+        list.add(new ApiTrigger(SB_SH_2023.getCode(), SB_SH_2023.getName()));
+        list.add(new ApiTrigger(GATEWAY_SC_2023.getCode(), GATEWAY_SC_2023.getName()));
+
+        return list;
+    }
+
+
+
     public String getCode() {
         return code;
     }
diff --git a/src/main/java/com/fzzy/api/data/SyncProtocol.java b/src/main/java/com/fzzy/api/data/SyncProtocol.java
index 984af8c..1da4a40 100644
--- a/src/main/java/com/fzzy/api/data/SyncProtocol.java
+++ b/src/main/java/com/fzzy/api/data/SyncProtocol.java
@@ -1,6 +1,11 @@
 package com.fzzy.api.data;
 
 
+import com.fzzy.api.entity.ApiTrigger;
+
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * @Desc: 绯荤粺鏀寔鐨勫悓姝ュ崗璁�
  * @author: andy.jia
@@ -20,6 +25,19 @@
     private String name;
 
 
+    public static List<ApiTrigger> listTrigger() {
+        List<ApiTrigger> list = new ArrayList<>();
+        list.add(new ApiTrigger(GB_DEFAULT.getCode(), GB_DEFAULT.getName()));
+        list.add(new ApiTrigger(FZZY_V30_GB.getCode(), FZZY_V30_GB.getName()));
+        list.add(new ApiTrigger(FZZY_V35_GB.getCode(), FZZY_V35_GB.getName()));
+        list.add(new ApiTrigger(FZZY_V40_GB.getCode(), FZZY_V40_GB.getName()));
+        list.add(new ApiTrigger(FZZY_V40_WHJL.getCode(), FZZY_V40_WHJL.getName()));
+        list.add(new ApiTrigger(FZZY_V35_SHYZ.getCode(), FZZY_V35_SHYZ.getName()));
+
+        return list;
+    }
+
+
     public String getCode() {
         return code;
     }
diff --git a/src/main/java/com/fzzy/api/service/ApiTriggerService.java b/src/main/java/com/fzzy/api/service/ApiTriggerService.java
index 819b278..adc7454 100644
--- a/src/main/java/com/fzzy/api/service/ApiTriggerService.java
+++ b/src/main/java/com/fzzy/api/service/ApiTriggerService.java
@@ -4,10 +4,7 @@
 import com.bstek.dorado.annotation.DataProvider;
 import com.bstek.dorado.annotation.Expose;
 import com.fzzy.api.Constant;
-import com.fzzy.api.data.GatewayDeviceProtocol;
-import com.fzzy.api.data.GatewayProtocol;
-import com.fzzy.api.data.PushProtocol;
-import com.fzzy.api.data.SyncProtocol;
+import com.fzzy.api.data.*;
 import com.fzzy.api.entity.ApiTrigger;
 import com.fzzy.api.utils.RedisConst;
 import com.fzzy.api.utils.RedisUtil;
@@ -180,21 +177,7 @@
      */
     @DataProvider
     public List<ApiTrigger> triggerPushProtocol() {
-        List<ApiTrigger> list = new ArrayList<>();
-        list.add(new ApiTrigger(PushProtocol.GB_DEFAULT.getCode(), PushProtocol.GB_DEFAULT.getName()));
-        list.add(new ApiTrigger(PushProtocol.GB_2022.getCode(), PushProtocol.GB_2022.getName()));
-        list.add(new ApiTrigger(PushProtocol.SB_SH_2021.getCode(), PushProtocol.SB_SH_2021.getName()));
-        list.add(new ApiTrigger(PushProtocol.SB_SC_2021.getCode(), PushProtocol.SB_SC_2021.getName()));
-        list.add(new ApiTrigger(PushProtocol.SB_GD_2022.getCode(), PushProtocol.SB_GD_2022.getName()));
-        list.add(new ApiTrigger(PushProtocol.SB_GD_2020.getCode(), PushProtocol.SB_GD_2020.getName()));
-        list.add(new ApiTrigger(PushProtocol.SB_HN_2022.getCode(), PushProtocol.SB_HN_2022.getName()));
-        list.add(new ApiTrigger(PushProtocol.SB_WHJL_2023.getCode(), PushProtocol.SB_WHJL_2023.getName()));
-        list.add(new ApiTrigger(PushProtocol.HB_FZZY_JG_2022.getCode(), PushProtocol.HB_FZZY_JG_2022.getName()));
-        list.add(new ApiTrigger(PushProtocol.SB_SHJdJW_2023.getCode(), PushProtocol.SB_SHJdJW_2023.getName()));
-        list.add(new ApiTrigger(PushProtocol.SB_SH_2023.getCode(), PushProtocol.SB_SH_2023.getName()));
-
-        list.add(new ApiTrigger(PushProtocol.GATEWAY_SC_2023.getCode(), PushProtocol.GATEWAY_SC_2023.getName()));
-        return list;
+        return PushProtocol.listTrigger();
     }
 
     /**
@@ -205,14 +188,7 @@
      */
     @DataProvider
     public List<ApiTrigger> triggerSyncProtocol() {
-        List<ApiTrigger> list = new ArrayList<>();
-        list.add(new ApiTrigger(SyncProtocol.GB_DEFAULT.getCode(), SyncProtocol.GB_DEFAULT.getName()));
-        list.add(new ApiTrigger(SyncProtocol.FZZY_V30_GB.getCode(), SyncProtocol.FZZY_V30_GB.getName()));
-        list.add(new ApiTrigger(SyncProtocol.FZZY_V35_GB.getCode(), SyncProtocol.FZZY_V35_GB.getName()));
-        list.add(new ApiTrigger(SyncProtocol.FZZY_V40_GB.getCode(), SyncProtocol.FZZY_V40_GB.getName()));
-        list.add(new ApiTrigger(SyncProtocol.FZZY_V40_WHJL.getCode(), SyncProtocol.FZZY_V40_WHJL.getName()));
-        list.add(new ApiTrigger(SyncProtocol.FZZY_V35_SHYZ.getCode(), SyncProtocol.FZZY_V35_SHYZ.getName()));
-        return list;
+        return SyncProtocol.listTrigger();
     }
 
     /**
@@ -223,12 +199,7 @@
      */
     @DataProvider
     public List<ApiTrigger> triggerGatewayProtocol() {
-        List<ApiTrigger> list = new ArrayList<>();
-        list.add(new ApiTrigger(GatewayProtocol.GATE_HTTP.getCode(), GatewayProtocol.GATE_HTTP.getName()));
-        list.add(new ApiTrigger(GatewayProtocol.GATE_MQTT.getCode(), GatewayProtocol.GATE_MQTT.getName()));
-        list.add(new ApiTrigger(GatewayProtocol.GATE_WEBSOCKET.getCode(), GatewayProtocol.GATE_WEBSOCKET.getName()));
-        list.add(new ApiTrigger(GatewayProtocol.GATE_TEST.getName(), GatewayProtocol.GATE_TEST.getName()));
-        return list;
+        return GatewayProtocol.listTrigger();
     }
 
     /**
@@ -239,16 +210,18 @@
      */
     @DataProvider
     public List<ApiTrigger> triggerGatewayDeviceProtocol() {
-        List<ApiTrigger> list = new ArrayList<>();
-        list.add(new ApiTrigger(GatewayDeviceProtocol.GRAIN_FZZY_ZH_2023.getCode(), GatewayDeviceProtocol.GRAIN_FZZY_ZH_2023.getName()));
+        return GatewayDeviceProtocol.listTrigger();
+    }
 
-        list.add(new ApiTrigger(GatewayDeviceProtocol.DEVICE_WEIGHT_HTTP.getCode(), GatewayDeviceProtocol.DEVICE_WEIGHT_HTTP.getName()));
-        list.add(new ApiTrigger(GatewayDeviceProtocol.DEVICE_IDCARD_HTTP.getCode(), GatewayDeviceProtocol.DEVICE_IDCARD_HTTP.getName()));
-        list.add(new ApiTrigger(GatewayDeviceProtocol.DEVICE_LED_HTTP.getCode(), GatewayDeviceProtocol.DEVICE_LED_HTTP.getName()));
-        list.add(new ApiTrigger(GatewayDeviceProtocol.DEVICE_LPR_HTTP.getCode(), GatewayDeviceProtocol.DEVICE_LPR_HTTP.getName()));
-        list.add(new ApiTrigger(GatewayDeviceProtocol.DEVICE_TEST.getCode(), GatewayDeviceProtocol.DEVICE_TEST.getName()));
-
-        return list;
+    /**
+     * ${dorado.getDataProvider("apiTriggerService#triggerGatewayDeviceType").getResult()}
+     * 绯荤粺涓庣綉鍏崇洿鎺ョ殑閫氳鍗忚
+     *
+     * @return
+     */
+    @DataProvider
+    public List<ApiTrigger> triggerGatewayDeviceType() {
+        return GatewayDeviceType.listTrigger();
     }
 
 
diff --git a/src/main/java/com/fzzy/api/utils/BytesUtil.java b/src/main/java/com/fzzy/api/utils/BytesUtil.java
new file mode 100644
index 0000000..af40a1d
--- /dev/null
+++ b/src/main/java/com/fzzy/api/utils/BytesUtil.java
@@ -0,0 +1,404 @@
+package com.fzzy.api.utils;
+
+import java.math.BigInteger;
+
+public class BytesUtil {
+
+	/**
+	 * bytes杈撳嚭鍗佽繘鍒�
+	 * 
+	 * @param bytes
+	 * @return
+	 */
+	public static Integer bytesToInt(byte[] bytes) {
+		String str = "";
+		int i = 0;
+		boolean flag = true && bytes.length > 0;
+		while (flag) {
+			Byte b = bytes[i];
+			i++;
+			Integer bi = Byte.toUnsignedInt(b);
+			str += toHexString(bi);
+			if (i >= bytes.length || str.endsWith("EEEE"))
+				flag = false;
+		}
+		return Integer.parseInt(str, 16);
+	}
+
+	/**
+	 * bytes杈撳嚭鍗佸叚杩涘埗瀛楃涓�
+	 * 
+	 * @param bytes
+	 * @return
+	 */
+	public static String bytesToString(byte[] bytes) {
+		String str = "";
+		int i = 0;
+		boolean flag = true && bytes.length > 0;
+		while (flag) {
+			Byte b = bytes[i];
+			i++;
+			Integer bi = Byte.toUnsignedInt(b);
+			str += toHexString(bi);
+			if (i >= bytes.length)
+				flag = false;
+		}
+		return str;
+	}
+
+	/**
+	 * 鍗佸叚杩涘埗杞瓧鑺�
+	 * 
+	 * @param hex
+	 * @return
+	 */
+	public static byte hexToByte(Integer hex) {
+		return hex.byteValue();
+	}
+
+	/**
+	 * short杞�2瀛楄妭 宸茶皟鏁撮珮浣庝綅
+	 * 
+	 * @param number
+	 * @return
+	 */
+	public static byte[] shortToByte(short number) {
+		int temp = number;
+		byte[] b = new byte[2];
+		for (int i = 0; i < b.length; i++) {
+			b[i] = new Integer(temp & 0xff).byteValue();// 灏嗘渶浣庝綅淇濆瓨鍦ㄦ渶浣庝綅
+			temp = temp >> 8; // 鍚戝彸绉�8浣�
+		}
+		return b;
+	}
+
+	/**
+	 * 浜岃繘鍒跺瓙涓茶浆16杩涘埗瀛愪覆
+	 * 
+	 * @param bin
+	 * @return
+	 */
+	public static String binToHex(String bin) {
+		String hexStr = "";
+		int size = bin.length() / 8;
+		for (int i = 0; i < size; i++) {
+			String value = bin.substring(i * 8, (i + 1) * 8);
+			int temp = Integer.parseInt(value, 2);
+			String tempHex = Integer.toHexString(temp);
+			hexStr += tempHex;
+		}
+		return hexStr;
+	}
+
+	/**
+	 * 浜岃繘鍒惰浆16杩涘埗锛屼笉瓒�2浣嶈ˉ浣�
+	 * 
+	 * @param bin
+	 * @return
+	 */
+	public static String bin2Hex(String bin) {
+		String hexStr = "";
+		int size = bin.length() / 8;
+		for (int i = 0; i < size; i++) {
+			String value = bin.substring(i * 8, (i + 1) * 8);
+			int temp = Integer.parseInt(value, 2);
+			String tempHex = Integer.toHexString(temp);
+			if (tempHex.length() < 2) {
+				tempHex = "0" + tempHex;
+			}
+			hexStr += tempHex;
+		}
+
+		return hexStr;
+	}
+
+	/**
+	 * 杞负鍗佸叚杩涘埗涓诧紝涓嶈冻2浣嶈ˉ0
+	 * 
+	 * @param value
+	 * @return
+	 */
+	public static String toHexString(int value) {
+		String tempHex = Integer.toHexString(value);
+		if (tempHex.length() < 2) {
+			tempHex = "0" + tempHex;
+		}
+		return tempHex.toUpperCase();
+	}
+
+	public static String getTargetId(String value, boolean isTwo) {
+		String tempHex = Integer.toHexString(Integer.valueOf(value));
+		if (tempHex.length() < 2) {
+			tempHex = "0" + tempHex;
+		}
+		if (isTwo) {
+			if (tempHex.length() < 4) {
+				tempHex = "0" + tempHex;
+			}
+			if (tempHex.length() < 4) {
+				tempHex = "0" + tempHex;
+			}
+		}
+		return tempHex.toUpperCase();
+	}
+
+	/**
+	 * 鏍规嵁鏁板�艰幏鍙栧埌闀垮害涓�2瀛楄妭鐨�16杩涘埗瀛楃
+	 * 
+	 * @param value
+	 * @return
+	 */
+	public static String getHex2LenStr(int value) {
+		String tempHex = Integer.toHexString(value);
+		if (tempHex.length() < 2) {
+			tempHex = "0" + tempHex;
+		}
+		if (tempHex.length() < 4) {
+			tempHex = "0" + tempHex;
+		}
+		if (tempHex.length() < 4) {
+			tempHex = "0" + tempHex;
+		}
+		return tempHex.toUpperCase();
+	}
+
+	public static String getOrderId(int value) {
+		return getHex2LenStr(value);
+	}
+
+	/**
+	 * 灏唙alue杞负same涓浉鍚屾弧8浣嶇殑浜岃繘鍒跺瓧涓�
+	 * 
+	 * @param value
+	 * @param same
+	 * @return
+	 */
+	public static String toBinary8StringSame(int value, int same) {
+		String tempBinStr = toBinary8String(value);
+		String rsBinStr = "";
+		for (int i = 0; i < same; i++) {
+			rsBinStr += tempBinStr;
+		}
+		return rsBinStr;
+	}
+
+	/**
+	 * 涓嶈冻width涓瓧鑺傚搴︽椂锛屽墠闈㈣ˉ0鑷硍idth*8
+	 * 
+	 * @param value
+	 * @param width
+	 * @return
+	 */
+	public static String toBinary8String(int value, int width) {
+		String tempBinStr = toBinary8String(value);
+		int size = tempBinStr.length();
+		for (int i = 0; i < width; i++) {
+			int temp = (i + 1) * 8;
+			if (temp > size) {
+				tempBinStr = "00000000" + tempBinStr;
+				size = tempBinStr.length();
+			}
+		}
+		return tempBinStr;
+	}
+
+	/**
+	 * 琛ヨ冻8浣�
+	 * 
+	 * @param value
+	 * @return
+	 */
+	public static String toBinary8String(int value) {
+		String temp = Integer.toBinaryString(value);
+		if (value == 0) {
+			temp = "00000000";
+		}
+		int length = temp.length();
+		while (length < 8) {
+			temp = "0" + temp;
+			length = temp.length();
+		}
+		return temp;
+	}
+
+	public static String toEmptyBinaryWidthString(int width) {
+		String str = "";
+		for (int i = 0; i < width; i++) {
+			str += "00000000";
+		}
+		return str;
+	}
+
+	public static byte[] emptyBytes(int bytes) {
+		byte[] bys = new byte[bytes];
+		for (int i = 0; i < bytes; i++) {
+			bys[i] = emptyByte();
+		}
+		return bys;
+	}
+
+	public static byte emptyByte() {
+		Integer b0 = 0x00;
+		return b0.byteValue();
+	}
+
+	public static byte binToBytes(String bin) {
+		return Integer.valueOf(bin, 2).byteValue();
+	}
+
+	public static byte[] binaryStrToBytes(String binStr) {
+		int size = binStr.length() / 8;
+		byte[] bs = new byte[size];
+		for (int i = 0; i < size; i++) {
+			String temp = binStr.substring(i * 8, (i + 1) * 8);
+			bs[i] = Integer.valueOf(temp, 2).byteValue();
+		}
+		return bs;
+	}
+
+	/**
+	 * 鍗佸叚杩涘埗涓茶浆瀛楄妭鏁扮粍
+	 * 
+	 * @param hexStr
+	 * @return
+	 */
+	public static byte[] hexStrToBytes(String hexStr) {
+		int size = hexStr.length() / 2;
+		byte[] bytes = new byte[size];
+		for (int i = 0; i < size; i++) {
+			String tmp = hexStr.substring(i * 2, (i + 1) * 2);
+			Integer tmpHex = Integer.parseInt(tmp, 16);
+			bytes[i] = tmpHex.byteValue();
+		}
+		return bytes;
+	}
+
+	/**
+	 * 涓ゅ瓧鑺傞珮浣庝綅瑁呮崲
+	 *
+	 * @param b
+	 * @return
+	 */
+	public static byte[] hexHeightLow(byte[] b) {
+		byte[] b2 = new byte[2];
+		// 杞崲楂樹綆浣�
+		b2[0] = b[1];
+		b2[1] = b[0];
+		return b2;
+	}
+
+	/**
+	 * 16杩涘埗杞崲涓�10杩涘埗
+	 * 
+	 * @param strHex
+	 * @return
+	 */
+	public static int hexToInt(String strHex) {
+		short s = (short) (Integer.valueOf(strHex, 16) & 0xffff);
+		return s;
+	}
+
+	/**
+	 * 16杩涘埗杞崲涓�10杩涘埗
+	 * 
+	 * @param strHex
+	 * @return
+	 */
+	public static int hexToBigInt(String strHex) {
+		BigInteger bigint = new BigInteger(strHex, 16);
+		return bigint.intValue();
+	}
+
+	/**
+	 * int杞�16杩涘埗瀛楃涓� 2浣� 00 00
+	 *
+	 * @param num
+	 * @return
+	 */
+	public static String intToHexStr(int num) {
+		// 闇�瑕佷娇鐢�2瀛楄妭琛ㄧずb
+		return String.format("%04x", num).toUpperCase();
+	}
+
+	// 璁$畻16杩涘埗瀵瑰簲鐨勬暟鍊�
+	public static int GetHex(char ch) throws Exception {
+		if (ch >= '0' && ch <= '9')
+			return (int) (ch - '0');
+		if (ch >= 'a' && ch <= 'f')
+			return (int) (ch - 'a' + 10);
+		if (ch >= 'A' && ch <= 'F')
+			return (int) (ch - 'A' + 10);
+		throw new Exception("error param");
+	}
+
+	// 璁$畻骞�
+	public static int GetPower(int nValue, int nCount) throws Exception {
+		if (nCount < 0)
+			throw new Exception("nCount can't small than 1!");
+		if (nCount == 0)
+			return 1;
+		int nSum = 1;
+		for (int i = 0; i < nCount; ++i) {
+			nSum = nSum * nValue;
+		}
+		return nSum;
+	}
+
+	public static void main(String[] args) {
+		
+		double d1 = hexToBigInt("000906EB")/100.0;
+		double d2 = hexToBigInt("0004F6E6")/100.0;
+		
+		System.out.println(d1);
+		System.out.println(d2);
+		
+		System.out.println(d1 + d2);
+		
+	}
+
+	/**
+	 * 16杩涘埗瀛楃涓� 楂樹綆鎹綅
+	 *
+	 * @param info
+	 * @return
+	 */
+	public static String tran_LH(String info) {
+		return info.substring(2) + info.substring(0, 2);
+	}
+
+	/**
+	 * 16杩涘埗瀛楃涓� 楂樹綆鎹綅 8涓瓧绗�
+	 *
+	 * @param info
+	 * @return
+	 */
+	public static String tran_LH8(String info) {
+		return tran_LH(info.substring(4)) + tran_LH(info.substring(0, 4));
+	}
+
+	/**
+	 * 灏� 4瀛楄妭鐨�16杩涘埗瀛楃涓诧紝杞崲涓�32浣嶅甫绗﹀彿鐨勫崄杩涘埗娴偣鍨�
+	 * 
+	 * 42c60000 -> 99.00
+	 * 
+	 * @param str
+	 *            4瀛楄妭 16杩涘埗瀛楃
+	 * @return
+	 */
+	public static float hexToFloat(String str) {
+		return Float.intBitsToFloat(new BigInteger(str, 16).intValue());
+	}
+
+	/**
+	 * 灏嗗甫绗﹀彿鐨�32浣嶆诞鐐规暟瑁呮崲涓�16杩涘埗
+	 * 
+	 * 99.00 -> 42c60000
+	 * 
+	 * 
+	 * @param value
+	 * @return
+	 */
+	public static String folatToHexString(Float value) {
+		return Integer.toHexString(Float.floatToIntBits(value));
+	}
+}
diff --git a/src/main/java/com/fzzy/api/utils/ContextUtil.java b/src/main/java/com/fzzy/api/utils/ContextUtil.java
index a88a81c..cc8cafe 100644
--- a/src/main/java/com/fzzy/api/utils/ContextUtil.java
+++ b/src/main/java/com/fzzy/api/utils/ContextUtil.java
@@ -136,4 +136,15 @@
             return null;
         }
     }
+
+    /**
+     * 鐢熸垚TCP杩炴帴鐨凨EY
+     *
+     * @param ip
+     * @param port
+     * @return
+     */
+    public static String getServerKey(String ip, Integer port) {
+        return ip + ":" + port;
+    }
 }
diff --git a/src/main/java/com/fzzy/api/utils/SpringUtil.java b/src/main/java/com/fzzy/api/utils/SpringUtil.java
new file mode 100644
index 0000000..f2c8893
--- /dev/null
+++ b/src/main/java/com/fzzy/api/utils/SpringUtil.java
@@ -0,0 +1,58 @@
+package com.fzzy.api.utils;
+
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SpringUtil implements ApplicationContextAware {
+
+	private static ApplicationContext applicationContext;
+
+	@Override
+	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+		if (SpringUtil.applicationContext == null) {
+			SpringUtil.applicationContext = applicationContext;
+		}
+	}
+
+	/**
+	 * 鑾峰彇applicationContext
+	 * @return
+	 */
+	public static ApplicationContext getApplicationContext() {
+		return applicationContext;
+	}
+
+	/**
+	 * 閫氳繃name鑾峰彇 Bean.
+	 * @param name
+	 * @return
+	 */
+	public static Object getBean(String name) {
+		return getApplicationContext().getBean(name);
+	}
+
+	/**
+	 * 閫氳繃class鑾峰彇Bean.
+	 * @param clazz
+	 * @param <T>
+	 * @return
+	 */
+	public static <T> T getBean(Class<T> clazz) {
+		return getApplicationContext().getBean(clazz);
+	}
+
+	/**
+	 * 閫氳繃name,浠ュ強Clazz杩斿洖鎸囧畾鐨凚ean
+	 * @param name
+	 * @param clazz
+	 * @param <T>
+	 * @return
+	 */
+	public static <T> T getBean(String name, Class<T> clazz) {
+		return getApplicationContext().getBean(name, clazz);
+	}
+
+}
diff --git a/src/main/java/com/fzzy/gateway/GatewayRunner.java b/src/main/java/com/fzzy/gateway/GatewayRunner.java
index 9dfc519..9597fee 100644
--- a/src/main/java/com/fzzy/gateway/GatewayRunner.java
+++ b/src/main/java/com/fzzy/gateway/GatewayRunner.java
@@ -27,7 +27,6 @@
 
         //鍥涘窛缃戝叧鎺ュ彛锛屽惎鍔ㄩ粯璁よ幏鍙栭壌鏉冧俊鎭紝闀挎湡鏈夋晥
         apiInitService.init();
-
     }
 
 }
diff --git a/src/main/java/com/fzzy/gateway/GatewayUtils.java b/src/main/java/com/fzzy/gateway/GatewayUtils.java
new file mode 100644
index 0000000..655af00
--- /dev/null
+++ b/src/main/java/com/fzzy/gateway/GatewayUtils.java
@@ -0,0 +1,66 @@
+package com.fzzy.gateway;
+
+import com.fzzy.gateway.entity.GatewayDevice;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 甯搁噺
+ */
+public class GatewayUtils {
+
+
+
+    /**
+     * 璁惧鍦ㄧ嚎鏍囪锛岄拡瀵筗EBSocket璇锋眰锛屾帶鍒惰澶囨槸鍚﹀湪绾匡紝key = deviceId锛孷alue=Y/N
+     */
+    public static Map<String, String> contextOnlineMap = new HashMap<>();
+
+
+    /**
+     * 璁惧缂撳瓨
+     */
+    public static Map<String, GatewayDevice> cacheMapDeviceId = new HashMap<>();
+
+    /**
+     * 璁惧缂撳瓨
+     */
+    public static Map<String, GatewayDevice> cacheMapDeviceSn = new HashMap<>();
+
+
+    public static void add2Cache(GatewayDevice device) {
+        cacheMapDeviceId.put(device.getDeviceId(), device);
+        cacheMapDeviceSn.put(device.getDeviceSn(), device);
+    }
+
+    public static GatewayDevice getCacheByDeviceId(String deviceId) {
+        return cacheMapDeviceId.get(deviceId);
+    }
+
+    public static GatewayDevice getCacheByDeviceSn(String deviceSn) {
+        return cacheMapDeviceSn.get(deviceSn);
+    }
+
+
+    public static void removeCache(GatewayDevice data) {
+        cacheMapDeviceId.remove(data.getDeviceId());
+        cacheMapDeviceSn.remove(data.getDeviceSn());
+    }
+
+
+
+    public static void updateOnline(String deviceId) {
+        contextOnlineMap.put(deviceId, "Y");
+    }
+
+    public static void updateOffOnline(String deviceId) {
+        contextOnlineMap.put(deviceId, "N");
+    }
+
+    public static boolean isOnline(String deviceId) {
+        String value = contextOnlineMap.get(deviceId);
+        if (null == value || "N".equals(value)) return false;
+        return true;
+    }
+}
diff --git a/src/main/java/com/fzzy/gateway/api/DeviceReportService.java b/src/main/java/com/fzzy/gateway/api/DeviceReportService.java
new file mode 100644
index 0000000..0481757
--- /dev/null
+++ b/src/main/java/com/fzzy/gateway/api/DeviceReportService.java
@@ -0,0 +1,24 @@
+package com.fzzy.gateway.api;
+
+import com.fzzy.gateway.entity.GatewayDevice;
+
+
+public interface DeviceReportService {
+
+    /**
+     * 鍗忚瀹氫箟
+     *
+     * @return
+     */
+    String getProvinceProtocol();
+
+
+    /**
+     * 閫氳繃璁惧搴忓垪鍙疯繑鍥炵粨鏋滀俊鎭�
+     *
+     * @param weigh
+     * @param device 璁惧搴忓垪鍙�
+     */
+    String report2GatewayBySn(double weigh, GatewayDevice device);
+
+}
diff --git a/src/main/java/com/fzzy/gateway/api/GatewayRemoteManager.java b/src/main/java/com/fzzy/gateway/api/GatewayRemoteManager.java
index 6df640e..b90a996 100644
--- a/src/main/java/com/fzzy/gateway/api/GatewayRemoteManager.java
+++ b/src/main/java/com/fzzy/gateway/api/GatewayRemoteManager.java
@@ -17,6 +17,8 @@
 
     public static Map<String, GatewayRemoteService> remoteMap = new HashMap<>();
 
+    public static Map<String, DeviceReportService> reportMap = new HashMap<>();
+
     public static Map<String, GatewaySyncGranService> syncGrain = new HashMap<>();
 
     public static Map<String, GatewaySyncIdCardService> syncIdCard = new HashMap<>();
@@ -58,6 +60,11 @@
         Map<String, GatewaySyncWeightService> serviceMap6 = applicationContext.getBeansOfType(GatewaySyncWeightService.class);
         for (String key : serviceMap6.keySet()) {
             syncWeight.put(serviceMap6.get(key).getWeightProtocol(), serviceMap6.get(key));
+        }
+
+        Map<String, DeviceReportService> serviceMap7 = applicationContext.getBeansOfType(DeviceReportService.class);
+        for (String key : serviceMap7.keySet()) {
+            reportMap.put(serviceMap7.get(key).getProvinceProtocol(), serviceMap7.get(key));
         }
     }
 
@@ -123,4 +130,14 @@
         return syncWeight.get(protocol);
     }
 
+    /**
+     * 鏍规嵁瀹炵幇鍗忚鑾峰彇褰撳墠瀹炵幇鏂规硶
+     *
+     * @param protocol
+     * @return
+     */
+    public DeviceReportService getDeviceReportService(String protocol) {
+        return reportMap.get(protocol);
+    }
+
 }
diff --git a/src/main/java/com/fzzy/gateway/api/GatewaySyncWeightService.java b/src/main/java/com/fzzy/gateway/api/GatewaySyncWeightService.java
index 2a59985..061a83c 100644
--- a/src/main/java/com/fzzy/gateway/api/GatewaySyncWeightService.java
+++ b/src/main/java/com/fzzy/gateway/api/GatewaySyncWeightService.java
@@ -22,5 +22,4 @@
      * @return
      */
     public WeightInfo syncWeightInfo(SyncReqData reqData);
-
 }
diff --git a/src/main/java/com/fzzy/gateway/entity/GatewayDevice.java b/src/main/java/com/fzzy/gateway/entity/GatewayDevice.java
index f10ec07..1e9c529 100644
--- a/src/main/java/com/fzzy/gateway/entity/GatewayDevice.java
+++ b/src/main/java/com/fzzy/gateway/entity/GatewayDevice.java
@@ -1,9 +1,11 @@
 package com.fzzy.gateway.entity;
 
 import com.bstek.dorado.annotation.PropertyDef;
+
 import lombok.Data;
 
 import javax.persistence.*;
+
 import java.io.Serializable;
 
 /**
@@ -27,7 +29,7 @@
     @PropertyDef(label = "璁惧搴忓垪鍙�")
     private String deviceSn;
 
-    @Column(name = "DEVICE_ID_", length = 100)
+    @Column(name = "DEVICE_ID_", length = 50)
     @PropertyDef(label = "璁惧ID")
     private String deviceId;
 
@@ -54,7 +56,15 @@
     @Column(name = "PORT_")
     @PropertyDef(label = "閫氳绔彛")
     private Integer port;
-    
+
+    @PropertyDef(label = "璁惧鐢ㄦ埛鍚�")
+    @Column(name = "username", length = 50)
+    private String userName;
+
+    @PropertyDef(label = "璁惧瀵嗙爜")
+    @Column(name = "password", length = 50)
+    private String password;
+
     @Column(name = "RTSP_", length = 100)
     @PropertyDef(label = "瑙嗛RTSP", description = "鐢ㄤ簬灞�鍩熺綉鍐呮姄鎷嶉厤缃�")
     private String rtsp;
@@ -67,6 +77,10 @@
     @Column(name = "PUSH_PROTOCOL_", length = 20)
     private String pushProtocol;
 
+    @PropertyDef(label = "鐪佸钩鍙板崗璁�")
+    @Column(name = "PROVINCE_PROTOCOL_", length = 20)
+    private String provinceProtocol;
+
     @PropertyDef(label = "鍚屾鍗忚")
     @Column(name = "SYNC_PROTOCOL_", length = 20)
     private String syncProtocol;
diff --git a/src/main/java/com/fzzy/gateway/hx2023/ScConstant.java b/src/main/java/com/fzzy/gateway/hx2023/ScConstant.java
index 1623d17..7ca1516 100644
--- a/src/main/java/com/fzzy/gateway/hx2023/ScConstant.java
+++ b/src/main/java/com/fzzy/gateway/hx2023/ScConstant.java
@@ -1,8 +1,5 @@
 package com.fzzy.gateway.hx2023;
 
-import java.util.HashMap;
-import java.util.Map;
-
 /**
  * 甯搁噺
  */
@@ -10,26 +7,6 @@
 
     public static String API_URL_AUTH = "${auth}/authorize/login";
 
-
-    /**
-     * 璁惧鍦ㄧ嚎鏍囪锛岄拡瀵筗EBSocket璇锋眰锛屾帶鍒惰澶囨槸鍚﹀湪绾匡紝key = deviceId锛孷alue=Y/N
-     */
-    public static Map<String, String> contextOnlineMap = new HashMap<>();
-
-
-    public static void updateOnline(String deviceId) {
-        contextOnlineMap.put(deviceId, "Y");
-    }
-
-    public static void updateOffOnline(String deviceId) {
-        contextOnlineMap.put(deviceId, "N");
-    }
-
-    public static boolean isOnline(String deviceId) {
-        String value = contextOnlineMap.get(deviceId);
-        if (null == value || "N".equals(value)) return false;
-        return true;
-    }
 
 
 }
diff --git a/src/main/java/com/fzzy/gateway/hx2023/data/WebSocketPacketHeader.java b/src/main/java/com/fzzy/gateway/hx2023/data/WebSocketPacketHeader.java
index 58eddd0..00759bb 100644
--- a/src/main/java/com/fzzy/gateway/hx2023/data/WebSocketPacketHeader.java
+++ b/src/main/java/com/fzzy/gateway/hx2023/data/WebSocketPacketHeader.java
@@ -8,13 +8,11 @@
 
     private String productId;
 
-    private String keepOnlineTimeoutSeconds;
+    private int keepOnlineTimeoutSeconds = 600 ;
 
-    private String keepOnline;
+    private boolean keepOnline = true;
 
     private String deviceName;
 
     private String orgId;
-
-
 }
diff --git a/src/main/java/com/fzzy/gateway/hx2023/service/DeviceReportServiceImpl.java b/src/main/java/com/fzzy/gateway/hx2023/service/DeviceReportServiceImpl.java
new file mode 100644
index 0000000..7f76daa
--- /dev/null
+++ b/src/main/java/com/fzzy/gateway/hx2023/service/DeviceReportServiceImpl.java
@@ -0,0 +1,56 @@
+package com.fzzy.gateway.hx2023.service;
+
+import com.fzzy.api.data.GatewayProtocol;
+import com.fzzy.api.data.PushProtocol;
+import com.fzzy.gateway.api.DeviceReportService;
+import com.fzzy.gateway.entity.GatewayDevice;
+import com.fzzy.gateway.hx2023.data.WebSocketPacket;
+import com.fzzy.gateway.hx2023.data.WebSocketPacketHeader;
+import com.fzzy.gateway.hx2023.websocket.WebSocketDeviceReport;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+@Slf4j
+@Component
+public class DeviceReportServiceImpl implements DeviceReportService {
+
+
+    @Resource
+    private WebSocketDeviceReport webSocketDeviceReport;
+
+    @Override
+    public String getProvinceProtocol() {
+        return PushProtocol.GATEWAY_SC_2023.getCode();
+    }
+
+    @Override
+    public String report2GatewayBySn(double weigh, GatewayDevice device) {
+
+        if (null == device) {
+            log.error("-----------娌℃湁鑾峰彇鍒拌澶囬厤缃俊鎭�-----");
+            return "ERROR:娌℃湁鑾峰彇鍒拌澶囬厤缃俊鎭�";
+        }
+
+        //浣跨敤WEBSOCKET杩斿洖
+        if (GatewayProtocol.GATE_WEBSOCKET.equals(device.getPushProtocol())) {
+
+            WebSocketPacket packet = new WebSocketPacket();
+
+            WebSocketPacketHeader header = new WebSocketPacketHeader();
+            header.setDeviceName(device.getDeviceName());
+            packet.setHeaders(header);
+            packet.setMessageType("");
+            packet.setDeviceId(device.getDeviceId());
+            packet.setProperties(null);
+            packet.setTimestamp(System.currentTimeMillis());
+
+
+            webSocketDeviceReport.sendByPacket(packet);
+
+        }
+
+        return null;
+    }
+}
diff --git a/src/main/java/com/fzzy/gateway/hx2023/service/HxGatewaySyncWeightImpl1.java b/src/main/java/com/fzzy/gateway/hx2023/service/HxGatewaySyncWeightImpl1.java
index 970be79..c615730 100644
--- a/src/main/java/com/fzzy/gateway/hx2023/service/HxGatewaySyncWeightImpl1.java
+++ b/src/main/java/com/fzzy/gateway/hx2023/service/HxGatewaySyncWeightImpl1.java
@@ -1,14 +1,18 @@
 package com.fzzy.gateway.hx2023.service;
 
 import com.fzzy.api.data.GatewayDeviceProtocol;
-import com.fzzy.gateway.api.GatewaySyncLprService;
+import com.fzzy.api.data.GatewayProtocol;
+import com.fzzy.api.utils.ContextUtil;
 import com.fzzy.gateway.api.GatewaySyncWeightService;
-import com.fzzy.gateway.hx2023.data.LprData;
-import com.fzzy.gateway.hx2023.data.SyncReqData;
-import com.fzzy.gateway.hx2023.data.WeightInfo;
+import com.fzzy.gateway.entity.GatewayDevice;
+import com.fzzy.gateway.hx2023.data.*;
+import com.fzzy.gateway.hx2023.websocket.WebSocketDeviceReport;
+import com.fzzy.gateway.service.GatewayDeviceService;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
 
 /**
  * 缃戝叧涓庤澶囦箣闂寸殑閫氳
@@ -19,6 +23,12 @@
 public class HxGatewaySyncWeightImpl1 implements GatewaySyncWeightService {
 
 
+    @Resource
+    private GatewayDeviceService deviceService;
+    @Resource
+    private WebSocketDeviceReport webSocketDeviceReport;
+
+
     @Override
     public String getWeightProtocol() {
         return GatewayDeviceProtocol.DEVICE_WEIGHT_TCP_YH.getCode();
@@ -27,6 +37,7 @@
     @Override
     public WeightInfo syncWeightInfo(SyncReqData reqData) {
 
+        //doNothing
         return null;
     }
 
diff --git a/src/main/java/com/fzzy/gateway/hx2023/websocket/WebSocketDeviceLed.java b/src/main/java/com/fzzy/gateway/hx2023/websocket/WebSocketDeviceLed.java
index 7662a8a..a8d27d6 100644
--- a/src/main/java/com/fzzy/gateway/hx2023/websocket/WebSocketDeviceLed.java
+++ b/src/main/java/com/fzzy/gateway/hx2023/websocket/WebSocketDeviceLed.java
@@ -1,7 +1,7 @@
 package com.fzzy.gateway.hx2023.websocket;
 
 import com.alibaba.fastjson.JSONObject;
-import com.fzzy.gateway.hx2023.ScConstant;
+import com.fzzy.gateway.GatewayUtils;
 import com.fzzy.gateway.hx2023.data.WebSocketPacket;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
@@ -42,7 +42,7 @@
         sessionPool.put(key, session);
         sessionIds.put(session.getId(), key);
 
-        ScConstant.updateOnline(deviceId);
+        GatewayUtils.updateOnline(deviceId);
 
         log.info("new webSocket,clientId={}", key);
     }
@@ -57,7 +57,7 @@
 
         String deviceId = key.substring(0, key.indexOf("-"));
 
-        ScConstant.updateOffOnline(deviceId);
+        GatewayUtils.updateOffOnline(deviceId);
 
         log.info("WebSocket杩炴帴鍏抽棴={}", key);
 
@@ -84,7 +84,7 @@
 
         String deviceId = key.substring(0, key.indexOf("-"));
 
-        ScConstant.updateOffOnline(deviceId);
+        GatewayUtils.updateOffOnline(deviceId);
 
         sessionPool.remove(key);
         sessionIds.remove(session.getId());
diff --git a/src/main/java/com/fzzy/gateway/hx2023/websocket/WebSocketDevice.java b/src/main/java/com/fzzy/gateway/hx2023/websocket/WebSocketDeviceReport.java
similarity index 83%
rename from src/main/java/com/fzzy/gateway/hx2023/websocket/WebSocketDevice.java
rename to src/main/java/com/fzzy/gateway/hx2023/websocket/WebSocketDeviceReport.java
index dce5180..b886a61 100644
--- a/src/main/java/com/fzzy/gateway/hx2023/websocket/WebSocketDevice.java
+++ b/src/main/java/com/fzzy/gateway/hx2023/websocket/WebSocketDeviceReport.java
@@ -1,6 +1,7 @@
 package com.fzzy.gateway.hx2023.websocket;
 
 import com.alibaba.fastjson.JSONObject;
+import com.fzzy.gateway.GatewayUtils;
 import com.fzzy.gateway.hx2023.ScConstant;
 import com.fzzy.gateway.hx2023.data.WebSocketPacket;
 import lombok.extern.slf4j.Slf4j;
@@ -19,7 +20,7 @@
 @Slf4j
 @Component
 @ServerEndpoint(value = "/device/{productId}/{deviceId}/message/property/report")
-public class WebSocketDevice {
+public class WebSocketDeviceReport {
 
     private static Map<String, Session> sessionPool = new ConcurrentHashMap<>();
     private static Map<String, String> sessionIds = new ConcurrentHashMap<>();
@@ -42,7 +43,7 @@
         sessionPool.put(key, session);
         sessionIds.put(session.getId(), key);
 
-        ScConstant.updateOnline(deviceId);
+        GatewayUtils.updateOnline(deviceId);
 
         log.info("new webSocket,clientId={}", key);
     }
@@ -52,9 +53,9 @@
 
         String key = sessionIds.get(session.getId());
 
-        String deviceId = key.substring(0, key.indexOf("-"));
+        String deviceId = key.substring(key.indexOf("-"));
 
-        ScConstant.updateOffOnline(deviceId);
+        GatewayUtils.updateOffOnline(deviceId);
 
         sessionPool.remove(key);
         sessionIds.remove(session.getId());
@@ -81,9 +82,9 @@
 
         String key = sessionIds.get(session.getId());
 
-        String deviceId = key.substring(0, key.indexOf("-"));
+        String deviceId = key.substring(key.indexOf("-"));
 
-        ScConstant.updateOffOnline(deviceId);
+        GatewayUtils.updateOffOnline(deviceId);
 
         sessionPool.remove(key);
         sessionIds.remove(session.getId());
@@ -96,17 +97,24 @@
      *
      * @param packet
      */
-    public static void sendByPacket(WebSocketPacket packet) {
+    public void sendByPacket(WebSocketPacket packet) {
         if (StringUtils.isEmpty(packet.getDeviceId())) {
             log.error("WebSocket淇℃伅鎺ㄩ�佸け璐ワ紝璁惧缂栫爜涓虹┖銆�");
             return;
         }
 
+
         String tag = packet.getDeviceId();
 
         // 閬嶅巻鎺ㄩ��
         Session session;
+        String productId;
         for (String key : sessionPool.keySet()) {
+
+            productId = key.substring(0, key.indexOf("-"));
+
+            packet.getHeaders().setProductId(productId);
+
             if (key.indexOf(tag) != -1) {
                 session = sessionPool.get(key);
                 session.getAsyncRemote().sendText(
diff --git a/src/main/java/com/fzzy/gateway/service/GatewayDeviceService.java b/src/main/java/com/fzzy/gateway/service/GatewayDeviceService.java
index 5a738b1..fd196ab 100644
--- a/src/main/java/com/fzzy/gateway/service/GatewayDeviceService.java
+++ b/src/main/java/com/fzzy/gateway/service/GatewayDeviceService.java
@@ -6,22 +6,22 @@
 import com.fzzy.api.utils.ContextUtil;
 import com.fzzy.api.utils.RedisConst;
 import com.fzzy.api.utils.RedisUtil;
+import com.fzzy.gateway.GatewayUtils;
 import com.fzzy.gateway.entity.GatewayDevice;
 import com.fzzy.gateway.service.repository.GatewayDeviceRep;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 @Component
 public class GatewayDeviceService {
 
     @Resource
     private GatewayDeviceRep gatewayDeviceRep;
-    @Resource
-    private RedisUtil redisUtil;
-
 
     /**
      * gatewayDeviceService#listAll
@@ -30,10 +30,7 @@
      */
     @DataProvider
     public List<GatewayDevice> listAll() {
-
-        List<GatewayDevice> list = gatewayDeviceRep.findAll();
-
-        return list;
+        return gatewayDeviceRep.findAll();
     }
 
     /**
@@ -48,6 +45,15 @@
 
         if (null == data.getId()) {
             data.setId(ContextUtil.getUUID());
+        }
+
+
+        if (null == data.getDeviceSn()) {
+            if (null != entity.getIp()) {
+                data.setDeviceSn(entity.getIp());
+            } else {
+                data.setDeviceSn(data.getDeviceId());
+            }
         }
 
         gatewayDeviceRep.save(data);
@@ -66,6 +72,8 @@
         BeanUtils.copyProperties(data, data2);
         gatewayDeviceRep.delete(data2);
 
+        GatewayUtils.removeCache(data2);
+
         flushCache();
         return null;
     }
@@ -78,23 +86,8 @@
     public void flushCache() {
         List<GatewayDevice> list = listAll();
         if (null == list || list.isEmpty()) return;
-        String key;
         for (GatewayDevice device : list) {
-            key = RedisConst.buildKey(RedisConst.KYE_GATE_DEVICE, device.getDeviceId());
-            redisUtil.set(key, device);
+            GatewayUtils.add2Cache(device);
         }
     }
-
-    /**
-     * 缂撳瓨鑾峰彇璁惧淇℃伅
-     *
-     * @param deviceId
-     * @return
-     */
-    public GatewayDevice getCacheDevice(String deviceId) {
-        String key = RedisConst.buildKey(RedisConst.KYE_GATE_DEVICE, deviceId);
-        return (GatewayDevice) redisUtil.get(key);
-    }
-
-
 }
diff --git a/src/main/java/com/fzzy/gateway/view/GatewayConf.view.xml b/src/main/java/com/fzzy/gateway/view/GatewayConf.view.xml
index 9c6076c..131ebaa 100644
--- a/src/main/java/com/fzzy/gateway/view/GatewayConf.view.xml
+++ b/src/main/java/com/fzzy/gateway/view/GatewayConf.view.xml
@@ -16,31 +16,39 @@
         <Property name="required">true</Property>
       </PropertyDef>
       <PropertyDef name="appId">
-        <Property/>
+        <Property></Property>
         <Property name="label">appId</Property>
       </PropertyDef>
       <PropertyDef name="gatewayId">
-        <Property/>
+        <Property></Property>
         <Property name="label">缃戝叧ID</Property>
       </PropertyDef>
-      <PropertyDef name="gatewayIp">
+      <PropertyDef name="gatewayUsername">
         <Property/>
+        <Property name="label">缃戝叧鐢ㄦ埛鍚�</Property>
+      </PropertyDef>
+      <PropertyDef name="gatewayPassword">
+        <Property/>
+        <Property name="label">缃戝叧瀵嗙爜</Property>
+      </PropertyDef>
+      <PropertyDef name="gatewayIp">
+        <Property></Property>
         <Property name="label">缃戝叧IP</Property>
       </PropertyDef>
       <PropertyDef name="gatewayMac">
-        <Property/>
+        <Property></Property>
         <Property name="label">缃戝叧Mac</Property>
       </PropertyDef>
       <PropertyDef name="gatewayCPU">
-        <Property/>
+        <Property></Property>
         <Property name="label">缃戝叧CPU</Property>
       </PropertyDef>
       <PropertyDef name="gatewayMem">
-        <Property/>
+        <Property></Property>
         <Property name="label">缃戝叧鍐呭瓨</Property>
       </PropertyDef>
       <PropertyDef name="gatewayHardDisk">
-        <Property/>
+        <Property></Property>
         <Property name="label">缃戝叧纭洏</Property>
       </PropertyDef>
       <PropertyDef name="userName">
@@ -216,6 +224,17 @@
               <Editor/>
             </AutoFormElement>
             <AutoFormElement>
+              <Property name="name">gatewayUsername</Property>
+              <Property name="property">gatewayUsername</Property>
+              <Editor/>
+            </AutoFormElement>
+            <AutoFormElement>
+              <Property name="name">gatewayPassword</Property>
+              <Property name="property">gatewayPassword</Property>
+              <Property name="editorType">PasswordEditor</Property>
+              <Editor/>
+            </AutoFormElement>
+            <AutoFormElement>
               <Property name="name">gatewayIp</Property>
               <Property name="property">gatewayIp</Property>
               <Editor/>
diff --git a/src/main/java/com/fzzy/gateway/view/GatewayDevice.view.xml b/src/main/java/com/fzzy/gateway/view/GatewayDevice.view.xml
index 617451d..1d47410 100644
--- a/src/main/java/com/fzzy/gateway/view/GatewayDevice.view.xml
+++ b/src/main/java/com/fzzy/gateway/view/GatewayDevice.view.xml
@@ -22,14 +22,15 @@
       <PropertyDef name="type">
         <Property></Property>
         <Property name="label">璁惧绫诲瀷</Property>
+        <Property name="mapping">
+          <Property name="keyProperty">code</Property>
+          <Property name="valueProperty">name</Property>
+          <Property name="mapValues">${dorado.getDataProvider(&quot;apiTriggerService#triggerGatewayDeviceType&quot;).getResult()}</Property>
+        </Property>
       </PropertyDef>
       <PropertyDef name="depotId">
         <Property></Property>
-        <Property name="label">鎵�灞炰粨搴�</Property>
-      </PropertyDef>
-      <PropertyDef name="depotName">
-        <Property></Property>
-        <Property name="label">鎵�灞炰粨搴�</Property>
+        <Property name="label">鎵�灞炰粨搴撶紪鐮�</Property>
       </PropertyDef>
       <PropertyDef name="ip">
         <Property></Property>
@@ -43,6 +44,16 @@
         <Property></Property>
         <Property name="label">瑙嗛RTSP</Property>
       </PropertyDef>
+      <PropertyDef name="provinceProtocol">
+        <Property/>
+        <Property name="label">鐪佸钩鍙板崗璁�</Property>
+        <Property name="mapping">
+          <Property name="mapValues">${dorado.getDataProvider(&quot;apiTriggerService#triggerPushProtocol&quot;).getResult()}</Property>
+          <Property name="keyProperty">code</Property>
+          <Property name="valueProperty">name</Property>
+        </Property>
+        <Property name="required">true</Property>
+      </PropertyDef>
       <PropertyDef name="pushProtocol">
         <Property></Property>
         <Property name="label">绯荤粺缃戝叧閫氳鍗忚</Property>
@@ -55,7 +66,7 @@
       </PropertyDef>
       <PropertyDef name="syncProtocol">
         <Property></Property>
-        <Property name="label">缃戝叧涓庤澶囬�氳鍗忚</Property>
+        <Property name="label">缃戝叧璁惧閫氳鍗忚</Property>
         <Property name="mapping">
           <Property name="keyProperty">code</Property>
           <Property name="valueProperty">name</Property>
@@ -76,8 +87,24 @@
         <Property name="label">HTTP鍦板潃</Property>
       </PropertyDef>
       <PropertyDef name="deviceSn">
-        <Property/>
+        <Property></Property>
         <Property name="label">璁惧搴忓垪鍙�</Property>
+      </PropertyDef>
+      <PropertyDef name="serPort">
+        <Property name="dataType">int</Property>
+        <Property name="label">TCP鏈嶅姟绔彛</Property>
+      </PropertyDef>
+      <PropertyDef name="userName">
+        <Property/>
+        <Property name="label">璁惧鐢ㄦ埛鍚�</Property>
+      </PropertyDef>
+      <PropertyDef name="password">
+        <Property/>
+        <Property name="label">璁惧瀵嗙爜</Property>
+      </PropertyDef>
+      <PropertyDef name="depotName">
+        <Property/>
+        <Property name="label">鎵�灞炰粨搴�</Property>
       </PropertyDef>
     </DataType>
   </Model>
@@ -150,9 +177,6 @@
       <DataColumn name="type">
         <Property name="property">type</Property>
       </DataColumn>
-      <DataColumn name="depotName">
-        <Property name="property">depotName</Property>
-      </DataColumn>
       <DataColumn name="syncProtocol">
         <Property name="property">syncProtocol</Property>
       </DataColumn>
@@ -192,13 +216,18 @@
           <AutoForm>
             <Property name="dataSet">dsMain</Property>
             <Property name="cols">*,*,*</Property>
-            <Property name="labelWidth">100</Property>
+            <Property name="labelWidth">125</Property>
             <Property name="labelAlign">right</Property>
             <Property name="labelSeparator">锛�</Property>
             <Property name="labelPosition">left</Property>
-            <AutoFormElement>
+            <AutoFormElement layoutConstraint="colSpan:2">
               <Property name="name">deviceId</Property>
               <Property name="property">deviceId</Property>
+              <Editor/>
+            </AutoFormElement>
+            <AutoFormElement>
+              <Property name="name">deviceSn</Property>
+              <Property name="property">deviceSn</Property>
               <Editor/>
             </AutoFormElement>
             <AutoFormElement>
@@ -209,6 +238,11 @@
             <AutoFormElement>
               <Property name="name">type</Property>
               <Property name="property">type</Property>
+              <Editor/>
+            </AutoFormElement>
+            <AutoFormElement>
+              <Property name="name">orgId</Property>
+              <Property name="property">orgId</Property>
               <Editor/>
             </AutoFormElement>
             <AutoFormElement>
@@ -227,18 +261,32 @@
               <Editor/>
             </AutoFormElement>
             <AutoFormElement>
+              <Property name="name">userName</Property>
+              <Property name="property">userName</Property>
+              <Editor/>
+            </AutoFormElement>
+            <AutoFormElement>
+              <Property name="name">password</Property>
+              <Property name="property">password</Property>
+              <Editor/>
+            </AutoFormElement>
+            <Control/>
+            <AutoFormElement>
               <Property name="name">pushProtocol</Property>
               <Property name="property">pushProtocol</Property>
+              <Property name="labelWidth">150</Property>
               <Editor/>
             </AutoFormElement>
             <AutoFormElement>
               <Property name="name">syncProtocol</Property>
               <Property name="property">syncProtocol</Property>
+              <Property name="labelWidth">150</Property>
               <Editor/>
             </AutoFormElement>
             <AutoFormElement>
-              <Property name="name">orgId</Property>
-              <Property name="property">orgId</Property>
+              <Property name="name">serPort</Property>
+              <Property name="property">serPort</Property>
+              <Property name="labelWidth">150</Property>
               <Editor/>
             </AutoFormElement>
             <AutoFormElement layoutConstraint="colSpan:2">
diff --git a/src/main/java/com/fzzy/protocol/package-info.java b/src/main/java/com/fzzy/protocol/package-info.java
new file mode 100644
index 0000000..ed755f0
--- /dev/null
+++ b/src/main/java/com/fzzy/protocol/package-info.java
@@ -0,0 +1,4 @@
+/**
+ * 绯荤粺鐩稿叧鍗忚
+ */
+package com.fzzy.protocol;
\ No newline at end of file
diff --git a/src/main/java/com/fzzy/protocol/weightyh/MessageConsumer.java b/src/main/java/com/fzzy/protocol/weightyh/MessageConsumer.java
new file mode 100644
index 0000000..354596c
--- /dev/null
+++ b/src/main/java/com/fzzy/protocol/weightyh/MessageConsumer.java
@@ -0,0 +1,114 @@
+package com.fzzy.protocol.weightyh;
+
+import com.fzzy.api.utils.BytesUtil;
+import com.fzzy.api.utils.SpringUtil;
+import com.fzzy.gateway.GatewayUtils;
+import com.fzzy.gateway.api.DeviceReportService;
+import com.fzzy.gateway.api.GatewayRemoteManager;
+import com.fzzy.gateway.entity.GatewayDevice;
+import com.fzzy.gateway.hx2023.service.HxGatewaySyncWeightImpl1;
+import com.ld.io.api.IoMsgConsumer;
+import com.ld.io.api.IoSession;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * 鍦扮淇℃伅鎺ㄩ��
+ *
+ * @author: andy.jia
+ * @description:
+ * @version:
+ * @data:2020骞�3鏈�19鏃�
+ */
+@Slf4j
+public class MessageConsumer implements IoMsgConsumer {
+
+    private long timeTag = 0;
+
+    private GatewayRemoteManager reportService;
+
+    @Override
+    public void consume(IoSession session, byte[] bytes) {
+        analysisInfo(session.getAddress(), session.getPort(), bytes);
+    }
+
+    /**
+     * 02 2B 30 30 31 31 38 30 30 31 33 03 02寮�濮� 03 缁撴潫
+     */
+    public void analysisInfo(String ip, Integer port, byte[] bytes) {
+        String strMsg = BytesUtil.bytesToString(bytes);
+        //log.debug("寮�濮嬭В鏋愬湴纾呰繑鍥炰俊鎭�=" + strMsg);
+        if (strMsg.length() < 22) {
+            return;
+        }
+
+        // 姣忛棿闅�2.5鎵ц涓�娆�
+        if (System.currentTimeMillis() - timeTag <= 2500) {
+            return;
+        }
+        timeTag = System.currentTimeMillis();
+
+        String temp = strMsg.substring(2, 4);
+        String symbol = HexASCIIToConvert(temp);
+        temp = strMsg.substring(4, 16);
+        String w = HexASCIIToConvert(temp);
+        temp = strMsg.substring(16, 18);
+        int d = getProduct(Integer.parseInt(HexASCIIToConvert(temp)));
+
+        //鏈�缁堥噸閲忕粨鏋�
+        double weigh = Double.valueOf(w) / d;
+
+
+        log.debug("----------鍦扮绉伴噸鏁板�艰В鏋�------{}", weigh);
+
+        //褰撳墠鍦扮鍗忚涓嶆敮鎸佷紶閫扴N锛屼娇鐢ㄥ眬鍩熺綉IP浣滀负SN
+        String sn = ip;
+
+
+        //鏍规嵁淇℃伅鑾峰彇璁惧
+        GatewayDevice device = GatewayUtils.getCacheByDeviceSn(sn);
+
+        if (null == device) {
+            log.error("----------娌℃湁鑾峰彇鍒拌澶囦俊鎭�--------{}", sn);
+            return;
+        }
+
+        //鐩存帴璋冪敤瀹炵幇绫伙紝鏇村瀹炵幇绫诲崟鐙皟鐢�
+        if (null == reportService) {
+            reportService = SpringUtil.getBean(GatewayRemoteManager.class);
+        }
+
+        reportService.getDeviceReportService(device.getProvinceProtocol()).report2GatewayBySn(weigh, device);
+    }
+
+    /**
+     * 鏍规嵁灏忔暟鐐逛綅鏁拌绠楀師鏁板瓧闇�瑕侀櫎浠ュ灏�
+     *
+     * @param i
+     */
+    private int getProduct(int i) {
+        if (i == 0)
+            return 1;
+        int num = 1;
+        for (int a = 0; a < i; a++) {
+            num = num * 10;
+        }
+        return num;
+    }
+
+    private String HexASCIIToConvert(String value) {
+        // String value = "30 30 31 31 38 30 30";
+        StringBuffer sbu = new StringBuffer();
+        char t = 0;
+        int size = value.length() / 2;
+        for (int i = 0; i < size; i++) {
+            String tmp = value.substring(i * 2, (i + 1) * 2);
+            t = (char) Integer.parseInt(""
+                    + BytesUtil.bytesToInt(BytesUtil.hexStrToBytes(tmp)));
+            sbu.append(t);
+        }
+
+        return sbu.toString();
+    }
+
+
+}
diff --git a/src/main/java/com/fzzy/protocol/weightyh/SessionListener.java b/src/main/java/com/fzzy/protocol/weightyh/SessionListener.java
new file mode 100644
index 0000000..87855a4
--- /dev/null
+++ b/src/main/java/com/fzzy/protocol/weightyh/SessionListener.java
@@ -0,0 +1,31 @@
+package com.fzzy.protocol.weightyh;
+
+import com.fzzy.api.utils.ContextUtil;
+import com.ld.io.api.IoSession;
+import com.ld.io.api.IoSessionListener;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * @author: andy.jia
+ * @description:
+ * @version:
+ */
+@Slf4j
+public class SessionListener implements IoSessionListener {
+
+    public static final String BEAN_ID = "yh.sessionListener";
+
+    @Override
+    public void onCreate(IoSession session) {
+        // 娣诲姞鑷畾涔変笟鍔D
+        session.setBusinessKey(ContextUtil.getServerKey(session.getAddress(), session.getPort()));
+
+        log.info("鍦扮鎴愬姛杩炴帴锛孖P={},port={}", session.getAddress(), session.getPort());
+    }
+
+    @Override
+    public void onDestroy(IoSession session) {
+        log.info("鍦扮鏂紑杩炴帴锛孖P={},port={}", session.getAddress(), session.getPort());
+
+    }
+}
diff --git a/src/main/java/com/fzzy/protocol/weightyh/YhScaleServerEngine.java b/src/main/java/com/fzzy/protocol/weightyh/YhScaleServerEngine.java
new file mode 100644
index 0000000..9d5221a
--- /dev/null
+++ b/src/main/java/com/fzzy/protocol/weightyh/YhScaleServerEngine.java
@@ -0,0 +1,43 @@
+package com.fzzy.protocol.weightyh;
+
+import com.fzzy.api.utils.BytesUtil;
+import com.ld.io.api.IoServerOption;
+import com.ld.io.netty.NettyServer;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * 鍦扮鏈嶅姟鍚姩
+ *
+ * @author: andy.jia
+ * @description:
+ * @version:
+ */
+@Slf4j
+public class YhScaleServerEngine {
+
+    public static final int port = 19090;
+
+    public static NettyServer ioServer = null;
+    // 閰嶇疆娑堟伅鎺ユ敹绫�
+    private static MessageConsumer messageConsume = new MessageConsumer();
+    // 鐩戝惉浼氳瘽鐨勫垱寤轰笌閿�姣�
+    private static SessionListener ioSessionListener = new SessionListener();
+
+    public static void start() throws InterruptedException {
+        // 閰嶇疆Server鐨勯厤缃�
+        IoServerOption ioServerOption = new IoServerOption(port);
+        // 鎷嗗寘鍣ㄩ厤缃�
+        //ioServerOption.setSplitDecoderType(SplitByteDecoderType.DELIMITER_SYMBOL);
+        ioServerOption.setDelimiter(BytesUtil.hexStrToBytes("03"));
+
+        ioServer = new NettyServer(ioServerOption, messageConsume, ioSessionListener);
+        ioServer.startup();
+
+        log.info("* ========================");
+        log.info("* ");
+        log.info("* 鍦扮-鑰�鍗庡搧鐗屾湇鍔″惎鍔紝绔彛鍙�={}", YhScaleServerEngine.port);
+        log.info("* ");
+        log.info("* ========================");
+    }
+
+}

--
Gitblit v1.9.3