From 191d08e39e796efe2a9a41d18b8a26d532308d11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Fri, 13 Jun 2025 10:28:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=BD=93=E5=B7=A5=E8=89=BA=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E3=80=81=E5=81=9C=E6=AD=A2=E7=8A=B6=E6=80=81=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=8F=AF=E4=BB=A5=E8=BF=9B=E8=A1=8C=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iflytop/gd/app/command/control/FanStartCommand.java | 6 +++++- .../iflytop/gd/app/command/control/FanStopCommand.java | 6 +++++- .../gd/app/command/control/HeatStartCommand.java | 6 +++++- .../iflytop/gd/app/command/control/HeatStopCommand.java | 6 +++++- .../gd/app/command/control/ShakeStartCommand.java | 17 +++++++++++++---- .../gd/app/command/control/ShakeStopCommand.java | 6 +++++- .../gd/app/command/control/SolutionAddCommand.java | 6 +++++- .../iflytop/gd/app/command/control/TrayDownCommand.java | 8 ++++++-- .../iflytop/gd/app/command/control/TrayUpCommand.java | 8 ++++++-- .../gd/app/command/control/WarmUpStartCommand.java | 6 +++++- .../com/iflytop/gd/app/controller/PhotoController.java | 2 +- 11 files changed, 61 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/iflytop/gd/app/command/control/FanStartCommand.java b/src/main/java/com/iflytop/gd/app/command/control/FanStartCommand.java index 94bbc3c..70f6db6 100644 --- a/src/main/java/com/iflytop/gd/app/command/control/FanStartCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/control/FanStartCommand.java @@ -7,6 +7,7 @@ import com.iflytop.gd.app.service.device.DeviceStateService; import com.iflytop.gd.app.service.device.module.HeatModuleService; import com.iflytop.gd.common.annotation.CommandMapping; import com.iflytop.gd.common.enums.HeatModuleCode; +import com.iflytop.gd.common.enums.automaton.CraftStates; import com.iflytop.gd.common.exception.AppException; import com.iflytop.gd.common.result.ResultCode; import lombok.RequiredArgsConstructor; @@ -32,7 +33,10 @@ public class FanStartCommand extends BaseCommandHandler { HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); TrayState trayState = deviceStateService.getDeviceState().getTrayStateByHeatModuleCode(heatModuleCode); if (trayState != null && trayState.getCrafts() != null) { - throw new AppException(ResultCode.CRAFT_RUNNING); + CraftStates craftStates = trayState.getCrafts().getState(); + if(!(CraftStates.ERROR.equals(craftStates) || CraftStates.STOPPED.equals(craftStates))){ + throw new AppException(ResultCode.CRAFT_RUNNING); + } } return runAsync(() -> { heatModuleService.fanStart(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode); diff --git a/src/main/java/com/iflytop/gd/app/command/control/FanStopCommand.java b/src/main/java/com/iflytop/gd/app/command/control/FanStopCommand.java index a684242..b347608 100644 --- a/src/main/java/com/iflytop/gd/app/command/control/FanStopCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/control/FanStopCommand.java @@ -7,6 +7,7 @@ import com.iflytop.gd.app.service.device.DeviceStateService; import com.iflytop.gd.app.service.device.module.HeatModuleService; import com.iflytop.gd.common.annotation.CommandMapping; import com.iflytop.gd.common.enums.HeatModuleCode; +import com.iflytop.gd.common.enums.automaton.CraftStates; import com.iflytop.gd.common.exception.AppException; import com.iflytop.gd.common.result.ResultCode; import lombok.RequiredArgsConstructor; @@ -32,7 +33,10 @@ public class FanStopCommand extends BaseCommandHandler { HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); TrayState trayState = deviceStateService.getDeviceState().getTrayStateByHeatModuleCode(heatModuleCode); if (trayState != null && trayState.getCrafts() != null) { - throw new AppException(ResultCode.CRAFT_RUNNING); + CraftStates craftStates = trayState.getCrafts().getState(); + if(!(CraftStates.ERROR.equals(craftStates) || CraftStates.STOPPED.equals(craftStates))){ + throw new AppException(ResultCode.CRAFT_RUNNING); + } } return runAsync(() -> { heatModuleService.fanClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode); diff --git a/src/main/java/com/iflytop/gd/app/command/control/HeatStartCommand.java b/src/main/java/com/iflytop/gd/app/command/control/HeatStartCommand.java index 60fcf66..f6fa160 100644 --- a/src/main/java/com/iflytop/gd/app/command/control/HeatStartCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/control/HeatStartCommand.java @@ -9,6 +9,7 @@ import com.iflytop.gd.app.service.device.module.HeatModuleService; import com.iflytop.gd.common.annotation.CommandMapping; import com.iflytop.gd.common.enums.HeatModuleCode; import com.iflytop.gd.common.enums.HeatingType; +import com.iflytop.gd.common.enums.automaton.CraftStates; import com.iflytop.gd.common.enums.data.DevicePositionCode; import com.iflytop.gd.common.exception.AppException; import com.iflytop.gd.common.result.ResultCode; @@ -41,7 +42,10 @@ public class HeatStartCommand extends BaseCommandHandler { HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); TrayState trayState = deviceStateService.getDeviceState().getTrayStateByHeatModuleCode(heatModuleCode); if (trayState != null && trayState.getCrafts() != null) { - throw new AppException(ResultCode.CRAFT_RUNNING); + CraftStates craftStates = trayState.getCrafts().getState(); + if(!(CraftStates.ERROR.equals(craftStates) || CraftStates.STOPPED.equals(craftStates))){ + throw new AppException(ResultCode.CRAFT_RUNNING); + } } return runAsync(() -> { heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, temperature); diff --git a/src/main/java/com/iflytop/gd/app/command/control/HeatStopCommand.java b/src/main/java/com/iflytop/gd/app/command/control/HeatStopCommand.java index 56cd8ab..1eb1b41 100644 --- a/src/main/java/com/iflytop/gd/app/command/control/HeatStopCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/control/HeatStopCommand.java @@ -8,6 +8,7 @@ import com.iflytop.gd.app.service.device.module.HeatModuleService; import com.iflytop.gd.common.annotation.CommandMapping; import com.iflytop.gd.common.enums.HeatModuleCode; import com.iflytop.gd.common.enums.HeatingType; +import com.iflytop.gd.common.enums.automaton.CraftStates; import com.iflytop.gd.common.exception.AppException; import com.iflytop.gd.common.result.ResultCode; import lombok.RequiredArgsConstructor; @@ -34,7 +35,10 @@ public class HeatStopCommand extends BaseCommandHandler { HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); TrayState trayState = deviceStateService.getDeviceState().getTrayStateByHeatModuleCode(heatModuleCode); if (trayState != null && trayState.getCrafts() != null) { - throw new AppException(ResultCode.CRAFT_RUNNING); + CraftStates craftStates = trayState.getCrafts().getState(); + if(!(CraftStates.ERROR.equals(craftStates) || CraftStates.STOPPED.equals(craftStates))){ + throw new AppException(ResultCode.CRAFT_RUNNING); + } } return runAsync(() -> { //关闭加热 diff --git a/src/main/java/com/iflytop/gd/app/command/control/ShakeStartCommand.java b/src/main/java/com/iflytop/gd/app/command/control/ShakeStartCommand.java index d3bef4b..912ea90 100644 --- a/src/main/java/com/iflytop/gd/app/command/control/ShakeStartCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/control/ShakeStartCommand.java @@ -6,6 +6,7 @@ import com.iflytop.gd.app.model.dto.CmdDTO; import com.iflytop.gd.app.service.device.DeviceStateService; import com.iflytop.gd.app.service.device.module.SolutionModuleService; import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.enums.automaton.CraftStates; import com.iflytop.gd.common.exception.AppException; import com.iflytop.gd.common.result.ResultCode; import lombok.RequiredArgsConstructor; @@ -38,12 +39,20 @@ public class ShakeStartCommand extends BaseCommandHandler { } TrayState trayState = deviceStateService.getDeviceState().getTrayInSolutionModule(); if (trayState != null && trayState.getCrafts() != null) { - throw new AppException(ResultCode.CRAFT_RUNNING); + CraftStates craftStates = trayState.getCrafts().getState(); + if (!(CraftStates.ERROR.equals(craftStates) || CraftStates.STOPPED.equals(craftStates))) { + throw new AppException(ResultCode.CRAFT_RUNNING); + } } + deviceStateService.getCommandMutexState().get().setShakeStartCommandExecuting(true); + deviceStateService.getDeviceState().getSolutionModule().setShaking(true); return runAsync(() -> { - deviceStateService.getCommandMutexState().get().setShakeStartCommandExecuting(true); - solutionModuleService.shakeStart(cmdDTO.getCommandId(), cmdDTO.getCommand());//开始摇匀 - deviceStateService.getDeviceState().getSolutionModule().setShaking(true); + try { + solutionModuleService.shakeStart(cmdDTO.getCommandId(), cmdDTO.getCommand());//开始摇匀 + } catch (Exception e) { + deviceStateService.getCommandMutexState().get().setShakeStartCommandExecuting(false); + deviceStateService.getDeviceState().getSolutionModule().setShaking(false); + } }); } } diff --git a/src/main/java/com/iflytop/gd/app/command/control/ShakeStopCommand.java b/src/main/java/com/iflytop/gd/app/command/control/ShakeStopCommand.java index 6139b33..9f77345 100644 --- a/src/main/java/com/iflytop/gd/app/command/control/ShakeStopCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/control/ShakeStopCommand.java @@ -6,6 +6,7 @@ import com.iflytop.gd.app.model.dto.CmdDTO; import com.iflytop.gd.app.service.device.DeviceStateService; import com.iflytop.gd.app.service.device.module.SolutionModuleService; import com.iflytop.gd.common.annotation.CommandMapping; +import com.iflytop.gd.common.enums.automaton.CraftStates; import com.iflytop.gd.common.exception.AppException; import com.iflytop.gd.common.result.ResultCode; import lombok.RequiredArgsConstructor; @@ -29,7 +30,10 @@ public class ShakeStopCommand extends BaseCommandHandler { public CompletableFuture handle(CmdDTO cmdDTO) { TrayState trayState = deviceStateService.getDeviceState().getTrayInSolutionModule(); if (trayState != null && trayState.getCrafts() != null) { - throw new AppException(ResultCode.CRAFT_RUNNING); + CraftStates craftStates = trayState.getCrafts().getState(); + if(!(CraftStates.ERROR.equals(craftStates) || CraftStates.STOPPED.equals(craftStates))){ + throw new AppException(ResultCode.CRAFT_RUNNING); + } } return runAsync(() -> { solutionModuleService.shakeStop(cmdDTO.getCommandId(), cmdDTO.getCommand());//停止摇匀 diff --git a/src/main/java/com/iflytop/gd/app/command/control/SolutionAddCommand.java b/src/main/java/com/iflytop/gd/app/command/control/SolutionAddCommand.java index 07973bd..a2f3881 100644 --- a/src/main/java/com/iflytop/gd/app/command/control/SolutionAddCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/control/SolutionAddCommand.java @@ -13,6 +13,7 @@ import com.iflytop.gd.app.service.device.module.SolutionModuleService; import com.iflytop.gd.common.annotation.CommandMapping; import com.iflytop.gd.common.command.CommandFuture; import com.iflytop.gd.common.enums.AcidPumpDeviceCode; +import com.iflytop.gd.common.enums.automaton.CraftStates; import com.iflytop.gd.common.exception.AppException; import com.iflytop.gd.common.result.ResultCode; import com.iflytop.gd.common.utils.CommandUtil; @@ -53,7 +54,10 @@ public class SolutionAddCommand extends BaseCommandHandler { } TrayState trayState = deviceStateService.getDeviceState().getTrayInSolutionModule(); if (trayState != null && trayState.getCrafts() != null) { - throw new AppException(ResultCode.CRAFT_RUNNING); + CraftStates craftStates = trayState.getCrafts().getState(); + if(!(CraftStates.ERROR.equals(craftStates) || CraftStates.STOPPED.equals(craftStates))){ + throw new AppException(ResultCode.CRAFT_RUNNING); + } } deviceStateService.getCommandMutexState().get().setSolutionAddCommandExecuting(true); deviceStateService.getDeviceState().getSolutionModule().setPumping(true); diff --git a/src/main/java/com/iflytop/gd/app/command/control/TrayDownCommand.java b/src/main/java/com/iflytop/gd/app/command/control/TrayDownCommand.java index 41ab585..2ecc58d 100644 --- a/src/main/java/com/iflytop/gd/app/command/control/TrayDownCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/control/TrayDownCommand.java @@ -9,6 +9,7 @@ import com.iflytop.gd.app.service.device.module.HeatModuleService; import com.iflytop.gd.common.annotation.CommandMapping; import com.iflytop.gd.common.enums.HeatModuleCode; import com.iflytop.gd.common.enums.HeatingType; +import com.iflytop.gd.common.enums.automaton.CraftStates; import com.iflytop.gd.common.enums.data.DevicePositionCode; import com.iflytop.gd.common.exception.AppException; import com.iflytop.gd.common.result.ResultCode; @@ -40,9 +41,12 @@ public class TrayDownCommand extends BaseCommandHandler { String heatId = cmdDTO.getStringParam("heatId"); HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); - TrayState trayState = deviceStateService.getDeviceState().getTrayInSolutionModule(); + TrayState trayState = deviceStateService.getDeviceState().getTrayStateByHeatModuleCode(heatModuleCode); if (trayState != null && trayState.getCrafts() != null) { - throw new AppException(ResultCode.CRAFT_RUNNING); + CraftStates craftStates = trayState.getCrafts().getState(); + if(!(CraftStates.ERROR.equals(craftStates) || CraftStates.STOPPED.equals(craftStates))){ + throw new AppException(ResultCode.CRAFT_RUNNING); + } } //从数据库获取加热位下降托盘位置 double trayLower = devicePositionService.getPosition(DevicePositionCode.trayLower).getDistance(); diff --git a/src/main/java/com/iflytop/gd/app/command/control/TrayUpCommand.java b/src/main/java/com/iflytop/gd/app/command/control/TrayUpCommand.java index 09df4f0..543fc6b 100644 --- a/src/main/java/com/iflytop/gd/app/command/control/TrayUpCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/control/TrayUpCommand.java @@ -8,6 +8,7 @@ import com.iflytop.gd.app.service.device.DeviceStateService; import com.iflytop.gd.app.service.device.module.HeatModuleService; import com.iflytop.gd.common.annotation.CommandMapping; import com.iflytop.gd.common.enums.HeatModuleCode; +import com.iflytop.gd.common.enums.automaton.CraftStates; import com.iflytop.gd.common.enums.data.DevicePositionCode; import com.iflytop.gd.common.exception.AppException; import com.iflytop.gd.common.result.ResultCode; @@ -38,9 +39,12 @@ public class TrayUpCommand extends BaseCommandHandler { String heatId = cmdDTO.getStringParam("heatId"); HeatModuleCode heatModuleCode = HeatModuleCode.valueOf(heatId); - TrayState trayState = deviceStateService.getDeviceState().getTrayInSolutionModule(); + TrayState trayState = deviceStateService.getDeviceState().getTrayStateByHeatModuleCode(heatModuleCode); if (trayState != null && trayState.getCrafts() != null) { - throw new AppException(ResultCode.CRAFT_RUNNING); + CraftStates craftStates = trayState.getCrafts().getState(); + if(!(CraftStates.ERROR.equals(craftStates) || CraftStates.STOPPED.equals(craftStates))){ + throw new AppException(ResultCode.CRAFT_RUNNING); + } } //获取加热位抬升托盘位置 double trayLift = devicePositionService.getPosition(DevicePositionCode.trayLift).getDistance(); diff --git a/src/main/java/com/iflytop/gd/app/command/control/WarmUpStartCommand.java b/src/main/java/com/iflytop/gd/app/command/control/WarmUpStartCommand.java index 802eec0..73c7a5f 100644 --- a/src/main/java/com/iflytop/gd/app/command/control/WarmUpStartCommand.java +++ b/src/main/java/com/iflytop/gd/app/command/control/WarmUpStartCommand.java @@ -8,6 +8,7 @@ import com.iflytop.gd.app.service.device.module.HeatModuleService; import com.iflytop.gd.common.annotation.CommandMapping; import com.iflytop.gd.common.enums.HeatModuleCode; import com.iflytop.gd.common.enums.HeatingType; +import com.iflytop.gd.common.enums.automaton.CraftStates; import com.iflytop.gd.common.exception.AppException; import com.iflytop.gd.common.result.ResultCode; import lombok.RequiredArgsConstructor; @@ -34,7 +35,10 @@ public class WarmUpStartCommand extends BaseCommandHandler { Double temperature = cmdDTO.getDoubleParam("temperature"); TrayState trayState = deviceStateService.getDeviceState().getTrayStateByHeatModuleCode(heatModuleCode); if (trayState != null && trayState.getCrafts() != null) { - throw new AppException(ResultCode.CRAFT_RUNNING); + CraftStates craftStates = trayState.getCrafts().getState(); + if(!(CraftStates.ERROR.equals(craftStates) || CraftStates.STOPPED.equals(craftStates))){ + throw new AppException(ResultCode.CRAFT_RUNNING); + } } return runAsync(() -> { heatModuleService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleCode, temperature); diff --git a/src/main/java/com/iflytop/gd/app/controller/PhotoController.java b/src/main/java/com/iflytop/gd/app/controller/PhotoController.java index 76c61d0..d257c68 100644 --- a/src/main/java/com/iflytop/gd/app/controller/PhotoController.java +++ b/src/main/java/com/iflytop/gd/app/controller/PhotoController.java @@ -19,7 +19,7 @@ import java.util.List; /** * 照片接口 */ -@Tag(name = "认证") +@Tag(name = "照片") @RestController @RequestMapping("/api/photo") @RequiredArgsConstructor