From 785a6b60aa3da45eadf159dfa6f019040a2c670f Mon Sep 17 00:00:00 2001 From: huaqiang Date: Tue, 22 Sep 2026 09:08:08 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=90=E5=88=B6=E4=BD=8E=E7=94=B5=E9=87=8F?= =?UTF-8?q?=E5=9B=9E=E5=85=85=E6=95=B0=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/EquipmentManagementPage.vue | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/views/dashboard1/pages/EquipmentManagementPage.vue b/src/views/dashboard1/pages/EquipmentManagementPage.vue index 3aabe85..27fb158 100644 --- a/src/views/dashboard1/pages/EquipmentManagementPage.vue +++ b/src/views/dashboard1/pages/EquipmentManagementPage.vue @@ -1161,6 +1161,22 @@ function buildDevicePlans(device: DeviceRecord): PatrolTask[] { ]; } +// 自动回充低电量阈值上限:必须低于车端"充电完成脱离阈值"(95%)并留出滞后余量, +// 否则会出现"充到 95% 自动脱离 → 电量回落到阈值以下 → 又自动回充"的反复触发 +const MAX_LOW_BATTERY_THRESHOLD = 90; + +// 阈值统一下限与默认值,和 charging_dock 节点保持一致的量级 +const MIN_LOW_BATTERY_THRESHOLD = 1; +const DEFAULT_LOW_BATTERY_THRESHOLD = 30; + +// 把阈值收敛到 [1, 90];非法值回落到默认阈值 +function clampLowBatteryThreshold(value: number | undefined) { + if (typeof value !== "number" || !Number.isFinite(value)) { + return DEFAULT_LOW_BATTERY_THRESHOLD; + } + return Math.min(MAX_LOW_BATTERY_THRESHOLD, Math.max(MIN_LOW_BATTERY_THRESHOLD, Math.round(value))); +} + // 回充配置默认值与 charging_dock 节点保持一致:默认开启自动回充,阈值 30% function buildDockConfig(device: DeviceRecord): DockConfigState { return { @@ -1171,7 +1187,7 @@ function buildDockConfig(device: DeviceRecord): DockConfigState { preDockY: device.preDockY, preDockYaw: device.preDockYaw, autoRechargeEnabled: device.autoRechargeEnabled ?? true, - lowBatteryThreshold: device.lowBatteryThreshold ?? 30, + lowBatteryThreshold: clampLowBatteryThreshold(device.lowBatteryThreshold), }; } @@ -2522,6 +2538,16 @@ function fillDockPoseFromRobot(mode: "dock" | "preDock") { scheduleMapCanvasRender(); } +// 输入框即时收敛阈值,避免页面上留下超过上限的值 +function normalizeDockThreshold() { + if (!currentConfig.value) { + return; + } + currentConfig.value.dock.lowBatteryThreshold = clampLowBatteryThreshold( + currentConfig.value.dock.lowBatteryThreshold, + ); +} + // 保存充电点与自动回充配置;后端保存后会同步下发给在线小车 async function saveDockConfig() { const device = currentConfiguredDevice.value; @@ -2530,10 +2556,21 @@ async function saveDockConfig() { return; } + // 阈值上限收敛:超过上限会与车端 95% 的自动脱离阈值形成自激反复 + const rawThreshold = Number(config.dock.lowBatteryThreshold); + const overLimit = !Number.isFinite(rawThreshold) || rawThreshold > MAX_LOW_BATTERY_THRESHOLD; + const threshold = clampLowBatteryThreshold(rawThreshold); + config.dock.lowBatteryThreshold = threshold; + await updateRosCarDockConfig({ id: device.id, ...config.dock, + lowBatteryThreshold: threshold, }); + + if (overLimit) { + dockConfigMessage.value = `自动回充阈值最高 ${MAX_LOW_BATTERY_THRESHOLD}%,已按上限 ${threshold}% 保存`; + } } // 在地图上绘制充电点/预对接点标记 @@ -3349,8 +3386,8 @@ watch(