支持国标级联的目录订阅功能
This commit is contained in:
@@ -210,4 +210,8 @@ public interface IRedisCatchStorage {
|
||||
void delSubscribe(String key);
|
||||
|
||||
MediaItem getStreamInfo(String app, String streamId, String mediaServerId);
|
||||
|
||||
List<SubscribeInfo> getAllSubscribe();
|
||||
|
||||
List<String> getAllSubscribePlatform();
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ public interface IVideoManagerStorager {
|
||||
* @return
|
||||
*/
|
||||
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId);
|
||||
public List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
|
||||
|
||||
/**
|
||||
* 获取某个设备的通道
|
||||
@@ -341,7 +342,7 @@ public interface IVideoManagerStorager {
|
||||
* @param channelId
|
||||
* @return
|
||||
*/
|
||||
List<GbStream> queryStreamInParentPlatform(String platformId, String channelId);
|
||||
GbStream queryStreamInParentPlatform(String platformId, String channelId);
|
||||
|
||||
/**
|
||||
* 获取平台关联的直播流
|
||||
@@ -459,4 +460,10 @@ public interface IVideoManagerStorager {
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -54,17 +54,22 @@ public interface DeviceChannelMapper {
|
||||
int update(DeviceChannel channel);
|
||||
|
||||
@Select(value = {" <script>" +
|
||||
"SELECT * FROM ( "+
|
||||
" SELECT * , (SELECT count(0) FROM device_channel WHERE parentId=dc.channelId) as subCount FROM device_channel dc " +
|
||||
" WHERE dc.deviceId=#{deviceId} " +
|
||||
" <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
|
||||
" <if test='parentChannelId != null'> AND dc.parentId=#{parentChannelId} </if> " +
|
||||
" <if test='online == true' > AND dc.status=1</if>" +
|
||||
" <if test='online == false' > AND dc.status=0</if>) dcr" +
|
||||
" WHERE 1=1 " +
|
||||
"SELECT " +
|
||||
"dc1.*, " +
|
||||
"COUNT(dc2.channelId) as subCount " +
|
||||
"from " +
|
||||
"device_channel dc1 " +
|
||||
"left join device_channel dc2 on " +
|
||||
"dc1.channelId = dc2.parentId " +
|
||||
"WHERE " +
|
||||
"dc1.deviceId = #{deviceId} " +
|
||||
" <if test='query != null'> AND (dc1.channelId LIKE '%${query}%' OR dc1.name LIKE '%${query}%' OR dc1.name LIKE '%${query}%')</if> " +
|
||||
" <if test='parentChannelId != null'> AND dc1.parentId=#{parentChannelId} </if> " +
|
||||
" <if test='online == true' > AND dc1.status=1</if>" +
|
||||
" <if test='online == false' > AND dc1.status=0</if>" +
|
||||
" <if test='hasSubChannel == true' > AND subCount >0</if>" +
|
||||
" <if test='hasSubChannel == false' > AND subCount=0</if>" +
|
||||
" ORDER BY channelId ASC" +
|
||||
"GROUP BY dc1.channelId " +
|
||||
" </script>"})
|
||||
List<DeviceChannel> queryChannels(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online);
|
||||
|
||||
@@ -170,19 +175,30 @@ public interface DeviceChannelMapper {
|
||||
"</script>"})
|
||||
int batchUpdate(List<DeviceChannel> updateChannels);
|
||||
|
||||
|
||||
@Select(value = {" <script>" +
|
||||
"SELECT * FROM ( "+
|
||||
" SELECT * , (SELECT count(0) FROM device_channel WHERE parentId=dc.channelId) as subCount FROM device_channel dc " +
|
||||
" WHERE dc.deviceId=#{deviceId} " +
|
||||
" <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
|
||||
" <if test='parentChannelId != null'> AND dc.parentId=#{parentChannelId} </if> " +
|
||||
" <if test='online == true' > AND dc.status=1</if>" +
|
||||
" <if test='online == false' > AND dc.status=0</if>) dcr" +
|
||||
" WHERE 1=1 " +
|
||||
"SELECT " +
|
||||
"dc1.*, " +
|
||||
"COUNT(dc2.channelId) as subCount " +
|
||||
"from " +
|
||||
"device_channel dc1 " +
|
||||
"left join device_channel dc2 on " +
|
||||
"dc1.channelId = dc2.parentId " +
|
||||
"WHERE " +
|
||||
"dc1.deviceId = #{deviceId} " +
|
||||
" <if test='query != null'> AND (dc1.channelId LIKE '%${query}%' OR dc1.name LIKE '%${query}%' OR dc1.name LIKE '%${query}%')</if> " +
|
||||
" <if test='parentChannelId != null'> AND dc1.parentId=#{parentChannelId} </if> " +
|
||||
" <if test='online == true' > AND dc1.status=1</if>" +
|
||||
" <if test='online == false' > AND dc1.status=0</if>" +
|
||||
" <if test='hasSubChannel == true' > AND subCount >0</if>" +
|
||||
" <if test='hasSubChannel == false' > AND subCount=0</if>" +
|
||||
" ORDER BY channelId ASC" +
|
||||
" LIMIT #{limit} OFFSET #{start}" +
|
||||
"GROUP BY dc1.channelId " +
|
||||
"ORDER BY dc1.channelId ASC " +
|
||||
"Limit #{limit} OFFSET #{start}" +
|
||||
" </script>"})
|
||||
List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online, int start, int limit);
|
||||
List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String parentChannelId, String query,
|
||||
Boolean hasSubChannel, Boolean online, int start, int limit);
|
||||
|
||||
@Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND status=1")
|
||||
List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
@Repository
|
||||
public interface GbStreamMapper {
|
||||
|
||||
@Insert("INSERT INTO gb_stream (app, stream, gbId, name, " +
|
||||
@Insert("REPLACE INTO gb_stream (app, stream, gbId, name, " +
|
||||
"longitude, latitude, streamType, mediaServerId, status) VALUES" +
|
||||
"('${app}', '${stream}', '${gbId}', '${name}', " +
|
||||
"'${longitude}', '${latitude}', '${streamType}', " +
|
||||
@@ -48,7 +48,7 @@ public interface GbStreamMapper {
|
||||
@Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " +
|
||||
"LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " +
|
||||
"WHERE gs.gbId = '${gbId}' AND pgs.platformId = '${platformId}'")
|
||||
List<GbStream> queryStreamInPlatform(String platformId, String gbId);
|
||||
GbStream queryStreamInPlatform(String platformId, String gbId);
|
||||
|
||||
@Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " +
|
||||
"LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " +
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
|
||||
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
@@ -73,4 +74,18 @@ public interface PlatformChannelMapper {
|
||||
"DELETE FROM platform_gb_channel WHERE catalogId=#{parentId} AND platformId=#{platformId} AND channelId=#{id}" +
|
||||
"</script>")
|
||||
int delByCatalogIdAndChannelIdAndPlatformId(PlatformCatalog platformCatalog);
|
||||
|
||||
@Select("<script> " +
|
||||
"SELECT " +
|
||||
"pp.* " +
|
||||
"FROM " +
|
||||
"parent_platform pp " +
|
||||
"left join platform_gb_channel pgc on " +
|
||||
"pp.serverGBId = pgc.platformId " +
|
||||
"WHERE " +
|
||||
"pgc.channelId = #{channelId} " +
|
||||
"AND pp.serverGBId IN" +
|
||||
"<foreach collection='platforms' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
|
||||
"</script> ")
|
||||
List<ParentPlatform> queryPlatFormListForGBWithGBId(String channelId, List<String> platforms);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||
@@ -14,7 +15,7 @@ import java.util.List;
|
||||
@Repository
|
||||
public interface PlatformGbStreamMapper {
|
||||
|
||||
@Insert("INSERT INTO platform_gb_stream (app, stream, platformId, catalogId) VALUES" +
|
||||
@Insert("REPLACE INTO platform_gb_stream (app, stream, platformId, catalogId) VALUES" +
|
||||
"('${app}', '${stream}', '${platformId}', '${catalogId}')")
|
||||
int add(PlatformGbStream platformGbStream);
|
||||
|
||||
@@ -24,10 +25,20 @@ public interface PlatformGbStreamMapper {
|
||||
@Delete("DELETE FROM platform_gb_stream WHERE platformId=#{platformId}")
|
||||
int delByPlatformId(String platformId);
|
||||
|
||||
@Select("SELECT * FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream}")
|
||||
List<StreamProxyItem> selectByAppAndStream(String app, String stream);
|
||||
@Select("SELECT " +
|
||||
"pp.* " +
|
||||
"FROM " +
|
||||
"platform_gb_stream pgs " +
|
||||
"LEFT JOIN parent_platform pp ON pp.serverGBId = pgs.platformId " +
|
||||
"WHERE " +
|
||||
"pgs.app =#{app} " +
|
||||
"AND pgs.stream =#{stream} " +
|
||||
"GROUP BY pp.serverGBId")
|
||||
List<ParentPlatform> selectByAppAndStream(String app, String stream);
|
||||
|
||||
@Select("SELECT * FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream} AND platformId=#{serverGBId}")
|
||||
@Select("SELECT pgs.*, gs.gbId FROM platform_gb_stream pgs " +
|
||||
"LEFT JOIN gb_stream gs ON pgs.app = gs.app AND pgs.stream = gs.stream " +
|
||||
"WHERE pgs.app=#{app} AND pgs.stream=#{stream} AND pgs.platformId=#{serverGBId}")
|
||||
StreamProxyItem selectOne(String app, String stream, String serverGBId);
|
||||
|
||||
@Select("select gs.* \n" +
|
||||
@@ -47,4 +58,21 @@ public interface PlatformGbStreamMapper {
|
||||
@Delete("DELETE FROM platform_gb_stream WHERE catalogId=#{id}")
|
||||
int delByCatalogId(String id);
|
||||
|
||||
@Select("<script> " +
|
||||
"SELECT " +
|
||||
"pp.* " +
|
||||
"FROM " +
|
||||
"parent_platform pp " +
|
||||
"left join platform_gb_stream pgs on " +
|
||||
"pp.serverGBId = pgs.platformId " +
|
||||
"WHERE " +
|
||||
"pgs.app = #{app} " +
|
||||
"AND pgs.stream = #{stream}" +
|
||||
"AND pp.serverGBId IN" +
|
||||
"<foreach collection='platforms' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
|
||||
"</script> ")
|
||||
List<ParentPlatform> queryPlatFormListForGBWithGBId(String app, String stream, List<String> platforms);
|
||||
|
||||
@Select("SELECT * FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream} AND platformId=#{platformId}")
|
||||
int delByAppAndStreamAndPlatform(String app, String streamId, String platformId);
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
@Override
|
||||
public void updatePlatformRegisterInfo(String callId, String platformGbId) {
|
||||
String key = VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetup.getServerId() + "_" + callId;
|
||||
redis.set(key, platformGbId);
|
||||
redis.set(key, platformGbId, 30);
|
||||
}
|
||||
|
||||
|
||||
@@ -508,4 +508,30 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SubscribeInfo> getAllSubscribe() {
|
||||
String scanKey = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_*";
|
||||
List<SubscribeInfo> result = new ArrayList<>();
|
||||
List<Object> keys = redis.scan(scanKey);
|
||||
for (int i = 0; i < keys.size(); i++) {
|
||||
String key = (String) keys.get(i);
|
||||
SubscribeInfo subscribeInfo = (SubscribeInfo) redis.get(key);
|
||||
result.add(subscribeInfo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllSubscribePlatform() {
|
||||
String scanKey = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_*";
|
||||
List<String> result = new ArrayList<>();
|
||||
List<Object> keys = redis.scan(scanKey);
|
||||
for (int i = 0; i < keys.size(); i++) {
|
||||
String key = (String) keys.get(i);
|
||||
String platformId = key.substring(scanKey.length() - 1);
|
||||
result.add(platformId);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.genersoft.iot.vmp.storager.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
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.gb28181.session.VideoStreamSessionManager;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
|
||||
@@ -27,9 +30,9 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @description:视频设备数据存储-jdbc实现
|
||||
* @author: swwheihei
|
||||
* @date: 2020年5月6日 下午2:31:42
|
||||
* 视频设备数据存储-jdbc实现
|
||||
* swwheihei
|
||||
* 2020年5月6日 下午2:31:42
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Component
|
||||
@@ -37,6 +40,12 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(VideoManagerStoragerImpl.class);
|
||||
|
||||
@Autowired
|
||||
EventPublisher eventPublisher;
|
||||
|
||||
@Autowired
|
||||
SipConfig sipConfig;
|
||||
|
||||
@Autowired
|
||||
DataSourceTransactionManager dataSourceTransactionManager;
|
||||
|
||||
@@ -134,6 +143,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
return deviceMapper.add(device) > 0;
|
||||
}else {
|
||||
redisCatchStorage.updateDevice(device);
|
||||
|
||||
return deviceMapper.update(device) > 0;
|
||||
}
|
||||
|
||||
@@ -408,6 +418,8 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
device.setOnline(1);
|
||||
logger.info("更新设备在线: " + deviceId);
|
||||
redisCatchStorage.updateDevice(device);
|
||||
List<DeviceChannel> deviceChannelList = deviceChannelMapper.queryOnlineChannelsByDeviceId(deviceId);
|
||||
eventPublisher.catalogEventPublish(null, deviceChannelList, CatalogEvent.ON);
|
||||
return deviceMapper.update(device) > 0;
|
||||
}
|
||||
|
||||
@@ -514,7 +526,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
if (parentPlatform.isShareAllLiveStream()) {
|
||||
gbStreamService.addPlatformInfo(gbStreams, parentPlatform.getServerGBId(), parentPlatform.getCatalogId());
|
||||
}else {
|
||||
gbStreamService.delPlatformInfo(gbStreams);
|
||||
gbStreamService.delPlatformInfo(parentPlatform.getServerGBId(), gbStreams);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -590,6 +602,9 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
int result = 0;
|
||||
if (channelReducesToAdd.size() > 0) {
|
||||
result = platformChannelMapper.addChannels(platformId, channelReducesToAdd);
|
||||
// TODO 后续给平台增加控制开关以控制是否响应目录订阅
|
||||
List<DeviceChannel> deviceChannelList = getDeviceChannelListByChannelReduceList(channelReducesToAdd, catalogId);
|
||||
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.ADD);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -600,7 +615,13 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
public int delChannelForGB(String platformId, List<ChannelReduce> channelReduces) {
|
||||
|
||||
int result = platformChannelMapper.delChannelForGB(platformId, channelReduces);
|
||||
|
||||
List<DeviceChannel> deviceChannelList = new ArrayList<>();
|
||||
for (ChannelReduce channelReduce : channelReduces) {
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
deviceChannel.setChannelId(channelReduce.getChannelId());
|
||||
deviceChannelList.add(deviceChannel);
|
||||
}
|
||||
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -739,7 +760,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<GbStream> queryStreamInParentPlatform(String platformId, String gbId) {
|
||||
public GbStream queryStreamInParentPlatform(String platformId, String gbId) {
|
||||
return gbStreamMapper.queryStreamInPlatform(platformId, gbId);
|
||||
}
|
||||
|
||||
@@ -771,7 +792,11 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
streamPushMapper.addAll(streamPushItems);
|
||||
// TODO 待优化
|
||||
for (int i = 0; i < streamPushItems.size(); i++) {
|
||||
gbStreamMapper.setStatus(streamPushItems.get(i).getApp(), streamPushItems.get(i).getStream(), true);
|
||||
int onlineResult = gbStreamMapper.setStatus(streamPushItems.get(i).getApp(), streamPushItems.get(i).getStream(), true);
|
||||
if (onlineResult > 0) {
|
||||
// 发送上线通知
|
||||
eventPublisher.catalogEventPublishForStream(null, streamPushItems.get(i), CatalogEvent.ON);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -780,6 +805,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
streamPushMapper.del(streamPushItem.getApp(), streamPushItem.getStream());
|
||||
streamPushMapper.add(streamPushItem);
|
||||
gbStreamMapper.setStatus(streamPushItem.getApp(), streamPushItem.getStream(), true);
|
||||
|
||||
if(!StringUtils.isEmpty(streamPushItem.getGbId() )){
|
||||
// 查找开启了全部直播流共享的上级平台
|
||||
List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream();
|
||||
@@ -858,7 +884,12 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
|
||||
@Override
|
||||
public int addCatalog(PlatformCatalog platformCatalog) {
|
||||
return catalogMapper.add(platformCatalog);
|
||||
int result = catalogMapper.add(platformCatalog);
|
||||
if (result > 0) {
|
||||
DeviceChannel deviceChannel = getDeviceChannelByCatalog(platformCatalog);
|
||||
eventPublisher.catalogEventPublish(platformCatalog.getPlatformId(), deviceChannel, CatalogEvent.ADD);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -873,23 +904,56 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
List<PlatformCatalog> platformCatalogList = catalogMapper.selectByParentId(platformCatalog.getPlatformId(), platformCatalog.getId());
|
||||
for (PlatformCatalog catalog : platformCatalogList) {
|
||||
if (catalog.getChildrenCount() == 0) {
|
||||
catalogMapper.del(catalog.getId());
|
||||
platformGbStreamMapper.delByCatalogId(catalog.getId());
|
||||
platformChannelMapper.delByCatalogId(catalog.getId());
|
||||
delCatalogExecute(catalog.getId(), catalog.getPlatformId());
|
||||
}else {
|
||||
delCatalog(catalog.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
int delresult = catalogMapper.del(id);
|
||||
int delStreamresult = platformGbStreamMapper.delByCatalogId(id);
|
||||
int delChanneresult = platformChannelMapper.delByCatalogId(id);
|
||||
return delresult + delChanneresult + delStreamresult;
|
||||
return delCatalogExecute(id, platformCatalog.getPlatformId());
|
||||
}
|
||||
private int delCatalogExecute(String id, String platformId) {
|
||||
int delresult = catalogMapper.del(id);
|
||||
DeviceChannel deviceChannelForCatalog = new DeviceChannel();
|
||||
if (delresult > 0){
|
||||
deviceChannelForCatalog.setChannelId(id);
|
||||
eventPublisher.catalogEventPublish(platformId, deviceChannelForCatalog, CatalogEvent.DEL);
|
||||
}
|
||||
|
||||
List<GbStream> gbStreams = platformGbStreamMapper.queryChannelInParentPlatformAndCatalog(platformId, id);
|
||||
if (gbStreams.size() > 0){
|
||||
List<DeviceChannel> deviceChannelList = new ArrayList<>();
|
||||
for (GbStream gbStream : gbStreams) {
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
deviceChannel.setChannelId(gbStream.getGbId());
|
||||
deviceChannelList.add(deviceChannel);
|
||||
}
|
||||
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
|
||||
}
|
||||
int delStreamresult = platformGbStreamMapper.delByCatalogId(id);
|
||||
List<PlatformCatalog> platformCatalogs = platformChannelMapper.queryChannelInParentPlatformAndCatalog(platformId, id);
|
||||
if (platformCatalogs.size() > 0){
|
||||
List<DeviceChannel> deviceChannelList = new ArrayList<>();
|
||||
for (PlatformCatalog platformCatalog : platformCatalogs) {
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
deviceChannel.setChannelId(platformCatalog.getId());
|
||||
deviceChannelList.add(deviceChannel);
|
||||
}
|
||||
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL);
|
||||
}
|
||||
int delChannelresult = platformChannelMapper.delByCatalogId(id);
|
||||
return delresult + delChannelresult + delStreamresult;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int updateCatalog(PlatformCatalog platformCatalog) {
|
||||
return catalogMapper.update(platformCatalog);
|
||||
int result = catalogMapper.update(platformCatalog);
|
||||
if (result > 0) {
|
||||
DeviceChannel deviceChannel = getDeviceChannelByCatalog(platformCatalog);
|
||||
eventPublisher.catalogEventPublish(platformCatalog.getPlatformId(), deviceChannel, CatalogEvent.UPDATE);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -905,11 +969,17 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
@Override
|
||||
public int delRelation(PlatformCatalog platformCatalog) {
|
||||
if (platformCatalog.getType() == 1) {
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
deviceChannel.setChannelId(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());
|
||||
eventPublisher.catalogEventPublish(platformCatalog.getPlatformId(), deviceChannel, CatalogEvent.DEL);
|
||||
return platformGbStreamMapper.delByAppAndStream(gbStream.getApp(), gbStream.getStream());
|
||||
}
|
||||
}
|
||||
@@ -921,4 +991,57 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
|
||||
public int updateStreamGPS(List<GPSMsgInfo> gpsMsgInfos) {
|
||||
return gbStreamMapper.updateStreamGPS(gpsMsgInfos);
|
||||
}
|
||||
|
||||
private List<DeviceChannel> getDeviceChannelListByChannelReduceList(List<ChannelReduce> channelReduces, String catalogId) {
|
||||
List<DeviceChannel> deviceChannelList = new ArrayList<>();
|
||||
if (channelReduces.size() > 0){
|
||||
for (ChannelReduce channelReduce : channelReduces) {
|
||||
DeviceChannel deviceChannel = queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId());
|
||||
deviceChannel.setParental(1);
|
||||
deviceChannel.setParentId(catalogId);
|
||||
deviceChannelList.add(deviceChannel);
|
||||
}
|
||||
}
|
||||
return deviceChannelList;
|
||||
}
|
||||
|
||||
private DeviceChannel getDeviceChannelByCatalog(PlatformCatalog catalog) {
|
||||
ParentPlatform parentPlatByServerGBId = platformMapper.getParentPlatByServerGBId(catalog.getPlatformId());
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
deviceChannel.setChannelId(catalog.getId());
|
||||
deviceChannel.setName(catalog.getName());
|
||||
deviceChannel.setLongitude(0.0);
|
||||
deviceChannel.setLatitude(0.0);
|
||||
deviceChannel.setDeviceId(parentPlatByServerGBId.getDeviceGBId());
|
||||
deviceChannel.setManufacture("wvp-pro");
|
||||
deviceChannel.setStatus(1);
|
||||
deviceChannel.setParental(1);
|
||||
deviceChannel.setParentId(catalog.getParentId());
|
||||
deviceChannel.setRegisterWay(1);
|
||||
deviceChannel.setCivilCode(sipConfig.getDomain());
|
||||
deviceChannel.setModel("live");
|
||||
deviceChannel.setOwner("wvp-pro");
|
||||
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) {
|
||||
return platformGbStreamMapper.queryPlatFormListForGBWithGBId(app, stream, platforms);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GbStream getGbStream(String app, String streamId) {
|
||||
return gbStreamMapper.selectOne(app, streamId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user