From 38ef256136e57b07a6cde4753cbc12d3a7100732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=87=A4=E5=90=89?= Date: Tue, 20 May 2025 10:48:21 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8E=B0=E5=9C=BA=E4=BB=A3=E7=A0=81=E5=90=8C?= =?UTF-8?q?=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/iflytop/gd/app/cmd/FanStartCommand.java | 10 +++++++--- .../java/com/iflytop/gd/app/cmd/FanStopCommand.java | 10 +++++++--- .../com/iflytop/gd/app/cmd/HeatStartCommand.java | 20 ++++++++++++-------- .../java/com/iflytop/gd/app/cmd/HeatStopCommand.java | 14 +++++++++----- .../java/com/iflytop/gd/app/cmd/TrayDownCommand.java | 18 +++++++++++------- .../java/com/iflytop/gd/app/cmd/TrayUpCommand.java | 18 +++++++++++------- 6 files changed, 57 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/iflytop/gd/app/cmd/FanStartCommand.java b/src/main/java/com/iflytop/gd/app/cmd/FanStartCommand.java index de405e2..686e33b 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/FanStartCommand.java +++ b/src/main/java/com/iflytop/gd/app/cmd/FanStartCommand.java @@ -1,5 +1,6 @@ package com.iflytop.gd.app.cmd; +import cn.hutool.json.JSONArray; import com.iflytop.gd.app.core.BaseCommandHandler; import com.iflytop.gd.app.model.dto.CmdDTO; import com.iflytop.gd.app.service.DeviceCommandUtilService; @@ -23,10 +24,13 @@ public class FanStartCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { - String heatId = cmdDTO.getStringParam("heatId"); - HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); + JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatId"); return runAsync(() -> { - deviceCommandUtilService.fanStart(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId); + for (int i = 0; i < heatIdJsonArray.size(); i++) { + String heatId = heatIdJsonArray.getStr(i); + HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); + deviceCommandUtilService.fanStart(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId); + } }); } } diff --git a/src/main/java/com/iflytop/gd/app/cmd/FanStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/FanStopCommand.java index 45a5575..a3f47a0 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/FanStopCommand.java +++ b/src/main/java/com/iflytop/gd/app/cmd/FanStopCommand.java @@ -1,5 +1,6 @@ package com.iflytop.gd.app.cmd; +import cn.hutool.json.JSONArray; import com.iflytop.gd.app.core.BaseCommandHandler; import com.iflytop.gd.app.model.dto.CmdDTO; import com.iflytop.gd.app.service.DeviceCommandUtilService; @@ -23,10 +24,13 @@ public class FanStopCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { - String heatId = cmdDTO.getStringParam("heatId"); - HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); + JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatId"); return runAsync(() -> { - deviceCommandUtilService.fanClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId); + for (int i = 0; i < heatIdJsonArray.size(); i++) { + String heatId = heatIdJsonArray.getStr(i); + HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); + deviceCommandUtilService.fanClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId); + } }); } } diff --git a/src/main/java/com/iflytop/gd/app/cmd/HeatStartCommand.java b/src/main/java/com/iflytop/gd/app/cmd/HeatStartCommand.java index 1b46218..afe4076 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/HeatStartCommand.java +++ b/src/main/java/com/iflytop/gd/app/cmd/HeatStartCommand.java @@ -1,5 +1,6 @@ package com.iflytop.gd.app.cmd; +import cn.hutool.json.JSONArray; import com.iflytop.gd.app.core.BaseCommandHandler; import com.iflytop.gd.app.model.dto.CmdDTO; import com.iflytop.gd.app.service.DeviceCommandUtilService; @@ -25,15 +26,18 @@ public class HeatStartCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { - String heatId = cmdDTO.getStringParam("heatId");//获取加热区ID - HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); + JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatId"); return runAsync(() -> { - //从系统状态中获取指定加热区设定的温度数值 - double temperature = deviceStateService.getHeatModuleState(heatModuleId).getTemperature(); - //开启加热 - deviceCommandUtilService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, temperature); - deviceStateService.setHeatModuleStateHeating(heatModuleId, true);//设置状态加热中 - //TODO以后思考如果加热棒不可恒温 + for (int i = 0; i < heatIdJsonArray.size(); i++) { + String heatId = heatIdJsonArray.getStr(i); + HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); + //从系统状态中获取指定加热区设定的温度数值 + double temperature = deviceStateService.getHeatModuleState(heatModuleId).getTemperature(); + //开启加热 + deviceCommandUtilService.heatRodOpen(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, temperature); + deviceStateService.setHeatModuleStateHeating(heatModuleId, true);//设置状态加热中 + + } }); } } diff --git a/src/main/java/com/iflytop/gd/app/cmd/HeatStopCommand.java b/src/main/java/com/iflytop/gd/app/cmd/HeatStopCommand.java index 58a26bc..f27beac 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/HeatStopCommand.java +++ b/src/main/java/com/iflytop/gd/app/cmd/HeatStopCommand.java @@ -1,5 +1,6 @@ package com.iflytop.gd.app.cmd; +import cn.hutool.json.JSONArray; import com.iflytop.gd.app.core.BaseCommandHandler; import com.iflytop.gd.app.model.dto.CmdDTO; import com.iflytop.gd.app.service.DeviceCommandUtilService; @@ -25,12 +26,15 @@ public class HeatStopCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { - String heatId = cmdDTO.getStringParam("heatId");//获取加热区ID - HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); + JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatId"); return runAsync(() -> { - //关闭加热 - deviceCommandUtilService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId); - deviceStateService.setHeatModuleStateHeating(heatModuleId, false);//设置状态停止加热 + for (int i = 0; i < heatIdJsonArray.size(); i++) { + String heatId = heatIdJsonArray.getStr(i); + HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); + //关闭加热 + deviceCommandUtilService.heatRodClose(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId); + deviceStateService.setHeatModuleStateHeating(heatModuleId, false);//设置状态停止加热 + } }); } } diff --git a/src/main/java/com/iflytop/gd/app/cmd/TrayDownCommand.java b/src/main/java/com/iflytop/gd/app/cmd/TrayDownCommand.java index 7c22bb7..951cf60 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/TrayDownCommand.java +++ b/src/main/java/com/iflytop/gd/app/cmd/TrayDownCommand.java @@ -1,5 +1,6 @@ package com.iflytop.gd.app.cmd; +import cn.hutool.json.JSONArray; import com.iflytop.gd.app.core.BaseCommandHandler; import com.iflytop.gd.app.model.dto.CmdDTO; import com.iflytop.gd.app.service.DeviceCommandUtilService; @@ -28,14 +29,17 @@ public class TrayDownCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { - String heatId = cmdDTO.getStringParam("heatId"); - HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); + JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatId"); return runAsync(() -> { - //从数据库获取加热位下降托盘位置 - double trayLower = devicePositionService.getPosition(DevicePositionCode.trayLower).getDistance(); - //下降加热位托盘 - deviceCommandUtilService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, trayLower); - deviceStateService.setHeatModuleStateTrayUp(heatModuleId, 0); + for (int i = 0; i < heatIdJsonArray.size(); i++) { + String heatId = heatIdJsonArray.getStr(i); + HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); + //从数据库获取加热位下降托盘位置 + double trayLower = devicePositionService.getPosition(DevicePositionCode.trayLower).getDistance(); + //下降加热位托盘 + deviceCommandUtilService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, trayLower); + deviceStateService.setHeatModuleStateTrayUp(heatModuleId, 0); + } }); } } diff --git a/src/main/java/com/iflytop/gd/app/cmd/TrayUpCommand.java b/src/main/java/com/iflytop/gd/app/cmd/TrayUpCommand.java index 5948bac..c8f477a 100644 --- a/src/main/java/com/iflytop/gd/app/cmd/TrayUpCommand.java +++ b/src/main/java/com/iflytop/gd/app/cmd/TrayUpCommand.java @@ -1,5 +1,6 @@ package com.iflytop.gd.app.cmd; +import cn.hutool.json.JSONArray; import com.iflytop.gd.app.core.BaseCommandHandler; import com.iflytop.gd.app.model.dto.CmdDTO; import com.iflytop.gd.app.service.DeviceCommandUtilService; @@ -28,14 +29,17 @@ public class TrayUpCommand extends BaseCommandHandler { @Override public CompletableFuture handle(CmdDTO cmdDTO) { - String heatId = cmdDTO.getStringParam("heatId");//获取加热区ID - HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); + JSONArray heatIdJsonArray = cmdDTO.getJSONArrayParam("heatId"); return runAsync(() -> { - //获取加热位抬升托盘位置 - double trayLift = devicePositionService.getPosition(DevicePositionCode.trayLift).getDistance(); - //抬升加热位托盘 - deviceCommandUtilService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, trayLift); - deviceStateService.setHeatModuleStateTrayUp(heatModuleId, 1); + for (int i = 0; i < heatIdJsonArray.size(); i++) { + String heatId = heatIdJsonArray.getStr(i); + HeatModuleCode heatModuleId = HeatModuleCode.valueOf(heatId); + //获取加热位抬升托盘位置 + double trayLift = devicePositionService.getPosition(DevicePositionCode.trayLift).getDistance(); + //抬升加热位托盘 + deviceCommandUtilService.heaterMotorMove(cmdDTO.getCommandId(), cmdDTO.getCommand(), heatModuleId, trayLift); + deviceStateService.setHeatModuleStateTrayUp(heatModuleId, 1); + } }); } }