From c084d6c98af1ef4d36a61adc719df5db76589428 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期六, 07 十月 2023 18:00:08 +0800
Subject: [PATCH] 优化国标级联心跳失败判断逻辑

---
 src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java |  255 +++++++++++++++++++++++---------------------------
 1 files changed, 118 insertions(+), 137 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java
old mode 100644
new mode 100755
index 76b4427..d56e744
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java
@@ -1,137 +1,118 @@
-package com.genersoft.iot.vmp.gb28181.event;
-
-import com.genersoft.iot.vmp.gb28181.bean.Device;
-import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
-import com.genersoft.iot.vmp.gb28181.bean.GbStream;
-import com.genersoft.iot.vmp.gb28181.event.offline.OfflineEvent;
-import com.genersoft.iot.vmp.gb28181.event.platformKeepaliveExpire.PlatformKeepaliveExpireEvent;
-import com.genersoft.iot.vmp.gb28181.event.platformNotRegister.PlatformNotRegisterEvent;
-import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
-import com.genersoft.iot.vmp.media.zlm.event.ZLMOfflineEvent;
-import com.genersoft.iot.vmp.media.zlm.event.ZLMOnlineEvent;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationEventPublisher;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.stereotype.Component;
-
-import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
-import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent;
-import com.genersoft.iot.vmp.gb28181.event.online.OnlineEvent;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**    
- * @description:Event浜嬩欢閫氱煡鎺ㄩ�佸櫒锛屾敮鎸佹帹閫佸湪绾夸簨浠躲�佺绾夸簨浠�
- * @author: swwheihei
- * @date:   2020骞�5鏈�6鏃� 涓婂崍11:30:50     
- */
-@Component
-public class EventPublisher {
-
-	@Autowired
-    private ApplicationEventPublisher applicationEventPublisher;
-	
-	public void onlineEventPublish(Device device, String from) {
-		OnlineEvent onEvent = new OnlineEvent(this);
-		onEvent.setDevice(device);
-		onEvent.setFrom(from);
-        applicationEventPublisher.publishEvent(onEvent);
-    }
-	
-	public void outlineEventPublish(String deviceId, String from){
-		OfflineEvent outEvent = new OfflineEvent(this);
-		outEvent.setDeviceId(deviceId);
-		outEvent.setFrom(from);
-        applicationEventPublisher.publishEvent(outEvent);
-    }
-
-	/**
-	 * 骞冲彴蹇冭烦鍒版湡浜嬩欢
-	 * @param platformGbId
-	 */
-	public void platformKeepaliveExpireEventPublish(String platformGbId){
-		PlatformKeepaliveExpireEvent platformNotRegisterEvent = new PlatformKeepaliveExpireEvent(this);
-		platformNotRegisterEvent.setPlatformGbID(platformGbId);
-        applicationEventPublisher.publishEvent(platformNotRegisterEvent);
-    }
-
-	/**
-	 * 骞冲彴鏈敞鍐屼簨浠�
-	 * @param platformGbId
-	 */
-	public void platformNotRegisterEventPublish(String platformGbId){
-		PlatformNotRegisterEvent platformNotRegisterEvent = new PlatformNotRegisterEvent(this);
-		platformNotRegisterEvent.setPlatformGbID(platformGbId);
-        applicationEventPublisher.publishEvent(platformNotRegisterEvent);
-	}
-	
-	/**
-	 * 璁惧鎶ヨ浜嬩欢
-	 * @param deviceAlarm
-	 */
-	public void deviceAlarmEventPublish(DeviceAlarm deviceAlarm) {
-		AlarmEvent alarmEvent = new AlarmEvent(this);
-		alarmEvent.setAlarmInfo(deviceAlarm);
-		applicationEventPublisher.publishEvent(alarmEvent);
-	}
-
-	public void zlmOfflineEventPublish(String mediaServerId){
-		ZLMOfflineEvent outEvent = new ZLMOfflineEvent(this);
-		outEvent.setMediaServerId(mediaServerId);
-		applicationEventPublisher.publishEvent(outEvent);
-	}
-
-	public void zlmOnlineEventPublish(String mediaServerId) {
-		ZLMOnlineEvent outEvent = new ZLMOnlineEvent(this);
-		outEvent.setMediaServerId(mediaServerId);
-		applicationEventPublisher.publishEvent(outEvent);
-	}
-
-	@Async
-	public void catalogEventPublish(String platformId, DeviceChannel deviceChannel, String type) {
-		List<DeviceChannel> deviceChannelList = new ArrayList<>();
-		deviceChannelList.add(deviceChannel);
-		catalogEventPublish(platformId, deviceChannelList, type);
-	}
-
-	@Async
-	public void catalogEventPublish(String platformId, List<DeviceChannel> deviceChannels, String type) {
-		CatalogEvent outEvent = new CatalogEvent(this);
-		List<DeviceChannel> channels = new ArrayList<>();
-		if (deviceChannels.size() > 1) {
-			// 鏁版嵁鍘婚噸
-			Set<String> gbIdSet = new HashSet<>();
-			for (DeviceChannel deviceChannel : deviceChannels) {
-				if (!gbIdSet.contains(deviceChannel.getChannelId())) {
-					gbIdSet.add(deviceChannel.getChannelId());
-					channels.add(deviceChannel);
-				}
-			}
-		}else {
-			channels = deviceChannels;
-		}
-		outEvent.setDeviceChannels(channels);
-		outEvent.setType(type);
-		outEvent.setPlatformId(platformId);
-		applicationEventPublisher.publishEvent(outEvent);
-	}
-
-	@Async
-	public void catalogEventPublishForStream(String platformId, List<GbStream> gbStreams, String type) {
-		CatalogEvent outEvent = new CatalogEvent(this);
-		outEvent.setGbStreams(gbStreams);
-		outEvent.setType(type);
-		outEvent.setPlatformId(platformId);
-		applicationEventPublisher.publishEvent(outEvent);
-	}
-
-	@Async
-	public void catalogEventPublishForStream(String platformId, GbStream gbStream, String type) {
-		List<GbStream> gbStreamList = new ArrayList<>();
-		gbStreamList.add(gbStream);
-		catalogEventPublishForStream(platformId, gbStreamList, type);
-	}
-}
+package com.genersoft.iot.vmp.gb28181.event;
+
+import com.genersoft.iot.vmp.gb28181.bean.*;
+import com.genersoft.iot.vmp.gb28181.event.device.RequestTimeoutEvent;
+import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEvent;
+import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
+import com.genersoft.iot.vmp.media.zlm.event.ZLMOfflineEvent;
+import com.genersoft.iot.vmp.media.zlm.event.ZLMOnlineEvent;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationEventPublisher;
+import org.springframework.stereotype.Component;
+
+import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent;
+
+import javax.sip.TimeoutEvent;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**    
+ * @description:Event浜嬩欢閫氱煡鎺ㄩ�佸櫒锛屾敮鎸佹帹閫佸湪绾夸簨浠躲�佺绾夸簨浠�
+ * @author: swwheihei
+ * @date:   2020骞�5鏈�6鏃� 涓婂崍11:30:50     
+ */
+@Component
+public class EventPublisher {
+
+	@Autowired
+    private ApplicationEventPublisher applicationEventPublisher;
+	
+	/**
+	 * 璁惧鎶ヨ浜嬩欢
+	 * @param deviceAlarm
+	 */
+	public void deviceAlarmEventPublish(DeviceAlarm deviceAlarm) {
+		AlarmEvent alarmEvent = new AlarmEvent(this);
+		alarmEvent.setAlarmInfo(deviceAlarm);
+		applicationEventPublisher.publishEvent(alarmEvent);
+	}
+
+	public void zlmOfflineEventPublish(String mediaServerId){
+		ZLMOfflineEvent outEvent = new ZLMOfflineEvent(this);
+		outEvent.setMediaServerId(mediaServerId);
+		applicationEventPublisher.publishEvent(outEvent);
+	}
+
+	public void zlmOnlineEventPublish(String mediaServerId) {
+		ZLMOnlineEvent outEvent = new ZLMOnlineEvent(this);
+		outEvent.setMediaServerId(mediaServerId);
+		applicationEventPublisher.publishEvent(outEvent);
+	}
+
+
+	public void catalogEventPublish(String platformId, DeviceChannel deviceChannel, String type) {
+		List<DeviceChannel> deviceChannelList = new ArrayList<>();
+		deviceChannelList.add(deviceChannel);
+		catalogEventPublish(platformId, deviceChannelList, type);
+	}
+
+
+	public void requestTimeOut(TimeoutEvent timeoutEvent) {
+		RequestTimeoutEvent requestTimeoutEvent = new RequestTimeoutEvent(this);
+		requestTimeoutEvent.setTimeoutEvent(timeoutEvent);
+		applicationEventPublisher.publishEvent(requestTimeoutEvent);
+	}
+
+
+	/**
+	 *
+	 * @param platformId
+	 * @param deviceChannels
+	 * @param type
+	 */
+	public void catalogEventPublish(String platformId, List<DeviceChannel> deviceChannels, String type) {
+		CatalogEvent outEvent = new CatalogEvent(this);
+		List<DeviceChannel> channels = new ArrayList<>();
+		if (deviceChannels.size() > 1) {
+			// 鏁版嵁鍘婚噸
+			Set<String> gbIdSet = new HashSet<>();
+			for (DeviceChannel deviceChannel : deviceChannels) {
+				if (!gbIdSet.contains(deviceChannel.getChannelId())) {
+					gbIdSet.add(deviceChannel.getChannelId());
+					channels.add(deviceChannel);
+				}
+			}
+		}else {
+			channels = deviceChannels;
+		}
+		outEvent.setDeviceChannels(channels);
+		outEvent.setType(type);
+		outEvent.setPlatformId(platformId);
+		applicationEventPublisher.publishEvent(outEvent);
+	}
+
+
+	public void catalogEventPublishForStream(String platformId, List<GbStream> gbStreams, String type) {
+		CatalogEvent outEvent = new CatalogEvent(this);
+		outEvent.setGbStreams(gbStreams);
+		outEvent.setType(type);
+		outEvent.setPlatformId(platformId);
+		applicationEventPublisher.publishEvent(outEvent);
+	}
+
+
+	public void catalogEventPublishForStream(String platformId, GbStream gbStream, String type) {
+		List<GbStream> gbStreamList = new ArrayList<>();
+		gbStreamList.add(gbStream);
+		catalogEventPublishForStream(platformId, gbStreamList, type);
+	}
+
+	public void recordEndEventPush(RecordInfo recordInfo) {
+		RecordEndEvent outEvent = new RecordEndEvent(this);
+		outEvent.setRecordInfo(recordInfo);
+		applicationEventPublisher.publishEvent(outEvent);
+	}
+
+}

--
Gitblit v1.8.0