[集群] 优化国标级联目录更新

This commit is contained in:
648540858
2025-01-03 16:21:20 +08:00
parent b650d5821d
commit 42322c75cc
5 changed files with 31 additions and 38 deletions

View File

@@ -35,10 +35,10 @@ public class EventPublisher {
private ApplicationEventPublisher applicationEventPublisher;
@Autowired
private UserSetting userSetting;
private UserSetting userSetting;
@Autowired
private IRedisRpcService redisRpcService;
private IRedisRpcService redisRpcService;
/**
* 设备报警事件
@@ -76,15 +76,15 @@ public class EventPublisher {
}
public void catalogEventPublish(Platform platform, List<CommonGBChannel> deviceChannels, String type) {
if (!userSetting.getServerId().equals(platform.getServerId())) {
List<Integer> ids = new ArrayList<>();
for (int i = 0; i < deviceChannels.size(); i++) {
ids.add(deviceChannels.get(i).getGbId());
}
redisRpcService.catalogEventPublish(platform.getServerId(), platform.getId(), ids, type);
if (platform != null && !userSetting.getServerId().equals(platform.getServerId())) {
// 指定了上级平台的推送,则发送到指定的设备,未指定的则全部发送, 接收后各自处理自己的
CatalogEvent outEvent = new CatalogEvent(this);
outEvent.setChannels(deviceChannels);
outEvent.setType(type);
outEvent.setPlatform(platform);
redisRpcService.catalogEventPublish(platform.getServerId(), outEvent);
return;
}
CatalogEvent outEvent = new CatalogEvent(this);
List<CommonGBChannel> channels = new ArrayList<>();
if (deviceChannels.size() > 1) {
@@ -103,6 +103,14 @@ public class EventPublisher {
outEvent.setType(type);
outEvent.setPlatform(platform);
applicationEventPublisher.publishEvent(outEvent);
if (platform == null) {
// 如果没指定上级平台则推送消息到所有在线的wvp处理自己含有的平台的目录更新
redisRpcService.catalogEventPublish(null, outEvent);
}
}
public void catalogEventPublish(CatalogEvent event) {
applicationEventPublisher.publishEvent(event);
}
public void mobilePositionEventPublish(MobilePosition mobilePosition) {

View File

@@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.gb28181.event.subscribe.catalog;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
@@ -7,6 +8,7 @@ import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo;
import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService;
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
@@ -15,10 +17,7 @@ import org.springframework.stereotype.Component;
import javax.sip.InvalidArgumentException;
import javax.sip.SipException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* catalog事件
@@ -30,9 +29,6 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
@Autowired
private IPlatformChannelService platformChannelService;
@Autowired
private IPlatformService platformService;
@Autowired
private ISIPCommanderForPlatform sipCommanderFroPlatform;