处理服务重启或设备重新上线时的订阅,优化通道导入重复的处理
This commit is contained in:
@@ -35,6 +35,9 @@ public class OnlineEventListener implements ApplicationListener<OnlineEvent> {
|
||||
|
||||
@Autowired
|
||||
private IVideoManagerStorager storager;
|
||||
|
||||
@Autowired
|
||||
private IDeviceService deviceService;
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redis;
|
||||
@@ -57,6 +60,7 @@ public class OnlineEventListener implements ApplicationListener<OnlineEvent> {
|
||||
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<OnlineEvent> {
|
||||
}
|
||||
|
||||
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<DeviceChannel> deviceChannelList = storager.queryOnlineChannelsByDeviceId(device.getDeviceId());
|
||||
eventPublisher.catalogEventPublish(null, deviceChannelList, CatalogEvent.ON);
|
||||
}
|
||||
// 处理上线监听
|
||||
storager.updateDevice(device);
|
||||
|
||||
// TODO 上线添加订阅
|
||||
// 上线添加订阅
|
||||
if (device.getSubscribeCycleForCatalog() > 0) {
|
||||
deviceService.addCatalogSubscribe(device);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<CatalogEvent> {
|
||||
}else if (event.getGbStreams() != null) {
|
||||
if (platforms.size() > 0) {
|
||||
for (GbStream gbStream : event.getGbStreams()) {
|
||||
if (gbStream == null || StringUtils.isEmpty(gbStream.getGbId())) continue;
|
||||
List<ParentPlatform> parentPlatformsForGB = storager.queryPlatFormListForStreamWithGBId(gbStream.getApp(),gbStream.getStream(), platforms);
|
||||
parentPlatformMap.put(gbStream.getGbId(), parentPlatformsForGB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
switch (event.getType()) {
|
||||
case CatalogEvent.ON:
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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("<?xml version=\"1.0\" ?>\r\n")
|
||||
.append("<Response>\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("<?xml version=\"1.0\" ?>\r\n")
|
||||
.append("<Response>\r\n")
|
||||
|
||||
Reference in New Issue
Block a user