From f7178996ca77a1bccc941c0e7a73b36803e508cb Mon Sep 17 00:00:00 2001
From: vince <757871790@qq.com>
Date: 星期五, 01 三月 2024 16:13:11 +0800
Subject: [PATCH] 优化协议

---
 src/main/java/com/fzzy/protocol/fzzy/analysis/AnalysisSystem.java |   18 +++++++++++++++---
 1 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/fzzy/protocol/fzzy/analysis/AnalysisSystem.java b/src/main/java/com/fzzy/protocol/fzzy/analysis/AnalysisSystem.java
index 3a5a27f..16a7fab 100644
--- a/src/main/java/com/fzzy/protocol/fzzy/analysis/AnalysisSystem.java
+++ b/src/main/java/com/fzzy/protocol/fzzy/analysis/AnalysisSystem.java
@@ -4,6 +4,7 @@
 import com.fzzy.api.data.ApiCommonDevice;
 import com.fzzy.gateway.GatewayUtils;
 import com.fzzy.gateway.entity.GatewayDevice;
+import com.fzzy.gateway.service.GatewayDeviceService;
 import com.fzzy.protocol.fzzy.builder.ObjectCommandBuilder;
 import com.fzzy.protocol.fzzy.builder.SimpleCommandBuilder;
 import com.fzzy.protocol.fzzy.cmd.BaseRemoteImpl;
@@ -15,6 +16,7 @@
 import org.apache.commons.lang3.time.DateFormatUtils;
 import org.springframework.stereotype.Component;
 
+import javax.annotation.Resource;
 import java.util.Date;
 
 /**
@@ -27,19 +29,29 @@
     public static final String BEAN_ID = "fzzy.analysisSystem";
 
 
+    @Resource
+    private GatewayDeviceService gatewayDeviceService;
+
+
     public void analysis1001(ReMessage reMessage) {
 
         //鑾峰彇鍒扮櫥闄嗕俊鎭紝鎵ц璁惧淇℃伅鏁寸悊
-        ApiCommonDevice device = Constant.getCommonDeviceCache(reMessage.getSn());
-        if (null == device) {
-            device = new ApiCommonDevice();
+        GatewayDevice d = GatewayUtils.getCacheByDeviceSn(reMessage.getSn());
+        if (null == d) {
+            d = new GatewayDevice();
         }
+        ApiCommonDevice device = new ApiCommonDevice();
         device.setIp(reMessage.getIp());
         device.setPort(reMessage.getPort());
         device.setSn(reMessage.getSn());
         device.setId(reMessage.getIedId());
+        device.setOnlineTime(new Date());
+        device.setCode("SUCCESS");
         Constant.updateCache(device);
 
+        //鏇存柊璁惧鍦ㄧ嚎
+        gatewayDeviceService.onlineByCommonDevice(device);
+
 
         //杩斿洖褰撳墠绯荤粺鏃堕棿
         Response1001 response = new Response1001();

--
Gitblit v1.9.3