diff --git a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java index 18114c5a..1d4293ba 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java @@ -31,7 +31,7 @@ public class UserSetting { private Boolean recordSip = Boolean.TRUE; - private Boolean logInDatabase = Boolean.TRUE; + private Boolean logInDatabase = Boolean.FALSE; private Boolean usePushingAsStatus = Boolean.FALSE; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Group.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Group.java index a0982982..9cc392de 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Group.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Group.java @@ -29,6 +29,12 @@ public class Group implements Comparable{ @Schema(description = "区域名称") private String name; + /** + * 父分组ID + */ + @Schema(description = "父分组ID") + private Integer parentId; + /** * 父区域国标ID */ @@ -53,12 +59,6 @@ public class Group implements Comparable{ @Schema(description = "更新时间") private String updateTime; - /** - * 平台ID - */ - @Schema(description = "平台ID") - private Integer platformId; - public static Group getInstance(DeviceChannel channel) { GbCode gbCode = GbCode.decode(channel.getDeviceId()); if (gbCode == null || (!gbCode.getTypeCode().equals("215") && !gbCode.getTypeCode().equals("216"))) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GroupTree.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GroupTree.java index 6c8229f3..d11d345c 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GroupTree.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GroupTree.java @@ -8,37 +8,10 @@ import lombok.Data; */ @Data @Schema(description = "业务分组树") -public class GroupTree { +public class GroupTree extends Group{ - /** - * 数据库Id - */ - @Schema(description = "数据库Id") - private int dbId; - - /** - * 区域国标编号 - */ - @Schema(description = "区域国标编号") - private String id; - - /** - * 区域名称 - */ - @Schema(description = "区域名称") - private String label; - - /** - * 父区域国标ID - */ - @Schema(description = "父区域国标ID") - private String parentDeviceId; - - /** - * 业务分组ID - */ - @Schema(description = "父区域国标ID") - private String businessGroup; + @Schema(description = "树节点Id") + private String treeId; @Schema(description = "是否有子节点") private boolean isLeaf; @@ -46,13 +19,4 @@ public class GroupTree { @Schema(description = "类型, 行政区划:0 摄像头: 1") private int type; - public static GroupTree getInstance(CommonGBChannel channel) { - GroupTree regionTree = new GroupTree(); - regionTree.setId(channel.getGbDeviceId()); - regionTree.setLabel(channel.getGbName()); - regionTree.setParentDeviceId(channel.getGbCivilCode()); - regionTree.setType(1); - regionTree.setLeaf(true); - return regionTree; - } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/GroupController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/GroupController.java index d04b3980..ef30624c 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/GroupController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/GroupController.java @@ -36,21 +36,16 @@ public class GroupController { @Operation(summary = "查询分组") @Parameter(name = "query", description = "要搜索的内容", required = true) @Parameter(name = "parent", description = "所属分组编号", required = true) - @Parameter(name = "platformId", description = "上级平台ID", required = true) @ResponseBody @GetMapping("/tree/list") public List queryForTree( @RequestParam(required = false) String query, - @RequestParam(required = false) String parent, - @RequestParam(required = false) Integer platformId + @RequestParam(required = false) Integer parent ){ - if (ObjectUtils.isEmpty(parent)) { - parent = null; - } if (ObjectUtils.isEmpty(query)) { query = null; } - return groupService.queryForTree(query, parent, platformId); + return groupService.queryForTree(query, parent); } @Operation(summary = "更新分组") diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlatformController.java index 8a73a2ff..e6391c00 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlatformController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/PlatformController.java @@ -298,6 +298,7 @@ public class PlatformController { public PageInfo queryChannelList(int page, int count, @RequestParam(required = false) Integer platformId, @RequestParam(required = false) String query, + @RequestParam(required = false) Boolean channelType, @RequestParam(required = false) Boolean online, @RequestParam(required = false) Boolean hasShare) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java index 394b9bcd..2d887b90 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/CommonGBChannelMapper.java @@ -343,11 +343,11 @@ public interface CommonGBChannelMapper { @Select(""}) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/GroupMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/GroupMapper.java index dd56ad91..e639f0ac 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/GroupMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/GroupMapper.java @@ -3,7 +3,6 @@ package com.genersoft.iot.vmp.gb28181.dao; import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.Group; import com.genersoft.iot.vmp.gb28181.bean.GroupTree; -import com.genersoft.iot.vmp.gb28181.bean.Region; import org.apache.ibatis.annotations.*; import java.util.List; @@ -12,13 +11,13 @@ import java.util.Set; @Mapper public interface GroupMapper { - @Insert("INSERT INTO wvp_common_group (device_id, name, parent_device_id, business_group, platform_id, create_time, update_time) " + - "VALUES (#{deviceId}, #{name}, #{parentDeviceId}, #{businessGroup}, #{platformId}, #{createTime}, #{updateTime})") + @Insert("INSERT INTO wvp_common_group (device_id, name, parent_id, parent_device_id, business_group, create_time, update_time) " + + "VALUES (#{deviceId}, #{name}, #{parentId}, #{parentDeviceId}, #{businessGroup}, #{createTime}, #{updateTime})") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") int add(Group group); - @Insert("INSERT INTO wvp_common_group (device_id, name, business_group, platform_id, create_time, update_time) " + - "VALUES (#{deviceId}, #{name}, #{businessGroup}, #{platformId}, #{createTime}, #{updateTime})") + @Insert("INSERT INTO wvp_common_group (device_id, name, business_group, create_time, update_time) " + + "VALUES (#{deviceId}, #{name}, #{businessGroup}, #{createTime}, #{updateTime})") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") int addBusinessGroup(Group group); @@ -26,7 +25,7 @@ public interface GroupMapper { int delete(@Param("id") int id); @Update(" UPDATE wvp_common_group " + - " SET update_time=#{updateTime}, device_id=#{deviceId}, name=#{name}, parent_device_id=#{parentDeviceId}, business_group=#{businessGroup}" + + " SET update_time=#{updateTime}, device_id=#{deviceId}, name=#{name}, parent_id=#{parentId}, parent_device_id=#{parentDeviceId}, business_group=#{businessGroup}" + " WHERE id = #{id}") int update(Group group); @@ -38,99 +37,67 @@ public interface GroupMapper { " "}) List query(@Param("query") String query, @Param("parentId") String parentId, @Param("businessGroup") String businessGroup); - @Select(value = {" "}) - List getChildren(@Param("parentId") String parentId , @Param("platformId") Integer platformId); + @Select("SELECT * from wvp_common_group WHERE parent_id = #{parentId} ") + List getChildren(@Param("parentId") int parentId); @Select("SELECT * from wvp_common_group WHERE id = #{id} ") Group queryOne(@Param("id") int id); - @Select(" select coalesce(dc.gb_civil_code, dc.civil_code) as civil_code " + - " from wvp_device_channel dc " + - " where coalesce(dc.gb_civil_code, dc.civil_code) not in " + - " (select device_id from wvp_common_group)") - List getUninitializedCivilCode(); - - @Select(" ") - List queryInList(Set codes); - @Insert(" ") int batchAdd(List groupList); @Select(" ") - List queryForTree(@Param("query") String query, @Param("parentId") String parentId, - @Param("platformId") Integer platformId); + List queryForTree(@Param("query") String query, @Param("parentId") Integer parentId); @Select(" ") List queryForTreeByBusinessGroup(@Param("query") String query, - @Param("businessGroup") String businessGroup, - @Param("platformId") Integer platformId); + @Param("businessGroup") String businessGroup); @Select(" ") - List queryBusinessGroupForTree(String query, Integer platformId); + List queryBusinessGroupForTree(@Param("query") String query); @Select("SELECT * from wvp_common_group WHERE device_id = #{deviceId} and business_group = #{businessGroup}") Group queryOneByDeviceId(@Param("deviceId") String deviceId, @Param("businessGroup") String businessGroup); @@ -152,15 +119,15 @@ public interface GroupMapper { @Update(" UPDATE wvp_common_group " + " SET parent_device_id=#{group.deviceId}, business_group = #{group.businessGroup}" + - " WHERE parent_device_id = #{oldDeviceId}") - int updateChild(@Param("oldDeviceId") String oldDeviceId, Group group); + " WHERE parentId = #{parentId}") + int updateChild(@Param("parentId") Integer parentId, Group group); @Select(" ") - List queryInGroupList(List groupList); + List queryInGroupListByDeviceId(List groupList); @Select(" ") - Set queryParentInChannelList(Set regionChannelList); - - @Select(" ") - Set queryBusinessGroupInChannelList(List channelList); + Set queryParentInChannelList(Set groupSet); @Select(" ") Set queryNotShareForPlatformByChannelList(List channelList, @Param("platformId") Integer platformId); @@ -215,7 +173,7 @@ public interface GroupMapper { " SELECT * " + " from wvp_common_group wcg" + " left join wvp_platform_group wpg on wpg.group_id = wcg.id and wpg.platform_id = #{platformId}" + - " where wpg.platform_id = null and wcg.id in " + + " where wpg.platform_id IS NULL and wcg.id in " + " #{item.id}" + " ") Set queryNotShareForPlatformByGroupList(Set allGroup, @Param("platformId") Integer platformId); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java index 52a3c08d..ba299ac4 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformChannelMapper.java @@ -10,6 +10,7 @@ import org.apache.ibatis.annotations.Select; import org.springframework.stereotype.Repository; import java.util.List; +import java.util.Set; @Mapper @Repository @@ -19,13 +20,13 @@ public interface PlatformChannelMapper { * 查询列表里已经关联的 */ @Select("") List findChannelRelatedPlatform(@Param("platformId") String platformId, @Param("channelReduces") List channelReduces); @Insert("") 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_platform_gb_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE dc.channel_id=#{channelId} and pgc.platform_id=#{platformId}") + @Select("SELECT dc.* from wvp_platform_channel 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("") 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_platform_gb_channel pgc on dc.id = pgc.device_channel_id " + + " from wvp_device_channel dc left join wvp_platform_channel 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_platform_gb_channel pgc\n" + + "from wvp_platform_channel 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); @@ -88,7 +89,7 @@ public interface PlatformChannelMapper { "pp.* " + "FROM " + "wvp_platform pp " + - "left join wvp_platform_gb_channel pgc on " + + "left join wvp_platform_channel pgc on " + "pp.id = pgc.platform_id " + "left join wvp_device_channel dc on " + "dc.id = pgc.device_channel_id " + @@ -100,24 +101,24 @@ public interface PlatformChannelMapper { 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_platform_gb_channel pgc\n" + + "from wvp_platform_channel 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_platform_gb_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE dc.device_id=#{channelId}") + @Select("SELECT pgc.platform_id from wvp_platform_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE dc.device_id=#{channelId}") List queryParentPlatformByChannelId(@Param("channelId") String channelId); @@ -166,7 +167,7 @@ public interface PlatformChannelMapper { " coalesce(wpgc.svc_time_support_mode, wdc.gb_svc_time_support_mode, wdc.svc_time_support_mode) as gb_svc_time_support_mode, \n" + " wpgc.platform_id " + " from wvp_device_channel wdc" + - " left join wvp_platform_gb_channel wpgc on wdc.id = wpgc.device_channel_id and wpgc.platform_id = #{platformId}" + + " left join wvp_platform_channel wpgc on wdc.id = wpgc.device_channel_id and wpgc.platform_id = #{platformId}" + " where 1=1" + " AND (coalesce(wpgc.device_id, wdc.gb_device_id, wdc.device_id) LIKE concat('%',#{query},'%') " + " OR coalesce(wpgc.name, wdc.gb_name, wdc.name) LIKE concat('%',#{query},'%')) " + @@ -221,7 +222,7 @@ public interface PlatformChannelMapper { " coalesce(wpgc.svc_space_support_mod, wdc.gb_svc_space_support_mod, wdc.svc_space_support_mod) as gb_svc_space_support_mod,\n" + " coalesce(wpgc.svc_time_support_mode, wdc.gb_svc_time_support_mode, wdc.svc_time_support_mode) as gb_svc_time_support_mode\n" + " from wvp_device_channel wdc" + - " left join wvp_platform_gb_channel wpgc on wdc.id = wpgc.device_channel_id" + + " left join wvp_platform_channel wpgc on wdc.id = wpgc.device_channel_id" + " where wpgc.platform_id = #{platformId} and coalesce(wpgc.device_id, wdc.gb_device_id, wdc.device_id) = #{channelDeviceId}" ) @@ -271,12 +272,11 @@ public interface PlatformChannelMapper { " coalesce(wpgc.svc_space_support_mod, wdc.gb_svc_space_support_mod, wdc.svc_space_support_mod) as gb_svc_space_support_mod,\n" + " coalesce(wpgc.svc_time_support_mode, wdc.gb_svc_time_support_mode, wdc.svc_time_support_mode) as gb_svc_time_support_mode\n" + " from wvp_device_channel wdc" + - " left join wvp_platform_gb_channel wpgc on wdc.id = wpgc.device_channel_id and wpgc.platform_id = #{platformId}" + + " left join wvp_platform_channel wpgc on wdc.id = wpgc.device_channel_id and wpgc.platform_id = #{platformId}" + " where wpgc.platform_id is null" + - " AND wdc.id in " + - "#{item} " + - " " + - + " AND wdc.id in " + + " #{item} " + + "" + "") List queryNotShare(@Param("platformId") Integer platformId, List channelIds); @@ -323,7 +323,7 @@ public interface PlatformChannelMapper { " coalesce(wpgc.svc_space_support_mod, wdc.gb_svc_space_support_mod, wdc.svc_space_support_mod) as gb_svc_space_support_mod,\n" + " coalesce(wpgc.svc_time_support_mode, wdc.gb_svc_time_support_mode, wdc.svc_time_support_mode) as gb_svc_time_support_mode\n" + " from wvp_device_channel wdc" + - " left join wvp_platform_gb_channel wpgc on wdc.id = wpgc.device_channel_id" + + " left join wvp_platform_channel wpgc on wdc.id = wpgc.device_channel_id" + " where wpgc.platform_id = #{platformId}" + " AND wdc.id in " + " " + @@ -334,7 +334,7 @@ public interface PlatformChannelMapper { List queryShare(@Param("platformId") Integer platformId, List channelIds); @Delete("") void removePlatformGroupById(@Param("id") int id, @Param("platformId") Integer platformId); + + @Select(" ") + Set queryShareChildrenGroup(@Param("parentId") String parentId, @Param("platformId") Integer platformId); + + @Select(" ") + Set queryShareParentGroupByGroupSet(Set groupSet, @Param("platformId") Integer platformId); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformMapper.java index db080ae6..647ad798 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/PlatformMapper.java @@ -15,11 +15,11 @@ public interface PlatformMapper { @Insert("INSERT INTO wvp_platform (enable, name, server_gb_id, server_gb_domain, server_ip, server_port,device_gb_id,device_ip,"+ " device_port,username,password,expires,keep_timeout,transport,character_set,ptz,rtcp,status,catalog_group, update_time," + - " create_time, as_message_channel, send_stream_ip, auto_push_channel, catalog_with_platform, custom_group, custom_civil_code, "+ + " create_time, as_message_channel, send_stream_ip, auto_push_channel, catalog_with_platform,catalog_with_group,catalog_with_region, "+ " civil_code,manufacturer,model,address,register_way,secrecy) " + " VALUES (#{enable}, #{name}, #{serverGBId}, #{serverGBDomain}, #{serverIp}, #{serverPort}, #{deviceGBId}, #{deviceIp}, " + " #{devicePort}, #{username}, #{password}, #{expires}, #{keepTimeout}, #{transport}, #{characterSet}, #{ptz}, #{rtcp}, #{status}, #{catalogGroup},#{updateTime}," + - " #{createTime}, #{asMessageChannel}, #{sendStreamIp}, #{autoPushChannel}, #{catalogWithPlatform}, #{customGroup},#{customCivilCode}, " + + " #{createTime}, #{asMessageChannel}, #{sendStreamIp}, #{autoPushChannel}, #{catalogWithPlatform}, #{catalogWithGroup},#{catalogWithRegion}, " + " #{civilCode}, #{manufacturer}, #{model}, #{address}, #{registerWay}, #{secrecy})") int add(Platform parentPlatform); @@ -48,8 +48,8 @@ public interface PlatformMapper { " send_stream_ip=#{sendStreamIp}, " + " auto_push_channel=#{autoPushChannel}, " + " catalog_with_platform=#{catalogWithPlatform}, " + - " custom_group=#{customGroup}, " + - " custom_civil_code=#{customCivilCode}, " + + " catalog_with_group=#{catalogWithGroup}, " + + " catalog_with_region=#{catalogWithRegion}, " + " civil_code=#{civilCode}, " + " manufacturer=#{manufacturer}, " + " model=#{model}, " + @@ -63,7 +63,7 @@ public interface PlatformMapper { int delParentPlatform(Platform parentPlatform); @Select(" SELECT pp.*, " + - " (SELECT count(0) FROM wvp_platform_gb_channel pc WHERE pc.platform_id = pp.id ) as channel_count" + + " (SELECT count(0) FROM wvp_platform_channel pc WHERE pc.platform_id = pp.id ) as channel_count" + " FROM wvp_platform pp " ) List queryList(); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGroupService.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGroupService.java index 67629645..a3265bd6 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGroupService.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/IGroupService.java @@ -14,7 +14,7 @@ public interface IGroupService { Group queryGroupByDeviceId(String regionDeviceId); - List queryForTree(String query, String parent, Integer platformId); + List queryForTree(String query, Integer parent); void syncFromChannel(); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java index 37afc575..fc20d723 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GbChannelServiceImpl.java @@ -60,6 +60,8 @@ public class GbChannelServiceImpl implements IGbChannelService { throw new ControllerException(ErrorCode.ERROR100.getCode(), "此代理已经关联通道"); } } + commonGBChannel.setCreateTime(DateUtil.getNow()); + commonGBChannel.setUpdateTime(DateUtil.getNow()); return commonGBChannelMapper.insert(commonGBChannel); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GroupServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GroupServiceImpl.java index 5efc0206..611938b8 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GroupServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/GroupServiceImpl.java @@ -1,6 +1,9 @@ package com.genersoft.iot.vmp.gb28181.service.impl; -import com.genersoft.iot.vmp.gb28181.bean.*; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; +import com.genersoft.iot.vmp.gb28181.bean.GbCode; +import com.genersoft.iot.vmp.gb28181.bean.Group; +import com.genersoft.iot.vmp.gb28181.bean.GroupTree; import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; import com.genersoft.iot.vmp.gb28181.dao.GroupMapper; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; @@ -19,7 +22,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; /** * 区域管理类 @@ -73,15 +75,6 @@ public class GroupServiceImpl implements IGroupService { group.setCreateTime(DateUtil.getNow()); group.setUpdateTime(DateUtil.getNow()); groupManager.add(group); - if (group.getPlatformId() != null) { - CommonGBChannel channel = CommonGBChannel.build(group); - try { - // 发送catalog - eventPublisher.catalogEventPublish(group.getPlatformId(), channel, CatalogEvent.ADD); - }catch (Exception e) { - log.warn("[添加虚拟组织] 发送失败, {}-{}", channel.getGbName(), channel.getGbDeviceDbId(), e); - } - } } private void addBusinessGroup(Group group) { @@ -89,24 +82,15 @@ public class GroupServiceImpl implements IGroupService { group.setCreateTime(DateUtil.getNow()); group.setUpdateTime(DateUtil.getNow()); groupManager.addBusinessGroup(group); - if (group.getPlatformId() != null) { - CommonGBChannel channel = CommonGBChannel.build(group); - try { - // 发送catalog - eventPublisher.catalogEventPublish(group.getPlatformId(), channel, CatalogEvent.ADD); - }catch (Exception e) { - log.warn("[添加虚拟组织] 发送失败, {}-{}", channel.getGbName(), channel.getGbDeviceDbId(), e); - } - } } - private List queryAllChildren(String deviceId, Integer platformId) { - List children = groupManager.getChildren(deviceId, platformId); + private List queryAllChildren(Integer id) { + List children = groupManager.getChildren(id); if (ObjectUtils.isEmpty(children)) { return children; } for (int i = 0; i < children.size(); i++) { - children.addAll(queryAllChildren(children.get(i).getDeviceId(), platformId)); + children.addAll(queryAllChildren(children.get(i).getId())); } return children; } @@ -126,9 +110,9 @@ public class GroupServiceImpl implements IGroupService { // 修改他的子节点 if (!group.getDeviceId().equals(groupInDb.getDeviceId()) || !group.getBusinessGroup().equals(groupInDb.getBusinessGroup())) { - List groupList = queryAllChildren(groupInDb.getDeviceId(), groupInDb.getPlatformId()); + List groupList = queryAllChildren(groupInDb.getId()); if (!groupList.isEmpty()) { - int result = groupManager.updateChild(groupInDb.getDeviceId(), group); + int result = groupManager.updateChild(groupInDb.getId(), group); if (result > 0) { for (Group chjildGroup : groupList) { chjildGroup.setParentDeviceId(group.getDeviceId()); @@ -173,32 +157,21 @@ public class GroupServiceImpl implements IGroupService { } @Override - public List queryForTree(String query, String parent, Integer platformId) { - if (parent == null) { - // 查询所有业务分组 - return groupManager.queryBusinessGroupForTree(query, platformId); - }else { - GbCode gbCode = GbCode.decode(parent); - if (gbCode.getTypeCode().equals("215")) { - return groupManager.queryForTreeByBusinessGroup(query, parent, platformId); - }else { - // 查询业务分组以及所属的通道 - List groupTrees = groupManager.queryForTree(query, parent, platformId); - if (platformId == null) { - List channelList = commonGBChannelMapper.queryForGroupTreeByParentId(query, parent); - List channelListForResult = channelList.stream().filter(groupTree -> { - GbCode gbCodeForChannel = GbCode.decode(groupTree.getId()); - return !gbCodeForChannel.getTypeCode().equals("215") && !gbCodeForChannel.getTypeCode().equals("216"); - }).collect(Collectors.toList()); - groupTrees.addAll(channelListForResult); - }else { - // TODO 查询平台独属的关联通道 - } - - return groupTrees; - } + public List queryForTree(String query, Integer parentId) { + List groupTrees = groupManager.queryForTree(query, parentId); + if (parentId == null) { + return groupTrees; } + // 查询含有的通道 + Group parentGroup = groupManager.queryOne(parentId); + if (parentGroup != null && !parentGroup.getDeviceId().equals(parentGroup.getBusinessGroup())) { + List groupTreesForChannel = commonGBChannelMapper.queryForGroupTreeByParentId(query, parentGroup.getDeviceId()); + if (ObjectUtils.isEmpty(groupTreesForChannel)) { + groupTrees.addAll(groupTreesForChannel); + } + } + return groupTrees; } @Override @@ -221,7 +194,7 @@ public class GroupServiceImpl implements IGroupService { // 业务分组 gbChannelService.removeParentIdByBusinessGroup(group.getDeviceId()); }else { - List groupList = queryAllChildren(group.getDeviceId(), group.getPlatformId()); + List groupList = queryAllChildren(group.getId()); if (!groupList.isEmpty()) { groupListForDelete.addAll(groupList); } @@ -252,10 +225,10 @@ public class GroupServiceImpl implements IGroupService { groupMapForVerification.put(group.getDeviceId(), group); } // 查询数据库中已经存在的. - List regionListInDb = groupManager.queryInGroupList(groupList); + List regionListInDb = groupManager.queryInGroupListByDeviceId(groupList); if (!regionListInDb.isEmpty()) { - for (Region region : regionListInDb) { - groupMapForVerification.remove(region.getDeviceId()); + for (Group group : regionListInDb) { + groupMapForVerification.remove(group.getDeviceId()); } } if (!groupMapForVerification.isEmpty()) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java index 1fe66e9c..5caf87af 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlatformChannelServiceImpl.java @@ -105,7 +105,7 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { continue; } // 获取分组关联的通道 - List channelList = platformChannelMapper.queryShareChannelByParentId(group.getDeviceId(), platformId); + List channelList = commonGBChannelMapper.queryShareChannelByParentId(group.getDeviceId(), platformId); if (!channelList.isEmpty()) { groupSet.remove(group); continue; @@ -129,6 +129,11 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { if (groupList.isEmpty()) { return new HashSet<>(); } + for (Group group : groupList) { + if (group.getParentDeviceId() == null) { + + } + } Set channelList = groupMapper.queryParentInChannelList(groupList); if (channelList.isEmpty()) { return channelList; @@ -147,13 +152,16 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { if (result > 0) { // 查询通道相关的分组信息是否共享,如果没共享就添加 Set groupListNotShare = getGroupNotShareByChannelList(channelListNotShare, platformId); - int addGroupResult = platformChannelMapper.addPlatformGroup(new ArrayList<>(groupListNotShare), platformId); - if (addGroupResult > 0) { - for (Group group : groupListNotShare) { - // 分组信息排序时需要将顶层排在最后 - channelListNotShare.add(0, CommonGBChannel.build(group)); + if (!groupListNotShare.isEmpty()) { + int addGroupResult = platformChannelMapper.addPlatformGroup(new ArrayList<>(groupListNotShare), platformId); + if (addGroupResult > 0) { + for (Group group : groupListNotShare) { + // 分组信息排序时需要将顶层排在最后 + channelListNotShare.add(0, CommonGBChannel.build(group)); + } } } + // 发送消息 try { // 发送catalog @@ -175,7 +183,9 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { Set groupSet = groupMapper.queryByChannelList(channelListNotShare); Set deleteGroup = deleteEmptyGroup(groupSet, platformId); if (!deleteGroup.isEmpty()) { - channelListNotShare.add(0, CommonGBChannel.build(group)); + for (Group group : deleteGroup) { + channelListNotShare.add(0, CommonGBChannel.build(group)); + } } // 发送消息 try { @@ -195,11 +205,10 @@ public class PlatformChannelServiceImpl implements IPlatformChannelService { int result = platformChannelMapper.removeChannels(platformId, channelList); if (result > 0) { // 查询通道相关的分组信息是否共享,如果没共享就添加 - List groupListShareEmptyChannel = getGroupShareEmptyChannel(channelList, platformId); - int addGroupResult = platformChannelMapper.removePlatformGroup(groupListShareEmptyChannel, platformId); - if (addGroupResult > 0) { - for (Group group : groupListShareEmptyChannel) { - // 分组信息排序时需要将顶层排在最后 + Set groupSet = groupMapper.queryByChannelList(channelList); + Set deleteGroup = deleteEmptyGroup(groupSet, platformId); + if (!deleteGroup.isEmpty()) { + for (Group group : deleteGroup) { channelList.add(0, CommonGBChannel.build(group)); } } diff --git a/web_src/src/components/PlatformEdit.vue b/web_src/src/components/PlatformEdit.vue index fa929801..9d93b619 100644 --- a/web_src/src/components/PlatformEdit.vue +++ b/web_src/src/components/PlatformEdit.vue @@ -125,6 +125,8 @@ + + diff --git a/web_src/src/components/common/GroupTree.vue b/web_src/src/components/common/GroupTree.vue index 23074e0e..9b822923 100755 --- a/web_src/src/components/common/GroupTree.vue +++ b/web_src/src/components/common/GroupTree.vue @@ -21,18 +21,19 @@ style="padding: 2rem 0 2rem 0.5rem" :load="loadNode" :data="treeData" + :props="props" :default-expanded-keys="['']" @node-contextmenu="contextmenuEventHandler" @node-click="nodeClickHandler" > - {{''}} + {{''}} - {{ node.label }}(编号:{{ node.data.id }}) - {{ node.label }} + {{ node.label }}(编号:{{ node.data.deviceId }}) + {{ node.label }} @@ -53,6 +54,10 @@ export default { }, data() { return { + props: { + id: "treeId", + label: "name", + }, showCode: false, searchSrt: "", chooseId: "", @@ -70,7 +75,7 @@ export default { if (node.level === 0) { resolve([{ id: "", - label: "根资源组", + name: "根资源组", isLeaf: false, type: 0 }]); @@ -112,7 +117,7 @@ export default { method: "post", url: `/api/common/channel/group/delete`, data: { - channelIds: [data.dbId] + channelIds: [data.id] } }).then((res) => { console.log("移除成功") @@ -225,7 +230,7 @@ export default { method: "delete", url: `/api/group/delete`, params: { - id: node.data.dbId, + id: node.data.id, } }).then((res) => { if (res.data.code === 0) { diff --git a/web_src/src/components/dialog/shareChannelAdd.vue b/web_src/src/components/dialog/shareChannelAdd.vue index 725abefa..b470b36c 100755 --- a/web_src/src/components/dialog/shareChannelAdd.vue +++ b/web_src/src/components/dialog/shareChannelAdd.vue @@ -14,6 +14,14 @@ + 类型: + + + + + + 添加状态: @@ -46,9 +54,9 @@ @@ -131,6 +139,7 @@ export default { count: this.count, query: this.searchSrt, online: this.online, + channelType: this.channelType, platformId: this.platformId, hasShare: this.hasShare } diff --git a/数据库/2.6.9/初始化-mysql-2.6.9.sql b/数据库/2.6.9/初始化-mysql-2.6.9.sql index 8eb8d716..d7178539 100644 --- a/数据库/2.6.9/初始化-mysql-2.6.9.sql +++ b/数据库/2.6.9/初始化-mysql-2.6.9.sql @@ -210,7 +210,7 @@ create table wvp_platform_catalog ( constraint uk_platform_catalog_id_platform_id unique (id, platform_id) ); -create table wvp_platform_gb_channel ( +create table wvp_platform_channel ( id serial primary key , platform_id character varying(50), catalog_id character varying(50), diff --git a/数据库/2.6.9/初始化-postgresql-kingbase-2.6.9.sql b/数据库/2.6.9/初始化-postgresql-kingbase-2.6.9.sql index b48f6468..3598ba9e 100644 --- a/数据库/2.6.9/初始化-postgresql-kingbase-2.6.9.sql +++ b/数据库/2.6.9/初始化-postgresql-kingbase-2.6.9.sql @@ -210,7 +210,7 @@ create table wvp_platform_catalog ( constraint uk_platform_catalog_id_platform_id unique (id, platform_id) ); -create table wvp_platform_gb_channel ( +create table wvp_platform_channel ( id serial primary key , platform_id character varying(50), catalog_id character varying(50), diff --git a/数据库/2.6.9/更新-mysql-2.6.9.sql b/数据库/2.6.9/更新-mysql-2.6.9.sql index 735e76d4..fe54e6fb 100644 --- a/数据库/2.6.9/更新-mysql-2.6.9.sql +++ b/数据库/2.6.9/更新-mysql-2.6.9.sql @@ -445,7 +445,7 @@ rename table log to wvp_log; rename table media_server to wvp_media_server; rename table parent_platform to wvp_platform; rename table platform_catalog to wvp_platform_catalog; -rename table platform_gb_channel to wvp_platform_gb_channel; +rename table platform_gb_channel to wvp_platform_channel; rename table platform_gb_stream to wvp_platform_gb_stream; rename table stream_proxy to wvp_stream_proxy; rename table stream_push to wvp_stream_push; diff --git a/数据库/2.6.9/更新-postgresql-kingbase-2.6.9.sql b/数据库/2.6.9/更新-postgresql-kingbase-2.6.9.sql index bbee04ed..ce159cb5 100644 --- a/数据库/2.6.9/更新-postgresql-kingbase-2.6.9.sql +++ b/数据库/2.6.9/更新-postgresql-kingbase-2.6.9.sql @@ -446,7 +446,7 @@ rename table log to wvp_log; rename table media_server to wvp_media_server; rename table parent_platform to wvp_platform; rename table platform_catalog to wvp_platform_catalog; -rename table platform_gb_channel to wvp_platform_gb_channel; +rename table platform_gb_channel to wvp_platform_channel; rename table platform_gb_stream to wvp_platform_gb_stream; rename table stream_proxy to wvp_stream_proxy; rename table stream_push to wvp_stream_push; diff --git a/数据库/2.7.0/初始化-mysql-2.7.0.sql b/数据库/2.7.0/初始化-mysql-2.7.0.sql index 147ed63d..aad4421a 100644 --- a/数据库/2.7.0/初始化-mysql-2.7.0.sql +++ b/数据库/2.7.0/初始化-mysql-2.7.0.sql @@ -211,7 +211,7 @@ create table wvp_platform_catalog ( constraint uk_platform_catalog_id_platform_id unique (id, platform_id) ); -create table wvp_platform_gb_channel ( +create table wvp_platform_channel ( id serial primary key , platform_id character varying(50), catalog_id character varying(50), diff --git a/数据库/2.7.0/初始化-postgresql-kingbase-2.7.0.sql b/数据库/2.7.0/初始化-postgresql-kingbase-2.7.0.sql index 790316d2..4c3ccb4b 100644 --- a/数据库/2.7.0/初始化-postgresql-kingbase-2.7.0.sql +++ b/数据库/2.7.0/初始化-postgresql-kingbase-2.7.0.sql @@ -211,7 +211,7 @@ create table wvp_platform_catalog ( constraint uk_platform_catalog_id_platform_id unique (id, platform_id) ); -create table wvp_platform_gb_channel ( +create table wvp_platform_channel ( id serial primary key , platform_id character varying(50), catalog_id character varying(50), diff --git a/数据库/2.7.1/初始化-mysql-2.7.1.sql b/数据库/2.7.1/初始化-mysql-2.7.1.sql index 98d43404..7f5401ac 100644 --- a/数据库/2.7.1/初始化-mysql-2.7.1.sql +++ b/数据库/2.7.1/初始化-mysql-2.7.1.sql @@ -217,7 +217,7 @@ create table wvp_platform_catalog ( constraint uk_platform_catalog_id_platform_id unique (id, platform_id) ); -create table wvp_platform_gb_channel ( +create table wvp_platform_channel ( id serial primary key , platform_id character varying(50), catalog_id character varying(50), diff --git a/数据库/2.7.1/初始化-postgresql-kingbase-2.7.1.sql b/数据库/2.7.1/初始化-postgresql-kingbase-2.7.1.sql index eb2bc838..c10fbb8c 100644 --- a/数据库/2.7.1/初始化-postgresql-kingbase-2.7.1.sql +++ b/数据库/2.7.1/初始化-postgresql-kingbase-2.7.1.sql @@ -217,7 +217,7 @@ create table wvp_platform_catalog ( constraint uk_platform_catalog_id_platform_id unique (id, platform_id) ); -create table wvp_platform_gb_channel ( +create table wvp_platform_channel ( id serial primary key , platform_id character varying(50), catalog_id character varying(50), diff --git a/数据库/2.7.2-重构/初始化-mysql-2.7.2.sql b/数据库/2.7.2-重构/初始化-mysql-2.7.2.sql index 0b73ff7c..ff4275d4 100644 --- a/数据库/2.7.2-重构/初始化-mysql-2.7.2.sql +++ b/数据库/2.7.2-重构/初始化-mysql-2.7.2.sql @@ -456,12 +456,12 @@ CREATE TABLE wvp_common_group id serial primary key, device_id varchar(50) NOT NULL, name varchar(255) NOT NULL, + parent_id int, parent_device_id varchar(50) DEFAULT NULL, business_group varchar(50) NOT NULL, - platform_id int, create_time varchar(50) NOT NULL, update_time varchar(50) NOT NULL, - UNIQUE KEY common_group_device_platform (device_id, platform_id) + UNIQUE KEY common_group_device_platform (device_id) ); CREATE TABLE wvp_common_region @@ -469,6 +469,7 @@ CREATE TABLE wvp_common_region id serial primary key, device_id varchar(50) NOT NULL, name varchar(255) NOT NULL, + parent_id int, parent_device_id varchar(50) DEFAULT NULL, create_time varchar(50) NOT NULL, update_time varchar(50) NOT NULL, diff --git a/数据库/2.7.2-重构/初始化-postgresql-kingbase-2.7.2.sql b/数据库/2.7.2-重构/初始化-postgresql-kingbase-2.7.2.sql index eb2bc838..c10fbb8c 100644 --- a/数据库/2.7.2-重构/初始化-postgresql-kingbase-2.7.2.sql +++ b/数据库/2.7.2-重构/初始化-postgresql-kingbase-2.7.2.sql @@ -217,7 +217,7 @@ create table wvp_platform_catalog ( constraint uk_platform_catalog_id_platform_id unique (id, platform_id) ); -create table wvp_platform_gb_channel ( +create table wvp_platform_channel ( id serial primary key , platform_id character varying(50), catalog_id character varying(50), diff --git a/数据库/2.7.2/初始化-mysql-2.7.2.sql b/数据库/2.7.2/初始化-mysql-2.7.2.sql index 98d43404..7f5401ac 100644 --- a/数据库/2.7.2/初始化-mysql-2.7.2.sql +++ b/数据库/2.7.2/初始化-mysql-2.7.2.sql @@ -217,7 +217,7 @@ create table wvp_platform_catalog ( constraint uk_platform_catalog_id_platform_id unique (id, platform_id) ); -create table wvp_platform_gb_channel ( +create table wvp_platform_channel ( id serial primary key , platform_id character varying(50), catalog_id character varying(50), diff --git a/数据库/2.7.2/初始化-postgresql-kingbase-2.7.2.sql b/数据库/2.7.2/初始化-postgresql-kingbase-2.7.2.sql index eb2bc838..c10fbb8c 100644 --- a/数据库/2.7.2/初始化-postgresql-kingbase-2.7.2.sql +++ b/数据库/2.7.2/初始化-postgresql-kingbase-2.7.2.sql @@ -217,7 +217,7 @@ create table wvp_platform_catalog ( constraint uk_platform_catalog_id_platform_id unique (id, platform_id) ); -create table wvp_platform_gb_channel ( +create table wvp_platform_channel ( id serial primary key , platform_id character varying(50), catalog_id character varying(50), diff --git a/数据库/old/2.6.8升级2.6.9.sql b/数据库/old/2.6.8升级2.6.9.sql index 5cc2668e..49436ce5 100644 --- a/数据库/old/2.6.8升级2.6.9.sql +++ b/数据库/old/2.6.8升级2.6.9.sql @@ -448,7 +448,7 @@ rename table log to wvp_log; rename table media_server to wvp_media_server; rename table parent_platform to wvp_platform; rename table platform_catalog to wvp_platform_catalog; -rename table platform_gb_channel to wvp_platform_gb_channel; +rename table platform_gb_channel to wvp_platform_channel; rename table platform_gb_stream to wvp_platform_gb_stream; rename table stream_proxy to wvp_stream_proxy; rename table stream_push to wvp_stream_push;