优化国标级联目录订阅通知以及目录查询回复
This commit is contained in:
@@ -154,6 +154,11 @@ public class ParentPlatform {
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 树类型 国标规定了两种树的展现方式 行政区划 CivilCode 和业务分组:BusinessGroup
|
||||
*/
|
||||
private String treeType;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
@@ -394,4 +399,12 @@ public class ParentPlatform {
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getTreeType() {
|
||||
return treeType;
|
||||
}
|
||||
|
||||
public void setTreeType(String treeType) {
|
||||
this.treeType = treeType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,28 @@
|
||||
package com.genersoft.iot.vmp.gb28181.bean;
|
||||
|
||||
/**
|
||||
* 国标级联-目录
|
||||
* @author lin
|
||||
*/
|
||||
public class PlatformCatalog {
|
||||
private String id;
|
||||
private String name;
|
||||
private String platformId;
|
||||
private String parentId;
|
||||
private int childrenCount; // 子节点数
|
||||
private int type; // 0 目录, 1 国标通道, 2 直播流
|
||||
|
||||
private String civilCode;
|
||||
|
||||
private String businessGroupId;
|
||||
|
||||
/**
|
||||
* 子节点数
|
||||
*/
|
||||
private int childrenCount;
|
||||
|
||||
/**
|
||||
* 0 目录, 1 国标通道, 2 直播流
|
||||
*/
|
||||
private int type;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
@@ -68,4 +84,19 @@ public class PlatformCatalog {
|
||||
this.type = 2;
|
||||
}
|
||||
|
||||
public String getCivilCode() {
|
||||
return civilCode;
|
||||
}
|
||||
|
||||
public void setCivilCode(String civilCode) {
|
||||
this.civilCode = civilCode;
|
||||
}
|
||||
|
||||
public String getBusinessGroupId() {
|
||||
return businessGroupId;
|
||||
}
|
||||
|
||||
public void setBusinessGroupId(String businessGroupId) {
|
||||
this.businessGroupId = businessGroupId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.genersoft.iot.vmp.gb28181.bean;
|
||||
|
||||
/**
|
||||
* 目录结构类型
|
||||
* @author lin
|
||||
*/
|
||||
public class TreeType {
|
||||
public static final String BUSINESS_GROUP = "BusinessGroup";
|
||||
public static final String CIVIL_CODE = "CivilCode";
|
||||
}
|
||||
@@ -11,13 +11,40 @@ public class CatalogEvent extends ApplicationEvent {
|
||||
super(source);
|
||||
}
|
||||
|
||||
public static final String ON = "ON"; // 上线
|
||||
public static final String OFF = "OFF"; // 离线
|
||||
public static final String VLOST = "VLOST"; // 视频丢失
|
||||
public static final String DEFECT = "DEFECT"; // 故障
|
||||
public static final String ADD = "ADD"; // 增加
|
||||
public static final String DEL = "DEL"; // 删除
|
||||
public static final String UPDATE = "UPDATE"; // 更新
|
||||
/**
|
||||
* 上线
|
||||
*/
|
||||
public static final String ON = "ON";
|
||||
|
||||
/**
|
||||
* 离线
|
||||
*/
|
||||
public static final String OFF = "OFF";
|
||||
|
||||
/**
|
||||
* 视频丢失
|
||||
*/
|
||||
public static final String VLOST = "VLOST";
|
||||
|
||||
/**
|
||||
* 故障
|
||||
*/
|
||||
public static final String DEFECT = "DEFECT";
|
||||
|
||||
/**
|
||||
* 增加
|
||||
*/
|
||||
public static final String ADD = "ADD";
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
public static final String DEL = "DEL";
|
||||
|
||||
/**
|
||||
* 更新
|
||||
*/
|
||||
public static final String UPDATE = "UPDATE";
|
||||
|
||||
private List<DeviceChannel> deviceChannels;
|
||||
private List<GbStream> gbStreams;
|
||||
|
||||
@@ -59,16 +59,15 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
|
||||
|
||||
Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>();
|
||||
if (!StringUtils.isEmpty(event.getPlatformId())) {
|
||||
subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId());
|
||||
if (subscribe == null) {
|
||||
return;
|
||||
}
|
||||
parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId());
|
||||
if (parentPlatform != null && !parentPlatform.isStatus()) {
|
||||
return;
|
||||
}
|
||||
subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId());
|
||||
|
||||
if (subscribe == null) {
|
||||
logger.info("发送订阅消息时发现订阅信息已经不存在: {}", event.getPlatformId());
|
||||
return;
|
||||
}
|
||||
}else {
|
||||
// 获取所用订阅
|
||||
List<String> platforms = subscribeHolder.getAllCatalogSubscribePlatform();
|
||||
@@ -144,11 +143,8 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
|
||||
}
|
||||
if (event.getGbStreams() != null && event.getGbStreams().size() > 0){
|
||||
for (GbStream gbStream : event.getGbStreams()) {
|
||||
DeviceChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), parentPlatform);
|
||||
if (deviceChannelByStream.getParentId().length() <= 10) { // 父节点是行政区划,则设置CivilCode使用此行政区划
|
||||
deviceChannelByStream.setCivilCode(deviceChannelByStream.getParentId());
|
||||
}
|
||||
deviceChannelList.add(deviceChannelByStream);
|
||||
deviceChannelList.add(
|
||||
gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), parentPlatform));
|
||||
}
|
||||
}
|
||||
if (deviceChannelList.size() > 0) {
|
||||
|
||||
@@ -57,18 +57,14 @@ public class MobilePositionSubscribeHandlerTask implements ISubscribeTask {
|
||||
SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId());
|
||||
if (subscribe != null) {
|
||||
|
||||
// if (!parentPlatform.isStatus()) {
|
||||
// logger.info("发送订阅时发现平台已经离线:{}", platformId);
|
||||
// return;
|
||||
// }
|
||||
// TODO 暂时只处理视频流的回复,后续增加对国标设备的支持
|
||||
List<GbStream> gbStreams = storager.queryGbStreamListInPlatform(platform.getServerGBId());
|
||||
List<DeviceChannel> gbStreams = storager.queryGbStreamListInPlatform(platform.getServerGBId());
|
||||
if (gbStreams.size() == 0) {
|
||||
logger.info("发送订阅时发现平台已经没有关联的直播流:{}", platform.getServerGBId());
|
||||
return;
|
||||
}
|
||||
for (GbStream gbStream : gbStreams) {
|
||||
String gbId = gbStream.getGbId();
|
||||
for (DeviceChannel deviceChannel : gbStreams) {
|
||||
String gbId = deviceChannel.getChannelId();
|
||||
GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId);
|
||||
if (gpsMsgInfo != null) { // 无最新位置不发送
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
||||
@@ -257,37 +257,37 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
||||
catalogXml.append("<DeviceList Num=\"" + channels.size() +"\">\r\n");
|
||||
if (channels.size() > 0) {
|
||||
for (DeviceChannel channel : channels) {
|
||||
if (parentPlatform.getServerGBId().equals(channel.getParentId())) {
|
||||
channel.setParentId(parentPlatform.getDeviceGBId());
|
||||
}
|
||||
catalogXml.append("<Item>\r\n");
|
||||
// 行政区划分组只需要这两项就可以
|
||||
catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");
|
||||
catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n");
|
||||
catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
|
||||
if (channel.getParentId() != null) {
|
||||
// 业务分组加上这一项即可,提高兼容性,
|
||||
catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n");
|
||||
}
|
||||
if (channel.getChannelId().length() == 20) {
|
||||
if (Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) { // 虚拟组织增加BusinessGroupID字段
|
||||
catalogXml.append("<BusinessGroupID>" + channel.getParentId() + "</BusinessGroupID>\r\n");
|
||||
}
|
||||
if (channel.getChannelId().length() == 20 && Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) {
|
||||
// 虚拟组织增加BusinessGroupID字段
|
||||
catalogXml.append("<BusinessGroupID>" + channel.getParentId() + "</BusinessGroupID>\r\n");
|
||||
}
|
||||
catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
|
||||
if (channel.getParental() == 0) {
|
||||
// 通道项
|
||||
catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n");
|
||||
catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");
|
||||
catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n");
|
||||
catalogXml.append("<Status>" + (channel.getStatus() == 0?"OFF":"ON") + "</Status>\r\n");
|
||||
if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下字段
|
||||
catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");
|
||||
catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n");
|
||||
|
||||
if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性
|
||||
catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n");
|
||||
catalogXml.append("<Owner>" + channel.getOwner() + "</Owner>\r\n");
|
||||
catalogXml.append("<Owner> " + channel.getOwner()+ "</Owner>\r\n");
|
||||
catalogXml.append("<CivilCode>" + channel.getCivilCode() + "</CivilCode>\r\n");
|
||||
catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n");
|
||||
catalogXml.append("<Longitude>" + channel.getLongitudeWgs84() + "</Longitude>\r\n");
|
||||
catalogXml.append("<Latitude>" + channel.getLatitudeWgs84() + "</Latitude>\r\n");
|
||||
catalogXml.append("<IPAddress>" + channel.getIpAddress() + "</IPAddress>\r\n");
|
||||
catalogXml.append("<Port>" + channel.getPort() + "</Port>\r\n");
|
||||
catalogXml.append("<Info>\r\n");
|
||||
catalogXml.append("<PTZType>" + channel.getPTZType() + "</PTZType>\r\n");
|
||||
catalogXml.append("</Info>\r\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
catalogXml.append("</Item>\r\n");
|
||||
}
|
||||
}
|
||||
@@ -592,27 +592,35 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
||||
channel.setParentId(parentPlatform.getDeviceGBId());
|
||||
}
|
||||
catalogXml.append("<Item>\r\n");
|
||||
// 行政区划分组只需要这两项就可以
|
||||
catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");
|
||||
catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n");
|
||||
catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n");
|
||||
catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
|
||||
if (channel.getParentId() != null) {
|
||||
// 业务分组加上这一项即可,提高兼容性,
|
||||
catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n");
|
||||
}
|
||||
catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");
|
||||
catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n");
|
||||
catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n");
|
||||
if (channel.getChannelId().length() == 20 && Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) { // 虚拟组织增加BusinessGroupID字段
|
||||
if (channel.getChannelId().length() == 20 && Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) {
|
||||
// 虚拟组织增加BusinessGroupID字段
|
||||
catalogXml.append("<BusinessGroupID>" + channel.getParentId() + "</BusinessGroupID>\r\n");
|
||||
}
|
||||
if (channel.getChannelType() == 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性
|
||||
catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n");
|
||||
catalogXml.append("<Owner>0</Owner>\r\n");
|
||||
catalogXml.append("<CivilCode>CivilCode</CivilCode>\r\n");
|
||||
catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n");
|
||||
}
|
||||
if (!"presence".equals(subscribeInfo.getEventType())) {
|
||||
catalogXml.append("<Event>" + type + "</Event>\r\n");
|
||||
catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
|
||||
if (channel.getParental() == 0) {
|
||||
// 通道项
|
||||
catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n");
|
||||
catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");
|
||||
catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n");
|
||||
catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n");
|
||||
|
||||
if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性
|
||||
catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n");
|
||||
catalogXml.append("<Owner> " + channel.getOwner()+ "</Owner>\r\n");
|
||||
catalogXml.append("<CivilCode>" + channel.getCivilCode() + "</CivilCode>\r\n");
|
||||
catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n");
|
||||
}
|
||||
if (!"presence".equals(subscribeInfo.getEventType())) {
|
||||
catalogXml.append("<Event>" + type + "</Event>\r\n");
|
||||
}
|
||||
|
||||
}
|
||||
catalogXml.append("</Item>\r\n");
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ 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;
|
||||
import com.genersoft.iot.vmp.service.IDeviceChannelService;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
@@ -71,6 +72,9 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
||||
@Autowired
|
||||
private SIPProcessorObserver sipProcessorObserver;
|
||||
|
||||
@Autowired
|
||||
private IDeviceChannelService deviceChannelService;
|
||||
|
||||
private boolean taskQueueHandlerRun = false;
|
||||
|
||||
private final ConcurrentLinkedQueue<HandlerCatchData> taskQueue = new ConcurrentLinkedQueue<>();
|
||||
@@ -173,28 +177,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
||||
logger.info("[收到 移动位置订阅]:{}/{}->{}.{}", mobilePosition.getDeviceId(), mobilePosition.getChannelId(),
|
||||
mobilePosition.getLongitude(), mobilePosition.getLatitude());
|
||||
mobilePosition.setReportSource("Mobile Position");
|
||||
// 默认来源坐标系为WGS-84处理
|
||||
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);
|
||||
}
|
||||
if (userSetting.getSavePositionHistory()) {
|
||||
storager.insertMobilePosition(mobilePosition);
|
||||
}
|
||||
|
||||
|
||||
// 更新device channel 的经纬度
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
@@ -202,11 +185,18 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
||||
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());
|
||||
deviceChannel.setGpsTime(mobilePosition.getTime());
|
||||
deviceChannel = deviceChannelService.updateGps(deviceChannel, device);
|
||||
|
||||
mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84());
|
||||
mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84());
|
||||
mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02());
|
||||
mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02());
|
||||
|
||||
if (userSetting.getSavePositionHistory()) {
|
||||
storager.insertMobilePosition(mobilePosition);
|
||||
}
|
||||
|
||||
storager.updateChannelPosition(deviceChannel);
|
||||
// 发送redis消息。 通知位置信息的变化
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
@@ -281,38 +271,28 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
||||
mobilePosition.setLongitude(deviceAlarm.getLongitude());
|
||||
mobilePosition.setLatitude(deviceAlarm.getLatitude());
|
||||
mobilePosition.setReportSource("GPS Alarm");
|
||||
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);
|
||||
}
|
||||
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());
|
||||
deviceChannel.setGpsTime(mobilePosition.getTime());
|
||||
|
||||
deviceChannel = deviceChannelService.updateGps(deviceChannel, device);
|
||||
|
||||
mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84());
|
||||
mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84());
|
||||
mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02());
|
||||
mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02());
|
||||
|
||||
if (userSetting.getSavePositionHistory()) {
|
||||
storager.insertMobilePosition(mobilePosition);
|
||||
}
|
||||
|
||||
storager.updateChannelPosition(deviceChannel);
|
||||
}
|
||||
// TODO: 需要实现存储报警信息、报警分类
|
||||
@@ -364,7 +344,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
||||
}else {
|
||||
event = eventElement.getText().toUpperCase();
|
||||
}
|
||||
DeviceChannel channel = XmlUtil.channelContentHander(itemDevice, device);
|
||||
DeviceChannel channel = XmlUtil.channelContentHander(itemDevice, device, event);
|
||||
channel.setDeviceId(device.getDeviceId());
|
||||
logger.info("[收到 目录订阅]:{}/{}", device.getDeviceId(), channel.getChannelId());
|
||||
switch (event) {
|
||||
@@ -389,7 +369,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
||||
case CatalogEvent.ADD:
|
||||
// 增加
|
||||
logger.info("收到来自设备【{}】的增加通道【{}】通知", device.getDeviceId(), channel.getChannelId());
|
||||
storager.updateChannel(deviceId, channel);
|
||||
deviceChannelService.updateChannel(deviceId, channel);
|
||||
break;
|
||||
case CatalogEvent.DEL:
|
||||
// 删除
|
||||
@@ -399,7 +379,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
|
||||
case CatalogEvent.UPDATE:
|
||||
// 更新
|
||||
logger.info("收到来自设备【{}】的更新通道【{}】通知", device.getDeviceId(), channel.getChannelId());
|
||||
storager.updateChannel(deviceId, channel);
|
||||
deviceChannelService.updateChannel(deviceId, channel);
|
||||
break;
|
||||
default:
|
||||
logger.warn("[ NotifyCatalog ] event not found : {}", event );
|
||||
|
||||
@@ -11,6 +11,7 @@ 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.service.IDeviceAlarmService;
|
||||
import com.genersoft.iot.vmp.service.IDeviceChannelService;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
@@ -58,6 +59,9 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
|
||||
@Autowired
|
||||
private IDeviceAlarmService deviceAlarmService;
|
||||
|
||||
@Autowired
|
||||
private IDeviceChannelService deviceChannelService;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
notifyMessageHandler.addHandler(cmdType, this);
|
||||
@@ -119,38 +123,26 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
|
||||
mobilePosition.setLongitude(deviceAlarm.getLongitude());
|
||||
mobilePosition.setLatitude(deviceAlarm.getLatitude());
|
||||
mobilePosition.setReportSource("GPS Alarm");
|
||||
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);
|
||||
}
|
||||
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());
|
||||
deviceChannel.setGpsTime(mobilePosition.getTime());
|
||||
|
||||
deviceChannel = deviceChannelService.updateGps(deviceChannel, device);
|
||||
|
||||
mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84());
|
||||
mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84());
|
||||
mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02());
|
||||
mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02());
|
||||
|
||||
if (userSetting.getSavePositionHistory()) {
|
||||
storager.insertMobilePosition(mobilePosition);
|
||||
}
|
||||
storager.updateChannelPosition(deviceChannel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,85 +58,21 @@ public class CatalogNotifyMessageHandler extends SIPRequestProcessorParent imple
|
||||
// 准备回复通道信息
|
||||
List<DeviceChannelInPlatform> deviceChannels = storage.queryChannelListInParentPlatform(parentPlatform.getServerGBId());
|
||||
// 查询关联的直播通道
|
||||
List<GbStream> gbStreams = storage.queryGbStreamListInPlatform(parentPlatform.getServerGBId());
|
||||
List<DeviceChannel> gbStreams = storage.queryGbStreamListInPlatform(parentPlatform.getServerGBId());
|
||||
// 回复目录信息
|
||||
List<DeviceChannel> catalogs = storage.queryCatalogInPlatform(parentPlatform.getServerGBId());
|
||||
|
||||
List<DeviceChannel> allChannels = new ArrayList<>();
|
||||
// 回复目录信息
|
||||
List<PlatformCatalog> catalogs = storage.queryCatalogInPlatform(parentPlatform.getServerGBId());
|
||||
if (catalogs.size() > 0) {
|
||||
for (PlatformCatalog catalog : catalogs) {
|
||||
if (catalog.getParentId().equals(catalog.getPlatformId())) {
|
||||
catalog.setParentId(parentPlatform.getDeviceGBId());
|
||||
}
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
deviceChannel.setChannelId(catalog.getId());
|
||||
deviceChannel.setName(catalog.getName());
|
||||
deviceChannel.setLongitude(0.0);
|
||||
deviceChannel.setLatitude(0.0);
|
||||
deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
|
||||
deviceChannel.setManufacture("wvp-pro");
|
||||
deviceChannel.setStatus(1);
|
||||
deviceChannel.setParental(1);
|
||||
deviceChannel.setParentId(catalog.getParentId());
|
||||
deviceChannel.setRegisterWay(1);
|
||||
if (catalog.getParentId() != null && catalog.getParentId().length() <= 10) {
|
||||
deviceChannel.setCivilCode(catalog.getParentId());
|
||||
}else {
|
||||
deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
|
||||
}
|
||||
deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
|
||||
deviceChannel.setModel("live");
|
||||
deviceChannel.setOwner("wvp-pro");
|
||||
deviceChannel.setSecrecy("0");
|
||||
allChannels.add(deviceChannel);
|
||||
}
|
||||
allChannels.addAll(catalogs);
|
||||
}
|
||||
// 回复级联的通道
|
||||
if (deviceChannels.size() > 0) {
|
||||
for (DeviceChannelInPlatform channel : deviceChannels) {
|
||||
if (channel.getCatalogId().equals(parentPlatform.getServerGBId())) {
|
||||
channel.setCatalogId(parentPlatform.getDeviceGBId());
|
||||
}
|
||||
DeviceChannel deviceChannel = storage.queryChannel(channel.getDeviceId(), channel.getChannelId());
|
||||
deviceChannel.setParental(0);
|
||||
deviceChannel.setParentId(channel.getCatalogId());
|
||||
if (channel.getCatalogId() != null && channel.getCatalogId().length() <= 10) {
|
||||
channel.setCivilCode(channel.getCatalogId());
|
||||
}else {
|
||||
deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
|
||||
}
|
||||
|
||||
allChannels.add(deviceChannel);
|
||||
}
|
||||
allChannels.addAll(deviceChannels);
|
||||
}
|
||||
// 回复直播的通道
|
||||
if (gbStreams.size() > 0) {
|
||||
for (GbStream gbStream : gbStreams) {
|
||||
if (gbStream.getCatalogId().equals(parentPlatform.getServerGBId())) {
|
||||
gbStream.setCatalogId(null);
|
||||
}
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
deviceChannel.setChannelId(gbStream.getGbId());
|
||||
deviceChannel.setName(gbStream.getName());
|
||||
deviceChannel.setLongitude(gbStream.getLongitude());
|
||||
deviceChannel.setLatitude(gbStream.getLatitude());
|
||||
deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
|
||||
deviceChannel.setManufacture("wvp-pro");
|
||||
// deviceChannel.setStatus(gbStream.isStatus()?1:0);
|
||||
deviceChannel.setStatus(1);
|
||||
deviceChannel.setParentId(gbStream.getCatalogId());
|
||||
deviceChannel.setRegisterWay(1);
|
||||
if (gbStream.getCatalogId() != null && gbStream.getCatalogId().length() <= 10) {
|
||||
deviceChannel.setCivilCode(gbStream.getCatalogId());
|
||||
}else {
|
||||
deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
|
||||
}
|
||||
deviceChannel.setModel("live");
|
||||
deviceChannel.setOwner("wvp-pro");
|
||||
deviceChannel.setParental(0);
|
||||
deviceChannel.setSecrecy("0");
|
||||
allChannels.add(deviceChannel);
|
||||
}
|
||||
allChannels.addAll(gbStreams);
|
||||
}
|
||||
if (allChannels.size() > 0) {
|
||||
cmderFroPlatform.catalogQuery(allChannels, parentPlatform, sn, fromHeader.getTag());
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessag
|
||||
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.IDeviceChannelService;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.utils.GpsUtil;
|
||||
@@ -42,6 +43,9 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen
|
||||
@Autowired
|
||||
private IVideoManagerStorage storager;
|
||||
|
||||
@Autowired
|
||||
private IDeviceChannelService deviceChannelService;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
notifyMessageHandler.addHandler(cmdType, this);
|
||||
@@ -79,38 +83,26 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen
|
||||
mobilePosition.setAltitude(0.0);
|
||||
}
|
||||
mobilePosition.setReportSource("Mobile Position");
|
||||
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);
|
||||
}
|
||||
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());
|
||||
deviceChannel.setGpsTime(mobilePosition.getTime());
|
||||
|
||||
deviceChannel = deviceChannelService.updateGps(deviceChannel, device);
|
||||
|
||||
mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84());
|
||||
mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84());
|
||||
mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02());
|
||||
mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02());
|
||||
|
||||
if (userSetting.getSavePositionHistory()) {
|
||||
storager.insertMobilePosition(mobilePosition);
|
||||
}
|
||||
storager.updateChannelPosition(deviceChannel);
|
||||
//回复 200 OK
|
||||
responseAck(evt, Response.OK);
|
||||
|
||||
@@ -70,86 +70,24 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
|
||||
Element snElement = rootElement.element("SN");
|
||||
String sn = snElement.getText();
|
||||
// 准备回复通道信息
|
||||
List<DeviceChannelInPlatform> deviceChannelInPlatforms = storager.queryChannelListInParentPlatform(parentPlatform.getServerGBId());
|
||||
List<DeviceChannel> deviceChannelInPlatforms = storager.queryChannelWithCatalog(parentPlatform.getServerGBId());
|
||||
// 查询关联的直播通道
|
||||
List<GbStream> gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId());
|
||||
List<DeviceChannel> gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId());
|
||||
// 回复目录信息
|
||||
List<PlatformCatalog> catalogs = storager.queryCatalogInPlatform(parentPlatform.getServerGBId());
|
||||
List<DeviceChannel> catalogs = storager.queryCatalogInPlatform(parentPlatform.getServerGBId());
|
||||
|
||||
List<DeviceChannel> allChannels = new ArrayList<>();
|
||||
|
||||
if (catalogs.size() > 0) {
|
||||
for (PlatformCatalog catalog : catalogs) {
|
||||
if (catalog.getParentId().equals(catalog.getPlatformId())) {
|
||||
catalog.setParentId(parentPlatform.getDeviceGBId());
|
||||
}
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
// 通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划
|
||||
deviceChannel.setChannelType(2);
|
||||
deviceChannel.setChannelId(catalog.getId());
|
||||
deviceChannel.setName(catalog.getName());
|
||||
deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
|
||||
deviceChannel.setManufacture("wvp-pro");
|
||||
deviceChannel.setStatus(1);
|
||||
deviceChannel.setParental(1);
|
||||
deviceChannel.setParentId(catalog.getParentId());
|
||||
deviceChannel.setRegisterWay(1);
|
||||
if (catalog.getParentId() != null && catalog.getParentId().length() < 10) {
|
||||
deviceChannel.setCivilCode(catalog.getParentId());
|
||||
}else {
|
||||
deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
|
||||
}
|
||||
allChannels.add(deviceChannel);
|
||||
}
|
||||
allChannels.addAll(catalogs);
|
||||
}
|
||||
// 回复级联的通道
|
||||
if (deviceChannelInPlatforms.size() > 0) {
|
||||
for (DeviceChannelInPlatform channel : deviceChannelInPlatforms) {
|
||||
if (channel.getCatalogId().equals(parentPlatform.getServerGBId())) {
|
||||
channel.setCatalogId(parentPlatform.getDeviceGBId());
|
||||
}
|
||||
DeviceChannel deviceChannel = storage.queryChannel(channel.getDeviceId(), channel.getChannelId());
|
||||
// 通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划
|
||||
deviceChannel.setChannelType(0);
|
||||
deviceChannel.setParental(0);
|
||||
deviceChannel.setParentId(channel.getCatalogId());
|
||||
if (channel.getCatalogId() != null && channel.getCatalogId().length() < 10) {
|
||||
deviceChannel.setCivilCode(channel.getCatalogId());
|
||||
}else {
|
||||
deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
|
||||
}
|
||||
allChannels.add(deviceChannel);
|
||||
}
|
||||
allChannels.addAll(deviceChannelInPlatforms);
|
||||
}
|
||||
// 回复直播的通道
|
||||
if (gbStreams.size() > 0) {
|
||||
for (GbStream gbStream : gbStreams) {
|
||||
if (gbStream.getCatalogId().equals(parentPlatform.getServerGBId())) {
|
||||
gbStream.setCatalogId(null);
|
||||
}
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
// 通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划
|
||||
deviceChannel.setChannelType(1);
|
||||
deviceChannel.setChannelId(gbStream.getGbId());
|
||||
deviceChannel.setName(gbStream.getName());
|
||||
deviceChannel.setLongitude(gbStream.getLongitude());
|
||||
deviceChannel.setLatitude(gbStream.getLatitude());
|
||||
deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
|
||||
deviceChannel.setManufacture("wvp-pro");
|
||||
// deviceChannel.setStatus(gbStream.isStatus()?1:0);
|
||||
deviceChannel.setStatus(1);
|
||||
deviceChannel.setParentId(gbStream.getCatalogId());
|
||||
deviceChannel.setRegisterWay(1);
|
||||
if (gbStream.getCatalogId() != null && gbStream.getCatalogId().length() < 10) {
|
||||
deviceChannel.setCivilCode(gbStream.getCatalogId());
|
||||
}else {
|
||||
deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
|
||||
}
|
||||
deviceChannel.setModel("live");
|
||||
deviceChannel.setOwner("wvp-pro");
|
||||
deviceChannel.setParental(0);
|
||||
deviceChannel.setSecrecy("0");
|
||||
allChannels.add(deviceChannel);
|
||||
}
|
||||
allChannels.addAll(gbStreams);
|
||||
}
|
||||
if (allChannels.size() > 0) {
|
||||
cmderFroPlatform.catalogQuery(allChannels, parentPlatform, sn, fromHeader.getTag());
|
||||
|
||||
@@ -125,11 +125,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
|
||||
if (channelDeviceElement == null) {
|
||||
continue;
|
||||
}
|
||||
//by brewswang
|
||||
// if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {//如果包含位置信息,就更新一下位置
|
||||
// processNotifyMobilePosition(evt, itemDevice);
|
||||
// }
|
||||
DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice, device);
|
||||
DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice, device, null);
|
||||
deviceChannel.setDeviceId(take.getDevice().getDeviceId());
|
||||
|
||||
channelList.add(deviceChannel);
|
||||
|
||||
@@ -87,7 +87,6 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent
|
||||
device.setStreamMode("UDP");
|
||||
}
|
||||
deviceService.updateDevice(device);
|
||||
// storager.updateDevice(device);
|
||||
|
||||
RequestMessage msg = new RequestMessage();
|
||||
msg.setKey(key);
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessag
|
||||
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.service.IDeviceChannelService;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.utils.GpsUtil;
|
||||
@@ -42,6 +43,9 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar
|
||||
@Autowired
|
||||
private IVideoManagerStorage storager;
|
||||
|
||||
@Autowired
|
||||
private IDeviceChannelService deviceChannelService;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
responseMessageHandler.addHandler(cmdType, this);
|
||||
@@ -79,38 +83,25 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar
|
||||
mobilePosition.setAltitude(0.0);
|
||||
}
|
||||
mobilePosition.setReportSource("Mobile Position");
|
||||
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);
|
||||
}
|
||||
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());
|
||||
deviceChannel.setGpsTime(mobilePosition.getTime());
|
||||
|
||||
deviceChannel = deviceChannelService.updateGps(deviceChannel, device);
|
||||
|
||||
mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84());
|
||||
mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84());
|
||||
mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02());
|
||||
mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02());
|
||||
|
||||
if (userSetting.getSavePositionHistory()) {
|
||||
storager.insertMobilePosition(mobilePosition);
|
||||
}
|
||||
storager.updateChannelPosition(deviceChannel);
|
||||
//回复 200 OK
|
||||
responseAck(evt, Response.OK);
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.TreeType;
|
||||
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import org.dom4j.Attribute;
|
||||
import org.dom4j.Document;
|
||||
@@ -29,7 +31,7 @@ public class XmlUtil {
|
||||
/**
|
||||
* 日志服务
|
||||
*/
|
||||
private static Logger LOG = LoggerFactory.getLogger(XmlUtil.class);
|
||||
private static Logger logger = LoggerFactory.getLogger(XmlUtil.class);
|
||||
|
||||
/**
|
||||
* 解析XML为Document对象
|
||||
@@ -46,7 +48,7 @@ public class XmlUtil {
|
||||
try {
|
||||
document = saxReader.read(sr);
|
||||
} catch (DocumentException e) {
|
||||
LOG.error("解析失败", e);
|
||||
logger.error("解析失败", e);
|
||||
}
|
||||
return null == document ? null : document.getRootElement();
|
||||
}
|
||||
@@ -182,47 +184,69 @@ public class XmlUtil {
|
||||
return xml.getRootElement();
|
||||
}
|
||||
|
||||
public static DeviceChannel channelContentHander(Element itemDevice, Device device){
|
||||
Element channdelNameElement = itemDevice.element("Name");
|
||||
String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim().toString() : "";
|
||||
Element statusElement = itemDevice.element("Status");
|
||||
String status = statusElement != null ? statusElement.getTextTrim().toString() : "ON";
|
||||
private enum ChannelType{
|
||||
CivilCode, BusinessGroup,VirtualOrganization,Other
|
||||
}
|
||||
|
||||
public static DeviceChannel channelContentHander(Element itemDevice, Device device, String event){
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
deviceChannel.setName(channelName);
|
||||
deviceChannel.setDeviceId(device.getDeviceId());
|
||||
Element channdelIdElement = itemDevice.element("DeviceID");
|
||||
String channelId = channdelIdElement != null ? channdelIdElement.getTextTrim().toString() : "";
|
||||
deviceChannel.setChannelId(channelId);
|
||||
// ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理
|
||||
if (status.equals("ON") || status.equals("On") || status.equals("ONLINE") || status.equals("OK")) {
|
||||
deviceChannel.setStatus(1);
|
||||
if (channdelIdElement == null) {
|
||||
logger.warn("解析Catalog消息时发现缺少 DeviceID");
|
||||
return null;
|
||||
}
|
||||
if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) {
|
||||
deviceChannel.setStatus(0);
|
||||
String channelId = channdelIdElement.getTextTrim();
|
||||
if (StringUtils.isEmpty(channelId)) {
|
||||
logger.warn("解析Catalog消息时发现缺少 DeviceID");
|
||||
return null;
|
||||
}
|
||||
deviceChannel.setChannelId(channelId);
|
||||
if (event != null && !event.equals(CatalogEvent.ADD) && !event.equals(CatalogEvent.UPDATE)) {
|
||||
// 除了ADD和update情况下需要识别全部内容,
|
||||
return deviceChannel;
|
||||
}
|
||||
|
||||
deviceChannel.setManufacture(XmlUtil.getText(itemDevice, "Manufacturer"));
|
||||
deviceChannel.setModel(XmlUtil.getText(itemDevice, "Model"));
|
||||
deviceChannel.setOwner(XmlUtil.getText(itemDevice, "Owner"));
|
||||
deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode"));
|
||||
deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block"));
|
||||
deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address"));
|
||||
String businessGroupID = XmlUtil.getText(itemDevice, "BusinessGroupID");
|
||||
if (XmlUtil.getText(itemDevice, "Parental") == null
|
||||
|| XmlUtil.getText(itemDevice, "Parental").equals("")) {
|
||||
if (deviceChannel.getChannelId().length() <= 10
|
||||
|| (deviceChannel.getChannelId().length() == 20 && (
|
||||
Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 215
|
||||
|| Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 216
|
||||
)
|
||||
)
|
||||
) {
|
||||
deviceChannel.setParental(1);
|
||||
}else {
|
||||
deviceChannel.setParental(0);
|
||||
ChannelType channelType = ChannelType.Other;
|
||||
if (channelId.length() <= 8) {
|
||||
channelType = ChannelType.CivilCode;
|
||||
}else {
|
||||
if (channelId.length() == 20) {
|
||||
int code = Integer.parseInt(channelId.substring(10, 13));
|
||||
switch (code){
|
||||
case 215:
|
||||
channelType = ChannelType.BusinessGroup;
|
||||
break;
|
||||
case 216:
|
||||
channelType = ChannelType.VirtualOrganization;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 由于海康会错误的发送65535作为这里的取值,所以这里除非是0否则认为是1
|
||||
deviceChannel.setParental(Integer.parseInt(XmlUtil.getText(itemDevice, "Parental")) == 1?1:0);
|
||||
}
|
||||
|
||||
Element channdelNameElement = itemDevice.element("Name");
|
||||
String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim() : "";
|
||||
deviceChannel.setName(channelName);
|
||||
|
||||
String civilCode = XmlUtil.getText(itemDevice, "CivilCode");
|
||||
deviceChannel.setCivilCode(civilCode);
|
||||
if (channelType == ChannelType.CivilCode && civilCode == null) {
|
||||
deviceChannel.setParental(1);
|
||||
// 行政区划如果没有传递具体值,则推测一个
|
||||
if (channelId.length() > 2) {
|
||||
deviceChannel.setCivilCode(channelId.substring(0, channelId.length() - 2));
|
||||
}
|
||||
}
|
||||
if (channelType.equals(ChannelType.CivilCode)) {
|
||||
// 行政区划其他字段没必要识别了,默认在线即可
|
||||
deviceChannel.setStatus(1);
|
||||
deviceChannel.setParental(1);
|
||||
deviceChannel.setCreateTime(DateUtil.getNow());
|
||||
deviceChannel.setUpdateTime(DateUtil.getNow());
|
||||
return deviceChannel;
|
||||
}
|
||||
/**
|
||||
* 行政区划展示设备树与业务分组展示设备树是两种不同的模式
|
||||
@@ -230,7 +254,17 @@ public class XmlUtil {
|
||||
* 河北省
|
||||
* --> 石家庄市
|
||||
* --> 摄像头
|
||||
* --> 正定县
|
||||
*String parentId = XmlUtil.getText(itemDevice, "ParentID");
|
||||
if (parentId != null) {
|
||||
if (parentId.contains("/")) {
|
||||
String lastParentId = parentId.substring(parentId.lastIndexOf("/") + 1);
|
||||
String businessGroup = parentId.substring(0, parentId.indexOf("/"));
|
||||
deviceChannel.setParentId(lastParentId);
|
||||
}else {
|
||||
deviceChannel.setParentId(parentId);
|
||||
}
|
||||
}
|
||||
deviceCh --> 正定县
|
||||
* --> 摄像头
|
||||
* --> 摄像头
|
||||
*
|
||||
@@ -243,59 +277,88 @@ public class XmlUtil {
|
||||
* --> 摄像头
|
||||
*/
|
||||
String parentId = XmlUtil.getText(itemDevice, "ParentID");
|
||||
String businessGroupID = XmlUtil.getText(itemDevice, "BusinessGroupID");
|
||||
if (parentId != null) {
|
||||
if (parentId.contains("/")) {
|
||||
String lastParentId = parentId.substring(parentId.lastIndexOf("/") + 1);
|
||||
if (businessGroupID == null) {
|
||||
businessGroupID = parentId.substring(0, parentId.indexOf("/"));
|
||||
}
|
||||
deviceChannel.setParentId(lastParentId);
|
||||
}else {
|
||||
deviceChannel.setParentId(parentId);
|
||||
}
|
||||
}
|
||||
deviceChannel.setBusinessGroupId(businessGroupID);
|
||||
if (channelType.equals(ChannelType.BusinessGroup) || channelType.equals(ChannelType.VirtualOrganization)) {
|
||||
// 业务分组和虚拟组织 其他字段没必要识别了,默认在线即可
|
||||
deviceChannel.setStatus(1);
|
||||
deviceChannel.setParental(1);
|
||||
deviceChannel.setCreateTime(DateUtil.getNow());
|
||||
deviceChannel.setUpdateTime(DateUtil.getNow());
|
||||
return deviceChannel;
|
||||
}
|
||||
|
||||
// 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());
|
||||
// }
|
||||
// }
|
||||
Element statusElement = itemDevice.element("Status");
|
||||
|
||||
if (XmlUtil.getText(itemDevice, "SafetyWay") == null
|
||||
|| XmlUtil.getText(itemDevice, "SafetyWay") == "") {
|
||||
if (statusElement != null) {
|
||||
String status = statusElement.getTextTrim().trim();
|
||||
// ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理
|
||||
if (status.equals("ON") || status.equals("On") || status.equals("ONLINE") || status.equals("OK")) {
|
||||
deviceChannel.setStatus(1);
|
||||
}
|
||||
if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) {
|
||||
deviceChannel.setStatus(0);
|
||||
}
|
||||
}else {
|
||||
deviceChannel.setStatus(1);
|
||||
}
|
||||
// 识别自带的目录标识
|
||||
String parental = XmlUtil.getText(itemDevice, "Parental");
|
||||
// 由于海康会错误的发送65535作为这里的取值,所以这里除非是0否则认为是1
|
||||
if (!StringUtils.isEmpty(parental) && parental.length() == 1 && Integer.parseInt(parental) == 0) {
|
||||
deviceChannel.setParental(0);
|
||||
}else {
|
||||
deviceChannel.setParental(1);
|
||||
}
|
||||
|
||||
|
||||
deviceChannel.setManufacture(XmlUtil.getText(itemDevice, "Manufacturer"));
|
||||
deviceChannel.setModel(XmlUtil.getText(itemDevice, "Model"));
|
||||
deviceChannel.setOwner(XmlUtil.getText(itemDevice, "Owner"));
|
||||
deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum"));
|
||||
deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block"));
|
||||
deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address"));
|
||||
deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password"));
|
||||
|
||||
String safetyWay = XmlUtil.getText(itemDevice, "SafetyWay");
|
||||
if (StringUtils.isEmpty(safetyWay)) {
|
||||
deviceChannel.setSafetyWay(0);
|
||||
} else {
|
||||
deviceChannel.setSafetyWay(Integer.parseInt(XmlUtil.getText(itemDevice, "SafetyWay")));
|
||||
deviceChannel.setSafetyWay(Integer.parseInt(safetyWay));
|
||||
}
|
||||
if (XmlUtil.getText(itemDevice, "RegisterWay") == null
|
||||
|| XmlUtil.getText(itemDevice, "RegisterWay") == "") {
|
||||
|
||||
String registerWay = XmlUtil.getText(itemDevice, "RegisterWay");
|
||||
if (StringUtils.isEmpty(registerWay)) {
|
||||
deviceChannel.setRegisterWay(1);
|
||||
} else {
|
||||
deviceChannel.setRegisterWay(Integer.parseInt(XmlUtil.getText(itemDevice, "RegisterWay")));
|
||||
deviceChannel.setRegisterWay(Integer.parseInt(registerWay));
|
||||
}
|
||||
deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum"));
|
||||
|
||||
if (XmlUtil.getText(itemDevice, "Certifiable") == null
|
||||
|| XmlUtil.getText(itemDevice, "Certifiable") == "") {
|
||||
deviceChannel.setCertifiable(0);
|
||||
} else {
|
||||
deviceChannel.setCertifiable(Integer.parseInt(XmlUtil.getText(itemDevice, "Certifiable")));
|
||||
}
|
||||
|
||||
if (XmlUtil.getText(itemDevice, "ErrCode") == null
|
||||
|| XmlUtil.getText(itemDevice, "ErrCode") == "") {
|
||||
deviceChannel.setErrCode(0);
|
||||
} else {
|
||||
deviceChannel.setErrCode(Integer.parseInt(XmlUtil.getText(itemDevice, "ErrCode")));
|
||||
}
|
||||
|
||||
deviceChannel.setEndTime(XmlUtil.getText(itemDevice, "EndTime"));
|
||||
deviceChannel.setSecrecy(XmlUtil.getText(itemDevice, "Secrecy"));
|
||||
deviceChannel.setIpAddress(XmlUtil.getText(itemDevice, "IPAddress"));
|
||||
@@ -304,43 +367,23 @@ public class XmlUtil {
|
||||
} else {
|
||||
deviceChannel.setPort(Integer.parseInt(XmlUtil.getText(itemDevice, "Port")));
|
||||
}
|
||||
deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password"));
|
||||
if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {
|
||||
deviceChannel.setLongitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Longitude")));
|
||||
|
||||
|
||||
String longitude = XmlUtil.getText(itemDevice, "Longitude");
|
||||
if (NumericUtil.isDouble(longitude)) {
|
||||
deviceChannel.setLongitude(Double.parseDouble(longitude));
|
||||
} else {
|
||||
deviceChannel.setLongitude(0.00);
|
||||
}
|
||||
if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Latitude"))) {
|
||||
deviceChannel.setLatitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Latitude")));
|
||||
String latitude = XmlUtil.getText(itemDevice, "Latitude");
|
||||
if (NumericUtil.isDouble(latitude)) {
|
||||
deviceChannel.setLatitude(Double.parseDouble(latitude));
|
||||
} else {
|
||||
deviceChannel.setLatitude(0.00);
|
||||
}
|
||||
deviceChannel.setGpsTime(DateUtil.getNow());
|
||||
if (deviceChannel.getLongitude()*deviceChannel.getLatitude() > 0) {
|
||||
if ("WGS84".equals(device.getGeoCoordSys())) {
|
||||
deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
|
||||
deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
|
||||
Double[] position = Coordtransform.WGS84ToGCJ02(deviceChannel.getLongitude(), deviceChannel.getLatitude());
|
||||
deviceChannel.setLongitudeGcj02(position[0]);
|
||||
deviceChannel.setLatitudeGcj02(position[1]);
|
||||
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
|
||||
deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
|
||||
deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
|
||||
Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude());
|
||||
deviceChannel.setLongitudeWgs84(position[0]);
|
||||
deviceChannel.setLatitudeWgs84(position[1]);
|
||||
}else {
|
||||
deviceChannel.setLongitudeGcj02(0.00);
|
||||
deviceChannel.setLatitudeGcj02(0.00);
|
||||
deviceChannel.setLongitudeWgs84(0.00);
|
||||
deviceChannel.setLatitudeWgs84(0.00);
|
||||
}
|
||||
}else {
|
||||
deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
|
||||
deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
|
||||
deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
|
||||
deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
|
||||
}
|
||||
|
||||
|
||||
if (XmlUtil.getText(itemDevice, "PTZType") == null || "".equals(XmlUtil.getText(itemDevice, "PTZType"))) {
|
||||
//兼容INFO中的信息
|
||||
Element info = itemDevice.element("Info");
|
||||
|
||||
Reference in New Issue
Block a user