diff --git a/src/main/java/com/dispose/service/impl/DisposeAbilityRouterServiceImpl.java b/src/main/java/com/dispose/service/impl/DisposeAbilityRouterServiceImpl.java index 86ed2833..d4cc9488 100644 --- a/src/main/java/com/dispose/service/impl/DisposeAbilityRouterServiceImpl.java +++ b/src/main/java/com/dispose/service/impl/DisposeAbilityRouterServiceImpl.java @@ -206,15 +206,10 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ for (AbilityInfo v : getAllAbilityDevices()) { DisposeDevice dev = disposeDeviceManager.getDisposeDeviceById(v.getDev().getId()); - if (dev != null && !dev.getStatus().equals(ObjectStatus.NORMAL)) { - // 更新设备状态 - v.getDev().setStatus(dev.getStatus()); - - v.getDb().periodTaskRuntime(); - - // 同步最新处置平台业务信息到设备 - v.getDb().upgradeServiceGroup(serviceGroupMapper.selectAll()); - + if (dev == null || !dev.getStatus().equals(ObjectStatus.NORMAL)) { + // 如果数据库中设备不存在,那么删除该设备 + v.getDev().setStatus(ObjectStatus.DELETED); + } else { // 数据库中的设备信息和缓存中的设备信息同步 v.getDev().getDevCapacity().forEach(k -> dev.getDevCapacity().forEach(m -> { if (k.getId().equals(m.getId())) { @@ -239,6 +234,10 @@ public class DisposeAbilityRouterServiceImpl implements DisposeAbilityRouterServ } } })); + + v.getDb().periodTaskRuntime(); + // 同步最新处置平台业务信息到设备 + v.getDb().upgradeServiceGroup(serviceGroupMapper.selectAll()); } } }