添加优化后的地图页面,完全一处百度地图相关的api

This commit is contained in:
648540858
2022-04-22 16:21:05 +08:00
parent 190fc62b72
commit 1e2d207aea
40 changed files with 745 additions and 1054 deletions

View File

@@ -4,7 +4,7 @@ public class DeviceChannel {
/**
* 数据库自ID
* 数据库自ID
*/
private int id;

View File

@@ -5,7 +5,6 @@ import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
import com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTree;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.github.pagehelper.PageInfo;
@@ -94,12 +93,6 @@ public interface IVideoManagerStorage {
public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit);
/**
* 获取某个设备的通道树
* @param deviceId 设备ID
* @return
*/
List<DeviceChannelTree> tree(String deviceId);
/**
* 获取某个设备的通道列表
@@ -285,7 +278,7 @@ public interface IVideoManagerStorage {
* @param startTime
* @param endTime
*/
public List<MobilePosition> queryMobilePositions(String deviceId, String startTime, String endTime);
public List<MobilePosition> queryMobilePositions(String deviceId, String channelId, String startTime, String endTime);
/**
* 查询最新移动位置

View File

@@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannelInPlatform;
import com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTree;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
@@ -236,23 +235,6 @@ public interface DeviceChannelMapper {
@Select("SELECT * FROM device_channel WHERE deviceId=#{deviceId} AND status=1")
List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
@Select(" SELECT\n" +
" id,\n" +
" channelId,\n" +
" deviceId,\n" +
" parentId,\n" +
" status,\n" +
" name as title,\n" +
" channelId as \"value\",\n" +
" channelId as \"key\",\n" +
" longitude,\n" +
" latitude,\n" +
" PTZType,\n" +
" subCount\n" +
" from device_channel\n" +
" where deviceId = #{deviceId}")
List<DeviceChannelTree> tree(String deviceId);
@Delete(value = {" <script>" +
"DELETE " +
"from " +

View File

@@ -16,12 +16,12 @@ public interface DeviceMobilePositionMapper {
@Select(value = {" <script>" +
"SELECT * FROM device_mobile_position" +
" WHERE deviceId = #{deviceId} " +
" WHERE deviceId = #{deviceId} and channelId = #{channelId} " +
"<if test=\"startTime != null\"> AND time&gt;=#{startTime}</if>" +
"<if test=\"endTime != null\"> AND time&lt;=#{endTime}</if>" +
" ORDER BY time ASC" +
" </script>"})
List<MobilePosition> queryPositionByDeviceIdAndTime(String deviceId, String startTime, String endTime);
List<MobilePosition> queryPositionByDeviceIdAndTime(String deviceId, String channelId, String startTime, String endTime);
@Select("SELECT * FROM device_mobile_position WHERE deviceId = #{deviceId}" +
" ORDER BY time DESC LIMIT 1")

View File

@@ -13,8 +13,6 @@ import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.storager.dao.*;
import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
import com.genersoft.iot.vmp.utils.node.ForestNodeMerger;
import com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTree;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@@ -354,10 +352,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, null, query, hasSubChannel, online, start, limit);
}
@Override
public List<DeviceChannelTree> tree(String deviceId) {
return ForestNodeMerger.merge(deviceChannelMapper.tree(deviceId));
}
@Override
public List<DeviceChannel> queryChannelsByDeviceId(String deviceId) {
@@ -504,8 +498,8 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
* @param endTime
*/
@Override
public synchronized List<MobilePosition> queryMobilePositions(String deviceId, String startTime, String endTime) {
return deviceMobilePositionMapper.queryPositionByDeviceIdAndTime(deviceId, startTime, endTime);
public synchronized List<MobilePosition> queryMobilePositions(String deviceId, String channelId, String startTime, String endTime) {
return deviceMobilePositionMapper.queryPositionByDeviceIdAndTime(deviceId, channelId, startTime, endTime);
}
@Override

View File

@@ -1,74 +0,0 @@
package com.genersoft.iot.vmp.utils.node;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.util.ArrayList;
import java.util.List;
/**
* 节点基类
*
*/
public class BaseNode<T> implements INode<T> {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
protected String channelId;
/**
* 父节点ID
*/
protected String parentId;
/**
* 子孙节点
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
protected List<T> children = new ArrayList<T>();
/**
* 是否有子孙节点
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Boolean hasChildren;
/**
* 是否有子孙节点
*
* @return Boolean
*/
@Override
public Boolean getHasChildren() {
if (children.size() > 0) {
return true;
} else {
return this.hasChildren;
}
}
@Override
public String getChannelId() {
return channelId;
}
@Override
public String getParentId() {
return parentId;
}
@Override
public List<T> getChildren() {
return children;
}
public void setChildren(List<T> children) {
this.children = children;
}
public void setHasChildren(Boolean hasChildren) {
this.hasChildren = hasChildren;
}
}

View File

@@ -1,31 +0,0 @@
package com.genersoft.iot.vmp.utils.node;
/**
* 森林节点类
*
*/
public class ForestNode extends BaseNode<ForestNode> {
private static final long serialVersionUID = 1L;
/**
* 节点内容
*/
private Object content;
public ForestNode(String id, String parentId, Object content) {
this.channelId = id;
this.parentId = parentId;
this.content = content;
}
public Object getContent() {
return content;
}
public void setContent(Object content) {
this.content = content;
}
}

View File

@@ -1,68 +0,0 @@
package com.genersoft.iot.vmp.utils.node;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 森林管理类
*
* @author smallchill
*/
public class ForestNodeManager<T extends INode<T>> {
/**
* 森林的所有节点
*/
private final ImmutableMap<String, T> nodeMap;
/**
* 森林的父节点ID
*/
private final Map<String, Object> parentIdMap = Maps.newHashMap();
public ForestNodeManager(List<T> nodes) {
nodeMap = Maps.uniqueIndex(nodes, INode::getChannelId);
}
/**
* 根据节点ID获取一个节点
*
* @param id 节点ID
* @return 对应的节点对象
*/
public INode<T> getTreeNodeAt(String id) {
if (nodeMap.containsKey(id)) {
return nodeMap.get(id);
}
return null;
}
/**
* 增加父节点ID
*
* @param parentId 父节点ID
*/
public void addParentId(String parentId) {
parentIdMap.put(parentId, "");
}
/**
* 获取树的根节点(一个森林对应多颗树)
*
* @return 树的根节点集合
*/
public List<T> getRoot() {
List<T> roots = new ArrayList<>();
nodeMap.forEach((key, node) -> {
if (node.getParentId() == null || parentIdMap.containsKey(node.getChannelId())) {
roots.add(node);
}
});
return roots;
}
}

View File

@@ -1,51 +0,0 @@
package com.genersoft.iot.vmp.utils.node;
import com.genersoft.iot.vmp.utils.CollectionUtil;
import java.util.List;
/**
* 森林节点归并类
*
*/
public class ForestNodeMerger {
/**
* 将节点数组归并为一个森林多棵树填充节点的children域
* 时间复杂度为O(n^2)
*
* @param items 节点域
* @return 多棵树的根节点集合
*/
public static <T extends INode<T>> List<T> merge(List<T> items) {
ForestNodeManager<T> forestNodeManager = new ForestNodeManager<>(items);
items.forEach(forestNode -> {
if (forestNode.getParentId() != null) {
INode<T> node = forestNodeManager.getTreeNodeAt(forestNode.getParentId());
if (node != null) {
node.getChildren().add(forestNode);
} else {
forestNodeManager.addParentId(forestNode.getChannelId());
}
}
});
return forestNodeManager.getRoot();
}
public static <T extends INode<T>> List<T> merge(List<T> items, String[] parentIds) {
ForestNodeManager<T> forestNodeManager = new ForestNodeManager<>(items);
items.forEach(forestNode -> {
if (forestNode.getParentId() != null) {
INode<T> node = forestNodeManager.getTreeNodeAt(forestNode.getParentId());
if (CollectionUtil.contains(parentIds, forestNode.getChannelId())){
forestNodeManager.addParentId(forestNode.getChannelId());
} else {
if (node != null){
node.getChildren().add(forestNode);
}
}
}
});
return forestNodeManager.getRoot();
}
}

View File

@@ -1,42 +0,0 @@
package com.genersoft.iot.vmp.utils.node;
import java.io.Serializable;
import java.util.List;
/**
*
* 节点
*/
public interface INode<T> extends Serializable {
/**
* 主键
*
* @return String
*/
String getChannelId();
/**
* 父主键
*
* @return String
*/
String getParentId();
/**
* 子孙节点
*
* @return List<T>
*/
List<T> getChildren();
/**
* 是否有子孙节点
*
* @return Boolean
*/
default Boolean getHasChildren() {
return false;
}
}

View File

@@ -1,42 +0,0 @@
package com.genersoft.iot.vmp.utils.node;
/**
* 树型节点类
*
*/
public class TreeNode extends BaseNode<TreeNode> {
private static final long serialVersionUID = 1L;
private String title;
private String key;
private String value;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}

View File

@@ -1,121 +0,0 @@
package com.genersoft.iot.vmp.vmanager.bean;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.utils.node.INode;
import io.swagger.annotations.ApiModel;
import java.util.ArrayList;
import java.util.List;
@ApiModel(value = "DeviceChannelTree对象", description = "DeviceChannelTree对象")
public class DeviceChannelTree extends DeviceChannel implements INode<DeviceChannelTree> {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private int id;
/**
* 父节点ID
*/
private String parentId;
private String parentName;
private String title;
private String key;
private String value;
/**
* 子孙节点
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private List<DeviceChannelTree> children;
/**
* 是否有子孙节点
*/
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private Boolean hasChildren;
@Override
public List<DeviceChannelTree> getChildren() {
if (this.children == null) {
this.children = new ArrayList<>();
}
return this.children;
}
@Override
public Boolean getHasChildren() {
if (children.size() > 0) {
return true;
} else {
return this.hasChildren;
}
}
@Override
public int getId() {
return id;
}
@Override
public void setId(int id) {
this.id = id;
}
@Override
public String getParentId() {
return parentId;
}
@Override
public void setParentId(String parentId) {
this.parentId = parentId;
}
public String getParentName() {
return parentName;
}
public void setParentName(String parentName) {
this.parentName = parentName;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public void setChildren(List<DeviceChannelTree> children) {
this.children = children;
}
public void setHasChildren(Boolean hasChildren) {
this.hasChildren = hasChildren;
}
}

View File

@@ -1,56 +0,0 @@
package com.genersoft.iot.vmp.vmanager.bean;
import com.genersoft.iot.vmp.utils.node.TreeNode;
public class DeviceChannelTreeNode extends TreeNode {
private Integer status;
private String deviceId;
private String channelId;
private Double lng;
private Double lat;
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getChannelId() {
return channelId;
}
public void setChannelId(String channelId) {
this.channelId = channelId;
}
public Double getLng() {
return lng;
}
public void setLng(Double lng) {
this.lng = lng;
}
public Double getLat() {
return lat;
}
public void setLat(Double lat) {
this.lat = lat;
}
}

View File

@@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.util.StringUtil;
import io.swagger.annotations.Api;
@@ -65,10 +66,11 @@ public class MobilePositionController {
@ApiImplicitParam(name = "start", value = "开始时间", required = true, dataTypeClass = String.class),
@ApiImplicitParam(name = "end", value = "结束时间", required = true, dataTypeClass = String.class),
})
@GetMapping("/history/{deviceId}")
public ResponseEntity<List<MobilePosition>> positions(@PathVariable String deviceId,
@RequestParam(required = false) String start,
@RequestParam(required = false) String end) {
@GetMapping("/history/{deviceId}/{channelId}")
public ResponseEntity<WVPResult<List<MobilePosition>>> positions(@PathVariable String deviceId,
@PathVariable String channelId,
@RequestParam(required = false) String start,
@RequestParam(required = false) String end) {
// if (logger.isDebugEnabled()) {
// logger.debug("查询设备" + deviceId + "的历史轨迹");
// }
@@ -79,9 +81,11 @@ public class MobilePositionController {
if (StringUtil.isEmpty(end)) {
end = null;
}
List<MobilePosition> result = storager.queryMobilePositions(deviceId, start, end);
return new ResponseEntity<>(result, HttpStatus.OK);
WVPResult<List<MobilePosition>> wvpResult = new WVPResult<>();
wvpResult.setCode(0);
List<MobilePosition> result = storager.queryMobilePositions(deviceId, channelId, start, end);
wvpResult.setData(result);
return new ResponseEntity<>(wvpResult, HttpStatus.OK);
}
/**

View File

@@ -9,7 +9,6 @@ import com.genersoft.iot.vmp.gb28181.bean.SyncStatus;
import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask;
import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeHandlerTask;
import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
@@ -17,14 +16,12 @@ 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.DeviceChannelTree;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.kxml2.wap.wv.WV;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -450,11 +447,6 @@ public class DeviceQuery {
return result;
}
@GetMapping("/{deviceId}/tree")
@ApiOperation(value = "通道树形结构", notes = "通道树形结构")
public WVPResult<List<DeviceChannelTree>> tree(@PathVariable String deviceId) {
return WVPResult.Data(storager.tree(deviceId));
}
@GetMapping("/{deviceId}/sync_status")
@ApiOperation(value = "获取通道同步进度", notes = "获取通道同步进度")