|
|
@ -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<Void> 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); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|