diff --git a/src/main/java/com/iflytop/gd/app/command/control/TrayUpCommand.java b/src/main/java/com/iflytop/gd/app/command/control/TrayUpCommand.java index 5c69bfb..e097e75 100644 --- a/src/main/java/com/iflytop/gd/app/command/control/TrayUpCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/control/TrayUpCommand.java @@ -1,5 +1,6 @@ package com.iflytop.gd.app.command.control; +import cn.hutool.json.JSONArray; import com.iflytop.gd.app.core.BaseCommandHandler; import com.iflytop.gd.app.model.dto.CmdDTO; import com.iflytop.gd.app.service.api.DevicePositionService; @@ -27,24 +28,29 @@ public class TrayUpCommand extends BaseCommandHandler { private final HeatModuleService heatModuleService; private final DevicePositionService devicePositionService; private final DeviceStateService deviceStateService; - @Override public CompletableFuture handle(CmdDTO cmdDTO) { if (deviceStateService.getCommandMutexState().get().isMoveToHeatAreaCommandExecuting() || deviceStateService.getCommandMutexState().get().isMoveToSolutionAreaCommandExecuting()) { 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(); 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); + } + }); } }); }