From 144a8bd7d9ea5fbab65c338a4bfa725c5b981330 Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Fri, 06 Nov 2026 11:26:44 +0800
Subject: [PATCH] fix(grid): 修复网格并发修改异常与日志变量错误

---
 src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java |    2 +-
 src/main/java/com/xcong/excoin/modules/gateApi/GridElement.java          |   13 +++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java b/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
index d2bfce3..51e112a 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GateGridTradeService.java
@@ -723,7 +723,7 @@
                     longEntryPrice = entryPrice;
                 } else {
 
-                    log.info("[Gate-0]多仓: {}", shortBaseEntryPrice);
+                    log.info("[Gate-0]多仓: {}", longBaseEntryPrice);
                     longActive = false;
                     longPositionSize = BigDecimal.ZERO;
                     longEntryPrice = BigDecimal.ZERO;
diff --git a/src/main/java/com/xcong/excoin/modules/gateApi/GridElement.java b/src/main/java/com/xcong/excoin/modules/gateApi/GridElement.java
index df24d27..e360981 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GridElement.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GridElement.java
@@ -5,6 +5,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 /**
  * 网格价格层级,策略的最小操作单元。
@@ -80,21 +81,21 @@
     /** 下一个网格编号,null 表示无下一级 */
     private Integer downId;
     /** 多仓挂单订单 ID 列表(支持同一网格多个挂单,由止损追单产生) */
-    private List<String> longOrderIds = new ArrayList<>();
+    private List<String> longOrderIds = new CopyOnWriteArrayList<>();
     /** 空仓挂单订单 ID 列表(支持同一网格多个挂单,由止损追单产生) */
-    private List<String> shortOrderIds = new ArrayList<>();
+    private List<String> shortOrderIds = new CopyOnWriteArrayList<>();
     /** 多仓止盈订单 ID 列表(支持一网格多笔止盈单:基础止盈 + 超额止盈并行挂单) */
-    private List<String> longTakeProfitOrderIds = new ArrayList<>();
+    private List<String> longTakeProfitOrderIds = new CopyOnWriteArrayList<>();
     /** 空仓止盈订单 ID 列表(支持一网格多笔止盈单:基础止盈 + 超额止盈并行挂单) */
-    private List<String> shortTakeProfitOrderIds = new ArrayList<>();
+    private List<String> shortTakeProfitOrderIds = new CopyOnWriteArrayList<>();
     /** 多仓止盈订单 ID → 张数(仓位止盈补仓时取本次止盈单张数) */
     private final Map<String, Integer> longTakeProfitOrderSizes = new ConcurrentHashMap<>();
     /** 空仓止盈订单 ID → 张数 */
     private final Map<String, Integer> shortTakeProfitOrderSizes = new ConcurrentHashMap<>();
     /** 多仓止损订单 ID 列表(支持一个网格多个止损单) */
-    private List<String> longStopLossOrderIds = new ArrayList<>();
+    private List<String> longStopLossOrderIds = new CopyOnWriteArrayList<>();
     /** 空仓止损订单 ID 列表(支持一个网格多个止损单) */
-    private List<String> shortStopLossOrderIds = new ArrayList<>();
+    private List<String> shortStopLossOrderIds = new CopyOnWriteArrayList<>();
     /** 多仓止损订单 ID → 张数(止损触发时统计该网格全部止损覆盖张数,修正追单的 REST 持仓时序竞态) */
     private final Map<String, Integer> longStopLossOrderSizes = new ConcurrentHashMap<>();
     /** 空仓止损订单 ID → 张数 */

--
Gitblit v1.9.1