使用阿里代码规范。规范代码写法
This commit is contained in:
@@ -62,7 +62,9 @@ public class OnlineEventListener implements ApplicationListener<OnlineEvent> {
|
||||
|
||||
logger.info("设备上线事件触发,deviceId:" + event.getDevice().getDeviceId() + ",from:" + event.getFrom());
|
||||
Device device = event.getDevice();
|
||||
if (device == null) return;
|
||||
if (device == null) {
|
||||
return;
|
||||
}
|
||||
String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + event.getDevice().getDeviceId();
|
||||
Device deviceInStore = storager.queryVideoDevice(device.getDeviceId());
|
||||
device.setOnline(1);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.genersoft.iot.vmp.gb28181.event.platformNotRegister;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
|
||||
@@ -22,6 +23,8 @@ public class PlatformCycleRegisterEventLister implements ApplicationListener<Pla
|
||||
private IVideoManagerStorage storager;
|
||||
@Autowired
|
||||
private ISIPCommanderForPlatform sipCommanderFroPlatform;
|
||||
@Autowired
|
||||
private DynamicTask dynamicTask;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(PlatformCycleRegisterEvent event) {
|
||||
@@ -31,17 +34,13 @@ public class PlatformCycleRegisterEventLister implements ApplicationListener<Pla
|
||||
logger.info("[ 平台未注册事件 ] 平台已经删除!!! 平台国标ID:" + event.getPlatformGbID());
|
||||
return;
|
||||
}
|
||||
Timer timer = new Timer();
|
||||
String taskKey = "platform-cycle-register" + parentPlatform.getServerGBId();;
|
||||
SipSubscribe.Event okEvent = (responseEvent)->{
|
||||
timer.cancel();
|
||||
dynamicTask.stop(taskKey);
|
||||
};
|
||||
sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
logger.info("[平台注册]再次向平台注册,平台国标ID:" + event.getPlatformGbID());
|
||||
sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
|
||||
}
|
||||
}, 15*1000 ,Long.parseLong(parentPlatform.getExpires())* 1000);
|
||||
dynamicTask.startCron(taskKey, ()->{
|
||||
logger.info("[平台注册]再次向平台注册,平台国标ID:" + event.getPlatformGbID());
|
||||
sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
|
||||
}, Integer.parseInt(parentPlatform.getExpires())* 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.genersoft.iot.vmp.gb28181.event.platformNotRegister;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||
import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
|
||||
@@ -46,6 +47,9 @@ public class PlatformNotRegisterEventLister implements ApplicationListener<Platf
|
||||
@Autowired
|
||||
private SipConfig config;
|
||||
|
||||
@Autowired
|
||||
private DynamicTask dynamicTask;
|
||||
|
||||
// @Autowired
|
||||
// private RedisUtil redis;
|
||||
|
||||
@@ -75,19 +79,13 @@ public class PlatformNotRegisterEventLister implements ApplicationListener<Platf
|
||||
}
|
||||
|
||||
}
|
||||
Timer timer = new Timer();
|
||||
String taskKey = "platform-not-register-" + parentPlatform.getServerGBId();
|
||||
SipSubscribe.Event okEvent = (responseEvent)->{
|
||||
timer.cancel();
|
||||
dynamicTask.stop(taskKey);
|
||||
};
|
||||
logger.info("[平台注册]平台国标ID:" + event.getPlatformGbID());
|
||||
sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
|
||||
// 设置注册失败则每隔15秒发起一次注册
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
logger.info("[平台注册]再次向平台注册,平台国标ID:" + event.getPlatformGbID());
|
||||
sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
|
||||
}
|
||||
}, config.getRegisterTimeInterval()* 1000, config.getRegisterTimeInterval()* 1000);//十五秒后再次发起注册
|
||||
dynamicTask.startCron(taskKey, ()->{
|
||||
logger.info("[平台注册]再次向平台注册,平台国标ID:" + event.getPlatformGbID());
|
||||
sipCommanderFroPlatform.register(parentPlatform, null, okEvent);
|
||||
}, config.getRegisterTimeInterval()* 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,9 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
|
||||
Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>();
|
||||
if (event.getPlatformId() != null) {
|
||||
parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId());
|
||||
if (parentPlatform != null && !parentPlatform.isStatus())return;
|
||||
if (parentPlatform != null && !parentPlatform.isStatus()) {
|
||||
return;
|
||||
}
|
||||
subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId());
|
||||
|
||||
if (subscribe == null) {
|
||||
@@ -80,7 +82,9 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
|
||||
}else if (event.getGbStreams() != null) {
|
||||
if (platforms.size() > 0) {
|
||||
for (GbStream gbStream : event.getGbStreams()) {
|
||||
if (gbStream == null || StringUtils.isEmpty(gbStream.getGbId())) continue;
|
||||
if (gbStream == null || StringUtils.isEmpty(gbStream.getGbId())) {
|
||||
continue;
|
||||
}
|
||||
List<ParentPlatform> parentPlatformsForGB = storager.queryPlatFormListForStreamWithGBId(gbStream.getApp(),gbStream.getStream(), platforms);
|
||||
parentPlatformMap.put(gbStream.getGbId(), parentPlatformsForGB);
|
||||
}
|
||||
@@ -113,7 +117,9 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
|
||||
if (parentPlatforms != null && parentPlatforms.size() > 0) {
|
||||
for (ParentPlatform platform : parentPlatforms) {
|
||||
SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getServerGBId());
|
||||
if (subscribeInfo == null) continue;
|
||||
if (subscribeInfo == null) {
|
||||
continue;
|
||||
}
|
||||
logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId);
|
||||
List<DeviceChannel> deviceChannelList = new ArrayList<>();
|
||||
DeviceChannel deviceChannel = new DeviceChannel();
|
||||
@@ -155,7 +161,9 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
|
||||
if (parentPlatforms != null && parentPlatforms.size() > 0) {
|
||||
for (ParentPlatform platform : parentPlatforms) {
|
||||
SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getServerGBId());
|
||||
if (subscribeInfo == null) continue;
|
||||
if (subscribeInfo == null) {
|
||||
continue;
|
||||
}
|
||||
logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId);
|
||||
List<DeviceChannel> deviceChannelList = new ArrayList<>();
|
||||
DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(platform.getServerGBId(), gbId);
|
||||
|
||||
Reference in New Issue
Block a user