From fb1d9ca50ab23a5361ea66ab0527be31b21cfd89 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 03 十一月 2022 20:39:30 +0800
Subject: [PATCH] Merge pull request #658 from itouxin/patch-2
---
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java | 26 ++++++++++++--------------
1 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java
index da2cb9c..3bc5c37 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java
@@ -16,6 +16,7 @@
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil;
+import gov.nist.javax.sip.message.SIPRequest;
import org.dom4j.Element;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -72,7 +73,7 @@
private boolean taskQueueHandlerRun = false;
- private final ConcurrentLinkedQueue<SipMsgInfo> taskQueue = new ConcurrentLinkedQueue<>();
+ private ConcurrentLinkedQueue<SipMsgInfo> taskQueue = new ConcurrentLinkedQueue<>();
@Qualifier("taskExecutor")
@Autowired
@@ -92,13 +93,14 @@
if (!taskQueueHandlerRun) {
taskQueueHandlerRun = true;
taskExecutor.execute(() -> {
+ logger.info("[澶勭悊鎶ヨ閫氱煡]寰呭鐞嗘暟閲忥細{}", taskQueue.size() );
while (!taskQueue.isEmpty()) {
SipMsgInfo sipMsgInfo = taskQueue.poll();
// 鍥炲200 OK
try {
- responseAck(getServerTransaction(sipMsgInfo.getEvt()), Response.OK);
+ responseAck((SIPRequest) sipMsgInfo.getEvt().getRequest(), Response.OK);
} catch (SipException | InvalidArgumentException | ParseException e) {
- logger.error("[鏀跺埌鎶ヨ閫氱煡], 鍥炲200OK澶辫触", e);
+ logger.error("[澶勭悊鎶ヨ閫氱煡], 鍥炲200OK澶辫触", e);
}
Element deviceIdElement = sipMsgInfo.getRootElement().element("DeviceID");
@@ -112,7 +114,7 @@
deviceAlarm.setAlarmMethod(getText(sipMsgInfo.getRootElement(), "AlarmMethod"));
String alarmTime = XmlUtil.getText(sipMsgInfo.getRootElement(), "AlarmTime");
if (alarmTime == null) {
- return;
+ continue;
}
deviceAlarm.setAlarmTime(DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(alarmTime));
String alarmDescription = getText(sipMsgInfo.getRootElement(), "AlarmDescription");
@@ -182,7 +184,7 @@
deviceAlarm.setAlarmType(getText(sipMsgInfo.getRootElement().element("Info"), "AlarmType"));
}
}
-
+ logger.info("[鏀跺埌鎶ヨ閫氱煡]鍐呭锛歿}", JSONObject.toJSON(deviceAlarm));
if ("7".equals(deviceAlarm.getAlarmMethod()) ) {
// 鍙戦�佺粰骞冲彴鐨勬姤璀︿俊鎭�� 鍙戦�乺edis閫氱煡
AlarmChannelMessage alarmChannelMessage = new AlarmChannelMessage();
@@ -190,7 +192,7 @@
alarmChannelMessage.setAlarmDescription(deviceAlarm.getAlarmDescription());
alarmChannelMessage.setGbId(channelId);
redisCatchStorage.sendAlarmMsg(alarmChannelMessage);
- return;
+ continue;
}
logger.debug("瀛樺偍鎶ヨ淇℃伅銆佹姤璀﹀垎绫�");
@@ -198,7 +200,7 @@
if (sipConfig.isAlarm()) {
deviceAlarmService.add(deviceAlarm);
}
- logger.info("[鏀跺埌鎶ヨ閫氱煡]鍐呭锛歿}", JSONObject.toJSON(deviceAlarm));
+
if (redisCatchStorage.deviceIsOnline(sipMsgInfo.getDevice().getDeviceId())) {
publisher.deviceAlarmEventPublish(deviceAlarm);
}
@@ -215,13 +217,9 @@
logger.info("鏀跺埌鏉ヨ嚜骞冲彴[{}]鐨勬姤璀﹂�氱煡", parentPlatform.getServerGBId());
// 鍥炲200 OK
try {
- responseAck(getServerTransaction(evt), Response.OK);
- } catch (SipException e) {
- throw new RuntimeException(e);
- } catch (InvalidArgumentException e) {
- throw new RuntimeException(e);
- } catch (ParseException e) {
- throw new RuntimeException(e);
+ responseAck((SIPRequest) evt.getRequest(), Response.OK);
+ } catch (SipException | InvalidArgumentException | ParseException e) {
+ logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈 鎶ヨ閫氱煡鍥炲: {}", e.getMessage());
}
Element deviceIdElement = rootElement.element("DeviceID");
String channelId = deviceIdElement.getText().toString();
--
Gitblit v1.8.0