From 8f3d68cfbd98254f92d5c83be9ee52764936377f Mon Sep 17 00:00:00 2001
From: Administrator <15274802129@163.com>
Date: Tue, 22 Sep 2026 17:47:06 +0800
Subject: [PATCH] feat(station): 扩展止盈模式配置功能

---
 src/main/java/com/xcong/excoin/modules/gateApi/GateCommandConsumer.java |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/modules/gateApi/GateCommandConsumer.java b/src/main/java/com/xcong/excoin/modules/gateApi/GateCommandConsumer.java
index 89907d8..98d1c11 100644
--- a/src/main/java/com/xcong/excoin/modules/gateApi/GateCommandConsumer.java
+++ b/src/main/java/com/xcong/excoin/modules/gateApi/GateCommandConsumer.java
@@ -5,6 +5,7 @@
 import com.xcong.excoin.modules.station.model.GateCommand;
 import com.xcong.excoin.modules.station.model.GateStatsEvent;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.amqp.rabbit.annotation.RabbitListener;
 import org.springframework.stereotype.Component;
 import org.springframework.util.StringUtils;
@@ -15,6 +16,7 @@
  * JAR 侧 — 消费 Station 下发的启停指令
  */
 @Slf4j
+@ConditionalOnProperty(name = "app.gate.enabled", havingValue = "true", matchIfMissing = true)
 @Component
 public class GateCommandConsumer {
 
@@ -80,11 +82,15 @@
             }
         } catch (Exception e) {
             success = false;
-            newState = "ERROR";
             message = e.getMessage();
             log.error("[Gate] 指令执行失败", e);
         }
 
+        // 指令异常/未知类型时 newState 可能为空,统一回退为当前真实状态,避免污染 Station 侧实例状态
+        if (newState == null || newState.isEmpty()) {
+            newState = strategy.getState().name();
+        }
+
         // 发送 ACK 到 Station
         CmdAckMsg ack = CmdAckMsg.builder()
                 .commandId(cmd.getCommandId())

--
Gitblit v1.9.1