Merge branch 'dev-V0.5.0-gaoyoulong' into dev-V0.5.0

* dev-V0.5.0-gaoyoulong:
  feat: 虚拟设备 - VirtualManager 定时任务开启;VirtualDeviceController 修改虚拟设备优化
V0.5.x
gaoyoulong 2024-03-01 12:20:12 +08:00
commit b412eec2a8
2 changed files with 5 additions and 2 deletions

View File

@ -82,6 +82,9 @@ public class VirtualDeviceController {
VirtualDevice oldData = checkOwner(virtualDevice.getId()); VirtualDevice oldData = checkOwner(virtualDevice.getId());
ReflectUtil.copyNoNulls(virtualDevice, oldData, ReflectUtil.copyNoNulls(virtualDevice, oldData,
"name", "productKey", "type", "trigger", "triggerExpression"); "name", "productKey", "type", "trigger", "triggerExpression");
if (VirtualDevice.STATE_RUNNING.equals(virtualDevice.getState())) {
virtualManager.remove(oldData);
}
virtualDevice.setState(VirtualDevice.STATE_STOPPED); virtualDevice.setState(VirtualDevice.STATE_STOPPED);
virtualDeviceData.save(virtualDevice); virtualDeviceData.save(virtualDevice);
} }

View File

@ -59,8 +59,8 @@ public class VirtualManager {
private MqProducer<ThingModelMessage> producer; private MqProducer<ThingModelMessage> producer;
public VirtualManager(){ public VirtualManager(){
// ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1); ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
// executorService.schedule(this::init, 8, TimeUnit.SECONDS); executorService.schedule(this::init, 8, TimeUnit.SECONDS);
} }
public void init() { public void init() {