优化地图-添加地图页面以及设备树

This commit is contained in:
648540858
2022-04-08 18:09:23 +08:00
parent 81f1b8ee25
commit ba8633e99a
25 changed files with 1076 additions and 579 deletions

View File

@@ -52,7 +52,6 @@ public class KeepaliveTimeoutListenerForPlatform extends RedisKeyExpirationEvent
public void onMessage(Message message, byte[] pattern) {
// 获取失效的key
String expiredKey = message.toString();
logger.debug(expiredKey);
// 平台心跳到期,需要重发, 判断是否已经多次未收到心跳回复, 多次未收到,则重新发起注册, 注册尝试多次未得到回复,则认为平台离线
String PLATFORM_KEEPLIVEKEY_PREFIX = VideoManagerConstants.PLATFORM_KEEPALIVE_PREFIX + userSetting.getServerId() + "_";
String PLATFORM_REGISTER_PREFIX = VideoManagerConstants.PLATFORM_REGISTER_PREFIX + userSetting.getServerId() + "_";

View File

@@ -57,10 +57,8 @@ public class OfflineEventListener implements ApplicationListener<OfflineEvent> {
@Override
public void onApplicationEvent(OfflineEvent event) {
if (logger.isDebugEnabled()) {
logger.debug("设备离线事件触发deviceId" + event.getDeviceId() + ",from:" + event.getFrom());
}
logger.info("设备离线事件触发deviceId" + event.getDeviceId() + ",from:" + event.getFrom());
String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + event.getDeviceId();

View File

@@ -58,10 +58,8 @@ public class OnlineEventListener implements ApplicationListener<OnlineEvent> {
@Override
public void onApplicationEvent(OnlineEvent event) {
if (logger.isDebugEnabled()) {
logger.debug("设备上线事件触发deviceId" + event.getDevice().getDeviceId() + ",from:" + event.getFrom());
}
logger.info("设备上线事件触发deviceId" + event.getDevice().getDeviceId() + ",from:" + event.getFrom());
Device device = event.getDevice();
if (device == null) return;
String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + event.getDevice().getDeviceId();

View File

@@ -31,10 +31,8 @@ public class RecordEndEventListener implements ApplicationListener<RecordEndEven
private Map<String, RecordEndEventHandler> handlerMap = new HashMap<>();
@Override
public void onApplicationEvent(RecordEndEvent event) {
if (logger.isDebugEnabled()) {
logger.debug("录像查询完成事件触发deviceId{}, channelId: {}, 录像数量{}条", event.getRecordInfo().getDeviceId(),
event.getRecordInfo().getChannelId(), event.getRecordInfo().getSumNum() );
}
logger.info("录像查询完成事件触发deviceId{}, channelId: {}, 录像数量{}条", event.getRecordInfo().getDeviceId(),
event.getRecordInfo().getChannelId(), event.getRecordInfo().getSumNum() );
if (handlerMap.size() > 0) {
for (RecordEndEventHandler recordEndEventHandler : handlerMap.values()) {
recordEndEventHandler.handler(event.getRecordInfo());

View File

@@ -39,7 +39,6 @@ public class SubscribeListenerForPlatform extends RedisKeyExpirationEventMessage
public void onMessage(Message message, byte[] pattern) {
// 获取失效的key
String expiredKey = message.toString();
logger.debug(expiredKey);
// 订阅到期
String PLATFORM_KEEPLIVEKEY_PREFIX = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "_";
if (expiredKey.startsWith(PLATFORM_KEEPLIVEKEY_PREFIX)) {

View File

@@ -66,7 +66,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId());
if (subscribe == null) {
logger.debug("发送订阅消息时发现订阅信息已经不存在");
logger.info("发送订阅消息时发现订阅信息已经不存在");
return;
}
}else {

View File

@@ -13,6 +13,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
@@ -149,11 +150,12 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
logger.info("[收到Notify-MobilePosition]{}/{}->{}.{}", mobilePosition.getDeviceId(), mobilePosition.getChannelId(),
mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setReportSource("Mobile Position");
BaiduPoint bp = GpsUtil.Wgs84ToBd09(String.valueOf(mobilePosition.getLongitude()), String.valueOf(mobilePosition.getLatitude()));
logger.info("百度坐标:" + bp.getBdLng() + ", " + bp.getBdLat());
mobilePosition.setGeodeticSystem("BD-09");
mobilePosition.setCnLng(bp.getBdLng());
mobilePosition.setCnLat(bp.getBdLat());
// 默认来源坐标系为WGS-84处理
Double[] gcj02Point = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
logger.info("GCJ02坐标" + gcj02Point[0] + ", " + gcj02Point[1]);
mobilePosition.setGeodeticSystem("GCJ-02");
mobilePosition.setCnLng(gcj02Point[0] + "");
mobilePosition.setCnLat(gcj02Point[1] + "");
if (!userSetting.getSavePositionHistory()) {
storager.clearMobilePositionsByDeviceId(deviceId);
}
@@ -223,12 +225,12 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
mobilePosition.setLongitude(deviceAlarm.getLongitude());
mobilePosition.setLatitude(deviceAlarm.getLatitude());
mobilePosition.setReportSource("GPS Alarm");
BaiduPoint bp = new BaiduPoint();
bp = GpsUtil.Wgs84ToBd09(String.valueOf(mobilePosition.getLongitude()), String.valueOf(mobilePosition.getLatitude()));
logger.info("百度坐标:" + bp.getBdLng() + ", " + bp.getBdLat());
mobilePosition.setGeodeticSystem("BD-09");
mobilePosition.setCnLng(bp.getBdLng());
mobilePosition.setCnLat(bp.getBdLat());
// 默认来源坐标系为WGS-84处理
Double[] gcj02Point = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
logger.info("GCJ02坐标:" + gcj02Point[0] + ", " + gcj02Point[1]);
mobilePosition.setGeodeticSystem("GCJ-02");
mobilePosition.setCnLng(gcj02Point[0] + "");
mobilePosition.setCnLat(gcj02Point[1] + "");
if (!userSetting.getSavePositionHistory()) {
storager.clearMobilePositionsByDeviceId(deviceId);
}

View File

@@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler;
import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
import com.genersoft.iot.vmp.service.IDeviceAlarmService;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
@@ -93,12 +94,12 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
mobilePosition.setLongitude(deviceAlarm.getLongitude());
mobilePosition.setLatitude(deviceAlarm.getLatitude());
mobilePosition.setReportSource("GPS Alarm");
BaiduPoint bp = new BaiduPoint();
bp = GpsUtil.Wgs84ToBd09(String.valueOf(mobilePosition.getLongitude()), String.valueOf(mobilePosition.getLatitude()));
logger.info("百度坐标:" + bp.getBdLng() + ", " + bp.getBdLat());
mobilePosition.setGeodeticSystem("BD-09");
mobilePosition.setCnLng(bp.getBdLng());
mobilePosition.setCnLat(bp.getBdLat());
// 默认来源坐标系为WGS-84处理
Double[] gcj02Point = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
logger.info("GCJ02坐标:" + gcj02Point[0] + ", " + gcj02Point[1]);
mobilePosition.setGeodeticSystem("GCJ-02");
mobilePosition.setCnLng(gcj02Point[0] + "");
mobilePosition.setCnLat(gcj02Point[1] + "");
if (!userSetting.getSavePositionHistory()) {
storager.clearMobilePositionsByDeviceId(device.getDeviceId());
}

View File

@@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler;
import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.GpsUtil;
@@ -79,12 +80,12 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen
mobilePosition.setAltitude(0.0);
}
mobilePosition.setReportSource("Mobile Position");
BaiduPoint bp = new BaiduPoint();
bp = GpsUtil.Wgs84ToBd09(String.valueOf(mobilePosition.getLongitude()), String.valueOf(mobilePosition.getLatitude()));
logger.info("百度坐标:" + bp.getBdLng() + ", " + bp.getBdLat());
mobilePosition.setGeodeticSystem("BD-09");
mobilePosition.setCnLng(bp.getBdLng());
mobilePosition.setCnLat(bp.getBdLat());
// 默认来源坐标系为WGS-84处理
Double[] gcj02Point = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
logger.info("GCJ02坐标:" + gcj02Point[0] + ", " + gcj02Point[1]);
mobilePosition.setGeodeticSystem("GCJ-02");
mobilePosition.setCnLng(gcj02Point[0] + "");
mobilePosition.setCnLat(gcj02Point[1] + "");
if (!userSetting.getSavePositionHistory()) {
storager.clearMobilePositionsByDeviceId(device.getDeviceId());
}

View File

@@ -12,6 +12,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler;
import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
@@ -215,12 +216,12 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
mobilePosition.setAltitude(0.0);
}
mobilePosition.setReportSource("Mobile Position");
BaiduPoint bp = new BaiduPoint();
bp = GpsUtil.Wgs84ToBd09(String.valueOf(mobilePosition.getLongitude()), String.valueOf(mobilePosition.getLatitude()));
logger.info("百度坐标:" + bp.getBdLng() + ", " + bp.getBdLat());
mobilePosition.setGeodeticSystem("BD-09");
mobilePosition.setCnLng(bp.getBdLng());
mobilePosition.setCnLat(bp.getBdLat());
// 默认来源坐标系为WGS-84处理
Double[] gcj02Point = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
logger.info("GCJ02坐标:" + gcj02Point[0] + ", " + gcj02Point[1]);
mobilePosition.setGeodeticSystem("GCJ-02");
mobilePosition.setCnLng(gcj02Point[0] + "");
mobilePosition.setCnLat(gcj02Point[1] + "");
if (!userSetting.getSavePositionHistory()) {
storager.clearMobilePositionsByDeviceId(deviceId);
}

View File

@@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler;
import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.GpsUtil;
@@ -79,12 +80,12 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar
mobilePosition.setAltitude(0.0);
}
mobilePosition.setReportSource("Mobile Position");
BaiduPoint bp = new BaiduPoint();
bp = GpsUtil.Wgs84ToBd09(String.valueOf(mobilePosition.getLongitude()), String.valueOf(mobilePosition.getLatitude()));
logger.info("百度坐标:" + bp.getBdLng() + ", " + bp.getBdLat());
mobilePosition.setGeodeticSystem("BD-09");
mobilePosition.setCnLng(bp.getBdLng());
mobilePosition.setCnLat(bp.getBdLat());
// 默认来源坐标系为WGS-84处理
Double[] gcj02Point = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
logger.info("GCJ02坐标:" + gcj02Point[0] + ", " + gcj02Point[1]);
mobilePosition.setGeodeticSystem("GCJ-02");
mobilePosition.setCnLng(gcj02Point[0] + "");
mobilePosition.setCnLat(gcj02Point[1] + "");
if (!userSetting.getSavePositionHistory()) {
storager.clearMobilePositionsByDeviceId(device.getDeviceId());
}

View File

@@ -0,0 +1,126 @@
package com.genersoft.iot.vmp.gb28181.utils;
/**
* 坐标转换
* 一个提供了百度坐标BD09、国测局坐标火星坐标GCJ02、和WGS84坐标系之间的转换的工具类
* 参考https://github.com/wandergis/coordtransform 写的Java版本
* @author Xinconan
* @date 2016-03-18
* @url https://github.com/xinconan/coordtransform
*/
public class Coordtransform {
private static double x_PI = 3.14159265358979324 * 3000.0 / 180.0;
private static double PI = 3.1415926535897932384626;
private static double a = 6378245.0;
private static double ee = 0.00669342162296594323;
/**
* 百度坐标系 (BD-09) 与 火星坐标系 (GCJ-02)的转换
* 即 百度 转 谷歌、高德
* @param bd_lon
* @param bd_lat
* @return Double[lon,lat]
*/
public static Double[] BD09ToGCJ02(Double bd_lon,Double bd_lat){
double x = bd_lon - 0.0065;
double y = bd_lat - 0.006;
double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_PI);
double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_PI);
Double[] arr = new Double[2];
arr[0] = z * Math.cos(theta);
arr[1] = z * Math.sin(theta);
return arr;
}
/**
* 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换
* 即谷歌、高德 转 百度
* @param gcj_lon
* @param gcj_lat
* @return Double[lon,lat]
*/
public static Double[] GCJ02ToBD09(Double gcj_lon,Double gcj_lat){
double z = Math.sqrt(gcj_lon * gcj_lon + gcj_lat * gcj_lat) + 0.00002 * Math.sin(gcj_lat * x_PI);
double theta = Math.atan2(gcj_lat, gcj_lon) + 0.000003 * Math.cos(gcj_lon * x_PI);
Double[] arr = new Double[2];
arr[0] = z * Math.cos(theta) + 0.0065;
arr[1] = z * Math.sin(theta) + 0.006;
return arr;
}
/**
* WGS84转GCJ02
* @param wgs_lon
* @param wgs_lat
* @return Double[lon,lat]
*/
public static Double[] WGS84ToGCJ02(Double wgs_lon,Double wgs_lat){
if(outOfChina(wgs_lon, wgs_lat)){
return new Double[]{wgs_lon,wgs_lat};
}
double dlat = transformlat(wgs_lon - 105.0, wgs_lat - 35.0);
double dlng = transformlng(wgs_lon - 105.0, wgs_lat - 35.0);
double radlat = wgs_lat / 180.0 * PI;
double magic = Math.sin(radlat);
magic = 1 - ee * magic * magic;
double sqrtmagic = Math.sqrt(magic);
dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI);
dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI);
Double[] arr = new Double[2];
arr[0] = wgs_lon + dlng;
arr[1] = wgs_lat + dlat;
return arr;
}
/**
* GCJ02转WGS84
* @param gcj_lon
* @param gcj_lat
* @return Double[lon,lat]
*/
public static Double[] GCJ02ToWGS84(Double gcj_lon,Double gcj_lat){
if(outOfChina(gcj_lon, gcj_lat)){
return new Double[]{gcj_lon,gcj_lat};
}
double dlat = transformlat(gcj_lon - 105.0, gcj_lat - 35.0);
double dlng = transformlng(gcj_lon - 105.0, gcj_lat - 35.0);
double radlat = gcj_lat / 180.0 * PI;
double magic = Math.sin(radlat);
magic = 1 - ee * magic * magic;
double sqrtmagic = Math.sqrt(magic);
dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI);
dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI);
double mglat = gcj_lat + dlat;
double mglng = gcj_lon + dlng;
return new Double[]{gcj_lon * 2 - mglng, gcj_lat * 2 - mglat};
}
private static Double transformlat(double lng, double lat) {
double ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0;
ret += (160.0 * Math.sin(lat / 12.0 * PI) + 320 * Math.sin(lat * PI / 30.0)) * 2.0 / 3.0;
return ret;
}
private static Double transformlng(double lng,double lat) {
double ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(lng * PI) + 40.0 * Math.sin(lng / 3.0 * PI)) * 2.0 / 3.0;
ret += (150.0 * Math.sin(lng / 12.0 * PI) + 300.0 * Math.sin(lng / 30.0 * PI)) * 2.0 / 3.0;
return ret;
}
/**
* outOfChina
* @描述: 判断是否在国内,不在国内则不做偏移
* @param lng
* @param lat
* @return {boolean}
*/
private static boolean outOfChina(Double lng,Double lat) {
return (lng < 72.004 || lng > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false);
};
}

View File

@@ -274,7 +274,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
channels = deviceChannelList;
}
if (stringBuilder.length() > 0) {
logger.debug("[目录查询]收到的数据存在重复: {}" , stringBuilder);
logger.info("[目录查询]收到的数据存在重复: {}" , stringBuilder);
}
try {
int cleanChannelsResult = deviceChannelMapper.cleanChannelsNotInList(deviceId, channels);