|
@ -50,26 +50,20 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor { |
|
|
|
|
|
|
|
|
private final static Logger logger = LoggerFactory.getLogger(MessageRequestProcessor.class); |
|
|
private final static Logger logger = LoggerFactory.getLogger(MessageRequestProcessor.class); |
|
|
|
|
|
|
|
|
private SIPCommander cmder; |
|
|
|
|
|
|
|
|
|
|
|
private IVideoManagerStorager storager; |
|
|
private IVideoManagerStorager storager; |
|
|
|
|
|
|
|
|
private IRedisCatchStorage redisCatchStorage; |
|
|
private IRedisCatchStorage redisCatchStorage; |
|
|
|
|
|
|
|
|
private EventPublisher publisher; |
|
|
private EventPublisher publisher; |
|
|
|
|
|
|
|
|
private RedisUtil redis; |
|
|
|
|
|
|
|
|
|
|
|
private DeferredResultHolder deferredResultHolder; |
|
|
|
|
|
|
|
|
|
|
|
private DeviceOffLineDetector offLineDetector; |
|
|
private DeviceOffLineDetector offLineDetector; |
|
|
|
|
|
|
|
|
private static final String NOTIFY_CATALOG = "Catalog"; |
|
|
private static final String NOTIFY_CATALOG = "Catalog"; |
|
|
private static final String NOTIFY_ALARM = "Alarm"; |
|
|
private static final String NOTIFY_ALARM = "Alarm"; |
|
|
private static final String NOTIFY_MOBILE_POSITION = "MobilePosition"; |
|
|
private static final String NOTIFY_MOBILE_POSITION = "MobilePosition"; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void process(RequestEvent evt) { |
|
|
public void process(RequestEvent evt) { |
|
|
try { |
|
|
try { |
|
|
Element rootElement = getRootElement(evt); |
|
|
Element rootElement = getRootElement(evt); |
|
|
String cmd = XmlUtil.getText(rootElement, "CmdType"); |
|
|
String cmd = XmlUtil.getText(rootElement, "CmdType"); |
|
@ -87,18 +81,19 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor { |
|
|
logger.info("接收到消息:" + cmd); |
|
|
logger.info("接收到消息:" + cmd); |
|
|
response200Ok(evt); |
|
|
response200Ok(evt); |
|
|
} |
|
|
} |
|
|
} catch (DocumentException | SipException |InvalidArgumentException | ParseException e) { |
|
|
} catch (DocumentException | SipException | InvalidArgumentException | ParseException e) { |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 处理MobilePosition移动位置Notify |
|
|
* 处理MobilePosition移动位置Notify |
|
|
|
|
|
* |
|
|
* @param evt |
|
|
* @param evt |
|
|
*/ |
|
|
*/ |
|
|
private void processNotifyMobilePosition(RequestEvent evt) { |
|
|
private void processNotifyMobilePosition(RequestEvent evt) { |
|
|
try { |
|
|
try { |
|
|
//回复 200 OK
|
|
|
// 回复 200 OK
|
|
|
Element rootElement = getRootElement(evt); |
|
|
Element rootElement = getRootElement(evt); |
|
|
MobilePosition mobilePosition = new MobilePosition(); |
|
|
MobilePosition mobilePosition = new MobilePosition(); |
|
|
Element deviceIdElement = rootElement.element("DeviceID"); |
|
|
Element deviceIdElement = rootElement.element("DeviceID"); |
|
@ -112,8 +107,8 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor { |
|
|
mobilePosition.setDeviceId(XmlUtil.getText(rootElement, "DeviceID")); |
|
|
mobilePosition.setDeviceId(XmlUtil.getText(rootElement, "DeviceID")); |
|
|
mobilePosition.setTime(XmlUtil.getText(rootElement, "Time")); |
|
|
mobilePosition.setTime(XmlUtil.getText(rootElement, "Time")); |
|
|
mobilePosition.setLongitude(Double.parseDouble(XmlUtil.getText(rootElement, "Longitude"))); |
|
|
mobilePosition.setLongitude(Double.parseDouble(XmlUtil.getText(rootElement, "Longitude"))); |
|
|
mobilePosition.setLatitude(Double.parseDouble(XmlUtil.getText(rootElement, "Latitude"))); |
|
|
mobilePosition.setLatitude(Double.parseDouble(XmlUtil.getText(rootElement, "Latitude"))); |
|
|
if (NumericUtil.isDouble(XmlUtil.getText(rootElement, "Speed"))) { |
|
|
if (NumericUtil.isDouble(XmlUtil.getText(rootElement, "Speed"))) { |
|
|
mobilePosition.setSpeed(Double.parseDouble(XmlUtil.getText(rootElement, "Speed"))); |
|
|
mobilePosition.setSpeed(Double.parseDouble(XmlUtil.getText(rootElement, "Speed"))); |
|
|
} else { |
|
|
} else { |
|
|
mobilePosition.setSpeed(0.0); |
|
|
mobilePosition.setSpeed(0.0); |
|
@ -147,6 +142,7 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor { |
|
|
|
|
|
|
|
|
/*** |
|
|
/*** |
|
|
* 处理alarm设备报警Notify |
|
|
* 处理alarm设备报警Notify |
|
|
|
|
|
* |
|
|
* @param evt |
|
|
* @param evt |
|
|
*/ |
|
|
*/ |
|
|
private void processNotifyAlarm(RequestEvent evt) { |
|
|
private void processNotifyAlarm(RequestEvent evt) { |
|
@ -180,7 +176,7 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor { |
|
|
deviceAlarm.setLatitude(0.00); |
|
|
deviceAlarm.setLatitude(0.00); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ( deviceAlarm.getAlarmMethod().equals("4")) { |
|
|
if (deviceAlarm.getAlarmMethod().equals("4")) { |
|
|
MobilePosition mobilePosition = new MobilePosition(); |
|
|
MobilePosition mobilePosition = new MobilePosition(); |
|
|
mobilePosition.setDeviceId(deviceAlarm.getDeviceId()); |
|
|
mobilePosition.setDeviceId(deviceAlarm.getDeviceId()); |
|
|
mobilePosition.setTime(deviceAlarm.getAlarmTime()); |
|
|
mobilePosition.setTime(deviceAlarm.getAlarmTime()); |
|
@ -245,7 +241,7 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor { |
|
|
DeviceChannel deviceChannel = new DeviceChannel(); |
|
|
DeviceChannel deviceChannel = new DeviceChannel(); |
|
|
deviceChannel.setName(channelName); |
|
|
deviceChannel.setName(channelName); |
|
|
deviceChannel.setChannelId(channelDeviceId); |
|
|
deviceChannel.setChannelId(channelDeviceId); |
|
|
// ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理
|
|
|
// ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理
|
|
|
if (status.equals("ON") || status.equals("On") || status.equals("ONLINE")) { |
|
|
if (status.equals("ON") || status.equals("On") || status.equals("ONLINE")) { |
|
|
deviceChannel.setStatus(1); |
|
|
deviceChannel.setStatus(1); |
|
|
} |
|
|
} |
|
@ -259,29 +255,34 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor { |
|
|
deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode")); |
|
|
deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode")); |
|
|
deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block")); |
|
|
deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block")); |
|
|
deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address")); |
|
|
deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address")); |
|
|
if (XmlUtil.getText(itemDevice, "Parental") == null || XmlUtil.getText(itemDevice, "Parental") == "") { |
|
|
if (XmlUtil.getText(itemDevice, "Parental") == null |
|
|
|
|
|
|| XmlUtil.getText(itemDevice, "Parental") == "") { |
|
|
deviceChannel.setParental(0); |
|
|
deviceChannel.setParental(0); |
|
|
} else { |
|
|
} else { |
|
|
deviceChannel.setParental(Integer.parseInt(XmlUtil.getText(itemDevice, "Parental"))); |
|
|
deviceChannel.setParental(Integer.parseInt(XmlUtil.getText(itemDevice, "Parental"))); |
|
|
} |
|
|
} |
|
|
deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID")); |
|
|
deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID")); |
|
|
if (XmlUtil.getText(itemDevice, "SafetyWay") == null || XmlUtil.getText(itemDevice, "SafetyWay")== "") { |
|
|
if (XmlUtil.getText(itemDevice, "SafetyWay") == null |
|
|
|
|
|
|| XmlUtil.getText(itemDevice, "SafetyWay") == "") { |
|
|
deviceChannel.setSafetyWay(0); |
|
|
deviceChannel.setSafetyWay(0); |
|
|
} else { |
|
|
} else { |
|
|
deviceChannel.setSafetyWay(Integer.parseInt(XmlUtil.getText(itemDevice, "SafetyWay"))); |
|
|
deviceChannel.setSafetyWay(Integer.parseInt(XmlUtil.getText(itemDevice, "SafetyWay"))); |
|
|
} |
|
|
} |
|
|
if (XmlUtil.getText(itemDevice, "RegisterWay") == null || XmlUtil.getText(itemDevice, "RegisterWay") =="") { |
|
|
if (XmlUtil.getText(itemDevice, "RegisterWay") == null |
|
|
|
|
|
|| XmlUtil.getText(itemDevice, "RegisterWay") == "") { |
|
|
deviceChannel.setRegisterWay(1); |
|
|
deviceChannel.setRegisterWay(1); |
|
|
} else { |
|
|
} else { |
|
|
deviceChannel.setRegisterWay(Integer.parseInt(XmlUtil.getText(itemDevice, "RegisterWay"))); |
|
|
deviceChannel.setRegisterWay(Integer.parseInt(XmlUtil.getText(itemDevice, "RegisterWay"))); |
|
|
} |
|
|
} |
|
|
deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum")); |
|
|
deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum")); |
|
|
if (XmlUtil.getText(itemDevice, "Certifiable") == null || XmlUtil.getText(itemDevice, "Certifiable") == "") { |
|
|
if (XmlUtil.getText(itemDevice, "Certifiable") == null |
|
|
|
|
|
|| XmlUtil.getText(itemDevice, "Certifiable") == "") { |
|
|
deviceChannel.setCertifiable(0); |
|
|
deviceChannel.setCertifiable(0); |
|
|
} else { |
|
|
} else { |
|
|
deviceChannel.setCertifiable(Integer.parseInt(XmlUtil.getText(itemDevice, "Certifiable"))); |
|
|
deviceChannel.setCertifiable(Integer.parseInt(XmlUtil.getText(itemDevice, "Certifiable"))); |
|
|
} |
|
|
} |
|
|
if (XmlUtil.getText(itemDevice, "ErrCode") == null || XmlUtil.getText(itemDevice, "ErrCode") == "") { |
|
|
if (XmlUtil.getText(itemDevice, "ErrCode") == null |
|
|
|
|
|
|| XmlUtil.getText(itemDevice, "ErrCode") == "") { |
|
|
deviceChannel.setErrCode(0); |
|
|
deviceChannel.setErrCode(0); |
|
|
} else { |
|
|
} else { |
|
|
deviceChannel.setErrCode(Integer.parseInt(XmlUtil.getText(itemDevice, "ErrCode"))); |
|
|
deviceChannel.setErrCode(Integer.parseInt(XmlUtil.getText(itemDevice, "ErrCode"))); |
|
@ -289,7 +290,7 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor { |
|
|
deviceChannel.setEndTime(XmlUtil.getText(itemDevice, "EndTime")); |
|
|
deviceChannel.setEndTime(XmlUtil.getText(itemDevice, "EndTime")); |
|
|
deviceChannel.setSecrecy(XmlUtil.getText(itemDevice, "Secrecy")); |
|
|
deviceChannel.setSecrecy(XmlUtil.getText(itemDevice, "Secrecy")); |
|
|
deviceChannel.setIpAddress(XmlUtil.getText(itemDevice, "IPAddress")); |
|
|
deviceChannel.setIpAddress(XmlUtil.getText(itemDevice, "IPAddress")); |
|
|
if (XmlUtil.getText(itemDevice, "Port") == null || XmlUtil.getText(itemDevice, "Port") =="") { |
|
|
if (XmlUtil.getText(itemDevice, "Port") == null || XmlUtil.getText(itemDevice, "Port") == "") { |
|
|
deviceChannel.setPort(0); |
|
|
deviceChannel.setPort(0); |
|
|
} else { |
|
|
} else { |
|
|
deviceChannel.setPort(Integer.parseInt(XmlUtil.getText(itemDevice, "Port"))); |
|
|
deviceChannel.setPort(Integer.parseInt(XmlUtil.getText(itemDevice, "Port"))); |
|
@ -305,7 +306,8 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor { |
|
|
} else { |
|
|
} else { |
|
|
deviceChannel.setLatitude(0.00); |
|
|
deviceChannel.setLatitude(0.00); |
|
|
} |
|
|
} |
|
|
if (XmlUtil.getText(itemDevice, "PTZType") == null || XmlUtil.getText(itemDevice, "PTZType") == "") { |
|
|
if (XmlUtil.getText(itemDevice, "PTZType") == null |
|
|
|
|
|
|| XmlUtil.getText(itemDevice, "PTZType") == "") { |
|
|
deviceChannel.setPTZType(0); |
|
|
deviceChannel.setPTZType(0); |
|
|
} else { |
|
|
} else { |
|
|
deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType"))); |
|
|
deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType"))); |
|
@ -330,9 +332,9 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*** |
|
|
/*** |
|
|
|
|
|
* 回复200 OK |
|
|
* 回复200 OK |
|
|
|
|
|
* |
|
|
* @param evt |
|
|
* @param evt |
|
|
* @throws SipException |
|
|
* @throws SipException |
|
|
* @throws InvalidArgumentException |
|
|
* @throws InvalidArgumentException |
|
@ -343,7 +345,7 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor { |
|
|
getServerTransaction(evt).sendResponse(response); |
|
|
getServerTransaction(evt).sendResponse(response); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private Element getRootElement(RequestEvent evt) throws DocumentException { |
|
|
private Element getRootElement(RequestEvent evt) throws DocumentException { |
|
|
Request request = evt.getRequest(); |
|
|
Request request = evt.getRequest(); |
|
|
SAXReader reader = new SAXReader(); |
|
|
SAXReader reader = new SAXReader(); |
|
|
reader.setEncoding("gbk"); |
|
|
reader.setEncoding("gbk"); |
|
@ -352,7 +354,6 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void setCmder(SIPCommander cmder) { |
|
|
public void setCmder(SIPCommander cmder) { |
|
|
this.cmder = cmder; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void setStorager(IVideoManagerStorager storager) { |
|
|
public void setStorager(IVideoManagerStorager storager) { |
|
@ -364,11 +365,9 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void setRedis(RedisUtil redis) { |
|
|
public void setRedis(RedisUtil redis) { |
|
|
this.redis = redis; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void setDeferredResultHolder(DeferredResultHolder deferredResultHolder) { |
|
|
public void setDeferredResultHolder(DeferredResultHolder deferredResultHolder) { |
|
|
this.deferredResultHolder = deferredResultHolder; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void setOffLineDetector(DeviceOffLineDetector offLineDetector) { |
|
|
public void setOffLineDetector(DeviceOffLineDetector offLineDetector) { |
|
|