From 69d9692f6194d1e03ec81cf87ea8f0e7a62f7173 Mon Sep 17 00:00:00 2001
From: wangyimeng <421132955@qq.com>
Date: 星期三, 16 三月 2022 15:27:12 +0800
Subject: [PATCH] 删除重复字段
---
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java | 83 ++++++++++++++++++++++++++++-------------
1 files changed, 57 insertions(+), 26 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
index 91ebd5d..feabbf1 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
@@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.storager.impl;
+import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
@@ -41,7 +42,7 @@
@Component
public class VideoManagerStoragerImpl implements IVideoManagerStorager {
- private Logger logger = LoggerFactory.getLogger(VideoManagerStoragerImpl.class);
+ private final Logger logger = LoggerFactory.getLogger(VideoManagerStoragerImpl.class);
@Autowired
EventPublisher eventPublisher;
@@ -157,7 +158,10 @@
public synchronized void updateChannel(String deviceId, DeviceChannel channel) {
String channelId = channel.getChannelId();
channel.setDeviceId(deviceId);
- channel.setStreamId(streamSession.getStreamId(deviceId, channel.getChannelId()));
+ StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId);
+ if (streamInfo != null) {
+ channel.setStreamId(streamInfo.getStream());
+ }
String now = this.format.format(System.currentTimeMillis());
channel.setUpdateTime(now);
DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(deviceId, channelId);
@@ -167,6 +171,7 @@
}else {
deviceChannelMapper.update(channel);
}
+ deviceChannelMapper.updateChannelSubCount(deviceId,channel.getParentId());
}
@Override
@@ -179,7 +184,10 @@
if (channelList.size() == 0) {
for (DeviceChannel channel : channels) {
channel.setDeviceId(deviceId);
- channel.setStreamId(streamSession.getStreamId(deviceId, channel.getChannelId()));
+ StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channel.getChannelId());
+ if (streamInfo != null) {
+ channel.setStreamId(streamInfo.getStream());
+ }
String now = this.format.format(System.currentTimeMillis());
channel.setUpdateTime(now);
channel.setCreateTime(now);
@@ -190,9 +198,11 @@
channelsInStore.put(deviceChannel.getChannelId(), deviceChannel);
}
for (DeviceChannel channel : channels) {
- String channelId = channel.getChannelId();
channel.setDeviceId(deviceId);
- channel.setStreamId(streamSession.getStreamId(deviceId, channel.getChannelId()));
+ StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channel.getChannelId());
+ if (streamInfo != null) {
+ channel.setStreamId(streamInfo.getStream());
+ }
String now = this.format.format(System.currentTimeMillis());
channel.setUpdateTime(now);
if (channelsInStore.get(channel.getChannelId()) != null) {
@@ -275,7 +285,8 @@
logger.debug("[鐩綍鏌ヨ]鏀跺埌鐨勬暟鎹瓨鍦ㄩ噸澶嶏細 {}" , stringBuilder);
}
try {
- int cleanChannelsResult = deviceChannelMapper.cleanChannelsByDeviceId(deviceId);
+// int cleanChannelsResult = deviceChannelMapper.cleanChannelsByDeviceId(deviceId);
+ int cleanChannelsResult = deviceChannelMapper.cleanChannelsNotInList(deviceId, channels);
int limitCount = 300;
boolean result = cleanChannelsResult < 0;
if (!result && channels.size() > 0) {
@@ -532,7 +543,7 @@
if (parentPlatformCatch == null) { // serverGBId 宸插彉鍖�
ParentPlatform parentPlatById = platformMapper.getParentPlatById(parentPlatform.getId());
// 浣跨敤鏃х殑鏌ュ嚭缂撳瓨ID
- parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatById.getServerGBId());
+ parentPlatformCatch = new ParentPlatformCatch();
parentPlatformCatch.setId(parentPlatform.getServerGBId());
redisCatchStorage.delPlatformCatchInfo(parentPlatById.getServerGBId());
}
@@ -608,19 +619,19 @@
@Override
public int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId) {
- Map<String, ChannelReduce> deviceAndChannels = new HashMap<>();
+ Map<Integer, ChannelReduce> deviceAndChannels = new HashMap<>();
for (ChannelReduce channelReduce : channelReduces) {
channelReduce.setCatalogId(catalogId);
- deviceAndChannels.put(channelReduce.getDeviceId() + "_" + channelReduce.getChannelId(), channelReduce);
+ deviceAndChannels.put(channelReduce.getId(), channelReduce);
}
- List<String> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet());
+ List<Integer> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet());
// 鏌ヨ褰撳墠宸茬粡瀛樺湪鐨�
- List<String> relatedPlatformchannels = platformChannelMapper.findChannelRelatedPlatform(platformId, deviceAndChannelList);
- if (relatedPlatformchannels != null) {
- deviceAndChannelList.removeAll(relatedPlatformchannels);
+ List<Integer> channelIds = platformChannelMapper.findChannelRelatedPlatform(platformId, channelReduces);
+ if (deviceAndChannelList != null) {
+ deviceAndChannelList.removeAll(channelIds);
}
- for (String relatedPlatformchannel : relatedPlatformchannels) {
- deviceAndChannels.remove(relatedPlatformchannel);
+ for (Integer channelId : channelIds) {
+ deviceAndChannels.remove(channelId);
}
List<ChannelReduce> channelReducesToAdd = new ArrayList<>(deviceAndChannels.values());
// 瀵瑰墿涓嬬殑鏁版嵁杩涜瀛樺偍
@@ -652,8 +663,16 @@
@Override
public DeviceChannel queryChannelInParentPlatform(String platformId, String channelId) {
- DeviceChannel channel = platformChannelMapper.queryChannelInParentPlatform(platformId, channelId);
- return channel;
+ List<DeviceChannel> channels = platformChannelMapper.queryChannelInParentPlatform(platformId, channelId);
+ if (channels.size() > 1) {
+ // 鍑虹幇闀垮害澶т簬0鐨勬椂鍊欒偗瀹氭槸鍥芥爣閫氶亾鐨処D閲嶅浜�
+ logger.warn("鍥芥爣ID瀛樺湪閲嶅锛歿}", channelId);
+ }
+ if (channels.size() == 0) {
+ return null;
+ }else {
+ return channels.get(0);
+ }
}
@Override
@@ -670,8 +689,18 @@
@Override
public Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId) {
- Device device = platformChannelMapper.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId);
- return device;
+ List<Device> devices = platformChannelMapper.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId);
+ if (devices.size() > 1) {
+ // 鍑虹幇闀垮害澶т簬0鐨勬椂鍊欒偗瀹氭槸鍥芥爣閫氶亾鐨処D閲嶅浜�
+ logger.warn("鍥芥爣ID瀛樺湪閲嶅锛歿}", channelId);
+ }
+ if (devices.size() == 0) {
+ return null;
+ }else {
+ return devices.get(0);
+ }
+
+
}
/**
@@ -708,7 +737,7 @@
try {
if (streamProxyMapper.add(streamProxyItem) > 0) {
if (!StringUtils.isEmpty(streamProxyItem.getGbId())) {
- if (gbStreamMapper.add(streamProxyItem) > 0) {
+ if (gbStreamMapper.add(streamProxyItem) < 0) {
//浜嬪姟鍥炴粴
dataSourceTransactionManager.rollback(transactionStatus);
return false;
@@ -743,13 +772,13 @@
try {
if (streamProxyMapper.update(streamProxyItem) > 0) {
if (!StringUtils.isEmpty(streamProxyItem.getGbId())) {
- if (gbStreamMapper.update(streamProxyItem) > 0) {
+ if (gbStreamMapper.update(streamProxyItem) < 0) {
//浜嬪姟鍥炴粴
dataSourceTransactionManager.rollback(transactionStatus);
return false;
}
}
- }else {
+ } else {
//浜嬪姟鍥炴粴
dataSourceTransactionManager.rollback(transactionStatus);
return false;
@@ -856,12 +885,11 @@
List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream();
if (parentPlatforms.size() > 0) {
for (ParentPlatform parentPlatform : parentPlatforms) {
- streamPushItem.setCatalogId(parentPlatform.getCatalogId());
- streamPushItem.setPlatformId(parentPlatform.getServerGBId());
- String stream = streamPushItem.getStream();
- StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(streamPushItem.getApp(), stream,
+ StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(streamPushItem.getApp(), streamPushItem.getStream(),
parentPlatform.getServerGBId());
if (streamProxyItems == null) {
+ streamPushItem.setCatalogId(parentPlatform.getCatalogId());
+ streamPushItem.setPlatformId(parentPlatform.getServerGBId());
platformGbStreamMapper.add(streamPushItem);
eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), streamPushItem, CatalogEvent.ADD);
}
@@ -1073,6 +1101,9 @@
@Override
public List<ParentPlatform> queryPlatFormListForStreamWithGBId(String app, String stream, List<String> platforms) {
+ if (platforms == null || platforms.size() == 0) {
+ return new ArrayList<>();
+ }
return platformGbStreamMapper.queryPlatFormListForGBWithGBId(app, stream, platforms);
}
--
Gitblit v1.8.0