diff --git a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java index ca204d93..eeee438f 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java @@ -41,6 +41,8 @@ public class UserSetting { private Boolean gbSendStreamStrict = Boolean.FALSE; + private Boolean syncChannelOnDeviceOnline = Boolean.FALSE; + private String serverId = "000000"; private String thirdPartyGBIdReg = "[\\s\\S]*"; @@ -186,4 +188,12 @@ public class UserSetting { public void setGbSendStreamStrict(Boolean gbSendStreamStrict) { this.gbSendStreamStrict = gbSendStreamStrict; } + + public Boolean getSyncChannelOnDeviceOnline() { + return syncChannelOnDeviceOnline; + } + + public void setSyncChannelOnDeviceOnline(Boolean syncChannelOnDeviceOnline) { + this.syncChannelOnDeviceOnline = syncChannelOnDeviceOnline; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index ac48e4df..d25e537e 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.service.impl; import com.genersoft.iot.vmp.conf.DynamicTask; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; @@ -12,7 +13,6 @@ import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; import com.genersoft.iot.vmp.storager.dao.DeviceMapper; import com.genersoft.iot.vmp.storager.dao.PlatformChannelMapper; @@ -78,7 +78,7 @@ public class DeviceServiceImpl implements IDeviceService { TransactionDefinition transactionDefinition; @Autowired - private IVideoManagerStorage storage; + private UserSetting userSetting; @Autowired private ISIPCommander commander; @@ -120,16 +120,18 @@ public class DeviceServiceImpl implements IDeviceService { if(device.getOnline() == 0){ device.setOnline(1); device.setCreateTime(now); - logger.info("[设备上线,离线状态下重新注册]: {},查询设备信息以及通道信息", device.getDeviceId()); deviceMapper.update(device); redisCatchStorage.updateDevice(device); - try { - commander.deviceInfoQuery(device); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 查询设备信息: {}", e.getMessage()); + if (userSetting.getSyncChannelOnDeviceOnline()) { + logger.info("[设备上线,离线状态下重新注册]: {},查询设备信息以及通道信息", device.getDeviceId()); + try { + commander.deviceInfoQuery(device); + } catch (InvalidArgumentException | SipException | ParseException e) { + logger.error("[命令发送失败] 查询设备信息: {}", e.getMessage()); + } + sync(device); + // TODO 如果设备下的通道级联到了其他平台,那么需要发送事件或者notify给上级平台 } - sync(device); - // TODO 如果设备下的通道级联到了其他平台,那么需要发送事件或者notify给上级平台 }else { if (deviceChannelMapper.queryAllChannels(device.getDeviceId()).size() == 0) { logger.info("[设备上线]: {},通道数为0,查询通道信息", device.getDeviceId()); diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml index 33039153..e8b28d0d 100644 --- a/src/main/resources/all-application.yml +++ b/src/main/resources/all-application.yml @@ -195,6 +195,8 @@ user-settings: # 国标级联发流严格模式,严格模式会使用与sdp信息中一致的端口发流,端口共享media.rtp.port-range,这会损失一些性能, # 非严格模式使用随机端口发流,性能更好, 默认关闭 gb-send-stream-strict: false + # 设备上线时是否自动同步通道 + sync-channel-on-device-online: false # 关闭在线文档(生产环境建议关闭) springdoc: diff --git a/web_src/src/components/dialog/SyncChannelProgress.vue b/web_src/src/components/dialog/SyncChannelProgress.vue index c972a46c..e1c9fe01 100644 --- a/web_src/src/components/dialog/SyncChannelProgress.vue +++ b/web_src/src/components/dialog/SyncChannelProgress.vue @@ -63,37 +63,29 @@ export default { } if (res.data.data != null) { - if (res.data.syncIng) { + if (res.data.data.syncIng) { if (res.data.data.total == 0) { - if (res.data.data.errorMsg !== null ){ - this.msg = res.data.data.errorMsg; - this.syncStatus = "exception" - }else { - this.msg = `等待同步中`; - this.timmer = setTimeout(this.getProgress, 300) - } - }else { - if (res.data.data.total == res.data.data.current) { - this.syncStatus = "success" - this.percentage = 100; - this.msg = '同步成功'; - }else { - if (res.data.data.errorMsg !== null ){ - this.msg = res.data.data.errorMsg; - this.syncStatus = "exception" - }else { - this.total = res.data.data.total; - this.current = res.data.data.current; - this.percentage = Math.floor(Number(res.data.data.current)/Number(res.data.data.total)* 10000)/100; - this.msg = `同步中...[${res.data.data.current}/${res.data.data.total}]`; - this.timmer = setTimeout(this.getProgress, 300) - } - } + this.msg = `等待同步中`; + this.timmer = setTimeout(this.getProgress, 300) + }else { + this.total = res.data.data.total; + this.current = res.data.data.current; + this.percentage = Math.floor(Number(res.data.data.current)/Number(res.data.data.total)* 10000)/100; + this.msg = `同步中...[${res.data.data.current}/${res.data.data.total}]`; + this.timmer = setTimeout(this.getProgress, 300) } }else { - this.syncStatus = "success" - this.percentage = 100; - this.msg = '同步成功'; + if (res.data.data.errorMsg){ + this.msg = res.data.data.errorMsg; + this.syncStatus = "exception" + }else { + this.syncStatus = "success" + this.percentage = 100; + this.msg = '同步成功'; + setTimeout(()=>{ + this.showDialog = false; + }, 3000) + } } } }else {