From 6f522dd93cca3aaa162393a8258ed7ae1236b014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Sun, 23 Mar 2025 23:14:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=9B=9E=E5=8E=9F=E7=82=B9=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=81=9C=E6=AD=A2=E6=B8=85?= =?UTF-8?q?=E6=B4=97=E5=81=9C=E6=AD=A2=E5=9F=BA=E8=B4=A8=E9=A2=84=E5=85=85?= =?UTF-8?q?=E4=B9=9F=E5=BA=94=E5=BD=93=E5=81=9C=E6=AD=A2xyz=E8=BD=B4?= =?UTF-8?q?=E7=A7=BB=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qyft/ms/app/controller/SelfTestController.java | 27 +++++++++++++++++++++- .../ms/app/front/cmd/business/DeviceSelfTest.java | 4 ++-- .../cmd/business/NozzlePipelinePreFillStop.java | 8 +++++++ .../cmd/business/SyringePipelineWashStop.java | 8 +++++++ 4 files changed, 44 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/qyft/ms/app/controller/SelfTestController.java b/src/main/java/com/qyft/ms/app/controller/SelfTestController.java index 5247b79..80fef5f 100644 --- a/src/main/java/com/qyft/ms/app/controller/SelfTestController.java +++ b/src/main/java/com/qyft/ms/app/controller/SelfTestController.java @@ -1,8 +1,13 @@ package com.qyft.ms.app.controller; +import com.qyft.ms.app.device.status.DeviceStatus; import com.qyft.ms.app.model.vo.SelfTestVO; import com.qyft.ms.app.service.SelfTestService; +import com.qyft.ms.system.common.device.command.CommandFuture; +import com.qyft.ms.system.common.device.command.DeviceCommandGenerator; import com.qyft.ms.system.common.result.Result; +import com.qyft.ms.system.model.bo.DeviceCommand; +import com.qyft.ms.system.service.device.DeviceCommandService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; @@ -11,6 +16,10 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + @Tag(name = "自检") @RestController @RequestMapping("/api/self-test") @@ -18,10 +27,26 @@ import org.springframework.web.bind.annotation.RestController; @Slf4j public class SelfTestController { private final SelfTestService selfTestService; + private final DeviceCommandService deviceCommandService; + private final DeviceStatus deviceStatus; @Operation(summary = "获取自检状态") @GetMapping("/") - public Result getSelfTestStatus() { + public Result getSelfTestStatus() throws ExecutionException, InterruptedException, TimeoutException { + DeviceCommand overallDeviceStatusGetCommand = DeviceCommandGenerator.overallDeviceStatusGet(); + CommandFuture overallDeviceStatusGetCommandFuture = deviceCommandService.sendCommandNoFront(overallDeviceStatusGetCommand); + overallDeviceStatusGetCommandFuture.getResponseFuture().get(5, TimeUnit.SECONDS); + boolean xAxisAtOrigin = overallDeviceStatusGetCommandFuture.getResponseResult().getJSONObject("data").getBool("xAxisAtOrigin"); + boolean yAxisAtOrigin = overallDeviceStatusGetCommandFuture.getResponseResult().getJSONObject("data").getBool("yAxisAtOrigin"); + boolean zAxisAtOrigin = overallDeviceStatusGetCommandFuture.getResponseResult().getJSONObject("data").getBool("zAxisAtOrigin"); + + selfTestService.getSelfTestStatus().setXAxisAtOrigin(xAxisAtOrigin); + selfTestService.getSelfTestStatus().setYAxisAtOrigin(yAxisAtOrigin); + selfTestService.getSelfTestStatus().setZAxisAtOrigin(zAxisAtOrigin); + + if (xAxisAtOrigin && yAxisAtOrigin && zAxisAtOrigin) { + deviceStatus.setSelfTestCompleted(true); + } return Result.success(selfTestService.getSelfTestStatus()); } diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/DeviceSelfTest.java b/src/main/java/com/qyft/ms/app/front/cmd/business/DeviceSelfTest.java index 9dc2d79..b2772f9 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/DeviceSelfTest.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/DeviceSelfTest.java @@ -30,7 +30,7 @@ public class DeviceSelfTest extends BaseCommandHandler { @Override public CompletableFuture handle(FrontCmdControlForm form) { return runAsync(() -> { - DeviceCommand overallDeviceStatusGetCommand = DeviceCommandGenerator.overallDeviceStatusGet(); + /* DeviceCommand overallDeviceStatusGetCommand = DeviceCommandGenerator.overallDeviceStatusGet(); CommandFuture overallDeviceStatusGetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), overallDeviceStatusGetCommand); commandWait(overallDeviceStatusGetCommandFuture); @@ -45,7 +45,7 @@ public class DeviceSelfTest extends BaseCommandHandler { if (xAxisAtOrigin && yAxisAtOrigin && zAxisAtOrigin) { deviceStatus.setSelfTestCompleted(true); } - +*/ /* DeviceCommand overallDeviceStatusGetCommand = DeviceCommandGenerator.overallDeviceStatusGet(); CommandFuture overallDeviceStatusGetCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), overallDeviceStatusGetCommand); commandWait(overallDeviceStatusGetCommandFuture); diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFillStop.java b/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFillStop.java index 4fe6837..3bdcaca 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFillStop.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/NozzlePipelinePreFillStop.java @@ -29,6 +29,14 @@ public class NozzlePipelinePreFillStop extends BaseCommandHandler { @Override public CompletableFuture handle(FrontCmdControlForm form) { return runAsync(() -> { + DeviceCommand motorXStopCommand = DeviceCommandGenerator.motorXStop(); //x轴停止移动 + DeviceCommand motorYStopCommand = DeviceCommandGenerator.motorYStop(); //y轴停止移动 + DeviceCommand motorZStopCommand = DeviceCommandGenerator.motorZStop(); //z轴停止移动 + CommandFuture motorXStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXStopCommand); + CommandFuture motorYStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorYStopCommand); + CommandFuture motorZStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZStopCommand); + commandWait(motorXStopCommandFuture, motorYStopCommandFuture, motorZStopCommandFuture); + //1.停止推动注射泵 DeviceCommand syringePumpStopCommand = DeviceCommandGenerator.syringePumpStop();//停止推动注射泵 CommandFuture syringePumpStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), syringePumpStopCommand); diff --git a/src/main/java/com/qyft/ms/app/front/cmd/business/SyringePipelineWashStop.java b/src/main/java/com/qyft/ms/app/front/cmd/business/SyringePipelineWashStop.java index f3030ed..d395f43 100644 --- a/src/main/java/com/qyft/ms/app/front/cmd/business/SyringePipelineWashStop.java +++ b/src/main/java/com/qyft/ms/app/front/cmd/business/SyringePipelineWashStop.java @@ -29,6 +29,14 @@ public class SyringePipelineWashStop extends BaseCommandHandler { @Override public CompletableFuture handle(FrontCmdControlForm form) { return runAsync(() -> { + DeviceCommand motorXStopCommand = DeviceCommandGenerator.motorXStop(); //x轴停止移动 + DeviceCommand motorYStopCommand = DeviceCommandGenerator.motorYStop(); //y轴停止移动 + DeviceCommand motorZStopCommand = DeviceCommandGenerator.motorZStop(); //z轴停止移动 + CommandFuture motorXStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorXStopCommand); + CommandFuture motorYStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorYStopCommand); + CommandFuture motorZStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), motorZStopCommand); + commandWait(motorXStopCommandFuture, motorYStopCommandFuture, motorZStopCommandFuture); + //1.停止推动注射泵 DeviceCommand syringePumpStopCommand = DeviceCommandGenerator.syringePumpStop(); //停止推动注射泵 CommandFuture syringePumpStopCommandFuture = deviceCommandService.sendCommand(form.getCmdId(), form.getCmdCode(), syringePumpStopCommand);