diff --git a/src/main/java/com/iflytop/gd/app/cmd/SolutionAddCommand.java b/src/main/java/com/iflytop/gd/app/cmd/SolutionAddCommand.java index 532832a..7f29f5f 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/SolutionAddCommand.java +++ b/src/main/java/com/iflytop/gd/app/cmd/SolutionAddCommand.java @@ -15,6 +15,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import java.util.Arrays; import java.util.concurrent.CompletableFuture; /** @@ -37,19 +38,23 @@ public class SolutionAddCommand extends BaseCommandHandler { JSONArray dataList = (JSONArray) cmdDTO.getParams().get("dataList"); for (int i = 0; i < dataList.size(); i++) {//遍历前端传入的加液配置 JSONObject tubeSol = dataList.getJSONObject(i); - Integer tubeNum = tubeSol.getInt("tubeNum");//获取试管编号 + String tubeNum = tubeSol.getStr("tubeNum");//获取试管编号 + int[] tubeNums = Arrays.stream(tubeNum.split(",")) + .mapToInt(s -> Integer.parseInt(s.trim())) + .toArray(); JSONArray solutionList = tubeSol.getJSONArray("solutionList"); - for (int j = 0; j < solutionList.size(); j++) {//遍历该试管应该加哪种液 - JSONObject addSolution = solutionList.getJSONObject(j); - Long solId = addSolution.getLong("solId"); - Double volume = addSolution.getDouble("volume"); - AcidPumpDeviceCode acidPumpDevice = containerService.getPumpBySolutionId(solId);//获取溶液对应的泵 - if (acidPumpDevice == null) { - throw new AppException(ResultCode.CRAFT_CONTAINER_NOT_FOUND);//工艺未找到对应溶液容器 + for (int num : tubeNums) { + for (int k = 0; k < solutionList.size(); k++) { + JSONObject addSolution = solutionList.getJSONObject(k); + Long solId = addSolution.getLong("solId"); + Double volume = addSolution.getDouble("volume"); + AcidPumpDeviceCode acidPumpDevice = containerService.getPumpBySolutionId(solId);//获取溶液对应的泵 + if (acidPumpDevice == null) { + throw new AppException(ResultCode.CRAFT_CONTAINER_NOT_FOUND);//工艺未找到对应溶液容器 + } + deviceCommandUtilService.dualRobotMovePoint(num);//移动加液机械臂到指定试管点位 + deviceCommandUtilService.acidPumpMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), acidPumpDevice, volume);//添加溶液 } - deviceCommandUtilService.dualRobotMovePoint(tubeNum);//移动加液机械臂到指定试管点位 - deviceCommandUtilService.acidPumpMoveBy(cmdDTO.getCommandId(), - cmdDTO.getCommand(), acidPumpDevice, volume);//添加溶液 } } deviceCommandUtilService.dualRobotOrigin();