修复轨迹的储存与查询展示
This commit is contained in:
@@ -57,20 +57,25 @@ public class MobilePosition {
|
||||
*/
|
||||
private String reportSource;
|
||||
|
||||
/**
|
||||
* 国内地理坐标系(GCJ-02 / BD-09)
|
||||
*/
|
||||
private String GeodeticSystem;
|
||||
|
||||
/**
|
||||
* 国内坐标系:经度坐标
|
||||
*/
|
||||
private String cnLng;
|
||||
private double longitudeGcj02;
|
||||
|
||||
/**
|
||||
* 国内坐标系:纬度坐标
|
||||
*/
|
||||
private String cnLat;
|
||||
private double latitudeGcj02;
|
||||
|
||||
/**
|
||||
* 国内坐标系:经度坐标
|
||||
*/
|
||||
private double longitudeWgs84;
|
||||
|
||||
/**
|
||||
* 国内坐标系:纬度坐标
|
||||
*/
|
||||
private double latitudeWgs84;
|
||||
|
||||
|
||||
public String getDeviceId() {
|
||||
@@ -145,30 +150,6 @@ public class MobilePosition {
|
||||
this.reportSource = reportSource;
|
||||
}
|
||||
|
||||
public String getGeodeticSystem() {
|
||||
return GeodeticSystem;
|
||||
}
|
||||
|
||||
public void setGeodeticSystem(String geodeticSystem) {
|
||||
GeodeticSystem = geodeticSystem;
|
||||
}
|
||||
|
||||
public String getCnLng() {
|
||||
return cnLng;
|
||||
}
|
||||
|
||||
public void setCnLng(String cnLng) {
|
||||
this.cnLng = cnLng;
|
||||
}
|
||||
|
||||
public String getCnLat() {
|
||||
return cnLat;
|
||||
}
|
||||
|
||||
public void setCnLat(String cnLat) {
|
||||
this.cnLat = cnLat;
|
||||
}
|
||||
|
||||
public String getChannelId() {
|
||||
return channelId;
|
||||
}
|
||||
@@ -176,4 +157,36 @@ public class MobilePosition {
|
||||
public void setChannelId(String channelId) {
|
||||
this.channelId = channelId;
|
||||
}
|
||||
|
||||
public double getLongitudeGcj02() {
|
||||
return longitudeGcj02;
|
||||
}
|
||||
|
||||
public void setLongitudeGcj02(double longitudeGcj02) {
|
||||
this.longitudeGcj02 = longitudeGcj02;
|
||||
}
|
||||
|
||||
public double getLatitudeGcj02() {
|
||||
return latitudeGcj02;
|
||||
}
|
||||
|
||||
public void setLatitudeGcj02(double latitudeGcj02) {
|
||||
this.latitudeGcj02 = latitudeGcj02;
|
||||
}
|
||||
|
||||
public double getLongitudeWgs84() {
|
||||
return longitudeWgs84;
|
||||
}
|
||||
|
||||
public void setLongitudeWgs84(double longitudeWgs84) {
|
||||
this.longitudeWgs84 = longitudeWgs84;
|
||||
}
|
||||
|
||||
public double getLatitudeWgs84() {
|
||||
return latitudeWgs84;
|
||||
}
|
||||
|
||||
public void setLatitudeWgs84(double latitudeWgs84) {
|
||||
this.latitudeWgs84 = latitudeWgs84;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,16 +173,39 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
||||
mobilePosition.getLongitude(), mobilePosition.getLatitude());
|
||||
mobilePosition.setReportSource("Mobile Position");
|
||||
// 默认来源坐标系为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);
|
||||
if ("WGS84".equals(device.getGeoCoordSys())) {
|
||||
mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
|
||||
mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
|
||||
Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
|
||||
mobilePosition.setLongitudeGcj02(position[0]);
|
||||
mobilePosition.setLatitudeGcj02(position[1]);
|
||||
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
|
||||
mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
|
||||
mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
|
||||
Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
|
||||
mobilePosition.setLongitudeWgs84(position[0]);
|
||||
mobilePosition.setLatitudeWgs84(position[1]);
|
||||
}else {
|
||||
mobilePosition.setLongitudeGcj02(0.00);
|
||||
mobilePosition.setLatitudeGcj02(0.00);
|
||||
mobilePosition.setLongitudeWgs84(0.00);
|
||||
mobilePosition.setLatitudeWgs84(0.00);
|
||||
}
|
||||
storager.insertMobilePosition(mobilePosition);
|
||||
storager.updateChannelPotion(deviceId, channelId, mobilePosition.getLongitude(), mobilePosition.getLatitude() );
|
||||
if (userSetting.getSavePositionHistory()) {
|
||||
storager.insertMobilePosition(mobilePosition);
|
||||
}
|
||||
|
||||
// 更新device channel 的经纬度
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
deviceChannel.setDeviceId(device.getDeviceId());
|
||||
deviceChannel.setChannelId(channelId);
|
||||
deviceChannel.setLongitude(mobilePosition.getLongitude());
|
||||
deviceChannel.setLatitude(mobilePosition.getLatitude());
|
||||
deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
|
||||
deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
|
||||
deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
|
||||
deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
|
||||
storager.updateChannelPosition(deviceChannel);
|
||||
// 发送redis消息。 通知位置信息的变化
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("time", time);
|
||||
@@ -209,9 +232,12 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
||||
return;
|
||||
}
|
||||
try {
|
||||
FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME);
|
||||
String deviceId = SipUtils.getUserIdFromFromHeader(fromHeader);
|
||||
|
||||
Element rootElement = getRootElement(evt);
|
||||
Element deviceIdElement = rootElement.element("DeviceID");
|
||||
String deviceId = deviceIdElement.getText().toString();
|
||||
String channelId = deviceIdElement.getText().toString();
|
||||
|
||||
Device device = redisCatchStorage.getDevice(deviceId);
|
||||
if (device == null) {
|
||||
@@ -252,16 +278,38 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
||||
mobilePosition.setLongitude(deviceAlarm.getLongitude());
|
||||
mobilePosition.setLatitude(deviceAlarm.getLatitude());
|
||||
mobilePosition.setReportSource("GPS Alarm");
|
||||
// 默认来源坐标系为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);
|
||||
if ("WGS84".equals(device.getGeoCoordSys())) {
|
||||
mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
|
||||
mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
|
||||
Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
|
||||
mobilePosition.setLongitudeGcj02(position[0]);
|
||||
mobilePosition.setLatitudeGcj02(position[1]);
|
||||
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
|
||||
mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
|
||||
mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
|
||||
Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
|
||||
mobilePosition.setLongitudeWgs84(position[0]);
|
||||
mobilePosition.setLatitudeWgs84(position[1]);
|
||||
}else {
|
||||
mobilePosition.setLongitudeGcj02(0.00);
|
||||
mobilePosition.setLatitudeGcj02(0.00);
|
||||
mobilePosition.setLongitudeWgs84(0.00);
|
||||
mobilePosition.setLatitudeWgs84(0.00);
|
||||
}
|
||||
storager.insertMobilePosition(mobilePosition);
|
||||
if (userSetting.getSavePositionHistory()) {
|
||||
storager.insertMobilePosition(mobilePosition);
|
||||
}
|
||||
// 更新device channel 的经纬度
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
deviceChannel.setDeviceId(device.getDeviceId());
|
||||
deviceChannel.setChannelId(channelId);
|
||||
deviceChannel.setLongitude(mobilePosition.getLongitude());
|
||||
deviceChannel.setLatitude(mobilePosition.getLatitude());
|
||||
deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
|
||||
deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
|
||||
deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
|
||||
deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
|
||||
storager.updateChannelPosition(deviceChannel);
|
||||
}
|
||||
// TODO: 需要实现存储报警信息、报警分类
|
||||
|
||||
|
||||
@@ -80,7 +80,6 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
|
||||
Element deviceIdElement = rootElement.element("DeviceID");
|
||||
String channelId = deviceIdElement.getText().toString();
|
||||
|
||||
|
||||
DeviceAlarm deviceAlarm = new DeviceAlarm();
|
||||
deviceAlarm.setDeviceId(device.getDeviceId());
|
||||
deviceAlarm.setChannelId(channelId);
|
||||
@@ -118,16 +117,38 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
|
||||
mobilePosition.setLongitude(deviceAlarm.getLongitude());
|
||||
mobilePosition.setLatitude(deviceAlarm.getLatitude());
|
||||
mobilePosition.setReportSource("GPS Alarm");
|
||||
// 默认来源坐标系为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());
|
||||
if ("WGS84".equals(device.getGeoCoordSys())) {
|
||||
mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
|
||||
mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
|
||||
Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
|
||||
mobilePosition.setLongitudeGcj02(position[0]);
|
||||
mobilePosition.setLatitudeGcj02(position[1]);
|
||||
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
|
||||
mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
|
||||
mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
|
||||
Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
|
||||
mobilePosition.setLongitudeWgs84(position[0]);
|
||||
mobilePosition.setLatitudeWgs84(position[1]);
|
||||
}else {
|
||||
mobilePosition.setLongitudeGcj02(0.00);
|
||||
mobilePosition.setLatitudeGcj02(0.00);
|
||||
mobilePosition.setLongitudeWgs84(0.00);
|
||||
mobilePosition.setLatitudeWgs84(0.00);
|
||||
}
|
||||
storager.insertMobilePosition(mobilePosition);
|
||||
if (userSetting.getSavePositionHistory()) {
|
||||
storager.insertMobilePosition(mobilePosition);
|
||||
}
|
||||
// 更新device channel 的经纬度
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
deviceChannel.setDeviceId(device.getDeviceId());
|
||||
deviceChannel.setChannelId(channelId);
|
||||
deviceChannel.setLongitude(mobilePosition.getLongitude());
|
||||
deviceChannel.setLatitude(mobilePosition.getLatitude());
|
||||
deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
|
||||
deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
|
||||
deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
|
||||
deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
|
||||
storager.updateChannelPosition(deviceChannel);
|
||||
}
|
||||
}
|
||||
if (!StringUtils.isEmpty(deviceAlarm.getDeviceId())) {
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.BaiduPoint;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
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;
|
||||
@@ -80,16 +77,38 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen
|
||||
mobilePosition.setAltitude(0.0);
|
||||
}
|
||||
mobilePosition.setReportSource("Mobile Position");
|
||||
// 默认来源坐标系为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());
|
||||
if ("WGS84".equals(device.getGeoCoordSys())) {
|
||||
mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
|
||||
mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
|
||||
Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
|
||||
mobilePosition.setLongitudeGcj02(position[0]);
|
||||
mobilePosition.setLatitudeGcj02(position[1]);
|
||||
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
|
||||
mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
|
||||
mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
|
||||
Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
|
||||
mobilePosition.setLongitudeWgs84(position[0]);
|
||||
mobilePosition.setLatitudeWgs84(position[1]);
|
||||
}else {
|
||||
mobilePosition.setLongitudeGcj02(0.00);
|
||||
mobilePosition.setLatitudeGcj02(0.00);
|
||||
mobilePosition.setLongitudeWgs84(0.00);
|
||||
mobilePosition.setLatitudeWgs84(0.00);
|
||||
}
|
||||
storager.insertMobilePosition(mobilePosition);
|
||||
if (userSetting.getSavePositionHistory()) {
|
||||
storager.insertMobilePosition(mobilePosition);
|
||||
}
|
||||
// 更新device channel 的经纬度
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
deviceChannel.setDeviceId(device.getDeviceId());
|
||||
deviceChannel.setChannelId(mobilePosition.getChannelId());
|
||||
deviceChannel.setLongitude(mobilePosition.getLongitude());
|
||||
deviceChannel.setLatitude(mobilePosition.getLatitude());
|
||||
deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
|
||||
deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
|
||||
deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
|
||||
deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
|
||||
storager.updateChannelPosition(deviceChannel);
|
||||
//回复 200 OK
|
||||
responseAck(evt, Response.OK);
|
||||
} catch (DocumentException | SipException | InvalidArgumentException | ParseException e) {
|
||||
|
||||
@@ -171,71 +171,6 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理设备位置的更新
|
||||
*
|
||||
* @param evt, itemDevice
|
||||
*/
|
||||
private void processNotifyMobilePosition(RequestEvent evt, Element itemDevice) {
|
||||
try {
|
||||
// 回复 200 OK
|
||||
Element rootElement = getRootElement(evt);
|
||||
MobilePosition mobilePosition = new MobilePosition();
|
||||
Element deviceIdElement = rootElement.element("DeviceID");
|
||||
String deviceId = deviceIdElement.getTextTrim().toString();
|
||||
Device device = redisCatchStorage.getDevice(deviceId);
|
||||
if (device != null) {
|
||||
if (!StringUtils.isEmpty(device.getName())) {
|
||||
mobilePosition.setDeviceName(device.getName());
|
||||
}
|
||||
}
|
||||
mobilePosition.setDeviceId(XmlUtil.getText(rootElement, "DeviceID"));
|
||||
|
||||
String time = XmlUtil.getText(itemDevice, "Time");
|
||||
if(time==null){
|
||||
time = XmlUtil.getText(itemDevice, "EndTime");
|
||||
}
|
||||
mobilePosition.setTime(time);
|
||||
String longitude = XmlUtil.getText(itemDevice, "Longitude");
|
||||
if(longitude!=null) {
|
||||
mobilePosition.setLongitude(Double.parseDouble(longitude));
|
||||
}
|
||||
String latitude = XmlUtil.getText(itemDevice, "Latitude");
|
||||
if(latitude!=null) {
|
||||
mobilePosition.setLatitude(Double.parseDouble(latitude));
|
||||
}
|
||||
if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Speed"))) {
|
||||
mobilePosition.setSpeed(Double.parseDouble(XmlUtil.getText(itemDevice, "Speed")));
|
||||
} else {
|
||||
mobilePosition.setSpeed(0.0);
|
||||
}
|
||||
if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Direction"))) {
|
||||
mobilePosition.setDirection(Double.parseDouble(XmlUtil.getText(itemDevice, "Direction")));
|
||||
} else {
|
||||
mobilePosition.setDirection(0.0);
|
||||
}
|
||||
if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Altitude"))) {
|
||||
mobilePosition.setAltitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Altitude")));
|
||||
} else {
|
||||
mobilePosition.setAltitude(0.0);
|
||||
}
|
||||
mobilePosition.setReportSource("Mobile Position");
|
||||
// 默认来源坐标系为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);
|
||||
}
|
||||
storager.insertMobilePosition(mobilePosition);
|
||||
responseAck(evt, Response.OK);
|
||||
} catch (DocumentException | SipException | InvalidArgumentException | ParseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public SyncStatus getChannelSyncProgress(String deviceId) {
|
||||
if (catalogDataCatch.get(deviceId) == null) {
|
||||
return null;
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.BaiduPoint;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
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;
|
||||
@@ -80,16 +77,38 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar
|
||||
mobilePosition.setAltitude(0.0);
|
||||
}
|
||||
mobilePosition.setReportSource("Mobile Position");
|
||||
// 默认来源坐标系为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());
|
||||
if ("WGS84".equals(device.getGeoCoordSys())) {
|
||||
mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
|
||||
mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
|
||||
Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
|
||||
mobilePosition.setLongitudeGcj02(position[0]);
|
||||
mobilePosition.setLatitudeGcj02(position[1]);
|
||||
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
|
||||
mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
|
||||
mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
|
||||
Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
|
||||
mobilePosition.setLongitudeWgs84(position[0]);
|
||||
mobilePosition.setLatitudeWgs84(position[1]);
|
||||
}else {
|
||||
mobilePosition.setLongitudeGcj02(0.00);
|
||||
mobilePosition.setLatitudeGcj02(0.00);
|
||||
mobilePosition.setLongitudeWgs84(0.00);
|
||||
mobilePosition.setLatitudeWgs84(0.00);
|
||||
}
|
||||
storager.insertMobilePosition(mobilePosition);
|
||||
if (userSetting.getSavePositionHistory()) {
|
||||
storager.insertMobilePosition(mobilePosition);
|
||||
}
|
||||
// 更新device channel 的经纬度
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
deviceChannel.setDeviceId(device.getDeviceId());
|
||||
deviceChannel.setChannelId(mobilePosition.getChannelId());
|
||||
deviceChannel.setLongitude(mobilePosition.getLongitude());
|
||||
deviceChannel.setLatitude(mobilePosition.getLatitude());
|
||||
deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
|
||||
deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
|
||||
deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
|
||||
deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
|
||||
storager.updateChannelPosition(deviceChannel);
|
||||
//回复 200 OK
|
||||
responseAck(evt, Response.OK);
|
||||
} catch (DocumentException | SipException | InvalidArgumentException | ParseException e) {
|
||||
|
||||
@@ -463,5 +463,5 @@ public interface IVideoManagerStorage {
|
||||
|
||||
List<ChannelSourceInfo> getChannelSource(String platformId, String gbId);
|
||||
|
||||
void updateChannelPotion(String deviceId, String channelId, double longitude, double latitude);
|
||||
void updateChannelPosition(DeviceChannel deviceChannel);
|
||||
}
|
||||
|
||||
@@ -276,8 +276,19 @@ public interface DeviceChannelMapper {
|
||||
" and channelId = #{channelId}")
|
||||
int updateChannelSubCount(String deviceId, String channelId);
|
||||
|
||||
@Update(value = {"UPDATE device_channel SET latitude=${latitude}, longitude=${longitude} WHERE deviceId=#{deviceId} AND channelId=#{channelId}"})
|
||||
void updatePotion(String deviceId, String channelId, double longitude, double latitude);
|
||||
@Update(value = {" <script>" +
|
||||
"UPDATE device_channel " +
|
||||
"SET " +
|
||||
"latitude=${latitude}, " +
|
||||
"longitude=${longitude}, " +
|
||||
"longitudeGcj02=${longitudeGcj02}," +
|
||||
"latitudeGcj02=${latitudeGcj02}," +
|
||||
"longitudeWgs84=${longitudeWgs84}," +
|
||||
"latitudeWgs84=${latitudeWgs84} " +
|
||||
"WHERE deviceId=#{deviceId} " +
|
||||
" <if test='channelId != null' > AND channelId=#{channelId}</if>" +
|
||||
" </script>"})
|
||||
void updatePosition(DeviceChannel deviceChannel);
|
||||
|
||||
@Select("SELECT * FROM device_channel WHERE length(trim(streamId)) > 0")
|
||||
List<DeviceChannel> getAllChannelInPlay();
|
||||
@@ -313,4 +324,6 @@ public interface DeviceChannelMapper {
|
||||
|
||||
@Select("select * from device_channel where deviceId=#{deviceId} and SUBSTRING(channelId, 11, 3)=#{typeCode}")
|
||||
List<DeviceChannel> getBusinessGroups(String deviceId, String typeCode);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,19 +4,18 @@ import java.util.List;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.MobilePosition;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
//import org.springframework.stereotype.Repository;
|
||||
|
||||
@Mapper
|
||||
//@Repository
|
||||
public interface DeviceMobilePositionMapper {
|
||||
|
||||
@Insert("INSERT INTO device_mobile_position (deviceId,channelId, deviceName, time, longitude, latitude, altitude, speed, direction, reportSource, geodeticSystem, cnLng, cnLat) " +
|
||||
"VALUES ('${deviceId}','${channelId}', '${deviceName}', '${time}', ${longitude}, ${latitude}, ${altitude}, ${speed}, ${direction}, '${reportSource}', '${geodeticSystem}', '${cnLng}', '${cnLat}')")
|
||||
@Insert("INSERT INTO device_mobile_position (deviceId,channelId, deviceName, time, longitude, latitude, altitude, speed, direction, reportSource, longitudeGcj02, latitudeGcj02, longitudeWgs84, latitudeWgs84) " +
|
||||
"VALUES ('${deviceId}','${channelId}', '${deviceName}', '${time}', ${longitude}, ${latitude}, ${altitude}, ${speed}, ${direction}, '${reportSource}', ${longitudeGcj02}, ${latitudeGcj02}, ${longitudeWgs84}, ${latitudeWgs84})")
|
||||
int insertNewPosition(MobilePosition mobilePosition);
|
||||
|
||||
@Select(value = {" <script>" +
|
||||
"SELECT * FROM device_mobile_position" +
|
||||
" WHERE deviceId = #{deviceId} and channelId = #{channelId} " +
|
||||
" WHERE deviceId = #{deviceId}" +
|
||||
"<if test=\"channelId != null\"> and channelId = #{channelId}</if>" +
|
||||
"<if test=\"startTime != null\"> AND time>=#{startTime}</if>" +
|
||||
"<if test=\"endTime != null\"> AND time<=#{endTime}</if>" +
|
||||
" ORDER BY time ASC" +
|
||||
|
||||
@@ -472,6 +472,9 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean insertMobilePosition(MobilePosition mobilePosition) {
|
||||
if (mobilePosition.getDeviceId().equals(mobilePosition.getChannelId())) {
|
||||
mobilePosition.setChannelId(null);
|
||||
}
|
||||
return deviceMobilePositionMapper.insertNewPosition(mobilePosition) > 0;
|
||||
}
|
||||
|
||||
@@ -1119,7 +1122,10 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateChannelPotion(String deviceId, String channelId, double longitude, double latitude) {
|
||||
deviceChannelMapper.updatePotion(deviceId, channelId, longitude, latitude);
|
||||
public void updateChannelPosition(DeviceChannel deviceChannel) {
|
||||
if (deviceChannel.getChannelId().equals(deviceChannel.getDeviceId())) {
|
||||
deviceChannel.setChannelId(null);
|
||||
}
|
||||
deviceChannelMapper.updatePosition(deviceChannel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,12 +63,13 @@ public class MobilePositionController {
|
||||
@ApiOperation("查询历史轨迹")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "deviceId", value = "设备ID", required = true, dataTypeClass = String.class),
|
||||
@ApiImplicitParam(name = "start", value = "开始时间", required = true, dataTypeClass = String.class),
|
||||
@ApiImplicitParam(name = "end", value = "结束时间", required = true, dataTypeClass = String.class),
|
||||
@ApiImplicitParam(name = "channelId", value = "通道ID", required = false, dataTypeClass = String.class),
|
||||
@ApiImplicitParam(name = "start", value = "开始时间", required = false, dataTypeClass = String.class),
|
||||
@ApiImplicitParam(name = "end", value = "结束时间", required = false, dataTypeClass = String.class),
|
||||
})
|
||||
@GetMapping("/history/{deviceId}/{channelId}")
|
||||
@GetMapping("/history/{deviceId}")
|
||||
public ResponseEntity<WVPResult<List<MobilePosition>>> positions(@PathVariable String deviceId,
|
||||
@PathVariable String channelId,
|
||||
@RequestParam(required = false) String channelId,
|
||||
@RequestParam(required = false) String start,
|
||||
@RequestParam(required = false) String end) {
|
||||
// if (logger.isDebugEnabled()) {
|
||||
|
||||
Reference in New Issue
Block a user