Browse Source

调整业务指令散热开、散热关

master
白凤吉 2 months ago
parent
commit
87a005b184
  1. 20
      src/main/java/com/iflytop/sgs/app/cmd/control/FanStartCommand.java
  2. 20
      src/main/java/com/iflytop/sgs/app/cmd/control/FanStopCommand.java

20
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<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.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);
}
});
}

20
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<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);
}
});
}

Loading…
Cancel
Save