优化日志以及属性设置代码

This commit is contained in:
648540858
2024-07-03 16:14:18 +08:00
parent 10c852c00d
commit 799932f614
95 changed files with 881 additions and 2385 deletions

View File

@@ -1,7 +1,6 @@
package com.genersoft.iot.vmp.storager;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
@@ -58,18 +57,6 @@ public interface IVideoManagerStorage {
* @return
*/
public PageInfo<DeviceChannel> queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice, int page, int count);
public List<DeviceChannelExtend> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, List<String> channelIds, String query, Boolean hasSubChannel, Boolean online, int start, int limit);
/**
* 获取某个设备的通道列表
*
* @param deviceId 设备ID
* @return
*/
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId,Boolean online,List<String> channelIds);
public List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
/**
* 获取某个设备的通道
@@ -78,13 +65,6 @@ public interface IVideoManagerStorage {
*/
public DeviceChannel queryChannel(String deviceId, String channelId);
/**
* 删除通道
* @param deviceId 设备ID
* @param channelId 通道ID
*/
public int delChannel(String deviceId, String channelId);
/**
* 获取多个设备
* @param page 当前页数
@@ -113,27 +93,12 @@ public interface IVideoManagerStorage {
*/
PageInfo querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, Boolean online, int page, int count);
/**
* 清空通道
* @param deviceId
*/
void cleanChannelsForDevice(String deviceId);
/**
* 更新上级平台
* @param parentPlatform
*/
boolean updateParentPlatform(ParentPlatform parentPlatform);
/**
* 添加上级平台
* @param parentPlatform
*/
boolean addParentPlatform(ParentPlatform parentPlatform);
/**
* 删除上级平台
* @param parentPlatform
@@ -153,22 +118,11 @@ public interface IVideoManagerStorage {
*/
ParentPlatform queryParentPlatByServerGBId(String platformGbId);
/**
* 所有平台离线
*/
void outlineForAllParentPlatform();
/**
* 查询通道信息,不区分设备(已关联平台或全部)
*/
PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId);
/**
* 查询设备的通道信息
*/
List<DeviceChannelInPlatform> queryChannelListInParentPlatform(String platformId);
/**
* 移除上级平台的通道信息
@@ -181,9 +135,6 @@ public interface IVideoManagerStorage {
DeviceChannel queryChannelInParentPlatform(String platformId, String channelId);
List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId);
List<PlatformCatalog> queryStreamInParentPlatformAndCatalog(String platformId, String catalogId);
Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId);
/**
@@ -193,12 +144,6 @@ public interface IVideoManagerStorage {
* @return 设备信息
*/
Device queryDeviceInfoByPlatformIdAndChannelId(String platformId, String channelId);
/**
* 添加Mobile Position设备移动位置
* @param mobilePosition
* @return
*/
public boolean insertMobilePosition(MobilePosition mobilePosition);
/**
* 查询移动位置轨迹
@@ -214,43 +159,6 @@ public interface IVideoManagerStorage {
*/
public MobilePosition queryLatestPosition(String deviceId);
/**
* 删除指定设备的所有移动位置
* @param deviceId
*/
public int clearMobilePositionsByDeviceId(String deviceId);
/**
* 移除代理流
* @param app
* @param stream
* @return
*/
public int deleteStreamProxy(String app, String stream);
/**
* 按照是否启用获取代理流
* @param enable
* @return
*/
public List<StreamProxy> getStreamProxyListForEnable(boolean enable);
/**
* 按照是app和stream获取代理流
* @param app
* @param stream
* @return
*/
public StreamProxy queryStreamProxy(String app, String stream);
/**
* 获取代理流
* @param page
* @param count
* @return
*/
PageInfo<StreamProxy> queryStreamProxyList(Integer page, Integer count);
/**
* 根据国标ID获取平台关联的直播流
* @param platformId
@@ -259,43 +167,6 @@ public interface IVideoManagerStorage {
*/
GbStream queryStreamInParentPlatform(String platformId, String channelId);
/**
* 获取平台关联的直播流
* @param platformId
* @return
*/
List<DeviceChannel> queryGbStreamListInPlatform(String platformId);
/**
* 移除单个推流
* @param app
* @param stream
*/
int removeMedia(String app, String stream);
/**
* 设置流离线
*/
int mediaOffline(String app, String streamId);
/**
* 设置流上线
*/
int mediaOnline(String app, String streamId);
/**
* 设置平台在线/离线
*/
void updateParentPlatformStatus(String platformGbID, boolean online);
/**
* 根据媒体ID获取启用/不启用的代理列表
* @param id 媒体ID
* @param enable 启用/不启用
* @return
*/
List<StreamProxy> getStreamProxyListForEnableInMediaServer(String id, boolean enable);
/**
* 根据通道ID获取其所在设备
* @param channelId 通道ID
@@ -303,35 +174,6 @@ public interface IVideoManagerStorage {
*/
Device queryVideoDeviceByChannelId(String channelId);
/**
* 通道上线
* @param channelId 通道ID
*/
void deviceChannelOnline(String deviceId, String channelId);
/**
* 通道离线
* @param channelId 通道ID
*/
void deviceChannelOffline(String deviceId, String channelId);
/**
* 通过app与stream获取StreamProxy
* @param app
* @param streamId
* @return
*/
StreamProxy getStreamProxyByAppAndStream(String app, String streamId);
/**
* catlog查询结束后完全重写通道信息
* @param deviceId
* @param deviceChannelList
*/
boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList);
boolean updateChannels(String deviceId, List<DeviceChannel> deviceChannelList);
/**
* 获取目录信息
* @param platformId
@@ -350,18 +192,12 @@ public interface IVideoManagerStorage {
int setDefaultCatalog(String platformId, String catalogId);
List<DeviceChannel> queryCatalogInPlatform(String serverGBId);
int delRelation(PlatformCatalog platformCatalog);
int updateStreamGPS(List<GPSMsgInfo> gpsMsgInfo);
List<ParentPlatform> queryPlatFormListForGBWithGBId(String channelId, List<String> platforms);
List<ParentPlatform> queryPlatFormListForStreamWithGBId(String app, String stream, List<String> platforms);
GbStream getGbStream(String app, String streamId);
void delCatalogByPlatformId(String serverGBId);
void delRelationByPlatformId(String serverGBId);
@@ -370,12 +206,6 @@ public interface IVideoManagerStorage {
List<ChannelSourceInfo> getChannelSource(String platformId, String gbId);
void updateChannelPosition(DeviceChannel deviceChannel);
void cleanContentForPlatform(String serverGBId);
List<DeviceChannel> queryChannelWithCatalog(String serverGBId);
List<DeviceChannelExtend> queryChannelsByDeviceId(String serial, List<String> channelIds, Boolean online);
List<ParentPlatform> queryEnablePlatformListWithAsMessageChannel();

View File

@@ -6,7 +6,6 @@ import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
import com.genersoft.iot.vmp.streamProxy.bean.StreamProxy;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
@@ -25,13 +24,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Component;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.ArrayList;
import java.util.List;
/**
* 视频设备数据存储-jdbc实现
@@ -108,269 +104,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return deviceMapper.getDeviceByDeviceId(deviceId) != null;
}
@Override
public boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList) {
if (CollectionUtils.isEmpty(deviceChannelList)) {
return false;
}
List<DeviceChannel> allChannels = deviceChannelMapper.queryAllChannels(deviceId);
Map<String,DeviceChannel> allChannelMap = new ConcurrentHashMap<>();
if (allChannels.size() > 0) {
for (DeviceChannel deviceChannel : allChannels) {
allChannelMap.put(deviceChannel.getChannelId(), deviceChannel);
}
}
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
// 数据去重
List<DeviceChannel> channels = new ArrayList<>();
List<DeviceChannel> updateChannels = new ArrayList<>();
List<DeviceChannel> addChannels = new ArrayList<>();
List<DeviceChannel> deleteChannels = new ArrayList<>();
StringBuilder stringBuilder = new StringBuilder();
Map<String, Integer> subContMap = new HashMap<>();
// 数据去重
Set<String> gbIdSet = new HashSet<>();
for (DeviceChannel deviceChannel : deviceChannelList) {
if (gbIdSet.contains(deviceChannel.getChannelId())) {
stringBuilder.append(deviceChannel.getChannelId()).append(",");
continue;
}
gbIdSet.add(deviceChannel.getChannelId());
if (allChannelMap.containsKey(deviceChannel.getChannelId())) {
deviceChannel.setStreamId(allChannelMap.get(deviceChannel.getChannelId()).getStreamId());
deviceChannel.setHasAudio(allChannelMap.get(deviceChannel.getChannelId()).getHasAudio());
if (allChannelMap.get(deviceChannel.getChannelId()).isStatus() !=deviceChannel.isStatus()){
List<String> strings = platformChannelMapper.queryParentPlatformByChannelId(deviceChannel.getChannelId());
if (!CollectionUtils.isEmpty(strings)){
strings.forEach(platformId->{
eventPublisher.catalogEventPublish(platformId, deviceChannel, deviceChannel.isStatus()?CatalogEvent.ON:CatalogEvent.OFF);
});
}
}
deviceChannel.setUpdateTime(DateUtil.getNow());
updateChannels.add(deviceChannel);
}else {
deviceChannel.setCreateTime(DateUtil.getNow());
deviceChannel.setUpdateTime(DateUtil.getNow());
addChannels.add(deviceChannel);
}
allChannelMap.remove(deviceChannel.getChannelId());
channels.add(deviceChannel);
if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) {
if (subContMap.get(deviceChannel.getParentId()) == null) {
subContMap.put(deviceChannel.getParentId(), 1);
}else {
Integer count = subContMap.get(deviceChannel.getParentId());
subContMap.put(deviceChannel.getParentId(), count++);
}
}
}
deleteChannels.addAll(allChannelMap.values());
if (!channels.isEmpty()) {
for (DeviceChannel channel : channels) {
if (subContMap.get(channel.getChannelId()) != null){
Integer count = subContMap.get(channel.getChannelId());
if (count > 0) {
channel.setSubCount(count);
channel.setParental(1);
}
}
}
}
if (stringBuilder.length() > 0) {
logger.info("[目录查询]收到的数据存在重复: {}" , stringBuilder);
}
if(CollectionUtils.isEmpty(channels)){
logger.info("通道重设,数据为空={}" , deviceChannelList);
return false;
}
try {
int limitCount = 50;
boolean result = false;
if (!result && !addChannels.isEmpty()) {
if (addChannels.size() > limitCount) {
for (int i = 0; i < addChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > addChannels.size()) {
toIndex = addChannels.size();
}
result = result || deviceChannelMapper.batchAdd(addChannels.subList(i, toIndex)) < 0;
}
}else {
result = result || deviceChannelMapper.batchAdd(addChannels) < 0;
}
}
if (!result && !updateChannels.isEmpty()) {
if (updateChannels.size() > limitCount) {
for (int i = 0; i < updateChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > updateChannels.size()) {
toIndex = updateChannels.size();
}
result = result || deviceChannelMapper.batchUpdate(updateChannels.subList(i, toIndex)) < 0;
}
}else {
result = result || deviceChannelMapper.batchUpdate(updateChannels) < 0;
}
}
if (!result && !deleteChannels.isEmpty()) {
System.out.println("删除: " + deleteChannels.size());
if (deleteChannels.size() > limitCount) {
for (int i = 0; i < deleteChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > deleteChannels.size()) {
toIndex = deleteChannels.size();
}
result = result || deviceChannelMapper.batchDel(deleteChannels.subList(i, toIndex)) < 0;
}
}else {
result = result || deviceChannelMapper.batchDel(deleteChannels) < 0;
}
}
if (result) {
//事务回滚
dataSourceTransactionManager.rollback(transactionStatus);
}
dataSourceTransactionManager.commit(transactionStatus); //手动提交
return true;
}catch (Exception e) {
logger.error("未处理的异常 ", e);
dataSourceTransactionManager.rollback(transactionStatus);
return false;
}
}
@Override
public boolean updateChannels(String deviceId, List<DeviceChannel> deviceChannelList) {
if (CollectionUtils.isEmpty(deviceChannelList)) {
return false;
}
List<DeviceChannel> allChannels = deviceChannelMapper.queryAllChannels(deviceId);
Map<String,DeviceChannel> allChannelMap = new ConcurrentHashMap<>();
if (allChannels.size() > 0) {
for (DeviceChannel deviceChannel : allChannels) {
allChannelMap.put(deviceChannel.getChannelId(), deviceChannel);
}
}
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
// 数据去重
List<DeviceChannel> channels = new ArrayList<>();
List<DeviceChannel> updateChannels = new ArrayList<>();
List<DeviceChannel> addChannels = new ArrayList<>();
StringBuilder stringBuilder = new StringBuilder();
Map<String, Integer> subContMap = new HashMap<>();
if (deviceChannelList.size() > 0) {
// 数据去重
Set<String> gbIdSet = new HashSet<>();
for (DeviceChannel deviceChannel : deviceChannelList) {
if (!gbIdSet.contains(deviceChannel.getChannelId())) {
gbIdSet.add(deviceChannel.getChannelId());
deviceChannel.setUpdateTime(DateUtil.getNow());
if (allChannelMap.containsKey(deviceChannel.getChannelId())) {
deviceChannel.setStreamId(allChannelMap.get(deviceChannel.getChannelId()).getStreamId());
deviceChannel.setHasAudio(allChannelMap.get(deviceChannel.getChannelId()).getHasAudio());
if (allChannelMap.get(deviceChannel.getChannelId()).isStatus() !=deviceChannel.isStatus()){
List<String> strings = platformChannelMapper.queryParentPlatformByChannelId(deviceChannel.getChannelId());
if (!CollectionUtils.isEmpty(strings)){
strings.forEach(platformId->{
eventPublisher.catalogEventPublish(platformId, deviceChannel, deviceChannel.isStatus()?CatalogEvent.ON:CatalogEvent.OFF);
});
}
}
updateChannels.add(deviceChannel);
}else {
deviceChannel.setCreateTime(DateUtil.getNow());
addChannels.add(deviceChannel);
}
channels.add(deviceChannel);
if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) {
if (subContMap.get(deviceChannel.getParentId()) == null) {
subContMap.put(deviceChannel.getParentId(), 1);
}else {
Integer count = subContMap.get(deviceChannel.getParentId());
subContMap.put(deviceChannel.getParentId(), count++);
}
}
}else {
stringBuilder.append(deviceChannel.getChannelId()).append(",");
}
}
if (channels.size() > 0) {
for (DeviceChannel channel : channels) {
if (subContMap.get(channel.getChannelId()) != null){
channel.setSubCount(subContMap.get(channel.getChannelId()));
}
}
}
}
if (stringBuilder.length() > 0) {
logger.info("[目录查询]收到的数据存在重复: {}" , stringBuilder);
}
if(CollectionUtils.isEmpty(channels)){
logger.info("通道重设,数据为空={}" , deviceChannelList);
return false;
}
try {
int limitCount = 50;
boolean result = false;
if (addChannels.size() > 0) {
if (addChannels.size() > limitCount) {
for (int i = 0; i < addChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > addChannels.size()) {
toIndex = addChannels.size();
}
result = result || deviceChannelMapper.batchAdd(addChannels.subList(i, toIndex)) < 0;
}
}else {
result = result || deviceChannelMapper.batchAdd(addChannels) < 0;
}
}
if (updateChannels.size() > 0) {
if (updateChannels.size() > limitCount) {
for (int i = 0; i < updateChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > updateChannels.size()) {
toIndex = updateChannels.size();
}
result = result || deviceChannelMapper.batchUpdate(updateChannels.subList(i, toIndex)) < 0;
}
}else {
result = result || deviceChannelMapper.batchUpdate(updateChannels) < 0;
}
}
if (result) {
//事务回滚
dataSourceTransactionManager.rollback(transactionStatus);
}
dataSourceTransactionManager.commit(transactionStatus); //手动提交
return true;
}catch (Exception e) {
logger.error("未处理的异常 ", e);
dataSourceTransactionManager.rollback(transactionStatus);
return false;
}
}
@Override
public void deviceChannelOnline(String deviceId, String channelId) {
deviceChannelMapper.online(deviceId, channelId);
}
@Override
public void deviceChannelOffline(String deviceId, String channelId) {
deviceChannelMapper.offline(deviceId, channelId);
}
@Override
public void startPlay(String deviceId, String channelId, String streamId) {
@@ -409,17 +142,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return new PageInfo<>(all);
}
@Override
public List<DeviceChannelExtend> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, List<String> channelIds, String query, Boolean hasSubChannel, Boolean online, int start, int limit) {
return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, channelIds, null, query, hasSubChannel, online, start, limit);
}
@Override
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId,Boolean online,List<String> channelIds) {
return deviceChannelMapper.queryChannels(deviceId, null,null, null, online,channelIds);
}
@Override
public List<DeviceChannelExtend> queryChannelsByDeviceId(String deviceId, List<String> channelIds, Boolean online) {
return deviceChannelMapper.queryChannelsWithDeviceInfo(deviceId, null,null, null, online,channelIds);
@@ -438,11 +160,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
}
@Override
public int delChannel(String deviceId, String channelId) {
return deviceChannelMapper.del(deviceId, channelId);
}
/**
* 获取多个设备
*
@@ -469,23 +186,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return deviceList;
}
/**
* 清空通道
* @param deviceId
*/
@Override
public void cleanChannelsForDevice(String deviceId) {
deviceChannelMapper.cleanChannelsByDeviceId(deviceId);
}
/**
* 添加Mobile Position设备移动位置
* @param mobilePosition
*/
@Override
public synchronized boolean insertMobilePosition(MobilePosition mobilePosition) {
return deviceMobilePositionMapper.insertNewPosition(mobilePosition) > 0;
}
/**
* 查询移动位置轨迹
@@ -498,15 +198,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return deviceMobilePositionMapper.queryPositionByDeviceIdAndTime(deviceId, channelId, startTime, endTime);
}
@Override
public boolean addParentPlatform(ParentPlatform parentPlatform) {
if (parentPlatform.getCatalogId() == null) {
parentPlatform.setCatalogId(parentPlatform.getServerGBId());
}
int result = platformMapper.addParentPlatform(parentPlatform);
return result > 0;
}
@Override
public boolean updateParentPlatform(ParentPlatform parentPlatform) {
int result = 0;
@@ -574,11 +265,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return deviceMapper.queryDeviceWithAsMessageChannel();
}
@Override
public void outlineForAllParentPlatform() {
platformMapper.outlineForAllParentPlatform();
}
@Override
public PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online,
@@ -588,21 +274,15 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return new PageInfo<>(all);
}
@Override
public List<DeviceChannelInPlatform> queryChannelListInParentPlatform(String platformId) {
return deviceChannelMapper.queryChannelByPlatformId(platformId);
}
@Override
public int delChannelForGB(String platformId, List<ChannelReduce> channelReduces) {
int result = platformChannelMapper.delChannelForGB(platformId, channelReduces);
List<DeviceChannel> deviceChannelList = new ArrayList<>();
List<CommonGBChannel> deviceChannelList = new ArrayList<>();
for (ChannelReduce channelReduce : channelReduces) {
DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setChannelId(channelReduce.getChannelId());
CommonGBChannel deviceChannel = new CommonGBChannel();
deviceChannel.setGbDeviceId(channelReduce.getChannelId());
deviceChannelList.add(deviceChannel);
}
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
@@ -623,18 +303,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
}
}
@Override
public List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId) {
List<PlatformCatalog> catalogs = platformChannelMapper.queryChannelInParentPlatformAndCatalog(platformId, catalogId);
return catalogs;
}
@Override
public List<PlatformCatalog> queryStreamInParentPlatformAndCatalog(String platformId, String catalogId) {
List<PlatformCatalog> catalogs = platformGbStreamMapper.queryChannelInParentPlatformAndCatalogForCatalog(platformId, catalogId);
return catalogs;
}
@Override
public Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId) {
List<Device> devices = platformChannelMapper.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId);
@@ -674,50 +342,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return deviceMobilePositionMapper.queryLatestPositionByDevice(deviceId);
}
/**
* 删除指定设备的所有移动位置
* @param deviceId
*/
@Override
public int clearMobilePositionsByDeviceId(String deviceId) {
return deviceMobilePositionMapper.clearMobilePositionsByDeviceId(deviceId);
}
/**
* 移除代理流
* @param app
* @param stream
* @return
*/
@Override
public int deleteStreamProxy(String app, String stream) {
return streamProxyMapper.del(app, stream);
}
/**
* 根据是否启用获取代理流列表
* @param enable
* @return
*/
@Override
public List<StreamProxy> getStreamProxyListForEnable(boolean enable) {
return streamProxyMapper.selectForEnable(enable);
}
/**
* 分页查询代理流列表
* @param page
* @param count
* @return
*/
@Override
public PageInfo<StreamProxy> queryStreamProxyList(Integer page, Integer count) {
PageHelper.startPage(page, count);
List<StreamProxy> all = streamProxyMapper.selectAll();
return new PageInfo<>(all);
}
/**
* 根据国标ID获取平台关联的直播流
* @param platformId
@@ -729,66 +353,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return gbStreamMapper.queryStreamInPlatform(platformId, gbId);
}
/**
* 获取平台关联的直播流
* @param platformId
* @return
*/
@Override
public List<DeviceChannel> queryGbStreamListInPlatform(String platformId) {
return gbStreamMapper.queryGbStreamListInPlatform(platformId, userSetting.isUsePushingAsStatus());
}
/**
* 按照是app和stream获取代理流
* @param app
* @param stream
* @return
*/
@Override
public StreamProxy queryStreamProxy(String app, String stream){
return streamProxyMapper.selectOne(app, stream);
}
@Override
public int removeMedia(String app, String stream) {
return streamPushMapper.del(app, stream);
}
@Override
public int mediaOffline(String app, String stream) {
GbStream gbStream = gbStreamMapper.selectOne(app, stream);
int result;
if ("proxy".equals(gbStream.getStreamType())) {
result = streamProxyMapper.updateStatus(app, stream, false);
}else {
result = streamPushMapper.updatePushStatus(app, stream, false);
}
return result;
}
@Override
public int mediaOnline(String app, String stream) {
GbStream gbStream = gbStreamMapper.selectOne(app, stream);
int result;
if ("proxy".equals(gbStream.getStreamType())) {
result = streamProxyMapper.updateStatus(app, stream, true);
}else {
result = streamPushMapper.updatePushStatus(app, stream, true);
}
return result;
}
@Override
public void updateParentPlatformStatus(String platformGbID, boolean online) {
platformMapper.updateParentPlatformStatus(platformGbID, online);
}
@Override
public List<StreamProxy> getStreamProxyListForEnableInMediaServer(String id, boolean enable) {
return streamProxyMapper.selectForEnableInMediaServer(id, enable);
}
@Override
public Device queryVideoDeviceByChannelId( String channelId) {
@@ -800,11 +364,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return result;
}
@Override
public StreamProxy getStreamProxyByAppAndStream(String app, String streamId) {
return streamProxyMapper.selectOne(app, streamId);
}
@Override
public List<PlatformCatalog> getChildrenCatalogByPlatform(String platformId, String parentId) {
return catalogMapper.selectByParentId(platformId, parentId);
@@ -889,27 +448,27 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
int delresult = catalogMapper.del(platformId, id);
DeviceChannel deviceChannelForCatalog = new DeviceChannel();
if (delresult > 0){
deviceChannelForCatalog.setChannelId(id);
deviceChannelForCatalog.setDeviceId(id);
eventPublisher.catalogEventPublish(platformId, deviceChannelForCatalog, CatalogEvent.DEL);
}
List<GbStream> gbStreams = platformGbStreamMapper.queryChannelInParentPlatformAndCatalog(platformId, id);
if (gbStreams.size() > 0){
List<DeviceChannel> deviceChannelList = new ArrayList<>();
if (!gbStreams.isEmpty()){
List<CommonGBChannel> deviceChannelList = new ArrayList<>();
for (GbStream gbStream : gbStreams) {
DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setChannelId(gbStream.getGbId());
CommonGBChannel deviceChannel = new CommonGBChannel();
deviceChannel.setGbDeviceId(gbStream.getGbId());
deviceChannelList.add(deviceChannel);
}
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
}
int delStreamresult = platformGbStreamMapper.delByPlatformAndCatalogId(platformId,id);
List<PlatformCatalog> platformCatalogs = platformChannelMapper.queryChannelInParentPlatformAndCatalog(platformId, id);
if (platformCatalogs.size() > 0){
List<DeviceChannel> deviceChannelList = new ArrayList<>();
if (!platformCatalogs.isEmpty()){
List<CommonGBChannel> deviceChannelList = new ArrayList<>();
for (PlatformCatalog platformCatalog : platformCatalogs) {
DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setChannelId(platformCatalog.getId());
CommonGBChannel deviceChannel = new CommonGBChannel();
deviceChannel.setGbDeviceId(platformCatalog.getId());
deviceChannelList.add(deviceChannel);
}
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
@@ -968,24 +527,19 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return platformMapper.setDefaultCatalog(platformId, catalogId, DateUtil.getNow());
}
@Override
public List<DeviceChannel> queryCatalogInPlatform(String platformId) {
return catalogMapper.queryCatalogInPlatform(platformId);
}
@Override
public int delRelation(PlatformCatalog platformCatalog) {
if (platformCatalog.getType() == 1) {
DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setChannelId(platformCatalog.getId());
CommonGBChannel deviceChannel = new CommonGBChannel();
deviceChannel.setGbDeviceId(platformCatalog.getId());
eventPublisher.catalogEventPublish(platformCatalog.getPlatformId(), deviceChannel, CatalogEvent.DEL);
return platformChannelMapper.delByCatalogIdAndChannelIdAndPlatformId(platformCatalog);
}else if (platformCatalog.getType() == 2) {
List<GbStream> gbStreams = platformGbStreamMapper.queryChannelInParentPlatformAndCatalog(platformCatalog.getPlatformId(), platformCatalog.getParentId());
for (GbStream gbStream : gbStreams) {
if (gbStream.getGbId().equals(platformCatalog.getId())) {
DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setChannelId(gbStream.getGbId());
CommonGBChannel deviceChannel = new CommonGBChannel();
deviceChannel.setGbDeviceId(gbStream.getGbId());
eventPublisher.catalogEventPublish(platformCatalog.getPlatformId(), deviceChannel, CatalogEvent.DEL);
return platformGbStreamMapper.delByAppAndStream(gbStream.getApp(), gbStream.getStream());
}
@@ -1003,11 +557,11 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
private DeviceChannel getDeviceChannelByCatalog(PlatformCatalog catalog) {
ParentPlatform platform = platformMapper.getParentPlatByServerGBId(catalog.getPlatformId());
DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setChannelId(catalog.getId());
deviceChannel.setDeviceId(catalog.getId());
deviceChannel.setName(catalog.getName());
deviceChannel.setDeviceId(platform.getDeviceGBId());
deviceChannel.setManufacture("wvp-pro");
deviceChannel.setStatus(true);
deviceChannel.setManufacturer("wvp-pro");
deviceChannel.setStatus("ON");
deviceChannel.setParental(1);
deviceChannel.setRegisterWay(1);
@@ -1016,33 +570,15 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
deviceChannel.setModel("live");
deviceChannel.setOwner("wvp-pro");
deviceChannel.setSecrecy("0");
deviceChannel.setSecrecy(0);
return deviceChannel;
}
@Override
public List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId) {
return deviceChannelMapper.queryOnlineChannelsByDeviceId(deviceId);
}
@Override
public List<ParentPlatform> queryPlatFormListForGBWithGBId(String channelId, List<String> platforms) {
return platformChannelMapper.queryPlatFormListForGBWithGBId(channelId, platforms);
}
@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);
}
@Override
public GbStream getGbStream(String app, String streamId) {
return gbStreamMapper.selectOne(app, streamId);
}
@Override
public void delCatalogByPlatformId(String serverGBId) {
catalogMapper.delByPlatformId(serverGBId);
@@ -1063,39 +599,4 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
public List<ChannelSourceInfo> getChannelSource(String platformId, String gbId) {
return platformMapper.getChannelSource(platformId, gbId);
}
@Override
public void updateChannelPosition(DeviceChannel deviceChannel) {
if (deviceChannel.getChannelId().equals(deviceChannel.getDeviceId())) {
deviceChannel.setChannelId(null);
}
if (deviceChannel.getGpsTime() == null) {
deviceChannel.setGpsTime(DateUtil.getNow());
}
deviceChannelMapper.updatePosition(deviceChannel);
}
@Override
public void cleanContentForPlatform(String serverGBId) {
// List<PlatformCatalog> catalogList = catalogMapper.selectByPlatForm(serverGBId);
// if (catalogList.size() > 0) {
// int result = catalogMapper.delByPlatformId(serverGBId);
// if (result > 0) {
// List<DeviceChannel> deviceChannels = new ArrayList<>();
// for (PlatformCatalog catalog : catalogList) {
// deviceChannels.add(getDeviceChannelByCatalog(catalog));
// }
// eventPublisher.catalogEventPublish(serverGBId, deviceChannels, CatalogEvent.DEL);
// }
// }
catalogMapper.delByPlatformId(serverGBId);
platformChannelMapper.delByPlatformId(serverGBId);
platformGbStreamMapper.delByPlatformId(serverGBId);
}
@Override
public List<DeviceChannel> queryChannelWithCatalog(String serverGBId) {
return deviceChannelMapper.queryChannelWithCatalog(serverGBId);
}
}