From c71a6d7d80dcbbbe2806d99870a36ad5040a889d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Tue, 29 Jul 2025 15:54:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=B7=BB=E5=8A=A0=E6=BA=B6=E6=B6=B2?= =?UTF-8?q?=E4=BB=8E=E9=85=8D=E6=96=B9=E4=B8=AD=E8=8E=B7=E5=8F=96=E8=BD=AC?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/command/control/SolutionAddStartCommand.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/iflytop/handacid/app/command/control/SolutionAddStartCommand.java b/src/main/java/com/iflytop/handacid/app/command/control/SolutionAddStartCommand.java index fd1302a..6211f35 100644 --- a/src/main/java/com/iflytop/handacid/app/command/control/SolutionAddStartCommand.java +++ b/src/main/java/com/iflytop/handacid/app/command/control/SolutionAddStartCommand.java @@ -14,6 +14,8 @@ import com.iflytop.handacid.app.core.state.DeviceState; import com.iflytop.handacid.app.model.dto.CommandDTO; import com.iflytop.handacid.app.service.ChannelCtrlService; import com.iflytop.handacid.app.service.DeviceCommandService; +import com.iflytop.handacid.common.model.entity.Formulation; +import com.iflytop.handacid.common.service.FormulationService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -31,6 +33,7 @@ import java.util.concurrent.CompletableFuture; @CommandMapping("solution_add_start") public class SolutionAddStartCommand extends BaseCommandHandler { private final DeviceCommandService deviceCommandService; + private final FormulationService formulationService; private final ChannelCtrlService channelCtrlService; private final DeviceState deviceState; @@ -46,9 +49,9 @@ public class SolutionAddStartCommand extends BaseCommandHandler { } ChannelCode channelCode = ChannelCode.valueOf(channelCodeStr); channelCodeList.add(channelCode); - Double volume = jsonObject.getDouble("volume"); - if (volume == null) { - throw new IllegalArgumentException("参数 volume 不能为空"); + Double formulationId = jsonObject.getDouble("formulationId"); + if (formulationId == null) { + throw new IllegalArgumentException("参数 formulationId 不能为空"); } } SolutionAddMode mode = commandDTO.getEnumParam("mode", SolutionAddMode.class); @@ -68,8 +71,9 @@ public class SolutionAddStartCommand extends BaseCommandHandler { JSONObject jsonObject = jsonArray.getJSONObject(i); String channelCodeStr = jsonObject.getStr("channelCode"); ChannelCode channelCode = ChannelCode.valueOf(channelCodeStr); - Double volume = jsonObject.getDouble("volume"); - DeviceCommand deviceCommand = channelCtrlService.getPumpMoveByCommandByChannel(channelCode, volume); + Long formulationId = jsonObject.getLong("formulationId"); + Formulation formulation = formulationService.getById(formulationId); + DeviceCommand deviceCommand = channelCtrlService.getPumpMoveByCommandByChannel(channelCode, formulation.getRevolutions()); commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); } CommandUtil.wait(commandFutureList); @@ -81,8 +85,9 @@ public class SolutionAddStartCommand extends BaseCommandHandler { JSONObject jsonObject = jsonArray.getJSONObject(i); String channelCodeStr = jsonObject.getStr("channelCode"); ChannelCode channelCode = ChannelCode.valueOf(channelCodeStr); - Double volume = jsonObject.getDouble("volume"); - DeviceCommand deviceCommand = channelCtrlService.getPumpMoveByCommandByChannel(channelCode, volume); + Double formulationId = jsonObject.getDouble("formulationId"); + Formulation formulation = formulationService.getById(formulationId); + DeviceCommand deviceCommand = channelCtrlService.getPumpMoveByCommandByChannel(channelCode, formulation.getRevolutions()); commandFutureList.add(deviceCommandService.sendCommand(deviceCommand)); } CommandUtil.wait(commandFutureList);