Browse Source

调整业务指令开始烘干,结束烘干

master
白凤吉 2 months ago
parent
commit
9511a83d9a
  1. 31
      src/main/java/com/iflytop/sgs/app/cmd/control/DryStartCommand.java
  2. 25
      src/main/java/com/iflytop/sgs/app/cmd/control/DryStopCommand.java

31
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<Void> 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); //设置加热区状态 正在烘干
}
});
}

25
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<Void> 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); //设置加热区状态 正在烘干
}
});
}

Loading…
Cancel
Save