feat: 虚拟设备 - VirtualManager 定时任务开启;VirtualDeviceController 修改虚拟设备优化

V0.5.x
gaoyoulong 2024-03-01 12:19:49 +08:00
parent 8c44979dcf
commit 9a4109fedb
2 changed files with 5 additions and 2 deletions

View File

@ -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);
}

View File

@ -59,8 +59,8 @@ public class VirtualManager {
private MqProducer<ThingModelMessage> 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() {