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/resources/static/station-dashboard.html | 4 ++--
src/main/java/com/xcong/excoin/modules/station/entity/StrategyStatus.java | 4 ++--
src/main/java/com/xcong/excoin/modules/station/service/impl/StationServiceImpl.java | 2 +-
src/main/resources/db/station-schema.sql | 12 +++++++++++-
4 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/xcong/excoin/modules/station/entity/StrategyStatus.java b/src/main/java/com/xcong/excoin/modules/station/entity/StrategyStatus.java
index 96942d4..8d0444f 100644
--- a/src/main/java/com/xcong/excoin/modules/station/entity/StrategyStatus.java
+++ b/src/main/java/com/xcong/excoin/modules/station/entity/StrategyStatus.java
@@ -67,8 +67,8 @@
/** 加仓启动阈值 */
private Integer addPositionStartThreshold;
- /** 超额止盈开关 */
- private Boolean placeExcessTakeProfit;
+ /** 止盈挂单模式:off=关闭 / concentrated=集中止盈 / dispersed=分散止盈 */
+ private String placeExcessTakeProfit;
/** 价格驱动开关 */
private Boolean priceDriveEnabled;
diff --git a/src/main/java/com/xcong/excoin/modules/station/service/impl/StationServiceImpl.java b/src/main/java/com/xcong/excoin/modules/station/service/impl/StationServiceImpl.java
index c84880d..df0ee9e 100644
--- a/src/main/java/com/xcong/excoin/modules/station/service/impl/StationServiceImpl.java
+++ b/src/main/java/com/xcong/excoin/modules/station/service/impl/StationServiceImpl.java
@@ -241,7 +241,7 @@
if (params.containsKey("addPositionQuantity")) status.setAddPositionQuantity(intVal(params.get("addPositionQuantity")));
if (params.containsKey("maxPositionPerSide")) status.setMaxPositionPerSide(intVal(params.get("maxPositionPerSide")));
if (params.containsKey("addPositionStartThreshold")) status.setAddPositionStartThreshold(intVal(params.get("addPositionStartThreshold")));
- if (params.containsKey("placeExcessTakeProfit")) status.setPlaceExcessTakeProfit(boolVal(params.get("placeExcessTakeProfit")));
+ if (params.containsKey("placeExcessTakeProfit")) status.setPlaceExcessTakeProfit(str(params.get("placeExcessTakeProfit")));
if (params.containsKey("priceDriveEnabled")) status.setPriceDriveEnabled(boolVal(params.get("priceDriveEnabled")));
if (params.containsKey("dualStopLossEnabled")) status.setDualStopLossEnabled(boolVal(params.get("dualStopLossEnabled")));
if (params.containsKey("longStopLossPrice")) status.setLongStopLossPrice(str(params.get("longStopLossPrice")));
diff --git a/src/main/resources/db/station-schema.sql b/src/main/resources/db/station-schema.sql
index 537b242..39280f9 100644
--- a/src/main/resources/db/station-schema.sql
+++ b/src/main/resources/db/station-schema.sql
@@ -21,7 +21,7 @@
`add_position_quantity` INT(11) DEFAULT 0 COMMENT '加仓数量',
`max_position_per_side` INT(11) DEFAULT 0 COMMENT '单边最大仓位',
`add_position_start_threshold` INT(11) DEFAULT 0 COMMENT '加仓启动阈值',
- `place_excess_take_profit` TINYINT(1) DEFAULT 0 COMMENT '超额止盈开关',
+ `place_excess_take_profit` VARCHAR(16) DEFAULT 'off' COMMENT '止盈挂单模式:off / concentrated / dispersed',
`price_drive_enabled` TINYINT(1) DEFAULT 1 COMMENT '价格驱动开关',
`dual_stop_loss_enabled` TINYINT(1) DEFAULT 0 COMMENT '双开止损触发开关',
`long_stop_loss_price` VARCHAR(32) DEFAULT NULL COMMENT '多头止损触发价',
@@ -87,3 +87,13 @@
ADD COLUMN `dual_stop_loss_enabled` TINYINT(1) DEFAULT 0 COMMENT '双开止损触发开关' AFTER `price_drive_enabled`,
ADD COLUMN `long_stop_loss_price` VARCHAR(32) DEFAULT NULL COMMENT '多头止损触发价' AFTER `dual_stop_loss_enabled`,
ADD COLUMN `short_stop_loss_price` VARCHAR(32) DEFAULT NULL COMMENT '空头止损触发价' AFTER `long_stop_loss_price`;
+
+-- ============================================================
+-- 升级脚本:止盈挂单模式从布尔开关升级为三态字符串(2026-09 新增)
+-- off=关闭 / concentrated=集中止盈 / dispersed=分散止盈
+-- ============================================================
+ALTER TABLE `strategy_status`
+ MODIFY COLUMN `place_excess_take_profit` VARCHAR(16) DEFAULT 'off' COMMENT '止盈挂单模式:off / concentrated / dispersed';
+-- 旧数据迁移:1(开启)→concentrated,0(关闭)→off
+UPDATE `strategy_status` SET `place_excess_take_profit` = 'concentrated' WHERE `place_excess_take_profit` = '1';
+UPDATE `strategy_status` SET `place_excess_take_profit` = 'off' WHERE `place_excess_take_profit` = '0';
diff --git a/src/main/resources/static/station-dashboard.html b/src/main/resources/static/station-dashboard.html
index e694045..2ef4010 100644
--- a/src/main/resources/static/station-dashboard.html
+++ b/src/main/resources/static/station-dashboard.html
@@ -1036,7 +1036,7 @@
addPositionQuantity: 1,
maxPositionPerSide: 0,
addPositionStartThreshold: 1,
- placeExcessTakeProfit: false,
+ placeExcessTakeProfit: 'off',
priceDriveEnabled: true,
dualStopLossEnabled: false,
longStopLossPrice: '',
@@ -1085,7 +1085,7 @@
{ key: 'addPositionStartThreshold', label: '加仓启动阈值 (次)', type: 'number', placeholder: '1', jtype: 'int', group: 'addon', tip: '前 N 次止损不触发加仓' },
{ key: 'rounds', label: '运行轮数 (0=不限)', type: 'number', placeholder: '0', jtype: 'int', group: 'run', tip: '盈利重启达此轮数后停止' },
- { key: 'placeExcessTakeProfit', label: '超额止盈', type: 'select', options: [{ v: 'false', l: '关闭' }, { v: 'true', l: '开启' }], group: 'run' },
+ { key: 'placeExcessTakeProfit', label: '止盈模式', type: 'select', options: [{ v: 'off', l: '关闭' }, { v: 'concentrated', l: '集中止盈' }, { v: 'dispersed', l: '分散止盈' }], group: 'run', tip: '超出基础仓位的加仓部分如何挂止盈' },
{ key: 'priceDriveEnabled', label: '价格驱动', type: 'select', options: [{ v: 'true', l: '开启' }, { v: 'false', l: '关闭' }], group: 'run' },
{ key: 'dualStopLossEnabled', label: '双开止损触发', type: 'select', options: [{ v: 'false', l: '关闭' }, { v: 'true', l: '开启' }], group: 'dual-sl', tip: '开启后按下方多空止损触发价初始化双向止损单,任一触发后重挂另一侧止损' },
--
Gitblit v1.9.1