优化国标树型展示

This commit is contained in:
648540858
2022-07-03 07:40:54 +08:00
parent 0da452293f
commit f5fcc79a2c
29 changed files with 1341 additions and 537 deletions

View File

@@ -0,0 +1,23 @@
package com.genersoft.iot.vmp.gb28181.bean;
/**
* 国标类型编码,国标编码中11-13位为类型编码
* 详见 附 录 D 编码规则 A
* @author lin
*/
public class ChannelIdType {
/**
* 中心信令控制服务器编码
*/
public final static String CENTRAL_SIGNALING_CONTROL_SERVER = "200";
/**
* 业务分组编码
*/
public final static String BUSINESS_GROUP = "215";
/**
* 虚拟组织编码
*/
public final static String VIRTUAL_ORGANIZATION = "216";
}

View File

@@ -138,6 +138,11 @@ public class Device {
*/
private String geoCoordSys;
/**
* 树类型 国标规定了两种树的展现方式 行政区划CivilCode 和业务分组:BusinessGroup
*/
private String treeType;
public String getDeviceId() {
return deviceId;
@@ -338,4 +343,12 @@ public class Device {
public void setGeoCoordSys(String geoCoordSys) {
this.geoCoordSys = geoCoordSys;
}
public String getTreeType() {
return treeType;
}
public void setTreeType(String treeType) {
this.treeType = treeType;
}
}

View File

@@ -194,6 +194,11 @@ public class DeviceChannel {
*/
private int channelType;
/**
* 业务分组
*/
private String businessGroupId;
public int getId() {
return id;
}
@@ -506,4 +511,12 @@ public class DeviceChannel {
public void setChannelType(int channelType) {
this.channelType = channelType;
}
public String getBusinessGroupId() {
return businessGroupId;
}
public void setBusinessGroupId(String businessGroupId) {
this.businessGroupId = businessGroupId;
}
}

View File

@@ -406,7 +406,10 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
if (parentPlatform == null) {
return false;
}
logger.info("[发送 移动位置订阅] {}/{}->{},{}", parentPlatform.getServerGBId(), gpsMsgInfo.getId(), gpsMsgInfo.getLng(), gpsMsgInfo.getLat());
if (logger.isDebugEnabled()) {
logger.debug("[发送 移动位置订阅] {}/{}->{},{}", parentPlatform.getServerGBId(), gpsMsgInfo.getId(), gpsMsgInfo.getLng(), gpsMsgInfo.getLat());
}
try {
String characterSet = parentPlatform.getCharacterSet();
StringBuffer deviceStatusXml = new StringBuffer(600);

View File

@@ -141,6 +141,7 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen
device.setStreamMode("UDP");
device.setCharset("GB2312");
device.setGeoCoordSys("WGS84");
device.setTreeType("CivilCode");
device.setDeviceId(deviceId);
}
device.setIp(received);

View File

@@ -249,23 +249,26 @@ public class XmlUtil {
}else {
deviceChannel.setParentId(parentId);
}
}else {
if (deviceChannel.getChannelId().length() <= 10) { // 此时为行政区划, 上下级行政区划使用DeviceId关联
deviceChannel.setParentId(deviceChannel.getChannelId().substring(0, deviceChannel.getChannelId().length() - 2));
}else if (deviceChannel.getChannelId().length() == 20) {
if (Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 216) { // 虚拟组织
deviceChannel.setParentId(businessGroupID);
}else if (Integer.parseInt(device.getDeviceId().substring(10, 13) )== 118) {//NVR 如果上级设备编号是NVR则直接将NVR的编号设置给通道的上级编号
deviceChannel.setParentId(device.getDeviceId());
}else if (deviceChannel.getCivilCode() != null) {
// 设备, 无parentId的20位是使用CivilCode表示上级的设备
// 注215 业务分组是需要有parentId的
deviceChannel.setParentId(deviceChannel.getCivilCode());
}
}else {
deviceChannel.setParentId(deviceChannel.getDeviceId());
}
}
deviceChannel.setBusinessGroupId(businessGroupID);
// else {
// if (deviceChannel.getChannelId().length() <= 10) { // 此时为行政区划, 上下级行政区划使用DeviceId关联
// deviceChannel.setParentId(deviceChannel.getChannelId().substring(0, deviceChannel.getChannelId().length() - 2));
// }else if (deviceChannel.getChannelId().length() == 20) {
// if (Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 216) { // 虚拟组织
// deviceChannel.setBusinessGroupId(businessGroupID);
// }else if (Integer.parseInt(device.getDeviceId().substring(10, 13) )== 118) {//NVR 如果上级设备编号是NVR则直接将NVR的编号设置给通道的上级编号
// deviceChannel.setParentId(device.getDeviceId());
// }else if (deviceChannel.getCivilCode() != null) {
// // 设备, 无parentId的20位是使用CivilCode表示上级的设备
// // 注215 业务分组是需要有parentId的
// deviceChannel.setParentId(deviceChannel.getCivilCode());
// }
// }else {
// deviceChannel.setParentId(deviceChannel.getDeviceId());
// }
// }
if (XmlUtil.getText(itemDevice, "SafetyWay") == null
|| XmlUtil.getText(itemDevice, "SafetyWay") == "") {

View File

@@ -1,7 +1,9 @@
package com.genersoft.iot.vmp.service;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.SyncStatus;
import com.genersoft.iot.vmp.vmanager.bean.BaseTree;
import java.util.List;
@@ -110,4 +112,21 @@ public interface IDeviceService {
* @param device 设备信息
*/
void updateDevice(Device device);
/**
* 树形查询接口
* @param deviceId 设备ID
* @param parentId 父ID
* @param onlyCatalog 只获取目录
* @return
*/
List<BaseTree<DeviceChannel>> queryVideoDeviceTree(String deviceId, String parentId, boolean onlyCatalog);
/**
* 查询树节点下的通道
* @param deviceId 设备ID
* @param parentId 父ID
* @return
*/
List<DeviceChannel> queryVideoDeviceInTreeNode(String deviceId, String parentId);
}

View File

@@ -1,9 +1,7 @@
package com.genersoft.iot.vmp.service.impl;
import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
@@ -12,20 +10,23 @@ import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask;
import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask;
import com.genersoft.iot.vmp.gb28181.bean.SyncStatus;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.BaseTree;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.support.incrementer.AbstractIdentityColumnMaxValueIncrementer;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
@@ -341,4 +342,180 @@ public class DeviceServiceImpl implements IDeviceService {
}
storage.updateChannels(device.getDeviceId(), deviceChannels);
}
@Override
public List<BaseTree<DeviceChannel>> queryVideoDeviceTree(String deviceId, String parentId, boolean onlyCatalog) {
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (device == null) {
return null;
}
if (parentId == null || parentId.equals(deviceId)) {
// 字根节点开始查询
List<DeviceChannel> rootNodes = getRootNodes(deviceId, "CivilCode".equals(device.getTreeType()), true, !onlyCatalog);
return transportChannelsToTree(rootNodes, "");
}
if ("CivilCode".equals(device.getTreeType())) {
if (parentId.length()%2 != 0) {
return null;
}
// 使用行政区划展示树
if (parentId.length() > 10) {
// TODO 可能是行政区划与业务分组混杂的情形
return null;
}
if (parentId.length() == 10 ) {
if (onlyCatalog) {
return null;
}
// parentId为行业编码 其下不会再有行政区划
List<DeviceChannel> channels = deviceChannelMapper.getChannelsByCivilCode(deviceId, parentId);
List<BaseTree<DeviceChannel>> trees = transportChannelsToTree(channels, parentId);
return trees;
}
// 查询其下的行政区划和摄像机
List<DeviceChannel> channelsForCivilCode = deviceChannelMapper.getChannelsWithCivilCodeAndLength(deviceId, parentId, parentId.length() + 2);
if (!onlyCatalog) {
List<DeviceChannel> channels = deviceChannelMapper.getChannelsByCivilCode(deviceId, parentId);
channelsForCivilCode.addAll(channels);
}
List<BaseTree<DeviceChannel>> trees = transportChannelsToTree(channelsForCivilCode, parentId);
return trees;
}
// 使用业务分组展示树
if ("BusinessGroup".equals(device.getTreeType())) {
if (parentId.length() < 14 ) {
return null;
}
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null);
List<BaseTree<DeviceChannel>> trees = transportChannelsToTree(deviceChannels, parentId);
return trees;
}
return null;
}
@Override
public List<DeviceChannel> queryVideoDeviceInTreeNode(String deviceId, String parentId) {
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (device == null) {
return null;
}
if (parentId == null || parentId.equals(deviceId)) {
// 字根节点开始查询
List<DeviceChannel> rootNodes = getRootNodes(deviceId, "CivilCode".equals(device.getTreeType()), false, true);
return rootNodes;
}
if ("CivilCode".equals(device.getTreeType())) {
if (parentId.length()%2 != 0) {
return null;
}
// 使用行政区划展示树
if (parentId.length() > 10) {
// TODO 可能是行政区划与业务分组混杂的情形
return null;
}
if (parentId.length() == 10 ) {
// parentId为行业编码 其下不会再有行政区划
List<DeviceChannel> channels = deviceChannelMapper.getChannelsByCivilCode(deviceId, parentId);
return channels;
}
// 查询其下的行政区划和摄像机
List<DeviceChannel> channels = deviceChannelMapper.getChannelsByCivilCode(deviceId, parentId);
return channels;
}
// 使用业务分组展示树
if ("BusinessGroup".equals(device.getTreeType())) {
if (parentId.length() < 14 ) {
return null;
}
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, parentId, null, null, null);
return deviceChannels;
}
return null;
}
private List<BaseTree<DeviceChannel>> transportChannelsToTree(List<DeviceChannel> channels, String parentId) {
if (channels == null) {
return null;
}
List<BaseTree<DeviceChannel>> treeNotes = new ArrayList<>();
if (channels.size() == 0) {
return treeNotes;
}
for (DeviceChannel channel : channels) {
BaseTree<DeviceChannel> node = new BaseTree<>();
node.setId(channel.getChannelId());
node.setDeviceId(channel.getDeviceId());
node.setName(channel.getName());
node.setPid(parentId);
node.setBasicData(channel);
node.setParent(false);
if (channel.getChannelId().length() > 8) {
String gbCodeType = channel.getChannelId().substring(10, 13);
node.setParent(gbCodeType.equals(ChannelIdType.BUSINESS_GROUP) || gbCodeType.equals(ChannelIdType.VIRTUAL_ORGANIZATION) );
}else {
node.setParent(true);
}
treeNotes.add(node);
}
Collections.sort(treeNotes);
return treeNotes;
}
private List<DeviceChannel> getRootNodes(String deviceId, boolean isCivilCode, boolean haveCatalog, boolean haveChannel) {
if (!haveCatalog && !haveChannel) {
return null;
}
List<DeviceChannel> result = new ArrayList<>();
if (isCivilCode) {
// 使用行政区划
Integer length= deviceChannelMapper.getChannelMinLength(deviceId);
if (length == null) {
return null;
}
if (length <= 10) {
if (haveCatalog) {
List<DeviceChannel> provinceNode = deviceChannelMapper.getChannelsWithCivilCodeAndLength(deviceId, null, length);
if (provinceNode != null && provinceNode.size() > 0) {
result.addAll(provinceNode);
}
}
if (haveChannel) {
// 查询那些civilCode不在通道中的不规范通道放置在根目录
List<DeviceChannel> nonstandardNode = deviceChannelMapper.getChannelWithoutCiviCode(deviceId);
if (nonstandardNode != null && nonstandardNode.size() > 0) {
result.addAll(nonstandardNode);
}
}
}else {
if (haveChannel) {
List<DeviceChannel> deviceChannels = deviceChannelMapper.queryChannels(deviceId, null, null, null, null);
if (deviceChannels != null && deviceChannels.size() > 0) {
result.addAll(deviceChannels);
}
}
}
}else {
// 使用业务分组+虚拟组织
// 只获取业务分组
List<DeviceChannel> deviceChannels = deviceChannelMapper.getBusinessGroups(deviceId, ChannelIdType.BUSINESS_GROUP);
if (deviceChannels != null && deviceChannels.size() > 0) {
result.addAll(deviceChannels);
}
}
return result;
}
}

View File

@@ -123,7 +123,7 @@ public class PlayServiceImpl implements IPlayService {
result.onCompletion(()->{
// 点播结束时调用截图接口
// TODO 应该在上流时调用更好,结束也可能是错误结束
String path = "static/static/snap/";
String path = "snap";
String fileName = deviceId + "_" + channelId + ".jpg";
ResponseEntity responseEntity = (ResponseEntity)result.getResult();
if (responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) {
@@ -178,7 +178,6 @@ public class PlayServiceImpl implements IPlayService {
}
}
if (streamInfo == null) {
String streamId = null;

View File

@@ -1,5 +1,6 @@
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.DeviceChannelInPlatform;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
@@ -17,10 +18,12 @@ public interface DeviceChannelMapper {
@Insert("INSERT INTO device_channel (channelId, deviceId, name, manufacture, model, owner, civilCode, block, " +
"address, parental, parentId, safetyWay, registerWay, certNum, certifiable, errCode, secrecy, " +
"ipAddress, port, password, PTZType, status, streamId, longitude, latitude, longitudeGcj02, latitudeGcj02, longitudeWgs84, latitudeWgs84, createTime, updateTime) " +
"ipAddress, port, password, PTZType, status, streamId, longitude, latitude, longitudeGcj02, latitudeGcj02, " +
"longitudeWgs84, latitudeWgs84, createTime, updateTime, businessGroupId) " +
"VALUES ('${channelId}', '${deviceId}', '${name}', '${manufacture}', '${model}', '${owner}', '${civilCode}', '${block}'," +
"'${address}', ${parental}, '${parentId}', ${safetyWay}, ${registerWay}, '${certNum}', ${certifiable}, ${errCode}, '${secrecy}', " +
"'${ipAddress}', ${port}, '${password}', ${PTZType}, ${status}, '${streamId}', ${longitude}, ${latitude}, ${longitudeGcj02}, ${latitudeGcj02}, ${longitudeWgs84}, ${latitudeWgs84},'${createTime}', '${updateTime}')")
"'${ipAddress}', ${port}, '${password}', ${PTZType}, ${status}, '${streamId}', ${longitude}, ${latitude}, ${longitudeGcj02}, " +
"${latitudeGcj02}, ${longitudeWgs84}, ${latitudeWgs84},'${createTime}', '${updateTime}', '${businessGroupId}')")
int add(DeviceChannel channel);
@Update(value = {" <script>" +
@@ -54,6 +57,7 @@ public interface DeviceChannelMapper {
"<if test='latitudeGcj02 != null'>, latitudeGcj02=${latitudeGcj02}</if>" +
"<if test='longitudeWgs84 != null'>, longitudeWgs84=${longitudeWgs84}</if>" +
"<if test='latitudeWgs84 != null'>, latitudeWgs84=${latitudeWgs84}</if>" +
"<if test='businessGroupId != null'>, businessGroupId=#{businessGroupId}</if>" +
"WHERE deviceId='${deviceId}' AND channelId='${channelId}'"+
" </script>"})
int update(DeviceChannel channel);
@@ -143,7 +147,7 @@ public interface DeviceChannelMapper {
"(channelId, deviceId, name, manufacture, model, owner, civilCode, block, subCount, " +
" address, parental, parentId, safetyWay, registerWay, certNum, certifiable, errCode, secrecy, " +
" ipAddress, port, password, PTZType, status, streamId, longitude, latitude, longitudeGcj02, latitudeGcj02, " +
" longitudeWgs84, latitudeWgs84, createTime, updateTime) " +
" longitudeWgs84, latitudeWgs84, createTime, updateTime, businessGroupId) " +
"values " +
"<foreach collection='addChannels' index='index' item='item' separator=','> " +
"('${item.channelId}', '${item.deviceId}', '${item.name}', '${item.manufacture}', '${item.model}', " +
@@ -152,7 +156,7 @@ public interface DeviceChannelMapper {
"'${item.certNum}', ${item.certifiable}, ${item.errCode}, '${item.secrecy}', " +
"'${item.ipAddress}', ${item.port}, '${item.password}', ${item.PTZType}, ${item.status}, " +
"'${item.streamId}', ${item.longitude}, ${item.latitude},${item.longitudeGcj02}, " +
"${item.latitudeGcj02},${item.longitudeWgs84}, ${item.latitudeWgs84},'${item.createTime}', '${item.updateTime}')" +
"${item.latitudeGcj02},${item.longitudeWgs84}, ${item.latitudeWgs84},'${item.createTime}', '${item.updateTime}, '${item.businessGroupId}')" +
"</foreach> " +
"ON DUPLICATE KEY UPDATE " +
"updateTime=VALUES(updateTime), " +
@@ -183,7 +187,8 @@ public interface DeviceChannelMapper {
"longitudeGcj02=VALUES(longitudeGcj02), " +
"latitudeGcj02=VALUES(latitudeGcj02), " +
"longitudeWgs84=VALUES(longitudeWgs84), " +
"latitudeWgs84=VALUES(latitudeWgs84) " +
"latitudeWgs84=VALUES(latitudeWgs84), " +
"businessGroupId=VALUES(businessGroupId) " +
"</script>")
int batchAdd(List<DeviceChannel> addChannels);
@@ -221,6 +226,7 @@ public interface DeviceChannelMapper {
"<if test='item.latitudeGcj02 != null'>, latitudeGcj02=${item.latitudeGcj02}</if>" +
"<if test='item.longitudeWgs84 != null'>, longitudeWgs84=${item.longitudeWgs84}</if>" +
"<if test='item.latitudeWgs84 != null'>, latitudeWgs84=${item.latitudeWgs84}</if>" +
"<if test='item.businessGroupId != null'>, businessGroupId=${item.businessGroupId}</if>" +
"WHERE deviceId='${item.deviceId}' AND channelId='${item.channelId}'"+
"</foreach>" +
"</script>"})
@@ -277,4 +283,33 @@ public interface DeviceChannelMapper {
@Select("select * from device_channel where longitude*latitude > 0 and deviceId = #{deviceId}")
List<DeviceChannel> getAllChannelWithCoordinate(String deviceId);
@Select(value = {" <script>" +
"select * " +
"from device_channel " +
"where deviceId=#{deviceId}" +
" <if test='parentId != null' > and left(channelId, ${parentId.length()}) = #{parentId}</if>" +
" <if test='length != null' > and length(channelId)=${length}</if>" +
" </script>"})
List<DeviceChannel> getChannelsWithCivilCodeAndLength(String deviceId, String parentId, Integer length);
@Select(value = {" <script>" +
"select * " +
"from device_channel " +
"where deviceId=#{deviceId} and length(channelId)>14 and civilCode=#{parentId}" +
" </script>"})
List<DeviceChannel> getChannelsByCivilCode(String deviceId, String parentId);
@Select("select min(length(channelId)) as minLength " +
"from device_channel " +
"where deviceId=#{deviceId}")
Integer getChannelMinLength(String deviceId);
@Select("select * from device_channel where deviceId=#{deviceId} and civilCode not in " +
"(select civilCode from device_channel where deviceId=#{deviceId} group by civilCode)")
List<DeviceChannel> getChannelWithoutCiviCode(String deviceId);
@Select("select * from device_channel where deviceId=#{deviceId} and SUBSTRING(channelId, 11, 3)=#{typeCode}")
List<DeviceChannel> getBusinessGroups(String deviceId, String typeCode);
}

View File

@@ -39,6 +39,7 @@ public interface DeviceMapper {
"subscribeCycleForAlarm," +
"ssrcCheck," +
"geoCoordSys," +
"treeType," +
"online" +
") VALUES (" +
"#{deviceId}," +
@@ -63,6 +64,7 @@ public interface DeviceMapper {
"#{subscribeCycleForAlarm}," +
"#{ssrcCheck}," +
"#{geoCoordSys}," +
"#{treeType}," +
"#{online}" +
")")
int add(Device device);
@@ -90,6 +92,7 @@ public interface DeviceMapper {
"<if test=\"subscribeCycleForAlarm != null\">, subscribeCycleForAlarm=${subscribeCycleForAlarm}</if>" +
"<if test=\"ssrcCheck != null\">, ssrcCheck=${ssrcCheck}</if>" +
"<if test=\"geoCoordSys != null\">, geoCoordSys=#{geoCoordSys}</if>" +
"<if test=\"treeType != null\">, treeType=#{treeType}</if>" +
"WHERE deviceId='${deviceId}'"+
" </script>"})
int update(Device device);

View File

@@ -0,0 +1,87 @@
package com.genersoft.iot.vmp.vmanager.bean;
import org.jetbrains.annotations.NotNull;
import java.text.Collator;
import java.util.Comparator;
/**
* @author lin
*/
public class BaseTree<T> implements Comparable<BaseTree>{
private String id;
private String deviceId;
private String pid;
private String name;
private boolean parent;
private T basicData;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public T getBasicData() {
return basicData;
}
public void setBasicData(T basicData) {
this.basicData = basicData;
}
public boolean isParent() {
return parent;
}
public void setParent(boolean parent) {
this.parent = parent;
}
@Override
public int compareTo(@NotNull BaseTree treeNode) {
if (this.parent || treeNode.isParent()) {
if (!this.parent && !treeNode.isParent()) {
Comparator cmp = Collator.getInstance(java.util.Locale.CHINA);
return cmp.compare(treeNode.getName(), this.getName());
}else {
if (this.isParent()) {
return 1;
}else {
return -1;
}
}
}else{
Comparator cmp = Collator.getInstance(java.util.Locale.CHINA);
return cmp.compare(treeNode.getName(), this.getName());
}
}
}

View File

@@ -15,6 +15,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.BaseTree;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
@@ -479,4 +480,99 @@ public class DeviceQuery {
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
}
/**
* 查询国标树
* @param deviceId 设备ID
* @param parentId 父ID
* @param page 当前页
* @param count 每页条数
* @return 国标设备
*/
@ApiOperation("查询国标树")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "设备ID", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "parentId", value = "父ID", required = false, dataTypeClass = String.class),
@ApiImplicitParam(name = "onlyCatalog", value = "只获取目录", required = false, dataTypeClass = Boolean.class),
@ApiImplicitParam(name="page", value = "当前页", required = true, dataTypeClass = Integer.class),
@ApiImplicitParam(name="count", value = "每页条数", required = true, dataTypeClass = Integer.class),
})
@GetMapping("/tree/{deviceId}")
public ResponseEntity<PageInfo> getTree(@PathVariable String deviceId, @RequestParam(required = false) String parentId, @RequestParam(required = false) Boolean onlyCatalog, int page, int count){
if (page <= 0) {
page = 1;
}
if (onlyCatalog == null) {
onlyCatalog = false;
}
List<BaseTree<DeviceChannel>> treeData = deviceService.queryVideoDeviceTree(deviceId, parentId, onlyCatalog);
if (treeData == null || (page - 1) * count > treeData.size()) {
PageInfo<BaseTree<DeviceChannel>> pageInfo = new PageInfo<>();
pageInfo.setPageNum(page);
pageInfo.setTotal(treeData == null? 0 : treeData.size());
pageInfo.setSize(0);
pageInfo.setList(new ArrayList<>());
return new ResponseEntity<>(pageInfo,HttpStatus.OK);
}
int toIndex = Math.min(page * count, treeData.size());
// 处理分页
List<BaseTree<DeviceChannel>> trees = treeData.subList((page - 1) * count, toIndex);
PageInfo<BaseTree<DeviceChannel>> pageInfo = new PageInfo<>();
pageInfo.setPageNum(page);
pageInfo.setTotal(treeData.size());
pageInfo.setSize(trees.size());
pageInfo.setList(trees);
return new ResponseEntity<>(pageInfo,HttpStatus.OK);
}
/**
* 查询国标树下的通道
* @param deviceId 设备ID
* @param parentId 父ID
* @param page 当前页
* @param count 每页条数
* @return 国标设备
*/
@ApiOperation("查询国标树下的通道")
@ApiImplicitParams({
@ApiImplicitParam(name = "deviceId", value = "设备ID", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "parentId", value = "父ID", required = false, dataTypeClass = String.class),
@ApiImplicitParam(name="page", value = "当前页", required = true, dataTypeClass = Integer.class),
@ApiImplicitParam(name="count", value = "每页条数", required = true, dataTypeClass = Integer.class),
})
@GetMapping("/tree/channel/{deviceId}")
public ResponseEntity<PageInfo> getChannelInTreeNode(@PathVariable String deviceId, @RequestParam(required = false) String parentId, int page, int count){
if (page <= 0) {
page = 1;
}
List<DeviceChannel> treeData = deviceService.queryVideoDeviceInTreeNode(deviceId, parentId);
if (treeData == null || (page - 1) * count > treeData.size()) {
PageInfo<BaseTree<DeviceChannel>> pageInfo = new PageInfo<>();
pageInfo.setPageNum(page);
pageInfo.setTotal(treeData == null? 0 : treeData.size());
pageInfo.setSize(0);
pageInfo.setList(new ArrayList<>());
return new ResponseEntity<>(pageInfo,HttpStatus.OK);
}
int toIndex = Math.min(page * count, treeData.size());
// 处理分页
List<DeviceChannel> trees = treeData.subList((page - 1) * count, toIndex);
PageInfo<DeviceChannel> pageInfo = new PageInfo<>();
pageInfo.setPageNum(page);
pageInfo.setTotal(treeData.size());
pageInfo.setSize(trees.size());
pageInfo.setList(trees);
return new ResponseEntity<>(pageInfo,HttpStatus.OK);
}
}