Commit 14699711028f0d157eddfb0432e26ab91f1b4493

Authored by 648540858
1 parent 1983b8b0

支持配置设备上线时自动更新查询通道,修复通道刷新进度展示

src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
@@ -41,6 +41,8 @@ public class UserSetting { @@ -41,6 +41,8 @@ public class UserSetting {
41 41
42 private Boolean gbSendStreamStrict = Boolean.FALSE; 42 private Boolean gbSendStreamStrict = Boolean.FALSE;
43 43
  44 + private Boolean syncChannelOnDeviceOnline = Boolean.FALSE;
  45 +
44 private String serverId = "000000"; 46 private String serverId = "000000";
45 47
46 private String thirdPartyGBIdReg = "[\\s\\S]*"; 48 private String thirdPartyGBIdReg = "[\\s\\S]*";
@@ -186,4 +188,12 @@ public class UserSetting { @@ -186,4 +188,12 @@ public class UserSetting {
186 public void setGbSendStreamStrict(Boolean gbSendStreamStrict) { 188 public void setGbSendStreamStrict(Boolean gbSendStreamStrict) {
187 this.gbSendStreamStrict = gbSendStreamStrict; 189 this.gbSendStreamStrict = gbSendStreamStrict;
188 } 190 }
  191 +
  192 + public Boolean getSyncChannelOnDeviceOnline() {
  193 + return syncChannelOnDeviceOnline;
  194 + }
  195 +
  196 + public void setSyncChannelOnDeviceOnline(Boolean syncChannelOnDeviceOnline) {
  197 + this.syncChannelOnDeviceOnline = syncChannelOnDeviceOnline;
  198 + }
189 } 199 }
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
1 package com.genersoft.iot.vmp.service.impl; 1 package com.genersoft.iot.vmp.service.impl;
2 2
3 import com.genersoft.iot.vmp.conf.DynamicTask; 3 import com.genersoft.iot.vmp.conf.DynamicTask;
  4 +import com.genersoft.iot.vmp.conf.UserSetting;
4 import com.genersoft.iot.vmp.gb28181.bean.*; 5 import com.genersoft.iot.vmp.gb28181.bean.*;
5 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; 6 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
6 import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; 7 import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
@@ -12,7 +13,6 @@ import com.genersoft.iot.vmp.service.IDeviceChannelService; @@ -12,7 +13,6 @@ import com.genersoft.iot.vmp.service.IDeviceChannelService;
12 import com.genersoft.iot.vmp.service.IDeviceService; 13 import com.genersoft.iot.vmp.service.IDeviceService;
13 import com.genersoft.iot.vmp.service.IMediaServerService; 14 import com.genersoft.iot.vmp.service.IMediaServerService;
14 import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 15 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
15 -import com.genersoft.iot.vmp.storager.IVideoManagerStorage;  
16 import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; 16 import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
17 import com.genersoft.iot.vmp.storager.dao.DeviceMapper; 17 import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
18 import com.genersoft.iot.vmp.storager.dao.PlatformChannelMapper; 18 import com.genersoft.iot.vmp.storager.dao.PlatformChannelMapper;
@@ -78,7 +78,7 @@ public class DeviceServiceImpl implements IDeviceService { @@ -78,7 +78,7 @@ public class DeviceServiceImpl implements IDeviceService {
78 TransactionDefinition transactionDefinition; 78 TransactionDefinition transactionDefinition;
79 79
80 @Autowired 80 @Autowired
81 - private IVideoManagerStorage storage; 81 + private UserSetting userSetting;
82 82
83 @Autowired 83 @Autowired
84 private ISIPCommander commander; 84 private ISIPCommander commander;
@@ -120,16 +120,18 @@ public class DeviceServiceImpl implements IDeviceService { @@ -120,16 +120,18 @@ public class DeviceServiceImpl implements IDeviceService {
120 if(device.getOnline() == 0){ 120 if(device.getOnline() == 0){
121 device.setOnline(1); 121 device.setOnline(1);
122 device.setCreateTime(now); 122 device.setCreateTime(now);
123 - logger.info("[设备上线,离线状态下重新注册]: {},查询设备信息以及通道信息", device.getDeviceId());  
124 deviceMapper.update(device); 123 deviceMapper.update(device);
125 redisCatchStorage.updateDevice(device); 124 redisCatchStorage.updateDevice(device);
126 - try {  
127 - commander.deviceInfoQuery(device);  
128 - } catch (InvalidArgumentException | SipException | ParseException e) {  
129 - logger.error("[命令发送失败] 查询设备信息: {}", e.getMessage()); 125 + if (userSetting.getSyncChannelOnDeviceOnline()) {
  126 + logger.info("[设备上线,离线状态下重新注册]: {},查询设备信息以及通道信息", device.getDeviceId());
  127 + try {
  128 + commander.deviceInfoQuery(device);
  129 + } catch (InvalidArgumentException | SipException | ParseException e) {
  130 + logger.error("[命令发送失败] 查询设备信息: {}", e.getMessage());
  131 + }
  132 + sync(device);
  133 + // TODO 如果设备下的通道级联到了其他平台,那么需要发送事件或者notify给上级平台
130 } 134 }
131 - sync(device);  
132 - // TODO 如果设备下的通道级联到了其他平台,那么需要发送事件或者notify给上级平台  
133 }else { 135 }else {
134 if (deviceChannelMapper.queryAllChannels(device.getDeviceId()).size() == 0) { 136 if (deviceChannelMapper.queryAllChannels(device.getDeviceId()).size() == 0) {
135 logger.info("[设备上线]: {},通道数为0,查询通道信息", device.getDeviceId()); 137 logger.info("[设备上线]: {},通道数为0,查询通道信息", device.getDeviceId());
src/main/resources/all-application.yml
@@ -195,6 +195,8 @@ user-settings: @@ -195,6 +195,8 @@ user-settings:
195 # 国标级联发流严格模式,严格模式会使用与sdp信息中一致的端口发流,端口共享media.rtp.port-range,这会损失一些性能, 195 # 国标级联发流严格模式,严格模式会使用与sdp信息中一致的端口发流,端口共享media.rtp.port-range,这会损失一些性能,
196 # 非严格模式使用随机端口发流,性能更好, 默认关闭 196 # 非严格模式使用随机端口发流,性能更好, 默认关闭
197 gb-send-stream-strict: false 197 gb-send-stream-strict: false
  198 + # 设备上线时是否自动同步通道
  199 + sync-channel-on-device-online: false
198 200
199 # 关闭在线文档(生产环境建议关闭) 201 # 关闭在线文档(生产环境建议关闭)
200 springdoc: 202 springdoc:
web_src/src/components/dialog/SyncChannelProgress.vue
@@ -63,37 +63,29 @@ export default { @@ -63,37 +63,29 @@ export default {
63 } 63 }
64 64
65 if (res.data.data != null) { 65 if (res.data.data != null) {
66 - if (res.data.syncIng) { 66 + if (res.data.data.syncIng) {
67 if (res.data.data.total == 0) { 67 if (res.data.data.total == 0) {
68 - if (res.data.data.errorMsg !== null ){  
69 - this.msg = res.data.data.errorMsg;  
70 - this.syncStatus = "exception"  
71 - }else {  
72 - this.msg = `等待同步中`;  
73 - this.timmer = setTimeout(this.getProgress, 300)  
74 - }  
75 - }else {  
76 - if (res.data.data.total == res.data.data.current) {  
77 - this.syncStatus = "success"  
78 - this.percentage = 100;  
79 - this.msg = '同步成功';  
80 - }else {  
81 - if (res.data.data.errorMsg !== null ){  
82 - this.msg = res.data.data.errorMsg;  
83 - this.syncStatus = "exception"  
84 - }else {  
85 - this.total = res.data.data.total;  
86 - this.current = res.data.data.current;  
87 - this.percentage = Math.floor(Number(res.data.data.current)/Number(res.data.data.total)* 10000)/100;  
88 - this.msg = `同步中...[${res.data.data.current}/${res.data.data.total}]`;  
89 - this.timmer = setTimeout(this.getProgress, 300)  
90 - }  
91 - } 68 + this.msg = `等待同步中`;
  69 + this.timmer = setTimeout(this.getProgress, 300)
  70 + }else {
  71 + this.total = res.data.data.total;
  72 + this.current = res.data.data.current;
  73 + this.percentage = Math.floor(Number(res.data.data.current)/Number(res.data.data.total)* 10000)/100;
  74 + this.msg = `同步中...[${res.data.data.current}/${res.data.data.total}]`;
  75 + this.timmer = setTimeout(this.getProgress, 300)
92 } 76 }
93 }else { 77 }else {
94 - this.syncStatus = "success"  
95 - this.percentage = 100;  
96 - this.msg = '同步成功'; 78 + if (res.data.data.errorMsg){
  79 + this.msg = res.data.data.errorMsg;
  80 + this.syncStatus = "exception"
  81 + }else {
  82 + this.syncStatus = "success"
  83 + this.percentage = 100;
  84 + this.msg = '同步成功';
  85 + setTimeout(()=>{
  86 + this.showDialog = false;
  87 + }, 3000)
  88 + }
97 } 89 }
98 } 90 }
99 }else { 91 }else {