From 5573f6bb1cb85504a21139f55ecc73b2a53a2bbb 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 19:11:21 +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=E9=80=80=E7=81=AB=EF=BC=8C=E5=81=9C?= =?UTF-8?q?=E6=AD=A2=E9=80=80=E7=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sgs/app/cmd/control/AnnealStartCommand.java | 29 ++++---------------- .../sgs/app/cmd/control/AnnealStopCommand.java | 22 +++------------ .../sgs/app/cmd/control/CleanStartCommand.java | 4 ++- .../service/device/module/HeatModuleService.java | 32 +++++++++++++++++----- 4 files changed, 38 insertions(+), 49 deletions(-) diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStartCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStartCommand.java index cae686b..7909479 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStartCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStartCommand.java @@ -1,7 +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; import com.iflytop.sgs.app.model.dto.CmdDTO; @@ -10,7 +8,6 @@ import com.iflytop.sgs.app.service.device.module.HeatModuleService; import com.iflytop.sgs.common.annotation.CommandMapping; import com.iflytop.sgs.common.enums.HeatModuleCode; import com.iflytop.sgs.common.enums.HeatingType; -import com.iflytop.sgs.common.exception.AppException; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -30,27 +27,13 @@ public class AnnealStartCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { - JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatModuleCode"); - + HeatModuleCode heatModuleCode = HeatModuleCode.heat_module_04; 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.getAnnealTemperature()); - //从系统状态中获取指定加热区设定的退火温度数值 - double temperature = deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).getAnnealTemperature(); - //开启退火 - heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, temperature); - //设置加热区状态 正在退火 - deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setHeatingType(HeatingType.annealing); - - } + 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.annealing); }); } } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStopCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStopCommand.java index 912f088..a580500 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStopCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/AnnealStopCommand.java @@ -1,9 +1,6 @@ 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; import com.iflytop.sgs.app.model.dto.CmdDTO; import com.iflytop.sgs.app.service.device.DeviceStateService; import com.iflytop.sgs.app.service.device.module.HeatModuleService; @@ -17,7 +14,7 @@ import org.springframework.stereotype.Component; import java.util.concurrent.CompletableFuture; /** - * 结束退火 + * 停止退火 */ @Slf4j @Component @@ -29,21 +26,10 @@ public class AnnealStopCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { - JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatId"); + HeatModuleCode heatModuleCode = HeatModuleCode.heat_module_04; 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.annealing), heatModuleId + "加热区目前不在退火状态"); - //关闭加热 - heatModuleService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId); - //设置加热区状态 退火结束 - deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setHeatingType(HeatingType.stop); - } + heatModuleService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode); + deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setHeatingType(HeatingType.stop); }); } } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java index 7da2f91..fdeef95 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/CleanStartCommand.java @@ -24,7 +24,7 @@ import org.springframework.stereotype.Component; import java.util.concurrent.CompletableFuture; /** - * 开始清洗 todo wmy 需要改 + * 开始清洗 */ @Slf4j @Component @@ -39,6 +39,8 @@ public class CleanStartCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { + //清洗次数 + JSONArray jsonArray=cmdDTO.getJSONArrayParam("index"); String heatId = cmdDTO.getStringParam("heatId"); HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); diff --git a/src/main/java/com/iflytop/sgs/app/service/device/module/HeatModuleService.java b/src/main/java/com/iflytop/sgs/app/service/device/module/HeatModuleService.java index 6528db8..ff37153 100644 --- a/src/main/java/com/iflytop/sgs/app/service/device/module/HeatModuleService.java +++ b/src/main/java/com/iflytop/sgs/app/service/device/module/HeatModuleService.java @@ -79,32 +79,50 @@ public class HeatModuleService { return devicePosition.getPoint3D(); } + /** + * 指定加热模块开启散热风扇 + */ + public void fanStart(HeatModuleCode heatModuleCode) throws Exception { + fanStart(null, null, heatModuleCode); + } - public void fanStart(String cmdId, String cmdCode, HeatModuleCode heatModuleId) throws Exception { + /** + * 指定加热模块开启散热风扇 + */ + public void fanStart(String cmdId, String cmdCode, HeatModuleCode heatModuleCode) throws Exception { DeviceCommandBundle deviceCommand; - switch (heatModuleId) { + switch (heatModuleCode) { case heat_module_01 -> deviceCommand = DeviceCommandGenerator.fan1Open(); case heat_module_02 -> deviceCommand = DeviceCommandGenerator.fan2Open(); case heat_module_03 -> deviceCommand = DeviceCommandGenerator.fan3Open(); case heat_module_04 -> deviceCommand = DeviceCommandGenerator.fan4Open(); - default -> throw new RuntimeException("heatId 未找到"); + default -> throw new RuntimeException("heatModuleCode 未找到"); } CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); CommandUtil.wait(deviceCommandFuture); - } + /** + * 指定加热模块关闭散热风扇 + */ + public void fanClose(HeatModuleCode heatModuleCode) throws Exception { + fanClose(null, null, heatModuleCode); + } - public void fanClose(String cmdId, String cmdCode, HeatModuleCode heatModuleId) throws Exception { + /** + * 指定加热模块关闭散热风扇 + */ + public void fanClose(String cmdId, String cmdCode, HeatModuleCode heatModuleCode) throws Exception { DeviceCommandBundle deviceCommand; - switch (heatModuleId) { + switch (heatModuleCode) { case heat_module_01 -> deviceCommand = DeviceCommandGenerator.fan1Close(); case heat_module_02 -> deviceCommand = DeviceCommandGenerator.fan2Close(); case heat_module_03 -> deviceCommand = DeviceCommandGenerator.fan3Close(); case heat_module_04 -> deviceCommand = DeviceCommandGenerator.fan4Close(); - default -> throw new RuntimeException("heatId 未找到"); + default -> throw new RuntimeException("heatModuleCode 未找到"); } CommandFuture deviceCommandFuture = deviceCommandService.sendCommand(cmdId, cmdCode, deviceCommand); CommandUtil.wait(deviceCommandFuture); } + }