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