diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java index 177401c9..bfce66f8 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java @@ -188,6 +188,9 @@ public class DeviceChannel extends CommonGBChannel { "用于选择码流时组成码流标识。默认为null,不设置。可选值: stream/streamnumber/streamprofile/streamMode") private String streamIdentification; + @Schema(description = "通道类型, 默认0, 0: 普通通道,1 行政区划 2 业务分组/虚拟组织") + private int channelType; + public void setPtzType(int ptzType) { this.ptzType = ptzType; switch (ptzType) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Region.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Region.java index cb70d360..bb4e1fdd 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Region.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Region.java @@ -1,7 +1,6 @@ package com.genersoft.iot.vmp.gb28181.bean; import com.genersoft.iot.vmp.common.CivilCodePo; -import com.genersoft.iot.vmp.jt1078.proc.request.Re; import com.genersoft.iot.vmp.utils.CivilCodeUtil; import com.genersoft.iot.vmp.utils.DateUtil; import io.swagger.v3.oas.annotations.media.Schema; @@ -32,6 +31,12 @@ public class Region implements Comparable{ @Schema(description = "区域名称") private String name; + /** + * 父区域国标ID + */ + @Schema(description = "父区域ID") + private Integer parentId; + /** * 父区域国标ID */ diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RegionTree.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RegionTree.java index 2adc31a0..8e6929a1 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RegionTree.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RegionTree.java @@ -8,61 +8,11 @@ import lombok.Data; */ @Data @Schema(description = "区域树") -public class RegionTree { - - /** - * 数据库Id - */ - @Schema(description = "数据库Id") - private int dbId; - - /** - * 区域国标编号 - */ - @Schema(description = "区域国标编号") - private String id; - - /** - * 区域名称 - */ - @Schema(description = "区域名称") - private String label; - - /** - * 父区域国标ID - */ - @Schema(description = "父区域国标ID") - private String parentDeviceId; +public class RegionTree extends Region { @Schema(description = "是否有子节点") private boolean isLeaf; @Schema(description = "类型, 行政区划:0 摄像头: 1") private int type; - - - - public static RegionTree getInstance(Region region) { - RegionTree regionTree = new RegionTree(); - regionTree.setId(region.getDeviceId()); - regionTree.setLabel(region.getName()); - regionTree.setParentDeviceId(region.getParentDeviceId()); - regionTree.setType(0); - if (region.getDeviceId().length() < 8) { - regionTree.setLeaf(false); - }else { - regionTree.setLeaf(true); - } - return regionTree; - } - - public static RegionTree getInstance(CommonGBChannel channel) { - RegionTree regionTree = new RegionTree(); - 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/RegionController.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/RegionController.java index 77c67d00..7da24489 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/RegionController.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/RegionController.java @@ -57,11 +57,8 @@ public class RegionController { @GetMapping("/tree/list") public List queryForTree( @RequestParam(required = false) String query, - @RequestParam(required = false) String parent + @RequestParam(required = false) Integer parent ){ - if (ObjectUtils.isEmpty(parent)) { - parent = null; - } if (ObjectUtils.isEmpty(query)) { query = null; } @@ -77,34 +74,17 @@ public class RegionController { } @Operation(summary = "删除区域") - @Parameter(name = "deviceId", description = "区域编码", required = true) + @Parameter(name = "id", description = "区域ID", required = true) @ResponseBody @DeleteMapping("/delete") - public void delete(String deviceId){ - Assert.hasLength(deviceId, "区域编码(deviceId)不需要存在"); - boolean result = regionService.deleteByDeviceId(deviceId); + public void delete(Integer id){ + Assert.notNull(id, "区域ID需要存在"); + boolean result = regionService.deleteByDeviceId(id); if (!result) { throw new ControllerException(ErrorCode.ERROR100.getCode(), "移除失败"); } } - @Operation(summary = "分页区域子节点") - @Parameter(name = "regionParentId", description = "行政区划父节点编号", required = true) - @Parameter(name = "page", description = "当前页", required = true) - @Parameter(name = "count", description = "每页查询数量", required = true) - @ResponseBody - @GetMapping("/child/list") - public PageInfo queryChildRegionList( - @RequestParam(required = true) String regionParentId, - @RequestParam(required = true) int page, - @RequestParam(required = true) int count - ){ - if (ObjectUtils.isEmpty(regionParentId.trim())) { - regionParentId = null; - } - return regionService.queryChildRegionList(regionParentId, page, count); - } - @Operation(summary = "根据区域Id查询区域") @Parameter(name = "regionDeviceId", description = "行政区划节点编号", required = true) @ResponseBody 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 0375fa24..6c994d17 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 @@ -262,17 +262,15 @@ public interface CommonGBChannelMapper { @Select("") - List queryForRegionTreeByCivilCode(@Param("query") String query, @Param("parent") String parent); + List queryForRegionTreeByCivilCode(@Param("query") String query, @Param("parentDeviceId") String parentDeviceId); @Update(value = {" ") diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java index 6838d9c5..5659828c 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java @@ -20,12 +20,12 @@ public interface DeviceChannelMapper { "address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, end_time, secrecy, " + "ip_address, port, password, status, longitude, latitude, ptz_type, position_type, room_type, use_type, " + "supply_light_type, direction_type, resolution, business_group_id, download_speed, svc_space_support_mod, " + - "svc_time_support_mode, create_time, update_time, sub_count,stream_id, has_audio, gps_time, stream_identification) " + + "svc_time_support_mode, create_time, update_time, sub_count,stream_id, has_audio, gps_time, stream_identification, channel_type) " + "VALUES (#{deviceId}, #{deviceDbId}, #{name}, #{manufacturer}, #{model}, #{owner}, #{civilCode}, #{block}," + "#{address}, #{parental}, #{parentId}, #{safetyWay}, #{registerWay}, #{certNum}, #{certifiable}, #{errCode}, #{endTime}, #{secrecy}, " + "#{ipAddress}, #{port}, #{password}, #{status}, #{longitude}, #{latitude}, #{ptzType}, #{positionType}, #{roomType}, #{useType}, " + "#{supplyLightType}, #{directionType}, #{resolution}, #{businessGroupId}, #{downloadSpeed}, #{svcSpaceSupportMod}," + - " #{svcTimeSupportMode}, #{createTime}, #{updateTime}, #{subCount}, #{streamId}, #{hasAudio}, #{gpsTime}, #{streamIdentification})") + " #{svcTimeSupportMode}, #{createTime}, #{updateTime}, #{subCount}, #{streamId}, #{hasAudio}, #{gpsTime}, #{streamIdentification}, #{channelType})") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") int add(DeviceChannel channel); @@ -72,6 +72,7 @@ public interface DeviceChannelMapper { ", has_audio=#{hasAudio}" + ", gps_time=#{gpsTime}" + ", stream_identification=#{streamIdentification}" + + ", channel_type=#{channelType}" + " WHERE id=#{id}" + " "}) int update(DeviceChannel channel); @@ -127,6 +128,7 @@ public interface DeviceChannelMapper { " dc.has_audio,\n" + " dc.gps_time,\n" + " dc.stream_identification,\n" + + " dc.channel_type,\n" + " coalesce(dc.gb_device_id, dc.device_id) as device_id,\n" + " coalesce(dc.gb_name, dc.name) as name,\n" + " coalesce(dc.gb_manufacturer, dc.manufacturer) as manufacturer,\n" + @@ -192,6 +194,7 @@ public interface DeviceChannelMapper { " has_audio,\n" + " gps_time,\n" + " stream_identification,\n" + + " channel_type,\n" + " coalesce(gb_device_id, device_id) as device_id,\n" + " coalesce(gb_name, name) as name,\n" + " coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" + @@ -264,6 +267,7 @@ public interface DeviceChannelMapper { " dc.has_audio,\n" + " dc.gps_time,\n" + " dc.stream_identification,\n" + + " dc.channel_type,\n" + " coalesce(dc.gb_device_id, dc.device_id) as device_id,\n" + " coalesce(dc.gb_name, dc.name) as name,\n" + " coalesce(dc.gb_manufacturer, dc.manufacturer) as manufacturer,\n" + @@ -354,6 +358,7 @@ public interface DeviceChannelMapper { " has_audio,\n" + " gps_time,\n" + " stream_identification,\n" + + " channel_type,\n" + " coalesce(gb_device_id, device_id) as device_id,\n" + " coalesce(gb_name, name) as name,\n" + " coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" + @@ -400,14 +405,14 @@ public interface DeviceChannelMapper { "address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, end_time, secrecy, " + "ip_address, port, password, status, longitude, latitude, ptz_type, position_type, room_type, use_type, " + "supply_light_type, direction_type, resolution, business_group_id, download_speed, svc_space_support_mod, " + - "svc_time_support_mode, create_time, update_time, sub_count, stream_id, has_audio, gps_time, stream_identification) " + + "svc_time_support_mode, create_time, update_time, sub_count, stream_id, has_audio, gps_time, stream_identification, channel_type) " + "values " + " " + "(#{item.deviceId}, #{item.deviceDbId}, #{item.name}, #{item.manufacturer}, #{item.model}, #{item.owner}, #{item.civilCode}, #{item.block}, " + "#{item.address}, #{item.parental}, #{item.parentId}, #{item.safetyWay}, #{item.registerWay}, #{item.certNum}, #{item.certifiable}, #{item.errCode}, #{item.endTime}, #{item.secrecy}, " + "#{item.ipAddress}, #{item.port}, #{item.password}, #{item.status}, #{item.longitude}, #{item.latitude}, #{item.ptzType}, #{item.positionType}, #{item.roomType}, #{item.useType}, " + "#{item.supplyLightType}, #{item.directionType}, #{item.resolution}, #{item.businessGroupId}, #{item.downloadSpeed}, #{item.svcSpaceSupportMod}," + - " #{item.svcTimeSupportMode}, #{item.createTime}, #{item.updateTime}, #{item.subCount}, #{item.streamId}, #{item.hasAudio}, #{item.gpsTime}, #{item.streamIdentification}) " + + " #{item.svcTimeSupportMode}, #{item.createTime}, #{item.updateTime}, #{item.subCount}, #{item.streamId}, #{item.hasAudio}, #{item.gpsTime}, #{item.streamIdentification}, #{item.channelType}) " + " " + "") int batchAdd(@Param("addChannels") List addChannels); @@ -461,6 +466,7 @@ public interface DeviceChannelMapper { ", has_audio=#{item.hasAudio}" + ", gps_time=#{item.gpsTime}" + ", stream_identification=#{item.streamIdentification}" + + ", channel_type=#{item.channelType}" + " WHERE id=#{item.id}" + "" + ""}) @@ -494,6 +500,7 @@ public interface DeviceChannelMapper { " has_audio,\n" + " gps_time,\n" + " stream_identification,\n" + + " channel_type,\n" + " coalesce(gb_device_id, device_id) as device_id,\n" + " coalesce(gb_name, name) as name,\n" + " coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" + @@ -574,6 +581,7 @@ public interface DeviceChannelMapper { " has_audio,\n" + " gps_time,\n" + " stream_identification,\n" + + " channel_type,\n" + " coalesce(gb_device_id, device_id) as device_id,\n" + " coalesce(gb_name, name) as name,\n" + " coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" + @@ -647,6 +655,7 @@ public interface DeviceChannelMapper { " has_audio,\n" + " gps_time,\n" + " stream_identification,\n" + + " channel_type,\n" + " coalesce(gb_device_id, device_id) as device_id,\n" + " coalesce(gb_name, name) as name,\n" + " coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" + @@ -697,6 +706,7 @@ public interface DeviceChannelMapper { " has_audio,\n" + " gps_time,\n" + " stream_identification,\n" + + " channel_type,\n" + " coalesce(gb_device_id, device_id) as device_id,\n" + " coalesce(gb_name, name) as name,\n" + " coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" + 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 f95d65f4..e1eb212e 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 @@ -58,6 +58,7 @@ public interface GroupMapper { " (#{item.deviceId}, #{item.name}, #{item.parentDeviceId}, #{item.parentId}, #{item.businessGroup},#{item.createTime},#{item.updateTime})" + " " + " ") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") int batchAdd(List groupList); @Select(" ") Set queryByChannelList(List channelList); + + @Update(" ") + void updateParentId(List groupListForAdd); + + @Update(" ") + void updateParentIdWithBusinessGroup(List groupListForAdd); + } 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 ba299ac4..50339ec4 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 @@ -43,7 +43,7 @@ public interface PlatformChannelMapper { "DELETE from wvp_platform_channel WHERE device_channel_id in " + "( select temp.device_channel_id from " + "(select pgc.device_channel_id from wvp_platform_channel pgc " + - "left join wvp_device_channel dc on dc.id = pgc.device_channel_id where dc.device_id =#{deviceId} " + + "left join wvp_device_channel dc on dc.id = pgc.device_channel_id where dc.channel_type = 0 and dc.device_id =#{deviceId} " + ") temp)" + "") int delChannelForDeviceId(String deviceId); @@ -53,25 +53,25 @@ public interface PlatformChannelMapper { "") int cleanChannelForGB(String 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}") + @Select("SELECT dc.* from wvp_platform_channel pgc left join wvp_device_channel dc on dc.id = pgc.device_channel_id WHERE dc.channel_type = 0 and 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_channel pgc on dc.id = pgc.device_channel_id " + - " where pgc.platform_id=#{platformId} and pgc.catalog_id=#{catalogId}") + " where dc.channel_type = 0 and 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_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}") + "where dc.channel_type = 0 and dc.channel_id = #{channelId} and pgc.platform_id=#{platformId}") List queryVideoDeviceByPlatformIdAndChannelId(@Param("platformId") String platformId, @Param("channelId") String channelId); @Delete(" ") List queryPlatFormListForGBWithGBId(@Param("channelId") String channelId, @Param("platforms") List platforms); @@ -115,14 +115,12 @@ public interface PlatformChannelMapper { "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}") + "where dc.channel_type = 0 and 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_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.channel_type = 0 and dc.device_id=#{channelId}") List queryParentPlatformByChannelId(@Param("channelId") String channelId); - - @Select(""}) List query(@Param("query") String query, @Param("parentId") String parentId); - @Select("SELECT * from wvp_common_region WHERE parent_device_id = #{parentId} ORDER BY id ") - List getChildren(@Param("parentId") String parentId); + @Select("SELECT * from wvp_common_region WHERE parent_id = #{parentId} ORDER BY id ") + List getChildren(@Param("parentId") Integer parentId); @Select("SELECT * from wvp_common_region WHERE id = #{id} ") Region queryOne(@Param("id") int id); @@ -57,33 +57,29 @@ public interface RegionMapper { " device_id," + " name, " + " parent_device_id," + + " parent_id," + " create_time," + " update_time) " + " VALUES " + " " + - " (#{item.deviceId}, #{item.name}, #{item.parentDeviceId},#{item.createTime},#{item.updateTime})" + + " (#{item.deviceId}, #{item.name}, #{item.parentDeviceId},#{item.parentId},#{item.createTime},#{item.updateTime})" + " " + " ") + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") int batchAdd(List regionList); @Select(" ") - List queryForTree(@Param("query") String query, @Param("parentId") String parentId); - - @Select("SELECT * from wvp_common_region WHERE device_id = #{deviceId} ") - Region queryOneByDeviceId(@Param("deviceId") String deviceId); + List queryForTree(@Param("query") String query, @Param("parentId") Integer parentId); @Delete("") - List queryInRegionList(List regionList); - - @Select(" ") - Set queryInChannelList(List channelList); - - - @Select(" ") - Set queryParentInChannelList(Set regionChannelList); + List queryInRegionListByDeviceId(List regionList); @Select("