From e7f5cfc422cb9ac8dc72f0c0faf063bf5fcb711c Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期五, 06 五月 2022 17:26:36 +0800
Subject: [PATCH] test
---
src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java | 54 +++++++++++++++++++++++++++++++++---------------------
1 files changed, 33 insertions(+), 21 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java
index 12a50e1..f32637e 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java
@@ -1,13 +1,13 @@
package com.genersoft.iot.vmp.gb28181.event.online;
import com.genersoft.iot.vmp.conf.SipConfig;
-import com.genersoft.iot.vmp.conf.UserSetup;
+import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
+import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.service.IDeviceService;
-import com.genersoft.iot.vmp.storager.dao.dto.User;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -15,7 +15,7 @@
import org.springframework.stereotype.Component;
import com.genersoft.iot.vmp.common.VideoManagerConstants;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
+import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import java.text.SimpleDateFormat;
@@ -34,7 +34,10 @@
private final static Logger logger = LoggerFactory.getLogger(OnlineEventListener.class);
@Autowired
- private IVideoManagerStorager storager;
+ private IVideoManagerStorage storager;
+
+ @Autowired
+ private IDeviceService deviceService;
@Autowired
private RedisUtil redis;
@@ -43,28 +46,39 @@
private SipConfig sipConfig;
@Autowired
- private UserSetup userSetup;
+ private UserSetting userSetting;
@Autowired
private EventPublisher eventPublisher;
+
+ @Autowired
+ private SIPCommander cmder;
+
private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@Override
public void onApplicationEvent(OnlineEvent event) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("璁惧涓婄嚎浜嬩欢瑙﹀彂锛宒eviceId锛�" + event.getDevice().getDeviceId() + ",from:" + event.getFrom());
- }
- Device device = event.getDevice();
- String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + event.getDevice().getDeviceId();
+ logger.info("璁惧涓婄嚎浜嬩欢瑙﹀彂锛宒eviceId锛�" + event.getDevice().getDeviceId() + ",from:" + event.getFrom());
+ Device device = event.getDevice();
+ if (device == null) {
+ return;
+ }
+ String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + event.getDevice().getDeviceId();
+ Device deviceInStore = storager.queryVideoDevice(device.getDeviceId());
+ device.setOnline(1);
switch (event.getFrom()) {
// 娉ㄥ唽鏃惰Е鍙戠殑鍦ㄧ嚎浜嬩欢锛屽厛鍦╮edis涓鍔犺秴鏃惰秴鏃剁洃鍚�
case VideoManagerConstants.EVENT_ONLINE_REGISTER:
// 瓒呮椂鏃堕棿
redis.set(key, event.getDevice().getDeviceId(), sipConfig.getKeepaliveTimeOut());
device.setRegisterTime(format.format(System.currentTimeMillis()));
+ if (deviceInStore == null) { //绗竴娆′笂绾�
+ logger.info("[{}] 棣栨娉ㄥ唽锛屾煡璇㈣澶囦俊鎭互鍙婇�氶亾淇℃伅", device.getDeviceId());
+ cmder.deviceInfoQuery(device);
+ deviceService.sync(device);
+ }
break;
// 璁惧涓诲姩鍙戦�佸績璺宠Е鍙戠殑鍦ㄧ嚎浜嬩欢
case VideoManagerConstants.EVENT_ONLINE_KEEPLIVE:
@@ -82,17 +96,15 @@
break;
}
-
- device.setOnline(1);
- Device deviceInstore = storager.queryVideoDevice(device.getDeviceId());
- if (deviceInstore.getOnline() == 0) {
- List<DeviceChannel> deviceChannelList = storager.queryOnlineChannelsByDeviceId(device.getDeviceId());
- eventPublisher.catalogEventPublish(null, deviceChannelList, CatalogEvent.ON);
- }
// 澶勭悊涓婄嚎鐩戝惉
storager.updateDevice(device);
-
- // TODO 涓婄嚎娣诲姞璁㈤槄
-
+ // 涓婄嚎娣诲姞璁㈤槄
+ if (device.getSubscribeCycleForCatalog() > 0) {
+ // 鏌ヨ鍦ㄧ嚎璁惧閭d簺寮�鍚簡璁㈤槄锛屼负璁惧寮�鍚畾鏃剁殑鐩綍璁㈤槄
+ deviceService.addCatalogSubscribe(device);
+ }
+ if (device.getSubscribeCycleForMobilePosition() > 0) {
+ deviceService.addMobilePositionSubscribe(device);
+ }
}
}
--
Gitblit v1.8.0