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() {