From 4804f805eba0b4390b88266ad85ebf038bc73500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Tue, 15 Jul 2025 18:38:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=96=B7=E6=B6=82=E8=B7=AF=E7=BA=BF?= =?UTF-8?q?=E4=B8=AD=E6=89=8D=E8=AE=B0=E5=BD=95=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/front/cmd/business/MatrixSprayPause.java | 28 +++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayPause.java b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayPause.java index 9853527..f7d4113 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayPause.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/MatrixSprayPause.java @@ -38,8 +38,10 @@ public class MatrixSprayPause extends BaseCommandHandler { @Override public CompletableFuture handle(FrontCmdControlForm form) { SprayTask sprayTask = SprayTask.getInstance(); + if(sprayTask.isPaused()){ + throw new RuntimeException("设备暂停中"); + } sprayTask.setPaused(true);//设置已暂停 - deviceStatus.setPaused(true); try { sprayTaskExecutor.stopTask();//终止喷涂任务线程 @@ -59,16 +61,18 @@ public class MatrixSprayPause extends BaseCommandHandler { CommandFuture motorZStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZStopCommand); commandWait(motorXStopCommandFuture, motorYStopCommandFuture, motorZStopCommandFuture); - //记录当前位置 - DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet(); // 生成获得电机XYZ相对原点坐标指令 - CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXyzPositionGetCommand); - commandWait(motorXyzPositionGetCommandFuture); - JSONObject motorXyzPositionGetCommandDeviceResult = motorXyzPositionGetCommandFuture.getResponseResult(); - Double xAxisPosition = motorXyzPositionGetCommandDeviceResult.getJSONObject("data").getDouble("xAxisPosition"); - Double yAxisPosition = motorXyzPositionGetCommandDeviceResult.getJSONObject("data").getDouble("yAxisPosition"); - Double zAxisPosition = motorXyzPositionGetCommandDeviceResult.getJSONObject("data").getDouble("zAxisPosition"); - Point3D point3D = new Point3D(xAxisPosition, yAxisPosition, zAxisPosition); - sprayTask.setCurrentPausedPoint(point3D); + if(sprayTask.getCurrentStep() > 0){ + //记录当前位置 + DeviceCommand motorXyzPositionGetCommand = DeviceCommandGenerator.motorXyzPositionGet(); // 生成获得电机XYZ相对原点坐标指令 + CommandFuture motorXyzPositionGetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXyzPositionGetCommand); + commandWait(motorXyzPositionGetCommandFuture); + JSONObject motorXyzPositionGetCommandDeviceResult = motorXyzPositionGetCommandFuture.getResponseResult(); + Double xAxisPosition = motorXyzPositionGetCommandDeviceResult.getJSONObject("data").getDouble("xAxisPosition"); + Double yAxisPosition = motorXyzPositionGetCommandDeviceResult.getJSONObject("data").getDouble("yAxisPosition"); + Double zAxisPosition = motorXyzPositionGetCommandDeviceResult.getJSONObject("data").getDouble("zAxisPosition"); + Point3D point3D = new Point3D(xAxisPosition, yAxisPosition, zAxisPosition); + sprayTask.setCurrentPausedPoint(point3D); + } OperationLog operationLog = operationLogService.getById(sprayTask.getOperationLogId()); operationLog.setStatus(2); @@ -84,6 +88,8 @@ public class MatrixSprayPause extends BaseCommandHandler { commandWait(motorXOriginCommandFuture, motorYOriginCommandFuture, motorZOriginCommandFuture); } catch (Exception e) { throw new RuntimeException(e); + }finally { + deviceStatus.setPaused(true); } return runAsync(() -> {