diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java index 82b4ffb2..4d25da6c 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/CommonGbChannelServiceImpl.java @@ -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; diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java index aec31f06..26d67413 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java @@ -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; diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/GroupServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/GroupServiceImpl.java index e9a3a4c5..007215f7 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/GroupServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/GroupServiceImpl.java @@ -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; diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java index bb8f3169..04630c99 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java @@ -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; diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RegionServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RegionServiceImpl.java index 5a306988..ce3d1af5 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/RegionServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RegionServiceImpl.java @@ -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 diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonGbChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonChannelMapper.java similarity index 99% rename from src/main/java/com/genersoft/iot/vmp/storager/dao/CommonGbChannelMapper.java rename to src/main/java/com/genersoft/iot/vmp/storager/dao/CommonChannelMapper.java index d90c22d6..b15f385c 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonGbChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonChannelMapper.java @@ -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 getChannels(String commonGroupId); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonChannelPlatformMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonChannelPlatformMapper.java new file mode 100644 index 00000000..a8273ce5 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/CommonChannelPlatformMapper.java @@ -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 { + + +} diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java deleted file mode 100755 index edd34e5d..00000000 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java +++ /dev/null @@ -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 selectByParentId(@Param("platformId") String platformId, @Param("parentId") String parentId); - - @Update(value = {" "}) - 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 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 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); -} diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java deleted file mode 100755 index 1a210e74..00000000 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java +++ /dev/null @@ -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("") - List findChannelRelatedPlatform(@Param("platformId") String platformId, @Param("channelReduces") List channelReduces); - - @Insert("") - int addChannels(@Param("platformId") Integer platformId, @Param("channelIds") List channelIds); - - @Delete("") - int delChannelForGB(@Param("platformId") String platformId, @Param("channelReducesToDel") List channelReducesToDel); - - @Delete("") - int delChannelForDeviceId(String deviceId); - - @Delete("") - 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 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 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 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 queryVideoDeviceByPlatformIdAndChannelId(@Param("platformId") String platformId, @Param("channelId") String channelId); - - @Delete("") - int delByCatalogId(@Param("platformId") String platformId, @Param("id") String id); - - @Delete("") - int delByCatalogIdAndChannelIdAndPlatformId(PlatformCatalog platformCatalog); - - @Select(" ") - List queryPlatFormListForGBWithGBId(@Param("channelId") String channelId, @Param("platforms") List platforms); - - @Delete("") - void delByPlatformId(String serverGBId); - - @Delete("") - 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 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 queryParentPlatformByChannelId(String channelId); - - @Select("") - List findChannelsInDb(@Param("platformId") Integer platformId, @Param("channelIds") List channelIds); -} diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java deleted file mode 100755 index c394bcbd..00000000 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java +++ /dev/null @@ -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("") - int batchAdd(List 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 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 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 queryChannelInParentPlatformAndCatalogForCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId); - - @Select(" ") - List queryPlatFormListForGBWithGBId(@Param("app") String app, @Param("stream") String stream, @Param("platforms") List 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("") - void delByGbStreams(List gbStreams); - - @Delete("") - void delByAppAndStreamsByPlatformId(@Param("gbStreams") List 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); -} diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/channel/CommonChannelPlatformController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/channel/CommonChannelPlatformController.java new file mode 100755 index 00000000..097b1152 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/channel/CommonChannelPlatformController.java @@ -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); + } + } + + +} diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java index 3028c529..8cf1f93d 100755 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java @@ -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 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(), "写入数据库失败"); - } - } - - }