From 3cacce3926b0ebef8878c48627b2f96aa53d653a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=A2=A6=E8=BF=9C?= <1063331231@qq.com> Date: Wed, 28 May 2025 16:35:22 +0800 Subject: [PATCH] =?UTF-8?q?add:=E5=A2=9E=E5=8A=A0=E5=AF=B9=E6=B3=B5?= =?UTF-8?q?=E8=BD=AC=E9=80=9F=E7=9A=84=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java | 7 +++++++ .../iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java | 5 +++++ .../com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStartCommand.java | 6 ++++++ src/main/java/com/iflytop/sgs/common/enums/SystemConfigCode.java | 5 +++-- 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java index 6c0d011..9e8e043 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpAddCommand.java @@ -1,7 +1,9 @@ package com.iflytop.sgs.app.cmd.debug; +import cn.hutool.core.lang.Assert; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.dto.CmdDTO; +import com.iflytop.sgs.app.model.entity.SystemConfig; import com.iflytop.sgs.app.service.api.SystemConfigService; import com.iflytop.sgs.app.service.device.DeviceCommandService; import com.iflytop.sgs.common.annotation.CommandDebugMapping; @@ -10,6 +12,8 @@ import com.iflytop.sgs.common.cmd.DeviceCommandBundle; import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; import com.iflytop.sgs.common.enums.SystemConfigCode; import com.iflytop.sgs.common.enums.cmd.CmdDirection; +import com.iflytop.sgs.common.exception.AppException; +import com.iflytop.sgs.common.result.ResultCode; import com.iflytop.sgs.common.utils.CommandUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -35,8 +39,11 @@ public class DebugLiquidPumpAddCommand extends BaseCommandHandler { Double position = volume * scale; Double speed = cmdDTO.getDoubleParam("speed"); + return runAsync(() -> { if (speed != null) { + double max_speed = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.liquid_max_speed)); + Assert.isTrue(speed < max_speed, () -> new AppException(ResultCode.INVALID_PARAMETER)); DeviceCommandBundle deviceCommand = DeviceCommandGenerator.liquidPumpSet(speed); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), deviceCommand); CommandUtil.wait(deviceCommandFuture); diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java index a46ac45..b096126 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpReduceCommand.java @@ -1,5 +1,6 @@ package com.iflytop.sgs.app.cmd.debug; +import cn.hutool.core.lang.Assert; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.dto.CmdDTO; import com.iflytop.sgs.app.service.api.SystemConfigService; @@ -10,6 +11,8 @@ import com.iflytop.sgs.common.cmd.DeviceCommandBundle; import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; import com.iflytop.sgs.common.enums.SystemConfigCode; import com.iflytop.sgs.common.enums.cmd.CmdDirection; +import com.iflytop.sgs.common.exception.AppException; +import com.iflytop.sgs.common.result.ResultCode; import com.iflytop.sgs.common.utils.CommandUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -36,6 +39,8 @@ public class DebugLiquidPumpReduceCommand extends BaseCommandHandler { Double speed = cmdDTO.getDoubleParam("speed"); return runAsync(() -> { if (speed != null) { + double max_speed = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.liquid_max_speed)); + Assert.isTrue(speed < max_speed, () -> new AppException(ResultCode.INVALID_PARAMETER)); DeviceCommandBundle liquidPumpSetCommand = DeviceCommandGenerator.liquidPumpSet(speed); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidPumpSetCommand); CommandUtil.wait(deviceCommandFuture); diff --git a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStartCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStartCommand.java index 81026f8..e1f01fa 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStartCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/debug/DebugLiquidPumpStartCommand.java @@ -3,11 +3,14 @@ package com.iflytop.sgs.app.cmd.debug; import cn.hutool.core.lang.Assert; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.dto.CmdDTO; +import com.iflytop.sgs.app.model.entity.SystemConfig; +import com.iflytop.sgs.app.service.api.SystemConfigService; import com.iflytop.sgs.app.service.device.DeviceCommandService; import com.iflytop.sgs.common.annotation.CommandDebugMapping; import com.iflytop.sgs.common.cmd.CommandFuture; import com.iflytop.sgs.common.cmd.DeviceCommandBundle; import com.iflytop.sgs.common.cmd.DeviceCommandGenerator; +import com.iflytop.sgs.common.enums.SystemConfigCode; import com.iflytop.sgs.common.enums.cmd.CmdDirection; import com.iflytop.sgs.common.exception.AppException; import com.iflytop.sgs.common.result.ResultCode; @@ -27,6 +30,7 @@ import java.util.concurrent.CompletableFuture; @CommandDebugMapping("liquid_pump_start") public class DebugLiquidPumpStartCommand extends BaseCommandHandler { private final DeviceCommandService deviceCommandService; + private final SystemConfigService systemConfigService; @Override public CompletableFuture handle(CmdDTO cmdDTO) { @@ -36,6 +40,8 @@ public class DebugLiquidPumpStartCommand extends BaseCommandHandler { CmdDirection cmdDirection = CmdDirection.valueOf(direction); return runAsync(() -> { if (speed != null) { + double max_speed = Double.parseDouble(systemConfigService.getSystemConfigValueByCode(SystemConfigCode.liquid_max_speed)); + Assert.isTrue(speed < max_speed, () -> new AppException(ResultCode.INVALID_PARAMETER)); DeviceCommandBundle liquidPumpSetCommand = DeviceCommandGenerator.liquidPumpSet(speed); CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdDTO.getCommandId(), cmdDTO.getCommand(), liquidPumpSetCommand); CommandUtil.wait(deviceCommandFuture); diff --git a/src/main/java/com/iflytop/sgs/common/enums/SystemConfigCode.java b/src/main/java/com/iflytop/sgs/common/enums/SystemConfigCode.java index 9254d6b..5b7fdb9 100644 --- a/src/main/java/com/iflytop/sgs/common/enums/SystemConfigCode.java +++ b/src/main/java/com/iflytop/sgs/common/enums/SystemConfigCode.java @@ -4,7 +4,6 @@ import lombok.Getter; /** * 系统配置累 - * */ @Getter public enum SystemConfigCode { @@ -17,7 +16,9 @@ public enum SystemConfigCode { volume_clean("清洁时加水的量"), number_reduce("抽液时机蠕动泵的转数"), cycle_clean_max - ("清洁最大次数"); + ("清洁最大次数"), + liquid_max_speed + ("蠕动泵最大转速"); private String description;