diff --git a/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java b/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java index 10dfc086..c9572ae5 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java @@ -3,7 +3,6 @@ package com.genersoft.iot.vmp.conf; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; -import org.springframework.scheduling.support.CronTrigger; import org.springframework.stereotype.Component; import java.util.Map; @@ -40,4 +39,8 @@ public class DynamicTask { } } + public boolean contains(String key) { + return futureMap.get(key) != null; + } + } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/runner/SipDeviceRunner.java b/src/main/java/com/genersoft/iot/vmp/conf/runner/SipDeviceRunner.java index 26b0a5cd..da4e2eda 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/runner/SipDeviceRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/runner/SipDeviceRunner.java @@ -1,7 +1,8 @@ package com.genersoft.iot.vmp.conf.runner; -import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import org.springframework.beans.factory.annotation.Autowired; @@ -28,6 +29,9 @@ public class SipDeviceRunner implements CommandLineRunner { @Autowired private UserSetup userSetup; + @Autowired + private IDeviceService deviceService; + @Override public void run(String... args) throws Exception { // 读取redis没有心跳信息的则设置为离线,等收到下次心跳设置为在线 @@ -36,9 +40,15 @@ public class SipDeviceRunner implements CommandLineRunner { List onlineForAll = redisCatchStorage.getOnlineForAll(); for (String deviceId : onlineForAll) { storager.online(deviceId); + Device device = redisCatchStorage.getDevice(deviceId); + if (device != null && device.getSubscribeCycleForCatalog() > 0) { + // 查询在线设备那些开启了订阅,为设备开启定时的目录订阅 + deviceService.addCatalogSubscribe(device); + } } // 重置cseq计数 redisCatchStorage.resetAllCSEQ(); - // TODO 查询在线设备那些开启了订阅,为设备开启定时的目录订阅 + + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java index 5f0d14d1..c0de8de3 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java @@ -35,6 +35,9 @@ public class OnlineEventListener implements ApplicationListener { @Autowired private IVideoManagerStorager storager; + + @Autowired + private IDeviceService deviceService; @Autowired private RedisUtil redis; @@ -57,6 +60,7 @@ public class OnlineEventListener implements ApplicationListener { logger.debug("设备上线事件触发,deviceId:" + event.getDevice().getDeviceId() + ",from:" + event.getFrom()); } Device device = event.getDevice(); + if (device == null) return; String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + event.getDevice().getDeviceId(); switch (event.getFrom()) { @@ -84,15 +88,18 @@ public class OnlineEventListener implements ApplicationListener { } device.setOnline(1); - Device deviceInstore = storager.queryVideoDevice(device.getDeviceId()); - if (deviceInstore != null && deviceInstore.getOnline() == 0) { + Device deviceInStore = storager.queryVideoDevice(device.getDeviceId()); + if (deviceInStore != null && deviceInStore.getOnline() == 0) { List deviceChannelList = storager.queryOnlineChannelsByDeviceId(device.getDeviceId()); eventPublisher.catalogEventPublish(null, deviceChannelList, CatalogEvent.ON); } // 处理上线监听 storager.updateDevice(device); - // TODO 上线添加订阅 + // 上线添加订阅 + if (device.getSubscribeCycleForCatalog() > 0) { + deviceService.addCatalogSubscribe(device); + } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java index a3523fd6..52442cc7 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java @@ -18,6 +18,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; import java.util.*; @@ -76,12 +77,12 @@ public class CatalogEventLister implements ApplicationListener { }else if (event.getGbStreams() != null) { if (platforms.size() > 0) { for (GbStream gbStream : event.getGbStreams()) { + if (gbStream == null || StringUtils.isEmpty(gbStream.getGbId())) continue; List parentPlatformsForGB = storager.queryPlatFormListForStreamWithGBId(gbStream.getApp(),gbStream.getStream(), platforms); parentPlatformMap.put(gbStream.getGbId(), parentPlatformsForGB); } } } - } switch (event.getType()) { case CatalogEvent.ON: diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java index 48c4939a..ac77f7b9 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java @@ -41,6 +41,8 @@ public class DeferredResultHolder { public static final String CALLBACK_CMD_STOP = "CALLBACK_STOP"; + public static final String UPLOAD_FILE_CHANNEL = "UPLOAD_FILE_CHANNEL"; + public static final String CALLBACK_CMD_MOBILEPOSITION = "CALLBACK_MOBILEPOSITION"; public static final String CALLBACK_CMD_PRESETQUERY = "CALLBACK_PRESETQUERY"; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java index 13335d60..8d0bdd2f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java @@ -80,17 +80,14 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme Element rootElement = getRootElement(evt); String cmd = XmlUtil.getText(rootElement, "CmdType"); if (CmdType.MOBILE_POSITION.equals(cmd)) { - logger.info("接收到MobilePosition订阅"); processNotifyMobilePosition(evt, rootElement); // } else if (CmdType.ALARM.equals(cmd)) { // logger.info("接收到Alarm订阅"); // processNotifyAlarm(evt, rootElement); } else if (CmdType.CATALOG.equals(cmd)) { - logger.info("接收到Catalog订阅"); processNotifyCatalogList(evt, rootElement); } else { logger.info("接收到消息:" + cmd); -// responseAck(evt, Response.OK); Response response = null; response = getMessageFactory().createResponse(200, request); @@ -132,7 +129,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme SubscribeInfo subscribeInfo = new SubscribeInfo(evt, platformId); String sn = XmlUtil.getText(rootElement, "SN"); String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_MobilePosition_" + platformId; - + logger.info("接收到{}的MobilePosition订阅", platformId); StringBuilder resultXml = new StringBuilder(200); resultXml.append("\r\n") .append("\r\n") @@ -182,7 +179,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme SubscribeInfo subscribeInfo = new SubscribeInfo(evt, platformId); String sn = XmlUtil.getText(rootElement, "SN"); String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_" + platformId; - + logger.info("接收到{}的Catalog订阅", platformId); StringBuilder resultXml = new StringBuilder(200); resultXml.append("\r\n") .append("\r\n") 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 11594847..66407a1c 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 @@ -30,11 +30,15 @@ public class DeviceServiceImpl implements IDeviceService { if (device == null || device.getSubscribeCycleForCatalog() < 0) { return false; } + if (dynamicTask.contains(device.getDeviceId())) { + logger.info("[添加目录订阅] 设备{}的目录订阅以存在", device.getDeviceId()); + return false; + } + logger.info("[添加目录订阅] 设备{}", device.getDeviceId()); // 添加目录订阅 CatalogSubscribeTask catalogSubscribeTask = new CatalogSubscribeTask(device, sipCommander); catalogSubscribeTask.run(); // 提前开始刷新订阅 - // TODO 使用jain sip的当时刷新订阅 int subscribeCycleForCatalog = device.getSubscribeCycleForCatalog(); // 设置最小值为30 subscribeCycleForCatalog = Math.max(subscribeCycleForCatalog, 30); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java index a68f5e9b..16924df3 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java @@ -14,15 +14,23 @@ import java.util.Set; public class StreamPushUploadFileHandler extends AnalysisEventListener { + private ErrorDataHandler errorDataHandler; private IStreamPushService pushService; private String defaultMediaServerId; private List streamPushItems = new ArrayList<>(); private Set streamPushStreamSet = new HashSet<>(); private Set streamPushGBSet = new HashSet<>(); + private List errorStreamList = new ArrayList<>(); + private List errorGBList = new ArrayList<>(); - public StreamPushUploadFileHandler(IStreamPushService pushService, String defaultMediaServerId) { + public StreamPushUploadFileHandler(IStreamPushService pushService, String defaultMediaServerId, ErrorDataHandler errorDataHandler) { this.pushService = pushService; this.defaultMediaServerId = defaultMediaServerId; + this.errorDataHandler = errorDataHandler; + } + + public interface ErrorDataHandler{ + void handle(List streams, List gbId); } @Override @@ -32,9 +40,16 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener 0) { + pushService.batchAdd(streamPushItems); + } streamPushGBSet.clear(); streamPushStreamSet.clear(); + errorDataHandler.handle(errorStreamList, errorGBList); } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java index 8a99d626..9a5d3be6 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java @@ -50,7 +50,7 @@ public interface StreamPushMapper { StreamPushItem selectOne(String app, String stream); @Insert(" @@ -82,4 +118,8 @@ export default { .upload-box{ text-align: center; } +.errDataBox{ + max-height: 15rem; + overflow: auto; +} diff --git a/web_src/src/components/dialog/importChannelShowErrorData.vue b/web_src/src/components/dialog/importChannelShowErrorData.vue new file mode 100644 index 00000000..5194b7ee --- /dev/null +++ b/web_src/src/components/dialog/importChannelShowErrorData.vue @@ -0,0 +1,64 @@ + + + + diff --git a/web_src/src/components/dialog/jessibuca.vue b/web_src/src/components/dialog/jessibuca.vue index 7e9e0097..c073719d 100644 --- a/web_src/src/components/dialog/jessibuca.vue +++ b/web_src/src/components/dialog/jessibuca.vue @@ -78,7 +78,7 @@ export default { this.jessibuca = new window.Jessibuca(Object.assign( { container: this.$refs.container, - videoBuffer: 0.5, // 最大缓冲时长,单位秒 + videoBuffer: 0.2, // 最大缓冲时长,单位秒 isResize: true, isFlv: true, decoder: "./static/js/jessibuca/index.js",