diff --git a/src/main/java/com/iflytop/gd/app/cmd/FilledSolutionStartCommand.java b/src/main/java/com/iflytop/gd/app/cmd/FilledSolutionStartCommand.java index ab72815..c7dc5a7 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/FilledSolutionStartCommand.java +++ b/src/main/java/com/iflytop/gd/app/cmd/FilledSolutionStartCommand.java @@ -1,20 +1,16 @@ package com.iflytop.gd.app.cmd; +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.model.entity.Container; import com.iflytop.gd.app.service.ContainerService; import com.iflytop.gd.app.service.DeviceCommandUtilService; import com.iflytop.gd.common.annotation.CommandMapping; import com.iflytop.gd.common.enums.AcidPumpDeviceCode; -import com.iflytop.gd.hardware.drivers.TricolorLightDriver; -import com.iflytop.gd.hardware.exception.HardwareException; -import com.iflytop.gd.hardware.type.MId; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; -import java.util.Arrays; import java.util.concurrent.CompletableFuture; /** @@ -31,18 +27,13 @@ public class FilledSolutionStartCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { return runAsync(() -> { - String ids = cmdDTO.getStringParam("list"); - - Long[] idArray = Arrays.stream(ids.split(",")) - .map(String::trim) - .map(Long::valueOf) - .toArray(Long[]::new); - for (Long id : idArray) { - + JSONArray idJsonArray = cmdDTO.getJSONArrayParam("list"); + for (int i = 0; i < idJsonArray.size(); i++) { + String idStr = idJsonArray.getStr(i); CompletableFuture.runAsync(() -> { try { - AcidPumpDeviceCode acidPumpDevice = containerService.getPumpByContainerId(id); - deviceCommandUtilService.acidPumpMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), acidPumpDevice, 99999);//添加溶液 + AcidPumpDeviceCode acidPumpDevice = containerService.getPumpByContainerId(Long.parseLong(idStr)); + deviceCommandUtilService.acidPumpFilledSolutionStart(cmdDTO.getCommandId(), cmdDTO.getCommand(), acidPumpDevice); } catch (Exception e) { log.error("预充失败", e); } diff --git a/src/main/java/com/iflytop/gd/app/cmd/FilledSolutionStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/FilledSolutionStopCommand.java index fb8d775..39fe475 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/FilledSolutionStopCommand.java +++ b/src/main/java/com/iflytop/gd/app/cmd/FilledSolutionStopCommand.java @@ -1,5 +1,6 @@ package com.iflytop.gd.app.cmd; +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.ContainerService; @@ -27,20 +28,16 @@ public class FilledSolutionStopCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { return runAsync(() -> { - String ids = cmdDTO.getStringParam("list"); - - Long[] idArray = Arrays.stream(ids.split(",")) - .map(String::trim) - .map(Long::valueOf) - .toArray(Long[]::new); - for (Long id : idArray) { + JSONArray idJsonArray = cmdDTO.getJSONArrayParam("list"); + for (int i = 0; i < idJsonArray.size(); i++) { + String idStr = idJsonArray.getStr(i); CompletableFuture.runAsync(() -> { try { - AcidPumpDeviceCode acidPumpDevice = containerService.getPumpByContainerId(id); - deviceCommandUtilService.acidPumpMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), acidPumpDevice, 99999);//添加溶液 + AcidPumpDeviceCode acidPumpDevice = containerService.getPumpByContainerId(Long.parseLong(idStr)); + deviceCommandUtilService.acidPumpStop(cmdDTO.getCommandId(), cmdDTO.getCommand(), acidPumpDevice); } catch (Exception e) { - log.error("预充失败", e); + log.error("停止预充失败", e); } }); }