|
@ -1,5 +1,6 @@ |
|
|
package com.iflytop.gd.app.command.control; |
|
|
package com.iflytop.gd.app.command.control; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.json.JSONArray; |
|
|
import com.iflytop.gd.app.core.BaseCommandHandler; |
|
|
import com.iflytop.gd.app.core.BaseCommandHandler; |
|
|
import com.iflytop.gd.app.model.dto.CmdDTO; |
|
|
import com.iflytop.gd.app.model.dto.CmdDTO; |
|
|
import com.iflytop.gd.app.service.api.DevicePositionService; |
|
|
import com.iflytop.gd.app.service.api.DevicePositionService; |
|
@ -27,24 +28,29 @@ public class TrayUpCommand extends BaseCommandHandler { |
|
|
private final HeatModuleService heatModuleService; |
|
|
private final HeatModuleService heatModuleService; |
|
|
private final DevicePositionService devicePositionService; |
|
|
private final DevicePositionService devicePositionService; |
|
|
private final DeviceStateService deviceStateService; |
|
|
private final DeviceStateService deviceStateService; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|
|
public CompletableFuture<Void> handle(CmdDTO cmdDTO) { |
|
|
if (deviceStateService.getCommandMutexState().get().isMoveToHeatAreaCommandExecuting() |
|
|
if (deviceStateService.getCommandMutexState().get().isMoveToHeatAreaCommandExecuting() |
|
|
|| deviceStateService.getCommandMutexState().get().isMoveToSolutionAreaCommandExecuting()) { |
|
|
|| deviceStateService.getCommandMutexState().get().isMoveToSolutionAreaCommandExecuting()) { |
|
|
throw new AppException(ResultCode.CMD_BUSY); |
|
|
throw new AppException(ResultCode.CMD_BUSY); |
|
|
} |
|
|
} |
|
|
String heatId = cmdDTO.getStringParam("heatId"); |
|
|
|
|
|
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); |
|
|
|
|
|
|
|
|
JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatId"); |
|
|
//获取加热位抬升托盘位置 |
|
|
//获取加热位抬升托盘位置 |
|
|
double trayLift = devicePositionService.getPosition(DevicePositionCode.trayLift).getDistance(); |
|
|
double trayLift = devicePositionService.getPosition(DevicePositionCode.trayLift).getDistance(); |
|
|
return runAsync(() -> { |
|
|
return runAsync(() -> { |
|
|
try { |
|
|
|
|
|
//抬升加热位托盘 |
|
|
|
|
|
heatModuleService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, trayLift); |
|
|
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(1); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("抬起托盘失败", e); |
|
|
|
|
|
|
|
|
for (int i = 0; i < heatIdJsonArray.size(); i++) { |
|
|
|
|
|
String heatId = heatIdJsonArray.getStr(i); |
|
|
|
|
|
HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); |
|
|
|
|
|
|
|
|
|
|
|
CompletableFuture.runAsync(() -> { |
|
|
|
|
|
try { |
|
|
|
|
|
//抬升加热位托盘 |
|
|
|
|
|
heatModuleService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, trayLift); |
|
|
|
|
|
deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).setTrayUp(1); |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
log.error("抬起托盘失败", e); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|