From 87a005b1849b788306a7f2cfb1bee696ea7148c2 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:19:45 +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=E6=95=A3=E7=83=AD=E5=BC=80=E3=80=81=E6=95=A3=E7=83=AD?= =?UTF-8?q?=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iflytop/sgs/app/cmd/control/FanStartCommand.java | 20 ++++++++------------ .../iflytop/sgs/app/cmd/control/FanStopCommand.java | 20 ++++++++------------ 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/FanStartCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/FanStartCommand.java index 4f2adfb..44f5999 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/FanStartCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/FanStartCommand.java @@ -1,9 +1,7 @@ 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; @@ -28,17 +26,15 @@ public class FanStartCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { - JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatId"); + + JSONArray heatModuleCodeJsonArray = cmdDTO.getJSONArrayParam("heatModuleCode"); + 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.isFanOpen(),heatModuleId+"加热区 风扇已打开"); - heatModuleService.fanStart(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId); - deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setFanOpen(true); + for (int i = 0; i < heatModuleCodeJsonArray.size(); i++) { + String heatModuleCodeStr = heatModuleCodeJsonArray.getStr(i); + HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr); + heatModuleService.fanStart(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode); + deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setFanOpen(true); } }); } diff --git a/src/main/java/com/iflytop/sgs/app/cmd/control/FanStopCommand.java b/src/main/java/com/iflytop/sgs/app/cmd/control/FanStopCommand.java index 682f432..2ee73d0 100644 --- a/src/main/java/com/iflytop/sgs/app/cmd/control/FanStopCommand.java +++ b/src/main/java/com/iflytop/sgs/app/cmd/control/FanStopCommand.java @@ -1,9 +1,7 @@ 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; @@ -28,17 +26,15 @@ public class FanStopCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { - JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatId"); + + JSONArray heatModuleCodeJsonArray = cmdDTO.getJSONArrayParam("heatModuleCode"); + 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.isFanOpen(),heatModuleId+"加热区 风扇已关闭"); - heatModuleService.fanClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId); - deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleId).setFanOpen(false); + for (int i = 0; i < heatModuleCodeJsonArray.size(); i++) { + String heatModuleCodeStr = heatModuleCodeJsonArray.getStr(i); + HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatModuleCodeStr); + heatModuleService.fanClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode); + deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setFanOpen(true); } }); }