From 5be6cacbb75914e146c78df15a55ef9f520b3e8f Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Sat, 13 Dec 2025 22:19:15 +0800
Subject: [PATCH] feat(okxNewPrice): 启用关键业务日志记录功能
---
src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/OrderInfoWs.java | 37 ++++++++++++++++++++++++-------------
1 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/OrderInfoWs.java b/src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/OrderInfoWs.java
index adfbc05..5250828 100644
--- a/src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/OrderInfoWs.java
+++ b/src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/OrderInfoWs.java
@@ -6,16 +6,23 @@
import com.xcong.excoin.modules.okxNewPrice.okxWs.enums.CoinEnums;
import com.xcong.excoin.modules.okxNewPrice.okxWs.enums.OrderParamEnums;
import com.xcong.excoin.modules.okxNewPrice.okxpi.MallUtils;
+import com.xcong.excoin.modules.okxNewPrice.utils.WsMapBuild;
import com.xcong.excoin.modules.okxNewPrice.utils.WsParamBuild;
import com.xcong.excoin.utils.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.java_websocket.client.WebSocketClient;
+
+import java.math.BigDecimal;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
/**
* @author Administrator
*/
@Slf4j
public class OrderInfoWs {
+
+ public static final Map<String,String> ORDERINFOWSMAP = new ConcurrentHashMap<>();
public static final String ORDERINFOWS_CHANNEL = "orders";
@@ -31,10 +38,14 @@
String connId = MallUtils.getOrderNum(ORDERINFOWS_CHANNEL);
JSONObject jsonObject = WsParamBuild.buildJsonObject(connId, option, argsArray);
webSocketClient.send(jsonObject.toJSONString());
- log.info("发送订单频道频道:{}", option);
+// log.info("发送订单频道频道:{}", option);
} catch (Exception e) {
log.error("订阅订单频道构建失败", e);
}
+ }
+
+ public static void initEvent(JSONObject response) {
+// log.info("订阅成功: {}", response.getJSONObject("arg"));
}
@@ -49,7 +60,7 @@
private static final String STATE_KEY = "state";
public static void handleEvent(JSONObject response, RedisUtils redisUtils) {
- log.info("开始执行OrderInfoWs......");
+// log.info("开始执行OrderInfoWs......");
try {
JSONArray dataArray = response.getJSONArray(DATA_KEY);
if (dataArray == null || dataArray.isEmpty()) {
@@ -80,24 +91,24 @@
accFillSz, avgPx,state
);
- String clOrdIdStr = (String) redisUtils.get(TradeOrderWs.ORDERWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":clOrdId");
- String stateStr = (String) redisUtils.get(TradeOrderWs.ORDERWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":state");
+ String clOrdIdStr = TradeOrderWs.TRADEORDERWSMAP.get("clOrdId");
+ String stateStr = TradeOrderWs.TRADEORDERWSMAP.get("state");
if (
StrUtil.isNotBlank(clOrdIdStr)
&& clOrdId.equals(clOrdIdStr)
&& StrUtil.isNotBlank(stateStr)
&& state.equals(stateStr)
){
- boolean setResult = false;
- String outStr = (String) redisUtils.get(InstrumentsWs.INSTRUMENTSWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":out");
- if (OrderParamEnums.OUT_YES.getValue().equals(outStr)){
- setResult = redisUtils.set(InstrumentsWs.INSTRUMENTSWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":state", OrderParamEnums.STATE_3.getValue(), 0);
- }else{
- setResult = redisUtils.set(InstrumentsWs.INSTRUMENTSWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":state", OrderParamEnums.STATE_1.getValue(), 0);
+ //记录成交均价
+ if (ORDERINFOWSMAP.get("orderPrice") == null){
+ WsMapBuild.saveStringToMap(ORDERINFOWSMAP, "orderPrice",avgPx);
}
- if (setResult){
- log.info("订单详情-币种: {}, 自定义编号: {}, 订单状态: {}", CoinEnums.HE_YUE.getCode(), clOrdId, OrderParamEnums.STATE_1.getValue());
- }
+ WsMapBuild.saveStringToMap(TradeOrderWs.TRADEORDERWSMAP, "state", CoinEnums.ORDER_LIVE.getCode());
+
+ WsMapBuild.saveBigDecimalToMap(PositionsWs.POSITIONSWSMAP, CoinEnums.READY_STATE.name(), WsMapBuild.parseBigDecimalSafe(CoinEnums.READY_STATE_NO.getCode()));
+ WsMapBuild.saveStringToMap(AccountWs.ACCOUNTWSMAP, CoinEnums.READY_STATE.name(), CoinEnums.READY_STATE_NO.getCode());
+
+ log.info("订单详情已完成: {}, 自定义编号: {}", CoinEnums.HE_YUE.getCode(), clOrdId);
}
}
} catch (Exception e) {
--
Gitblit v1.9.1