Browse Source

feat:添加溶液指令支持多试管添加一种溶液

master
白凤吉 3 months ago
parent
commit
1b89c17c9e
  1. 17
      src/main/java/com/iflytop/gd/app/cmd/SolutionAddCommand.java

17
src/main/java/com/iflytop/gd/app/cmd/SolutionAddCommand.java

@ -15,6 +15,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
/** /**
@ -37,19 +38,23 @@ public class SolutionAddCommand extends BaseCommandHandler {
JSONArray dataList = (JSONArray) cmdDTO.getParams().get("dataList"); JSONArray dataList = (JSONArray) cmdDTO.getParams().get("dataList");
for (int i = 0; i < dataList.size(); i++) {//遍历前端传入的加液配置 for (int i = 0; i < dataList.size(); i++) {//遍历前端传入的加液配置
JSONObject tubeSol = dataList.getJSONObject(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"); JSONArray solutionList = tubeSol.getJSONArray("solutionList");
for (int j = 0; j < solutionList.size(); j++) {//遍历该试管应该加哪种液
JSONObject addSolution = solutionList.getJSONObject(j);
for (int num : tubeNums) {
for (int k = 0; k < solutionList.size(); k++) {
JSONObject addSolution = solutionList.getJSONObject(k);
Long solId = addSolution.getLong("solId"); Long solId = addSolution.getLong("solId");
Double volume = addSolution.getDouble("volume"); Double volume = addSolution.getDouble("volume");
AcidPumpDeviceCode acidPumpDevice = containerService.getPumpBySolutionId(solId);//获取溶液对应的泵 AcidPumpDeviceCode acidPumpDevice = containerService.getPumpBySolutionId(solId);//获取溶液对应的泵
if (acidPumpDevice == null) { if (acidPumpDevice == null) {
throw new AppException(ResultCode.CRAFT_CONTAINER_NOT_FOUND);//工艺未找到对应溶液容器 throw new AppException(ResultCode.CRAFT_CONTAINER_NOT_FOUND);//工艺未找到对应溶液容器
} }
deviceCommandUtilService.dualRobotMovePoint(tubeNum);//移动加液机械臂到指定试管点位
deviceCommandUtilService.acidPumpMoveBy(cmdDTO.getCommandId(),
cmdDTO.getCommand(), acidPumpDevice, volume);//添加溶液
deviceCommandUtilService.dualRobotMovePoint(num);//移动加液机械臂到指定试管点位
deviceCommandUtilService.acidPumpMoveBy(cmdDTO.getCommandId(), cmdDTO.getCommand(), acidPumpDevice, volume);//添加溶液
}
} }
} }
deviceCommandUtilService.dualRobotOrigin(); deviceCommandUtilService.dualRobotOrigin();

Loading…
Cancel
Save