From d6262acf6ab2a5083e62ea98299b378f61cd5421 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 20 四月 2023 16:42:44 +0800
Subject: [PATCH] 更新readme
---
src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java | 52 ++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 44 insertions(+), 8 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java
index 1cc754d..194e90f 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java
@@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.service.redisMsg;
import com.alibaba.fastjson2.JSON;
+import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
@@ -44,13 +45,17 @@
@Autowired
private ThreadPoolTaskExecutor taskExecutor;
+ @Autowired
+ private UserSetting userSetting;
+
@Override
public void onMessage(@NotNull Message message, byte[] bytes) {
+ // 娑堟伅绀轰緥锛� PUBLISH alarm_receive '{ "gbId": "", "alarmSn": 1, "alarmType": "111", "alarmDescription": "222", }'
logger.info("鏀跺埌鏉ヨ嚜REDIS鐨凙LARM閫氱煡锛� {}", new String(message.getBody()));
boolean isEmpty = taskQueue.isEmpty();
taskQueue.offer(message);
if (isEmpty) {
- logger.info("[绾跨▼姹犱俊鎭痌娲诲姩绾跨▼鏁帮細{}, 鏈�澶х嚎绋嬫暟锛� {}", taskExecutor.getActiveCount(), taskExecutor.getMaxPoolSize());
+// logger.info("[绾跨▼姹犱俊鎭痌娲诲姩绾跨▼鏁帮細{}, 鏈�澶х嚎绋嬫暟锛� {}", taskExecutor.getActiveCount(), taskExecutor.getMaxPoolSize());
taskExecutor.execute(() -> {
while (!taskQueue.isEmpty()) {
Message msg = taskQueue.poll();
@@ -74,17 +79,47 @@
deviceAlarm.setLatitude(0);
if (ObjectUtils.isEmpty(gbId)) {
- // 鍙戦�佺粰鎵�鏈夌殑涓婄骇
- List<ParentPlatform> parentPlatforms = storage.queryEnableParentPlatformList(true);
- if (parentPlatforms.size() > 0) {
- for (ParentPlatform parentPlatform : parentPlatforms) {
+ if (userSetting.getSendToPlatformsWhenIdLost()) {
+ // 鍙戦�佺粰鎵�鏈夌殑涓婄骇
+ List<ParentPlatform> parentPlatforms = storage.queryEnableParentPlatformList(true);
+ if (parentPlatforms.size() > 0) {
+ for (ParentPlatform parentPlatform : parentPlatforms) {
+ try {
+ deviceAlarm.setChannelId(parentPlatform.getDeviceGBId());
+ commanderForPlatform.sendAlarmMessage(parentPlatform, deviceAlarm);
+ } catch (SipException | InvalidArgumentException | ParseException e) {
+ logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈 鍙戦�佹姤璀�: {}", e.getMessage());
+ }
+ }
+ }
+ }else {
+ // 鑾峰彇寮�鍚簡娑堟伅鎺ㄩ�佺殑璁惧鍜屽钩鍙�
+ List<ParentPlatform> parentPlatforms = storage.queryEnablePlatformListWithAsMessageChannel();
+ if (parentPlatforms.size() > 0) {
+ for (ParentPlatform parentPlatform : parentPlatforms) {
+ try {
+ deviceAlarm.setChannelId(parentPlatform.getDeviceGBId());
+ commanderForPlatform.sendAlarmMessage(parentPlatform, deviceAlarm);
+ } catch (SipException | InvalidArgumentException | ParseException e) {
+ logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈 鍙戦�佹姤璀�: {}", e.getMessage());
+ }
+ }
+ }
+
+ }
+ // 鑾峰彇寮�鍚簡娑堟伅鎺ㄩ�佺殑璁惧鍜屽钩鍙�
+ List<Device> devices = storage.queryDeviceWithAsMessageChannel();
+ if (devices.size() > 0) {
+ for (Device device : devices) {
try {
- commanderForPlatform.sendAlarmMessage(parentPlatform, deviceAlarm);
- } catch (SipException | InvalidArgumentException | ParseException e) {
- logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈 鍙戦�佹姤璀�: {}", e.getMessage());
+ deviceAlarm.setChannelId(device.getDeviceId());
+ commander.sendAlarmMessage(device, deviceAlarm);
+ } catch (InvalidArgumentException | SipException | ParseException e) {
+ logger.error("[鍛戒护鍙戦�佸け璐 鍙戦�佹姤璀�: {}", e.getMessage());
}
}
}
+
}else {
Device device = storage.queryVideoDevice(gbId);
ParentPlatform platform = storage.queryParentPlatByServerGBId(gbId);
@@ -105,6 +140,7 @@
}
}
}catch (Exception e) {
+ logger.error("鏈鐞嗙殑寮傚父 ", e);
logger.warn("[REDIS鐨凙LARM閫氱煡] 鍙戠幇鏈鐞嗙殑寮傚父, {}",e.getMessage());
}
}
--
Gitblit v1.8.0