Administrator
5 days ago eb365b75c8388d1a30a6659f4692b802a3066097
src/main/java/com/xcong/excoin/modules/gateApi/GridElement.java
@@ -91,6 +91,10 @@
    private List<String> longStopLossOrderIds = new ArrayList<>();
    /** 空仓止损订单 ID 列表(支持一个网格多个止损单) */
    private List<String> shortStopLossOrderIds = new ArrayList<>();
    /** 多仓止损订单 ID → 张数(止损触发时统计该网格全部止损覆盖张数,修正追单的 REST 持仓时序竞态) */
    private final Map<String, Integer> longStopLossOrderSizes = new ConcurrentHashMap<>();
    /** 空仓止损订单 ID → 张数 */
    private final Map<String, Integer> shortStopLossOrderSizes = new ConcurrentHashMap<>();
    /**
     * 止损追单是否正在进行中(防重入标记)。
@@ -525,27 +529,71 @@
    /** @return 多仓止损订单 ID 列表 */
    public List<String> getLongStopLossOrderIds() { return longStopLossOrderIds; }
    /** 添加一个多仓止损订单 ID */
    public void addLongStopLossOrderId(String orderId) { longStopLossOrderIds.add(orderId); }
    /** 移除一个多仓止损订单 ID */
    public boolean removeLongStopLossOrderId(String orderId) { return longStopLossOrderIds.remove(orderId); }
    /** 清空所有多仓止损订单 ID */
    public void clearLongStopLossOrderIds() { longStopLossOrderIds.clear(); }
    /** 添加一个多仓止损订单 ID(不记录张数,仅兼容旧调用方) */
    public void addLongStopLossOrderId(String orderId) { addLongStopLossOrderId(orderId, 0); }
    /** 添加一个多仓止损订单 ID 并记录该单张数 */
    public void addLongStopLossOrderId(String orderId, int size) {
        if (orderId == null) {
            return;
        }
        longStopLossOrderIds.add(orderId);
        longStopLossOrderSizes.put(orderId, size);
    }
    /** 移除一个多仓止损订单 ID(同步清理张数记录) */
    public boolean removeLongStopLossOrderId(String orderId) {
        longStopLossOrderSizes.remove(orderId);
        return longStopLossOrderIds.remove(orderId);
    }
    /** 清空所有多仓止损订单 ID(同步清理张数记录) */
    public void clearLongStopLossOrderIds() {
        longStopLossOrderIds.clear();
        longStopLossOrderSizes.clear();
    }
    /** @return 是否有止损单 */
    public boolean hasLongStopLossOrders() { return !longStopLossOrderIds.isEmpty(); }
    /** @return 该网格全部多仓止损单覆盖张数之和(用于止损触发时的追单量修正) */
    public int getLongStopLossTotalSize() {
        int total = 0;
        for (Integer size : longStopLossOrderSizes.values()) {
            total += size;
        }
        return total;
    }
    // ==================== 空仓止损订单 ID 列表 ====================
    /** @return 空仓止损订单 ID 列表 */
    public List<String> getShortStopLossOrderIds() { return shortStopLossOrderIds; }
    /** 添加一个空仓止损订单 ID */
    public void addShortStopLossOrderId(String orderId) { shortStopLossOrderIds.add(orderId); }
    /** 移除一个空仓止损订单 ID */
    public boolean removeShortStopLossOrderId(String orderId) { return shortStopLossOrderIds.remove(orderId); }
    /** 清空所有空仓止损订单 ID */
    public void clearShortStopLossOrderIds() { shortStopLossOrderIds.clear(); }
    /** 添加一个空仓止损订单 ID(不记录张数,仅兼容旧调用方) */
    public void addShortStopLossOrderId(String orderId) { addShortStopLossOrderId(orderId, 0); }
    /** 添加一个空仓止损订单 ID 并记录该单张数 */
    public void addShortStopLossOrderId(String orderId, int size) {
        if (orderId == null) {
            return;
        }
        shortStopLossOrderIds.add(orderId);
        shortStopLossOrderSizes.put(orderId, size);
    }
    /** 移除一个空仓止损订单 ID(同步清理张数记录) */
    public boolean removeShortStopLossOrderId(String orderId) {
        shortStopLossOrderSizes.remove(orderId);
        return shortStopLossOrderIds.remove(orderId);
    }
    /** 清空所有空仓止损订单 ID(同步清理张数记录) */
    public void clearShortStopLossOrderIds() {
        shortStopLossOrderIds.clear();
        shortStopLossOrderSizes.clear();
    }
    /** @return 是否有止损单 */
    public boolean hasShortStopLossOrders() { return !shortStopLossOrderIds.isEmpty(); }
    /** @return 该网格全部空仓止损单覆盖张数之和(用于止损触发时的追单量修正) */
    public int getShortStopLossTotalSize() {
        int total = 0;
        for (Integer size : shortStopLossOrderSizes.values()) {
            total += size;
        }
        return total;
    }
    // ==================== 止损追单防重入标记 ====================