临时提交
parent
2199db079a
commit
4897d9a501
|
@ -12,7 +12,7 @@ import com.genersoft.iot.vmp.service.ICommonGbChannelService;
|
|||
import com.genersoft.iot.vmp.service.IResourcePlayCallback;
|
||||
import com.genersoft.iot.vmp.service.IResourceService;
|
||||
import com.genersoft.iot.vmp.service.bean.*;
|
||||
import com.genersoft.iot.vmp.storager.dao.CommonGbChannelMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.CommonChannelMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.GroupMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.RegionMapper;
|
||||
|
@ -40,7 +40,7 @@ public class CommonGbChannelServiceImpl implements ICommonGbChannelService {
|
|||
private final static Logger logger = LoggerFactory.getLogger(CommonGbChannelServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private CommonGbChannelMapper commonGbChannelMapper;
|
||||
private CommonChannelMapper commonGbChannelMapper;
|
||||
|
||||
@Autowired
|
||||
private DeviceChannelMapper deviceChannelMapper;
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.genersoft.iot.vmp.gb28181.bean.Device;
|
|||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Gb28181CodeType;
|
||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
|
||||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||
import com.genersoft.iot.vmp.service.ICommonGbChannelService;
|
||||
|
@ -14,12 +13,10 @@ import com.genersoft.iot.vmp.service.IDeviceChannelService;
|
|||
import com.genersoft.iot.vmp.service.IInviteStreamService;
|
||||
import com.genersoft.iot.vmp.service.bean.Group;
|
||||
import com.genersoft.iot.vmp.service.bean.Region;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.dao.*;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo;
|
||||
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -30,7 +27,6 @@ import org.springframework.util.CollectionUtils;
|
|||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
|
@ -48,7 +44,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
|
|||
private DeviceChannelMapper channelMapper;
|
||||
|
||||
@Autowired
|
||||
private CommonGbChannelMapper commonGbChannelMapper;
|
||||
private CommonChannelMapper commonGbChannelMapper;
|
||||
|
||||
@Autowired
|
||||
private DeviceMapper deviceMapper;
|
||||
|
|
|
@ -8,7 +8,7 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
|||
import com.genersoft.iot.vmp.service.IGroupService;
|
||||
import com.genersoft.iot.vmp.service.bean.Group;
|
||||
import com.genersoft.iot.vmp.storager.dao.GroupMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.CommonGbChannelMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.CommonChannelMapper;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
@ -32,7 +32,7 @@ public class GroupServiceImpl implements IGroupService {
|
|||
private final static Logger logger = LoggerFactory.getLogger(GroupServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private CommonGbChannelMapper commonGbChannelMapper;
|
||||
private CommonChannelMapper commonGbChannelMapper;
|
||||
|
||||
@Autowired
|
||||
private GroupMapper groupMapper;
|
||||
|
|
|
@ -9,21 +9,15 @@ import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
|||
import com.genersoft.iot.vmp.service.IPlatformChannelService;
|
||||
import com.genersoft.iot.vmp.storager.dao.*;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author lin
|
||||
|
@ -37,7 +31,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService {
|
|||
private PlatformChannelMapper platformChannelMapper;
|
||||
|
||||
@Autowired
|
||||
private CommonGbChannelMapper commonGbChannelMapper;
|
||||
private CommonChannelMapper commonGbChannelMapper;
|
||||
|
||||
@Autowired
|
||||
TransactionDefinition transactionDefinition;
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
package com.genersoft.iot.vmp.service.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.common.BatchLimit;
|
||||
import com.genersoft.iot.vmp.common.CivilCodePo;
|
||||
import com.genersoft.iot.vmp.conf.CivilCodeFileConf;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||
import com.genersoft.iot.vmp.service.IRegionService;
|
||||
import com.genersoft.iot.vmp.service.bean.Region;
|
||||
import com.genersoft.iot.vmp.storager.dao.CommonGbChannelMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.CommonChannelMapper;
|
||||
import com.genersoft.iot.vmp.storager.dao.RegionMapper;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
|
@ -18,7 +16,6 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -34,7 +31,7 @@ public class RegionServiceImpl implements IRegionService {
|
|||
|
||||
|
||||
@Autowired
|
||||
private CommonGbChannelMapper commonGbChannelMapper;
|
||||
private CommonChannelMapper commonGbChannelMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.Map;
|
|||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface CommonGbChannelMapper {
|
||||
public interface CommonChannelMapper {
|
||||
|
||||
@Select(value = "select * from wvp_common_channel where common_gb_business_group_id = '#{commonGroupId}'")
|
||||
List<CommonGbChannel> getChannels(String commonGroupId);
|
|
@ -0,0 +1,20 @@
|
|||
package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.service.bean.Group;
|
||||
import com.genersoft.iot.vmp.service.bean.Region;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToGroup;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.UpdateCommonChannelToRegion;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface CommonChannelPlatformMapper {
|
||||
|
||||
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package com.genersoft.iot.vmp.storager.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface PlatformCatalogMapper {
|
||||
|
||||
@Insert("INSERT INTO wvp_platform_catalog (id, name, platform_id, parent_id, civil_code, business_group_id) VALUES" +
|
||||
"(#{id}, #{name}, #{platformId}, #{parentId}, #{civilCode}, #{businessGroupId})")
|
||||
int add(PlatformCatalog platformCatalog);
|
||||
|
||||
@Delete("DELETE from wvp_platform_catalog WHERE platform_id=#{platformId} and id=#{id}")
|
||||
int del(@Param("platformId") String platformId, @Param("id") String id);
|
||||
|
||||
@Delete("DELETE from wvp_platform_catalog WHERE platform_id=#{platformId}")
|
||||
int delByPlatformId(@Param("platformId") String platformId);
|
||||
|
||||
@Select("SELECT pc.*, count(pc2.id) as children_count from wvp_platform_catalog pc " +
|
||||
"left join wvp_platform_catalog pc2 on pc.id = pc2.parent_id " +
|
||||
"WHERE pc.parent_id=#{parentId} AND pc.platform_id=#{platformId} " +
|
||||
"group by pc.id, pc.name, pc.platform_id, pc.business_group_id, pc.civil_code, pc.parent_id")
|
||||
List<PlatformCatalog> selectByParentId(@Param("platformId") String platformId, @Param("parentId") String parentId);
|
||||
|
||||
@Update(value = {" <script>" +
|
||||
"UPDATE wvp_platform_catalog " +
|
||||
"SET name=#{name}" +
|
||||
"WHERE id=#{id} and platform_id=#{platformId}"+
|
||||
"</script>"})
|
||||
int update(@Param("platformCatalog") PlatformCatalog platformCatalog);
|
||||
|
||||
@Select("SELECT *, (SELECT COUNT(1) from wvp_platform_catalog where parent_id = pc.id) as children_count from wvp_platform_catalog pc WHERE pc.platform_id=#{platformId}")
|
||||
List<PlatformCatalog> selectByPlatForm(@Param("platformId") String platformId);
|
||||
|
||||
@Select("SELECT pc.* FROM wvp_platform_catalog pc WHERE pc.id = (SELECT pp.catalog_id from wvp_platform pp WHERE pp.server_gb_id=#{platformId})")
|
||||
PlatformCatalog selectDefaultByPlatFormId(@Param("platformId") String platformId);
|
||||
|
||||
@Select("SELECT pc.id as channel_id, pc.name, pc.civil_code, pc.business_group_id,'1' as parental, pc.parent_id " +
|
||||
" from wvp_platform_catalog pc WHERE pc.platform_id=#{platformId}")
|
||||
List<DeviceChannel> queryCatalogInPlatform(@Param("platformId") String platformId);
|
||||
|
||||
@Select("SELECT *, " +
|
||||
"(SELECT COUNT(1) from wvp_platform_catalog where parent_id = pc.id) as children_count " +
|
||||
" from wvp_platform_catalog pc " +
|
||||
" WHERE pc.id=#{id} and pc.platform_id=#{platformId}")
|
||||
PlatformCatalog selectByPlatFormAndCatalogId(@Param("platformId") String platformId, @Param("id") String id);
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
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;
|
||||
import org.apache.ibatis.annotations.Insert;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface PlatformChannelMapper {
|
||||
|
||||
/**
|
||||
* 查询列表里已经关联的
|
||||
*/
|
||||
@Select("<script> "+
|
||||
"SELECT device_channel_id from wvp_common_channel_platform WHERE platform_id=#{platformId} AND device_channel_id in" +
|
||||
"<foreach collection='channelReduces' open='(' item='item' separator=',' close=')'> #{item.id}</foreach>" +
|
||||
"</script>")
|
||||
List<Integer> findChannelRelatedPlatform(@Param("platformId") String platformId, @Param("channelReduces") List<ChannelReduce> channelReduces);
|
||||
|
||||
@Insert("<script> "+
|
||||
"INSERT INTO wvp_common_channel_platform (platform_id, common_gb_channel_id) VALUES" +
|
||||
"<foreach collection='channelIds' item='item' separator=','>" +
|
||||
" (#{platformId}, #{item})" +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
int addChannels(@Param("platformId") Integer platformId, @Param("channelIds") List<Integer> channelIds);
|
||||
|
||||
@Delete("<script> "+
|
||||
"DELETE from wvp_common_channel_platform WHERE platform_id=#{platformId} AND device_channel_id in" +
|
||||
"<foreach collection='channelReducesToDel' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
|
||||
"</script>")
|
||||
int delChannelForGB(@Param("platformId") String platformId, @Param("channelReducesToDel") List<ChannelReduce> channelReducesToDel);
|
||||
|
||||
@Delete("<script> "+
|
||||
"DELETE from wvp_common_channel_platform WHERE device_channel_id in " +
|
||||
"( select temp.device_channel_id from " +
|
||||
"(select pgc.device_channel_id from wvp_common_channel_platform pgc " +
|
||||
"left join wvp_device_channel dc on dc.id = pgc.device_channel_id where dc.device_id =#{deviceId} " +
|
||||
") temp)" +
|
||||
"</script>")
|
||||
int delChannelForDeviceId(String deviceId);
|
||||
|
||||
@Delete("<script> "+
|
||||
"DELETE from wvp_common_channel_platform WHERE platform_id=#{platformId}" +
|
||||
"</script>")
|
||||
int cleanChannelForGB(String platformId);
|
||||
|
||||
@Select("SELECT dc.* from wvp_common_channel_platform pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE dc.channel_id=#{channelId} and pgc.platform_id=#{platformId}")
|
||||
List<DeviceChannel> queryChannelInParentPlatform(@Param("platformId") String platformId, @Param("channelId") String channelId);
|
||||
|
||||
@Select("SELECT dc.* from wvp_common_channel_platform pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE pgc.platform_id=#{platformId} and pgc.catalog_id=#{catalogId}")
|
||||
List<DeviceChannel> queryAllChannelInCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
|
||||
|
||||
@Select(" select dc.channel_id as id, dc.name as name, pgc.platform_id as platform_id, pgc.catalog_id as parent_id, 0 as children_count, 1 as type " +
|
||||
" from wvp_device_channel dc left join wvp_common_channel_platform pgc on dc.id = pgc.device_channel_id " +
|
||||
" where pgc.platform_id=#{platformId} and pgc.catalog_id=#{catalogId}")
|
||||
List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
|
||||
|
||||
@Select("select d.*\n" +
|
||||
"from wvp_common_channel_platform pgc\n" +
|
||||
" left join wvp_device_channel dc on dc.id = pgc.device_channel_id\n" +
|
||||
" left join wvp_device d on dc.device_id = d.device_id\n" +
|
||||
"where dc.channel_id = #{channelId} and pgc.platform_id=#{platformId}")
|
||||
List<Device> queryVideoDeviceByPlatformIdAndChannelId(@Param("platformId") String platformId, @Param("channelId") String channelId);
|
||||
|
||||
@Delete("<script> "+
|
||||
"DELETE from wvp_common_channel_platform WHERE platform_id=#{platformId} and catalog_id=#{id}" +
|
||||
"</script>")
|
||||
int delByCatalogId(@Param("platformId") String platformId, @Param("id") String id);
|
||||
|
||||
@Delete("<script> "+
|
||||
"DELETE from wvp_common_channel_platform WHERE catalog_id=#{parentId} AND platform_id=#{platformId} AND channel_id=#{id}" +
|
||||
"</script>")
|
||||
int delByCatalogIdAndChannelIdAndPlatformId(PlatformCatalog platformCatalog);
|
||||
|
||||
@Select("<script> " +
|
||||
"SELECT " +
|
||||
"pp.* " +
|
||||
"FROM " +
|
||||
"wvp_platform pp " +
|
||||
"left join wvp_common_channel_platform pgc on " +
|
||||
"pp.server_gb_id = pgc.platform_id " +
|
||||
"left join wvp_device_channel dc on " +
|
||||
"dc.id = pgc.device_channel_id " +
|
||||
"WHERE " +
|
||||
"dc.channel_id = #{channelId} and pp.status = true " +
|
||||
"AND pp.server_gb_id IN" +
|
||||
"<foreach collection='platforms' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
|
||||
"</script> ")
|
||||
List<ParentPlatform> queryPlatFormListForGBWithGBId(@Param("channelId") String channelId, @Param("platforms") List<String> platforms);
|
||||
|
||||
@Delete("<script> " +
|
||||
"DELETE from wvp_common_channel_platform WHERE platform_id=#{serverGBId}" +
|
||||
"</script>")
|
||||
void delByPlatformId(String serverGBId);
|
||||
|
||||
@Delete("<script> " +
|
||||
"DELETE from wvp_common_channel_platform WHERE platform_id=#{platformId} and catalog_id=#{catalogId}" +
|
||||
"</script>")
|
||||
int delChannelForGBByCatalogId(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
|
||||
|
||||
@Select("select dc.channel_id dc.device_id,dc.name,d.manufacturer,d.model,d.firmware\n" +
|
||||
"from wvp_common_channel_platform pgc\n" +
|
||||
" left join wvp_device_channel dc on dc.id = pgc.device_channel_id\n" +
|
||||
" left join wvp_device d on dc.device_id = d.device_id\n" +
|
||||
"where dc.channel_id = #{channelId} and pgc.platform_id=#{platformId}")
|
||||
List<Device> queryDeviceInfoByPlatformIdAndChannelId(@Param("platformId") String platformId, @Param("channelId") String channelId);
|
||||
|
||||
@Select("SELECT pgc.platform_id from wvp_common_channel_platform pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE dc.channel_id='${channelId}'")
|
||||
List<String> queryParentPlatformByChannelId(String channelId);
|
||||
|
||||
@Select("<script> "+
|
||||
"select common_gb_channel_id from wvp_common_channel_platform WHERE platform_id=#{platformId} AND common_gb_channel_id in" +
|
||||
"<foreach collection='channelIds' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
|
||||
"</script>")
|
||||
List<Integer> findChannelsInDb(@Param("platformId") Integer platformId, @Param("channelIds") List<Integer> channelIds);
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
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;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Mapper
|
||||
@Repository
|
||||
public interface PlatformGbStreamMapper {
|
||||
|
||||
@Insert("INSERT INTO wvp_platform_gb_stream (gb_stream_id, platform_id, catalog_id) VALUES" +
|
||||
"( #{gbStreamId}, #{platformId}, #{catalogId})")
|
||||
int add(PlatformGbStream platformGbStream);
|
||||
|
||||
|
||||
@Insert("<script> " +
|
||||
"INSERT into wvp_platform_gb_stream " +
|
||||
"(gb_stream_id, platform_id, catalog_id) " +
|
||||
"values " +
|
||||
"<foreach collection='streamPushItems' index='index' item='item' separator=','> " +
|
||||
"(#{item.gbStreamId}, #{item.platform_id}, #{item.catalogId})" +
|
||||
"</foreach> " +
|
||||
"</script>")
|
||||
int batchAdd(List<StreamPushItem> streamPushItems);
|
||||
|
||||
@Delete("DELETE from wvp_platform_gb_stream WHERE gb_stream_id = (select gb_stream_id from wvp_gb_stream where app=#{app} AND stream=#{stream})")
|
||||
int delByAppAndStream(@Param("app") String app, @Param("stream") String stream);
|
||||
|
||||
@Delete("DELETE from wvp_platform_gb_stream WHERE platform_id=#{platformId}")
|
||||
int delByPlatformId(String platformId);
|
||||
|
||||
@Select("SELECT " +
|
||||
"pp.* " +
|
||||
"FROM " +
|
||||
"wvp_platform_gb_stream pgs " +
|
||||
"LEFT JOIN wvp_platform pp ON pp.server_gb_id = pgs.platform_id " +
|
||||
"LEFT join wvp_gb_stream gs ON gs.gb_stream_id = pgs.gb_stream_id " +
|
||||
"WHERE " +
|
||||
"gs.app =#{app} " +
|
||||
"AND gs.stream =#{stream} ")
|
||||
List<ParentPlatform> selectByAppAndStream(@Param("app") String app, @Param("stream") String stream);
|
||||
|
||||
@Select("SELECT pgs.*, gs.gb_id from wvp_platform_gb_stream pgs " +
|
||||
"LEFT join wvp_gb_stream gs ON pgs.gb_stream_id = gs.gb_stream_id " +
|
||||
"WHERE gs.app=#{app} AND gs.stream=#{stream} AND pgs.platform_id=#{platformId}")
|
||||
StreamProxyItem selectOne(@Param("app") String app, @Param("stream") String stream, @Param("platformId") String platformId);
|
||||
|
||||
@Select("select gs.* \n" +
|
||||
"from wvp_gb_stream gs\n" +
|
||||
" left join wvp_platform_gb_stream pgs\n" +
|
||||
" on gs.gb_stream_id = pgs.gb_stream_id\n" +
|
||||
"where pgs.platform_id=#{platformId} and pgs.catalog_id=#{catalogId}")
|
||||
List<GbStream> queryChannelInParentPlatformAndCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
|
||||
|
||||
@Select("select gs.gb_id as id, gs.name as name, pgs.platform_id as platform_id, pgs.catalog_id as catalog_id , 0 as children_count, 2 as type\n" +
|
||||
"from wvp_gb_stream gs\n" +
|
||||
" left join wvp_platform_gb_stream pgs\n" +
|
||||
" on gs.gb_stream_id = pgs.gb_stream_id\n" +
|
||||
"where pgs.platform_id=#{platformId} and pgs.catalog_id=#{catalogId}")
|
||||
List<PlatformCatalog> queryChannelInParentPlatformAndCatalogForCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
|
||||
|
||||
@Select("<script> " +
|
||||
"SELECT " +
|
||||
"pp.* " +
|
||||
"FROM " +
|
||||
"wvp_platform pp " +
|
||||
"left join wvp_platform_gb_stream pgs on " +
|
||||
"pp.server_gb_id = pgs.platform_id " +
|
||||
"left join wvp_gb_stream gs " +
|
||||
"on gs.gb_stream_id = pgs.gb_stream_id " +
|
||||
"WHERE " +
|
||||
"gs.app = #{app} " +
|
||||
"AND gs.stream = #{stream}" +
|
||||
"AND pp.server_gb_id IN" +
|
||||
"<foreach collection='platforms' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
|
||||
"</script> ")
|
||||
List<ParentPlatform> queryPlatFormListForGBWithGBId(@Param("app") String app, @Param("stream") String stream, @Param("platforms") List<String> platforms);
|
||||
|
||||
@Delete("DELETE from wvp_platform_gb_stream WHERE gb_stream_id = (select id from wvp_gb_stream where app=#{app} AND stream=#{stream}) AND platform_id=#{platformId}")
|
||||
int delByAppAndStreamAndPlatform(String app, String stream, String platformId);
|
||||
|
||||
@Delete("<script> "+
|
||||
"DELETE from wvp_platform_gb_stream where gb_stream_id in " +
|
||||
"<foreach collection='gbStreams' item='item' open='(' separator=',' close=')' >" +
|
||||
"#{item.gbStreamId}" +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
void delByGbStreams(List<GbStream> gbStreams);
|
||||
|
||||
@Delete("<script> "+
|
||||
"DELETE from wvp_platform_gb_stream where platform_id=#{platformId} and gb_stream_id in " +
|
||||
"<foreach collection='gbStreams' item='item' open='(' separator=',' close=')'>" +
|
||||
"#{item.gbStreamId} " +
|
||||
"</foreach>" +
|
||||
"</script>")
|
||||
void delByAppAndStreamsByPlatformId(@Param("gbStreams") List<GbStream> gbStreams, @Param("platformId") String platformId);
|
||||
|
||||
@Delete("DELETE from wvp_platform_gb_stream WHERE platform_id=#{platformId} and catalog_id=#{catalogId}")
|
||||
int delByPlatformAndCatalogId(@Param("platformId") String platformId, @Param("catalogId") String catalogId);
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
package com.genersoft.iot.vmp.vmanager.channel;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
||||
import com.genersoft.iot.vmp.service.ICommonGbChannelService;
|
||||
import com.genersoft.iot.vmp.service.IPlatformChannelService;
|
||||
import com.genersoft.iot.vmp.service.IPlatformService;
|
||||
import com.genersoft.iot.vmp.service.bean.DeviceType;
|
||||
import com.genersoft.iot.vmp.service.bean.IndustryCodeType;
|
||||
import com.genersoft.iot.vmp.service.bean.NetworkIdentificationType;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.*;
|
||||
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.UpdateChannelParam;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.async.DeferredResult;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name = "通用国标通道")
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/channel/platform")
|
||||
public class CommonChannelPlatformController {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(CommonChannelPlatformController.class);
|
||||
|
||||
@Autowired
|
||||
private ICommonGbChannelService commonGbChannelService;
|
||||
|
||||
@Autowired
|
||||
private DeferredResultHolder resultHolder;
|
||||
|
||||
@Autowired
|
||||
private UserSetting userSetting;
|
||||
|
||||
@Autowired
|
||||
private IPlatformService platformService;
|
||||
|
||||
@Autowired
|
||||
private IPlatformChannelService platformChannelService;
|
||||
|
||||
/**
|
||||
* 向上级平台添加国标通道
|
||||
*/
|
||||
@Operation(summary = "向上级平台添加国标通道")
|
||||
@PostMapping("/add")
|
||||
@ResponseBody
|
||||
public void addChannelForGB(@RequestBody UpdateChannelParam param) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("给上级平台添加国标通道API调用");
|
||||
}
|
||||
ParentPlatform platform = platformService.queryPlatformByServerGBId(param.getPlatformId());
|
||||
if (platform == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台不存在");
|
||||
}
|
||||
if (platform.isShareAllChannel()) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "已开启共享所有通道,不需要添加了");
|
||||
}
|
||||
if (param.getCommonGbChannelIds() == null || param.getCommonGbChannelIds().isEmpty()) {
|
||||
throw new ControllerException(ErrorCode.ERROR100);
|
||||
}
|
||||
if (platformChannelService.addChannelForGB(platform,param.getCommonGbChannelIds()) <= 0) {
|
||||
throw new ControllerException(ErrorCode.ERROR100);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从上级平台移除国标通道
|
||||
*
|
||||
* @param param 通道关联参数
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "从上级平台移除国标通道")
|
||||
@DeleteMapping("/delete")
|
||||
@ResponseBody
|
||||
public void delChannelForGB(@RequestBody UpdateChannelParam param) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("给上级平台删除国标通道API调用");
|
||||
}
|
||||
ParentPlatform platform = platformService.queryPlatformByServerGBId(param.getPlatformId());
|
||||
if (platform == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台不存在");
|
||||
}
|
||||
if (platform.isShareAllChannel()) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "已开启共享所有通道,不支持部分移除");
|
||||
}
|
||||
if (param.getCommonGbChannelIds() == null || param.getCommonGbChannelIds().isEmpty()) {
|
||||
throw new ControllerException(ErrorCode.ERROR100);
|
||||
}
|
||||
if (platformChannelService.removeChannelForGB(platform,param.getCommonGbChannelIds()) <= 0) {
|
||||
throw new ControllerException(ErrorCode.ERROR100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -51,9 +51,6 @@ public class PlatformController {
|
|||
@Autowired
|
||||
private IVideoManagerStorage storager;
|
||||
|
||||
@Autowired
|
||||
private IPlatformChannelService platformChannelService;
|
||||
|
||||
@Autowired
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
|
@ -72,12 +69,6 @@ public class PlatformController {
|
|||
@Autowired
|
||||
private IPlatformService platformService;
|
||||
|
||||
@Autowired
|
||||
private IDeviceChannelService deviceChannelService;
|
||||
|
||||
@Autowired
|
||||
private IGbStreamService gbStreamService;
|
||||
|
||||
/**
|
||||
* 获取国标服务的配置
|
||||
*
|
||||
|
@ -282,224 +273,4 @@ public class PlatformController {
|
|||
return parentPlatform != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 向上级平台添加国标通道
|
||||
*/
|
||||
@Operation(summary = "向上级平台添加国标通道")
|
||||
@PostMapping("/channel/add")
|
||||
@ResponseBody
|
||||
public void addChannelForGB(@RequestBody UpdateChannelParam param) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("给上级平台添加国标通道API调用");
|
||||
}
|
||||
ParentPlatform platform = platformService.queryPlatformByServerGBId(param.getPlatformId());
|
||||
if (platform == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台不存在");
|
||||
}
|
||||
if (platform.isShareAllChannel()) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "已开启共享所有通道,不需要添加了");
|
||||
}
|
||||
if (param.getCommonGbChannelIds() == null || param.getCommonGbChannelIds().isEmpty()) {
|
||||
throw new ControllerException(ErrorCode.ERROR100);
|
||||
}
|
||||
if (platformChannelService.addChannelForGB(platform,param.getCommonGbChannelIds()) <= 0) {
|
||||
throw new ControllerException(ErrorCode.ERROR100);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从上级平台移除国标通道
|
||||
*
|
||||
* @param param 通道关联参数
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "从上级平台移除国标通道")
|
||||
@DeleteMapping("/channel/delete")
|
||||
@ResponseBody
|
||||
public void delChannelForGB(@RequestBody UpdateChannelParam param) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("给上级平台删除国标通道API调用");
|
||||
}
|
||||
ParentPlatform platform = platformService.queryPlatformByServerGBId(param.getPlatformId());
|
||||
if (platform == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台不存在");
|
||||
}
|
||||
if (platform.isShareAllChannel()) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "已开启共享所有通道,不支持部分移除");
|
||||
}
|
||||
if (param.getCommonGbChannelIds() == null || param.getCommonGbChannelIds().isEmpty()) {
|
||||
throw new ControllerException(ErrorCode.ERROR100);
|
||||
}
|
||||
if (platformChannelService.removeChannelForGB(platform,param.getCommonGbChannelIds()) <= 0) {
|
||||
throw new ControllerException(ErrorCode.ERROR100);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取目录
|
||||
*
|
||||
* @param platformId 平台ID
|
||||
* @param parentId 目录父ID
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "获取目录")
|
||||
@Parameter(name = "platformId", description = "上级平台的国标编号", required = true)
|
||||
@Parameter(name = "parentId", description = "父级目录的国标编号", required = true)
|
||||
@GetMapping("/catalog")
|
||||
@ResponseBody
|
||||
public List<PlatformCatalog> getCatalogByPlatform(String platformId, String parentId) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("查询目录,platformId: {}, parentId: {}", platformId, parentId);
|
||||
}
|
||||
ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId);
|
||||
if (platform == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台未找到");
|
||||
}
|
||||
// if (platformId.equals(parentId)) {
|
||||
// parentId = platform.getDeviceGBId();
|
||||
// }
|
||||
|
||||
if (platformId.equals(platform.getDeviceGBId())) {
|
||||
parentId = null;
|
||||
}
|
||||
|
||||
return storager.getChildrenCatalogByPlatform(platformId, parentId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加目录
|
||||
*
|
||||
* @param platformCatalog 目录
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "添加目录")
|
||||
@PostMapping("/catalog/add")
|
||||
@ResponseBody
|
||||
public void addCatalog(@RequestBody PlatformCatalog platformCatalog) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("添加目录,{}", JSON.toJSONString(platformCatalog));
|
||||
}
|
||||
PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getPlatformId(), platformCatalog.getId());
|
||||
|
||||
if (platformCatalogInStore != null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), platformCatalog.getId() + " already exists");
|
||||
}
|
||||
int addResult = storager.addCatalog(platformCatalog);
|
||||
if (addResult <= 0) {
|
||||
throw new ControllerException(ErrorCode.ERROR100);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑目录
|
||||
*
|
||||
* @param platformCatalog 目录
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "编辑目录")
|
||||
@PostMapping("/catalog/edit")
|
||||
@ResponseBody
|
||||
public void editCatalog(@RequestBody PlatformCatalog platformCatalog) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("编辑目录,{}", JSON.toJSONString(platformCatalog));
|
||||
}
|
||||
PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getPlatformId(), platformCatalog.getId());
|
||||
|
||||
if (platformCatalogInStore == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), platformCatalog.getId() + " not exists");
|
||||
}
|
||||
int addResult = storager.updateCatalog(platformCatalog);
|
||||
if (addResult <= 0) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "写入数据库失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除目录
|
||||
*
|
||||
* @param id 目录Id
|
||||
* @param platformId 平台Id
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除目录")
|
||||
@Parameter(name = "id", description = "目录Id", required = true)
|
||||
@Parameter(name = "platformId", description = "平台Id", required = true)
|
||||
@DeleteMapping("/catalog/del")
|
||||
@ResponseBody
|
||||
public void delCatalog(String id, String platformId) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("删除目录,{}", id);
|
||||
}
|
||||
|
||||
if (ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(platformId)) {
|
||||
throw new ControllerException(ErrorCode.ERROR400);
|
||||
}
|
||||
|
||||
int delResult = storager.delCatalog(platformId, id);
|
||||
// 如果删除的是默认目录则根目录设置为默认目录
|
||||
PlatformCatalog parentPlatform = storager.queryDefaultCatalogInPlatform(platformId);
|
||||
|
||||
// 默认节点被移除
|
||||
if (parentPlatform == null) {
|
||||
storager.setDefaultCatalog(platformId, platformId);
|
||||
}
|
||||
|
||||
if (delResult <= 0) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "写入数据库失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除关联
|
||||
*
|
||||
* @param platformCatalog 关联的信息
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "删除关联")
|
||||
@DeleteMapping("/catalog/relation/del")
|
||||
@ResponseBody
|
||||
public void delRelation(@RequestBody PlatformCatalog platformCatalog) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("删除关联,{}", JSON.toJSONString(platformCatalog));
|
||||
}
|
||||
int delResult = storager.delRelation(platformCatalog);
|
||||
|
||||
if (delResult <= 0) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "写入数据库失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改默认目录
|
||||
*
|
||||
* @param platformId 平台Id
|
||||
* @param catalogId 目录Id
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "修改默认目录")
|
||||
@Parameter(name = "catalogId", description = "目录Id", required = true)
|
||||
@Parameter(name = "platformId", description = "平台Id", required = true)
|
||||
@PostMapping("/catalog/default/update")
|
||||
@ResponseBody
|
||||
public void setDefaultCatalog(String platformId, String catalogId) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("修改默认目录,{},{}", platformId, catalogId);
|
||||
}
|
||||
int updateResult = storager.setDefaultCatalog(platformId, catalogId);
|
||||
|
||||
if (updateResult <= 0) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "写入数据库失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue