From 9a4109fedb0854c0044c1f8b6b4c0544239d56b5 Mon Sep 17 00:00:00 2001 From: gaoyoulong <774597026@qq.com> Date: Fri, 1 Mar 2024 12:19:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=99=9A=E6=8B=9F=E8=AE=BE=E5=A4=87=20?= =?UTF-8?q?-=20VirtualManager=20=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E5=BC=80=E5=90=AF=EF=BC=9BVirtualDeviceController=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=99=9A=E6=8B=9F=E8=AE=BE=E5=A4=87=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cc/iotkit/manager/controller/VirtualDeviceController.java | 3 +++ .../src/main/java/cc/iotkit/virtualdevice/VirtualManager.java | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/VirtualDeviceController.java b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/VirtualDeviceController.java index 2bb9b6df..458529ac 100644 --- a/iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/VirtualDeviceController.java +++ b/iot-module/iot-manager/src/main/java/cc/iotkit/manager/controller/VirtualDeviceController.java @@ -82,6 +82,9 @@ public class VirtualDeviceController { VirtualDevice oldData = checkOwner(virtualDevice.getId()); ReflectUtil.copyNoNulls(virtualDevice, oldData, "name", "productKey", "type", "trigger", "triggerExpression"); + if (VirtualDevice.STATE_RUNNING.equals(virtualDevice.getState())) { + virtualManager.remove(oldData); + } virtualDevice.setState(VirtualDevice.STATE_STOPPED); virtualDeviceData.save(virtualDevice); } diff --git a/iot-test-tool/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/VirtualManager.java b/iot-test-tool/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/VirtualManager.java index 645157d4..2d3ea1e1 100644 --- a/iot-test-tool/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/VirtualManager.java +++ b/iot-test-tool/iot-virtual-device/src/main/java/cc/iotkit/virtualdevice/VirtualManager.java @@ -59,8 +59,8 @@ public class VirtualManager { private MqProducer producer; public VirtualManager(){ -// ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1); -// executorService.schedule(this::init, 8, TimeUnit.SECONDS); + ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1); + executorService.schedule(this::init, 8, TimeUnit.SECONDS); } public void init() {