[集群] 支持国标级联目录更新
parent
3903bc31b5
commit
232fa760e2
|
@ -1,14 +1,18 @@
|
||||||
package com.genersoft.iot.vmp.gb28181.event;
|
package com.genersoft.iot.vmp.gb28181.event;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.bean.Platform;
|
||||||
import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent;
|
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.RecordInfoEvent;
|
|
||||||
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.mobilePosition.MobilePositionEvent;
|
import com.genersoft.iot.vmp.gb28181.event.subscribe.mobilePosition.MobilePositionEvent;
|
||||||
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
import com.genersoft.iot.vmp.media.bean.MediaServer;
|
||||||
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;
|
||||||
|
import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationEventPublisher;
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -30,6 +34,12 @@ public class EventPublisher {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationEventPublisher applicationEventPublisher;
|
private ApplicationEventPublisher applicationEventPublisher;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserSetting userSetting;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IRedisRpcService redisRpcService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备报警事件
|
* 设备报警事件
|
||||||
* @param deviceAlarm
|
* @param deviceAlarm
|
||||||
|
@ -66,6 +76,15 @@ public class EventPublisher {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void catalogEventPublish(Platform platform, List<CommonGBChannel> deviceChannels, String type) {
|
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);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
CatalogEvent outEvent = new CatalogEvent(this);
|
CatalogEvent outEvent = new CatalogEvent(this);
|
||||||
List<CommonGBChannel> channels = new ArrayList<>();
|
List<CommonGBChannel> channels = new ArrayList<>();
|
||||||
if (deviceChannels.size() > 1) {
|
if (deviceChannels.size() > 1) {
|
||||||
|
|
|
@ -43,6 +43,8 @@ public interface IPlatformChannelService {
|
||||||
|
|
||||||
CommonGBChannel queryChannelByPlatformIdAndChannelId(Integer platformId, Integer channelId);
|
CommonGBChannel queryChannelByPlatformIdAndChannelId(Integer platformId, Integer channelId);
|
||||||
|
|
||||||
|
List<CommonGBChannel> queryChannelByPlatformIdAndChannelIds(Integer platformId, List<Integer> channelIds);
|
||||||
|
|
||||||
void checkRegionAdd(List<CommonGBChannel> channelList);
|
void checkRegionAdd(List<CommonGBChannel> channelList);
|
||||||
|
|
||||||
void checkRegionRemove(List<CommonGBChannel> channelList, List<Region> regionList);
|
void checkRegionRemove(List<CommonGBChannel> channelList, List<Region> regionList);
|
||||||
|
|
|
@ -596,4 +596,9 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
||||||
public CommonGBChannel queryChannelByPlatformIdAndChannelId(Integer platformId, Integer channelId) {
|
public CommonGBChannel queryChannelByPlatformIdAndChannelId(Integer platformId, Integer channelId) {
|
||||||
return platformChannelMapper.queryShareChannel(platformId, channelId);
|
return platformChannelMapper.queryShareChannel(platformId, channelId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CommonGBChannel> queryChannelByPlatformIdAndChannelIds(Integer platformId, List<Integer> channelIds) {
|
||||||
|
return platformChannelMapper.queryShare(platformId, channelIds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ import com.genersoft.iot.vmp.gb28181.bean.Platform;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.SendRtpInfo;
|
import com.genersoft.iot.vmp.gb28181.bean.SendRtpInfo;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface IRedisRpcService {
|
public interface IRedisRpcService {
|
||||||
|
|
||||||
SendRtpInfo getSendRtpItem(String callId);
|
SendRtpInfo getSendRtpItem(String callId);
|
||||||
|
@ -30,4 +32,6 @@ public interface IRedisRpcService {
|
||||||
void subscribeMobilePosition(int id, int cycle, int interval);
|
void subscribeMobilePosition(int id, int cycle, int interval);
|
||||||
|
|
||||||
boolean updatePlatform(String serverId, Platform platform);
|
boolean updatePlatform(String serverId, Platform platform);
|
||||||
|
|
||||||
|
void catalogEventPublish(String serverId, Integer platformId, List<Integer> channelIds, String type);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,10 @@ import com.genersoft.iot.vmp.conf.redis.RedisRpcConfig;
|
||||||
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage;
|
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcMessage;
|
||||||
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest;
|
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcRequest;
|
||||||
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse;
|
import com.genersoft.iot.vmp.conf.redis.bean.RedisRpcResponse;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.Platform;
|
import com.genersoft.iot.vmp.gb28181.bean.Platform;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.service.IPlatformChannelService;
|
||||||
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
|
import com.genersoft.iot.vmp.gb28181.service.IPlatformService;
|
||||||
import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcController;
|
import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcController;
|
||||||
import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcMapping;
|
import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcMapping;
|
||||||
|
@ -17,6 +20,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RedisRpcController("platform")
|
@RedisRpcController("platform")
|
||||||
|
@ -31,6 +37,12 @@ public class RedisRpcPlatformController extends RpcController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IPlatformService platformService;
|
private IPlatformService platformService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IPlatformChannelService platformChannelService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EventPublisher eventPublisher;
|
||||||
|
|
||||||
|
|
||||||
private void sendResponse(RedisRpcResponse response){
|
private void sendResponse(RedisRpcResponse response){
|
||||||
log.info("[redis-rpc] >> {}", response);
|
log.info("[redis-rpc] >> {}", response);
|
||||||
|
@ -53,4 +65,28 @@ public class RedisRpcPlatformController extends RpcController {
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 目录更新推送
|
||||||
|
*/
|
||||||
|
@RedisRpcMapping("catalogEventPublish")
|
||||||
|
public RedisRpcResponse catalogEventPublish(RedisRpcRequest request) {
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(request.getParam().toString());
|
||||||
|
int platformId = jsonObject.getIntValue("platformId");
|
||||||
|
Integer[] channelIds = jsonObject.getJSONArray("channelIds").toArray(Integer.class);
|
||||||
|
String type = jsonObject.getString("type");
|
||||||
|
RedisRpcResponse response = request.getResponse();
|
||||||
|
|
||||||
|
Platform platform = platformService.queryOne(platformId);
|
||||||
|
if (platform == null ) {
|
||||||
|
log.warn("[]");
|
||||||
|
response.setStatusCode(ErrorCode.ERROR400.getCode());
|
||||||
|
response.setBody(ErrorCode.ERROR400.getMsg());
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
List<CommonGBChannel> commonGBChannels = platformChannelService.queryChannelByPlatformIdAndChannelIds(platformId, Arrays.asList(channelIds));
|
||||||
|
eventPublisher.catalogEventPublish(platform, commonGBChannels, type);
|
||||||
|
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class RedisRpcServiceImpl implements IRedisRpcService {
|
public class RedisRpcServiceImpl implements IRedisRpcService {
|
||||||
|
@ -229,4 +231,14 @@ public class RedisRpcServiceImpl implements IRedisRpcService {
|
||||||
RedisRpcResponse response = redisRpcConfig.request(request, 40);
|
RedisRpcResponse response = redisRpcConfig.request(request, 40);
|
||||||
return Boolean.parseBoolean(response.getBody().toString());
|
return Boolean.parseBoolean(response.getBody().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void catalogEventPublish(String serverId, Integer platformId, List<Integer> channelIds, String type) {
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("platformId", platformId);
|
||||||
|
jsonObject.put("channelIds", channelIds);
|
||||||
|
jsonObject.put("type", type);
|
||||||
|
RedisRpcRequest request = buildRequest("platform/catalogEventPublish", jsonObject);
|
||||||
|
redisRpcConfig.request(request, 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue