From 87360634894ba7ff8e890bec1dca4bb818ead9fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Thu, 5 Jun 2025 17:15:56 +0800 Subject: [PATCH] 1 --- .../gd/app/service/crafts/CraftsStepService.java | 52 ++++++++++------------ 1 file changed, 23 insertions(+), 29 deletions(-) diff --git a/src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java b/src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java index f6dd6f7..62b9f1b 100644 --- a/src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java +++ b/src/main/java/com/iflytop/gd/app/service/crafts/CraftsStepService.java @@ -5,6 +5,8 @@ import cn.hutool.json.JSONObject; import com.iflytop.gd.app.core.CraftsDebugGenerator; import com.iflytop.gd.app.model.bo.CraftsStep; import com.iflytop.gd.app.model.bo.Point3D; +import com.iflytop.gd.app.model.bo.status.device.TrayState; +import com.iflytop.gd.app.model.bo.status.device.TubeState; import com.iflytop.gd.app.model.entity.Container; import com.iflytop.gd.app.service.api.ContainerService; import com.iflytop.gd.app.service.api.DevicePositionService; @@ -66,7 +68,6 @@ public class CraftsStepService { * 将托盘从加热区移动至加液区并且添加溶液 */ private boolean addLiquid(HeatModuleCode heatModuleCode, JSONObject params) throws Exception { - //TODO 判断加液区是否有托盘,如果没有托盘的话,判断加热区是否有托盘,然后将其移动至加液区 if((deviceStateService.getDeviceState().getSolutionModule().getTrayStatus() == 0 ) && deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getTrayStatus() == 0) { throw new AppException(ResultCode.CRAFT_NO_TRAY); @@ -75,33 +76,26 @@ public class CraftsStepService { && deviceStateService.getDeviceState().getHeatModuleByCode(heatModuleCode).getTrayStatus() == 1) { moveToSolutionModule(heatModuleCode); } - - JSONArray tubeNums = params.getJSONArray("tubeNums"); - for (int i = 0; i < tubeNums.size(); i++) { - JSONObject tubeSol = tubeNums.getJSONObject(i); - Integer tubeNum = tubeSol.getInt("tubeNum"); - - } - - - JSONArray tubeSolList = params.getJSONArray("tubeSolList"); - for (int i = 0; i < tubeSolList.size(); i++) { - JSONObject tubeSol = tubeSolList.getJSONObject(i); - Integer tubeNum = tubeSol.getInt("tubeNum"); - JSONArray addLiquidList = tubeSol.getJSONArray("addLiquidList"); - for (int j = 0; j < addLiquidList.size(); j++) { - JSONObject addLiquid = addLiquidList.getJSONObject(j); - Long solId = addLiquid.getLong("solId"); - Double volume = addLiquid.getDouble("volume"); - Container container = containerService.getContainerBySolutionId(solId); - if (container == null) { - throw new AppException(ResultCode.CONTAINER_NOT_FOUND);//未找到对应溶液容器 + JSONArray addLiquidList = params.getJSONArray("addLiquidList"); + TrayState trayState = deviceStateService.getDeviceState().getTrayStateByHeatModuleCode(heatModuleCode); + TubeState[] tubeArray = trayState.getTubes(); + for (TubeState tubeState : tubeArray) { + int tubeNum = tubeState.getTubeNum(); + if(tubeNum > 0){ + for (int i = 0; i < addLiquidList.size(); i++) { + JSONObject addLiquid = addLiquidList.getJSONObject(i); + Long containerId = addLiquid.getLong("containerId"); + Double volume = addLiquid.getDouble("volume"); + Container container = containerService.getById(containerId); + if (container == null) { + throw new AppException(ResultCode.CONTAINER_NOT_FOUND);//未找到对应溶液容器 + } + AcidPumpDeviceCode acidPumpDevice = AcidPumpDeviceCode.valueOf(container.getPumpId());//泵 + int scale = container.getScale() == null ? 120 : container.getScale();//系数 + solutionModuleService.dualRobotMovePoint(tubeNum);//移动加液机械臂到指定试管 + CommandFuture deviceCommandFuture = solutionModuleService.acidPumpMoveBy(acidPumpDevice, volume * ((double) scale /100));//添加溶液 + CommandUtil.wait(deviceCommandFuture); } - AcidPumpDeviceCode acidPumpDevice = AcidPumpDeviceCode.valueOf(container.getPumpId());//泵 - int scale = container.getScale() == null ? 120 : container.getScale();//系数 - solutionModuleService.dualRobotMovePoint(tubeNum);//移动加液机械臂到指定试管 - CommandFuture deviceCommandFuture = solutionModuleService.acidPumpMoveBy(acidPumpDevice, volume * ((double) scale /100));//添加溶液 - CommandUtil.wait(deviceCommandFuture); } } solutionModuleService.dualRobotOrigin(); @@ -112,7 +106,7 @@ public class CraftsStepService { * 摇匀操作 */ private boolean shaking(HeatModuleCode heatModuleCode, JSONObject params) throws Exception { - if (deviceStateService.getDeviceState().getSolutionModule().getTrayStatus() == 0) {//TODO 实际应该从传感器获取托盘状态 + if (deviceStateService.getDeviceState().getSolutionModule().getTrayStatus() == 0) { moveToSolutionModule(heatModuleCode); } Integer second = params.getInt("second"); @@ -154,7 +148,7 @@ public class CraftsStepService { moveToSolutionModule(heatModuleCode); } webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatModuleCode.toString(), "开启补光灯", 100.0)); - solutionModuleService.fillLightOpen(100.0);//TODO 开启补光灯 亮度从数据库获取 + solutionModuleService.fillLightOpen(100.0); webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatModuleCode.toString(), "拍照", null)); solutionModuleService.takePhoto();//拍照 webSocketService.pushCraftsDebug(CraftsDebugGenerator.generateJson(heatModuleCode.toString(), "关闭补光灯", null));