Commit e8090bc84c04d929c750338df26aa2bf86e1efc8

Authored by 648540858
1 parent 9be861ab

修复bug与目录订阅添加最小值60

src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java
... ... @@ -62,6 +62,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
62 62 if (!parentPlatform.isStatus())return;
63 63 String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_" + event.getPlatformId();
64 64 subscribe = redisCatchStorage.getSubscribe(key);
  65 + if (subscribe == null) return;
65 66 }else {
66 67 // 获取所用订阅
67 68 List<String> platforms = redisCatchStorage.getAllSubscribePlatform();
... ... @@ -107,9 +108,10 @@ public class CatalogEventLister implements ApplicationListener&lt;CatalogEvent&gt; {
107 108 List<ParentPlatform> parentPlatforms = parentPlatformMap.get(gbId);
108 109 if (parentPlatforms != null && parentPlatforms.size() > 0) {
109 110 for (ParentPlatform platform : parentPlatforms) {
110   - logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId);
111 111 String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_" + platform.getServerGBId();
112 112 SubscribeInfo subscribeInfo = redisCatchStorage.getSubscribe(key);
  113 + if (subscribeInfo == null) continue;
  114 + logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId);
113 115 List<DeviceChannel> deviceChannelList = new ArrayList<>();
114 116 DeviceChannel deviceChannel = new DeviceChannel();
115 117 deviceChannel.setChannelId(gbId);
... ... @@ -146,9 +148,10 @@ public class CatalogEventLister implements ApplicationListener&lt;CatalogEvent&gt; {
146 148 List<ParentPlatform> parentPlatforms = parentPlatformMap.get(gbId);
147 149 if (parentPlatforms != null && parentPlatforms.size() > 0) {
148 150 for (ParentPlatform platform : parentPlatforms) {
149   - logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId);
150 151 String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_" + platform.getServerGBId();
151 152 SubscribeInfo subscribeInfo = redisCatchStorage.getSubscribe(key);
  153 + if (subscribeInfo == null) continue;
  154 + logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId);
152 155 List<DeviceChannel> deviceChannelList = new ArrayList<>();
153 156 DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(platform.getServerGBId(), gbId);
154 157 deviceChannelList.add(deviceChannel);
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
... ... @@ -1498,7 +1498,10 @@ public class SIPCommander implements ISIPCommander {
1498 1498 CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId()
1499 1499 : udpSipProvider.getNewCallId();
1500 1500  
1501   - Request request = headerProvider.createSubscribeRequest(device, cmdXml.toString(), "z9hG4bK-viaPos-" + tm, "fromTagPos" + tm, null, device.getSubscribeCycleForCatalog(), "Catalog" , callIdHeader);
  1501 + // 有效时间默认为60秒以上
  1502 + Request request = headerProvider.createSubscribeRequest(device, cmdXml.toString(), "z9hG4bK-viaPos-" + tm,
  1503 + "fromTagPos" + tm, null, device.getSubscribeCycleForCatalog() + 60, "Catalog" ,
  1504 + callIdHeader);
1502 1505 transmitRequest(device, request, errorEvent, okEvent);
1503 1506  
1504 1507 return true;
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
... ... @@ -370,10 +370,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
370 370  
371 371 @Override
372 372 public boolean sendNotifyForCatalogAddOrUpdate(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo) {
373   - if (parentPlatform == null) {
374   - return false;
375   - }
376   - if (deviceChannels == null || deviceChannels.size() == 0) {
  373 + if (parentPlatform == null || deviceChannels == null || deviceChannels.size() == 0 || subscribeInfo == null) {
377 374 return false;
378 375 }
379 376 for (DeviceChannel channel : deviceChannels) {
... ... @@ -431,10 +428,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
431 428  
432 429 @Override
433 430 public boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo) {
434   - if (parentPlatform == null) {
435   - return false;
436   - }
437   - if (deviceChannels == null || deviceChannels.size() == 0) {
  431 + if (parentPlatform == null
  432 + || deviceChannels == null
  433 + || deviceChannels.size() == 0
  434 + || subscribeInfo == null) {
438 435 return false;
439 436 }
440 437  
... ...
src/main/java/com/genersoft/iot/vmp/service/bean/CatalogSubscribeTask.java
... ... @@ -26,20 +26,8 @@ public class CatalogSubscribeTask implements Runnable{
26 26 ResponseEvent event = (ResponseEvent) eventResult.event;
27 27 Element rootElement = null;
28 28 if (event.getResponse().getRawContent() != null) {
29   - try {
30   - rootElement = XmlUtil.getRootElement(event.getResponse().getRawContent(), "gb2312");
31   - } catch (DocumentException e) {
32   - e.printStackTrace();
33   - }
34   - Element resultElement = rootElement.element("Result");
35   - String result = resultElement.getText();
36   - if (result.toUpperCase().equals("OK")){
37   - // 成功
38   - logger.info("[目录订阅]成功: {}", device.getDeviceId());
39   - }else {
40   - // 失败
41   - logger.info("[目录订阅]失败: {}-{}", device.getDeviceId(), result);
42   - }
  29 + // 成功
  30 + logger.info("[目录订阅]成功: {}", device.getDeviceId());
43 31 }else {
44 32 // 成功
45 33 logger.info("[目录订阅]成功: {}", device.getDeviceId());
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java
... ... @@ -5,15 +5,20 @@ import com.alibaba.excel.event.AnalysisEventListener;
5 5 import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
6 6 import com.genersoft.iot.vmp.service.IStreamPushService;
7 7 import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto;
  8 +import org.springframework.util.StringUtils;
8 9  
9 10 import java.util.ArrayList;
  11 +import java.util.HashSet;
10 12 import java.util.List;
  13 +import java.util.Set;
11 14  
12 15 public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPushExcelDto> {
13 16  
14 17 private IStreamPushService pushService;
15 18 private String defaultMediaServerId;
16 19 private List<StreamPushItem> streamPushItems = new ArrayList<>();
  20 + private Set<String> streamPushStreamSet = new HashSet<>();
  21 + private Set<String> streamPushGBSet = new HashSet<>();
17 22  
18 23 public StreamPushUploadFileHandler(IStreamPushService pushService, String defaultMediaServerId) {
19 24 this.pushService = pushService;
... ... @@ -22,6 +27,14 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener&lt;StreamPus
22 27  
23 28 @Override
24 29 public void invoke(StreamPushExcelDto streamPushExcelDto, AnalysisContext analysisContext) {
  30 + if (StringUtils.isEmpty(streamPushExcelDto.getApp())
  31 + || StringUtils.isEmpty(streamPushExcelDto.getStream())
  32 + || StringUtils.isEmpty(streamPushExcelDto.getGbId())) {
  33 + return;
  34 + }
  35 + if (streamPushGBSet.contains(streamPushExcelDto.getGbId()) || streamPushStreamSet.contains(streamPushExcelDto.getApp() + streamPushExcelDto.getStream())) {
  36 + return;
  37 + }
25 38 StreamPushItem streamPushItem = new StreamPushItem();
26 39 streamPushItem.setApp(streamPushExcelDto.getApp());
27 40 streamPushItem.setStream(streamPushExcelDto.getStream());
... ... @@ -35,6 +48,8 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener&lt;StreamPus
35 48 streamPushItem.setOriginTypeStr("rtsp_push");
36 49 streamPushItem.setTotalReaderCount("0");
37 50 streamPushItems.add(streamPushItem);
  51 + streamPushGBSet.add(streamPushExcelDto.getGbId());
  52 + streamPushStreamSet.add(streamPushExcelDto.getApp()+streamPushExcelDto.getStream());
38 53 if (streamPushItems.size() > 300) {
39 54 pushService.batchAdd(streamPushItems);
40 55 // 存储完成清理 list
... ... @@ -46,5 +61,7 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener&lt;StreamPus
46 61 public void doAfterAllAnalysed(AnalysisContext analysisContext) {
47 62 // 这里也要保存数据,确保最后遗留的数据也存储到数据库
48 63 pushService.batchAdd(streamPushItems);
  64 + streamPushGBSet.clear();
  65 + streamPushStreamSet.clear();
49 66 }
50 67 }
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java
... ... @@ -316,7 +316,8 @@ public class DeviceQuery {
316 316 if (!StringUtils.isEmpty(device.getCharset())) deviceInStore.setCharset(device.getCharset());
317 317 if (!StringUtils.isEmpty(device.getMediaServerId())) deviceInStore.setMediaServerId(device.getMediaServerId());
318 318  
319   - if (deviceInStore.getSubscribeCycleForCatalog() <=0 && device.getSubscribeCycleForCatalog() > 0) {
  319 + if ((deviceInStore.getSubscribeCycleForCatalog() <=0 && device.getSubscribeCycleForCatalog() > 0)
  320 + || deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) {
320 321 deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog());
321 322 // 开启订阅
322 323 deviceService.addCatalogSubscribe(deviceInStore);
... ...
web_src/src/components/dialog/deviceEdit.vue
... ... @@ -10,7 +10,7 @@
10 10 @close="close()"
11 11 >
12 12 <div id="shared" style="margin-top: 1rem;margin-right: 100px;">
13   - <el-form ref="form" :rules="rules" :model="form" label-width="140px" >
  13 + <el-form ref="form" :rules="rules" :model="form" label-width="240px" >
14 14 <el-form-item label="设备编号" >
15 15 <el-input v-model="form.deviceId" disabled></el-input>
16 16 </el-form-item>
... ... @@ -36,8 +36,8 @@
36 36 <el-option key="UTF-8" label="UTF-8" value="utf-8"></el-option>
37 37 </el-select>
38 38 </el-form-item>
39   - <el-form-item label="目录订阅周期" prop="subscribeCycleForCatalog" >
40   - <el-input v-model="form.subscribeCycleForCatalog" clearable></el-input>
  39 + <el-form-item label="目录订阅周期(0为停用订阅)" prop="subscribeCycleForCatalog" >
  40 + <el-input v-model="form.subscribeCycleForCatalog" clearable ></el-input>
41 41 </el-form-item>
42 42 <el-form-item>
43 43 <div style="float: right;">
... ...