优化国标树型展示
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user