From 9511a83d9a53ea472d7ba552624ead37cae8d9e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Mon, 26 May 2025 20:18:15 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=9A=E5=8A=A1=E6=8C=87?= =?UTF-8?q?=E4=BB=A4=E5=BC=80=E5=A7=8B=E7=83=98=E5=B9=B2=EF=BC=8C=E7=BB=93?= =?UTF-8?q?=E6=9D=9F=E7=83=98=E5=B9=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sgs/app/cmd/control/DryStartCommand.java | 31 +++++++++------------- .../sgs/app/cmd/control/DryStopCommand.java | 25 ++++++++--------- 2 files changed, 23 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/DryStartCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/DryStartCommand.java index 93126b1..5daff97 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/DryStartCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/DryStartCommand.java @@ -1,6 +1,5 @@ package com.iflytop.sgs.app.cmd.control; -import cn.hutool.core.lang.Assert; import cn.hutool.json.JSONArray; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.bo.status.device.HeatModuleState; @@ -24,29 +23,23 @@ import java.util.concurrent.CompletableFuture; @RequiredArgsConstructor @CommandMapping("_start")//业务指令注解 public class DryStartCommand extends BaseCommandHandler { - private final HeatModuleService deviceCommandUtilService; + private final HeatModuleService heatModuleService; private final DeviceStateService deviceStateService; @Override public CompletableFuture handle(CmdDTO cmdDTO) { - JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatId"); - return runAsync(() -> { - for (int i = 0; i < heatIdJsonArray.size(); i++) { - //获取当前加热区 - String heatId = heatIdJsonArray.getStr(i); - HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); - HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId); - //判断有无托盘 - Assert.isTrue(heatModuleState.getTrayStatus() == 1, heatModuleId + "加热区无托盘"); - //设置加热区目标温度 - deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setTargetTemperature(heatModuleState.getDryTemperature()); - //从系统状态中获取指定加热区设定的烘干温度数值 - double temperature = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).getDryTemperature(); - //开启烘干 - deviceCommandUtilService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, temperature); - //设置加热区状态 正在烘干 - deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setHeatingType(HeatingType.drying); + JSONArray heatModuleCodeJsonArray = cmdDTO.getJSONArrayParam("heatModuleCode"); + + return runAsync(() -> { + for (int i = 0; i < heatModuleCodeJsonArray.size(); i++) { + String heatModuleCodeStr = heatModuleCodeJsonArray.getStr(i); + HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr); + HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode);//获取设定的退火温度 + double targetTemperature = heatModuleState.getAnnealTemperature(); + heatModuleState.setTargetTemperature(targetTemperature);//将退火温度设定为目标温度 + heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, targetTemperature); + deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.drying); //设置加热区状态 正在烘干 } }); } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/DryStopCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/DryStopCommand.java index 446d5f5..1e7cac2 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/DryStopCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/DryStopCommand.java @@ -1,6 +1,5 @@ package com.iflytop.sgs.app.cmd.control; -import cn.hutool.core.lang.Assert; import cn.hutool.json.JSONArray; import com.iflytop.sgs.app.core.BaseCommandHandler; import com.iflytop.sgs.app.model.bo.status.device.HeatModuleState; @@ -29,20 +28,18 @@ public class DryStopCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { - JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatId"); - return runAsync(() -> { - for (int i = 0; i < heatIdJsonArray.size(); i++) { - String heatId = heatIdJsonArray.getStr(i); - HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); - //获取当前加热区状态 - HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId); - //判断当前加热区是否处于烘干状态 - Assert.isTrue(heatModuleState.getHeatingType().equals(HeatingType.drying), heatModuleId + "加热区目前不在烘干状态"); - //关闭烘干 - heatModuleService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId); - //设置加热区状态 烘干结束 - deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setHeatingType(HeatingType.stop); + JSONArray heatModuleCodeJsonArray = cmdDTO.getJSONArrayParam("heatModuleCode"); + + return runAsync(() -> { + for (int i = 0; i < heatModuleCodeJsonArray.size(); i++) { + String heatModuleCodeStr = heatModuleCodeJsonArray.getStr(i); + HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr); + HeatModuleState heatModuleState = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode);//获取设定的退火温度 + double targetTemperature = heatModuleState.getAnnealTemperature(); + heatModuleState.setTargetTemperature(targetTemperature);//将退火温度设定为目标温度 + heatModuleService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode); + deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.stop); //设置加热区状态 正在烘干 } }); }