临时提交

pull/1642/head
648540858 2024-08-28 18:00:42 +08:00
parent ddf917d127
commit 1efb5fca0f
5 changed files with 76 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.gb28181.bean;
import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.common.VideoManagerConstants;
import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -23,6 +24,9 @@ public class SubscribeHolder {
@Autowired @Autowired
private UserSetting userSetting; private UserSetting userSetting;
@Autowired
private EventPublisher eventPublisher;
private final String taskOverduePrefix = "subscribe_overdue_"; private final String taskOverduePrefix = "subscribe_overdue_";
private static ConcurrentHashMap<String, SubscribeInfo> catalogMap = new ConcurrentHashMap<>(); private static ConcurrentHashMap<String, SubscribeInfo> catalogMap = new ConcurrentHashMap<>();
@ -37,6 +41,8 @@ public class SubscribeHolder {
// 添加任务处理订阅过期 // 添加任务处理订阅过期
dynamicTask.startDelay(taskOverdueKey, () -> removeCatalogSubscribe(subscribeInfo.getId()), dynamicTask.startDelay(taskOverdueKey, () -> removeCatalogSubscribe(subscribeInfo.getId()),
subscribeInfo.getExpires() * 1000); subscribeInfo.getExpires() * 1000);
// 发送目录订阅添加通知
eventPublisher.catalogSubscribePutEventPublish(platformId, subscribeInfo);
} }
} }

View File

@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent;
import com.genersoft.iot.vmp.gb28181.event.device.RequestTimeoutEvent; import com.genersoft.iot.vmp.gb28181.event.device.RequestTimeoutEvent;
import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEvent; import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEvent;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogSubscribePutEvent;
import com.genersoft.iot.vmp.gb28181.event.subscribe.mobilePosition.MobilePositionEvent; import com.genersoft.iot.vmp.gb28181.event.subscribe.mobilePosition.MobilePositionEvent;
import com.genersoft.iot.vmp.media.event.mediaServer.MediaServerOfflineEvent; import com.genersoft.iot.vmp.media.event.mediaServer.MediaServerOfflineEvent;
import com.genersoft.iot.vmp.media.event.mediaServer.MediaServerOnlineEvent; import com.genersoft.iot.vmp.media.event.mediaServer.MediaServerOnlineEvent;
@ -106,4 +107,10 @@ public class EventPublisher {
applicationEventPublisher.publishEvent(outEvent); applicationEventPublisher.publishEvent(outEvent);
} }
public void catalogSubscribePutEventPublish(String platformId, SubscribeInfo subscribeInfo) {
CatalogSubscribePutEvent event = new CatalogSubscribePutEvent(this);
event.setPlatformId(platformId);
event.setSubscribeInfo(subscribeInfo);
applicationEventPublisher.publishEvent(event);
}
} }

View File

@ -0,0 +1,21 @@
package com.genersoft.iot.vmp.gb28181.event.subscribe.catalog;
import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo;
import lombok.Getter;
import lombok.Setter;
import org.springframework.context.ApplicationEvent;
public class CatalogSubscribePutEvent extends ApplicationEvent {
public CatalogSubscribePutEvent(Object source) {
super(source);
}
@Getter
@Setter
private SubscribeInfo subscribeInfo;
@Getter
@Setter
private String platformId;
}

View File

@ -0,0 +1,41 @@
package com.genersoft.iot.vmp.gb28181.event.subscribe.catalog;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class CatalogSubscribePutEventLister implements ApplicationListener<CatalogSubscribePutEvent> {
@Autowired
private IPlatformService platformService;
@Autowired
private EventPublisher eventPublisher;
@Override
public void onApplicationEvent(CatalogSubscribePutEvent event) {
Platform platform = platformService.queryPlatformByServerGBId(event.getPlatformId());
if (platform == null){
return;
}
CommonGBChannel channel = CommonGBChannel.build(platform);
// 发送消息
try {
// 发送catalog
eventPublisher.catalogEventPublish(platform.getId(), channel, CatalogEvent.ADD);
} catch (Exception e) {
log.warn("[推送平台信息] 发送失败,平台{}{}", platform.getName(), platform.getServerGBId(), e);
}
}
}

View File

@ -319,6 +319,7 @@ public class PlatformServiceImpl implements IPlatformService {
if (subscribeHolder.getCatalogSubscribe(platform.getServerGBId()) == null) { if (subscribeHolder.getCatalogSubscribe(platform.getServerGBId()) == null) {
log.info("[国标级联]{}, 添加自动通道推送模拟订阅信息", platform.getServerGBId()); log.info("[国标级联]{}, 添加自动通道推送模拟订阅信息", platform.getServerGBId());
addSimulatedSubscribeInfo(platform); addSimulatedSubscribeInfo(platform);
} }
}else { }else {
SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(platform.getServerGBId()); SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(platform.getServerGBId());