From f32707264e3baff6035f9a485310260754d4105b Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Tue, 12 Nov 2024 22:38:53 +0800
Subject: [PATCH] 1

---
 geteClient/src/main/java/org/example/geteclient/wsClinet/GateClient.java |   19 +++++++++++++------
 1 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/geteClient/src/main/java/org/example/geteclient/wsClinet/GateClient.java b/geteClient/src/main/java/org/example/geteclient/wsClinet/GateClient.java
index cf395ba..2c03b74 100644
--- a/geteClient/src/main/java/org/example/geteclient/wsClinet/GateClient.java
+++ b/geteClient/src/main/java/org/example/geteclient/wsClinet/GateClient.java
@@ -6,9 +6,16 @@
 import com.google.gson.Gson;
 import com.google.gson.JsonSyntaxException;
 import lombok.extern.slf4j.Slf4j;
+import org.example.geteclient.GeteClientApplication;
+import org.example.geteclient.comm.ApplicationContextProvider;
 import org.example.geteclient.pojo.Currency;
 import org.example.geteclient.util.RedisUtil;
 import org.json.JSONException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.SpringApplication;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.stereotype.Component;
 
 import javax.websocket.*;
 import java.math.BigDecimal;
@@ -116,7 +123,7 @@
                         String[] asksData = dataArray[0];
                         pvMap.put("p", new BigDecimal(asksData[0]).toPlainString());
                         pvMap.put("v", new BigDecimal(asksData[1]).toPlainString());
-                        hashMap.put(BIDS_KEY, pvMap); // 放入 bids 数据
+                        hashMap.put(ASKS_KEY, pvMap); // 放入 bids 数据
                     }
 
                     if (bidsObj instanceof List && !((List<?>) bidsObj).isEmpty()) {
@@ -126,7 +133,7 @@
                         HashMap<String, Object> pvMap = new HashMap<>(); // 创建新的 HashMap 保存 bids 和 asks
                         pvMap.put("p", new BigDecimal(bidsData[0]).toPlainString());
                         pvMap.put("v", new BigDecimal(bidsData[1]).toPlainString());
-                        hashMap.put(ASKS_KEY,pvMap);
+                        hashMap.put(BIDS_KEY,pvMap);
                     }
 
                     String key = "gate" + resultMap.get(S_KEY); // 生成 Redis 键
@@ -143,15 +150,15 @@
 
 
     @OnClose
-    public void onClose() {
+    public void onClose() throws Exception {
         log.info("gate ws 连接已关闭,尝试重新连接..."); // 连接关闭日志
-        handleConnectionClosedOrError(); // 处理连接关闭或错误
+        handleConnectionClosedOrError();
     }
 
     @OnError
-    public void onError(Throwable throwable) {
+    public void onError(Throwable throwable) throws Exception {
         log.error("gate ws 发生错误: " + throwable.getMessage(), throwable); // 记录错误日志
-        handleConnectionClosedOrError(); // 处理连接关闭或错误
+        handleConnectionClosedOrError();
     }
 
     private void handleConnectionClosedOrError() {

--
Gitblit v1.9.3