From e61cce89f151c9fc660497135ccbd779c82fe969 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Mon, 15 Dec 2025 10:07:13 +0800
Subject: [PATCH] chore(logging): 调整账户与策略服务的日志输出
---
src/main/java/com/xcong/excoin/modules/okxNewPrice/okxWs/OrderInfoWs.java | 38 ++++++++++++++++++++++++++++++++------
1 files changed, 32 insertions(+), 6 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 42ccb40..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"));
}
@@ -48,6 +59,8 @@
private static final String AVGPX_KEY = "avgPx";
private static final String STATE_KEY = "state";
public static void handleEvent(JSONObject response, RedisUtils redisUtils) {
+
+// log.info("开始执行OrderInfoWs......");
try {
JSONArray dataArray = response.getJSONArray(DATA_KEY);
if (dataArray == null || dataArray.isEmpty()) {
@@ -59,6 +72,10 @@
JSONObject detail = dataArray.getJSONObject(i);
String instId = detail.getString(INSTID_KEY);
+ if (!CoinEnums.HE_YUE.getCode().equals(instId)){
+ log.info( "订单详情-币种: {} 没有成交订单", CoinEnums.HE_YUE.getCode() );
+ continue;
+ }
String ordId = detail.getString(ORDID_KEY);
String clOrdId = detail.getString(CLORDID_KEY);
String side = detail.getString(SIDE_KEY);
@@ -74,15 +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 (
- clOrdIdStr != null
+ StrUtil.isNotBlank(clOrdIdStr)
&& clOrdId.equals(clOrdIdStr)
- && stateStr != null
+ && StrUtil.isNotBlank(stateStr)
&& state.equals(stateStr)
){
- redisUtils.set(TradeOrderWs.ORDERWS_CHANNEL + ":" + CoinEnums.HE_YUE.getCode() + ":state", OrderParamEnums.STATE_1.getValue(), 0);
+ //记录成交均价
+ if (ORDERINFOWSMAP.get("orderPrice") == null){
+ WsMapBuild.saveStringToMap(ORDERINFOWSMAP, "orderPrice",avgPx);
+ }
+ 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