调整收到移动位置订阅后开启定时任务
parent
1efabbe4cc
commit
2127cbeca3
|
@ -4,7 +4,7 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants;
|
||||||
import com.genersoft.iot.vmp.conf.DynamicTask;
|
import com.genersoft.iot.vmp.conf.DynamicTask;
|
||||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||||
import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
|
import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
|
||||||
import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeHandlerTask;
|
import com.genersoft.iot.vmp.service.IPlatformService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@ -24,6 +24,9 @@ public class SubscribeHolder {
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserSetting userSetting;
|
private UserSetting userSetting;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IPlatformService platformService;
|
||||||
|
|
||||||
private final String taskOverduePrefix = "subscribe_overdue_";
|
private final String taskOverduePrefix = "subscribe_overdue_";
|
||||||
|
|
||||||
private static ConcurrentHashMap<String, SubscribeInfo> catalogMap = new ConcurrentHashMap<>();
|
private static ConcurrentHashMap<String, SubscribeInfo> catalogMap = new ConcurrentHashMap<>();
|
||||||
|
@ -62,7 +65,9 @@ public class SubscribeHolder {
|
||||||
mobilePositionMap.put(platformId, subscribeInfo);
|
mobilePositionMap.put(platformId, subscribeInfo);
|
||||||
String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "MobilePosition_" + platformId;
|
String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "MobilePosition_" + platformId;
|
||||||
// 添加任务处理GPS定时推送
|
// 添加任务处理GPS定时推送
|
||||||
dynamicTask.startCron(key, new MobilePositionSubscribeHandlerTask(platformId),
|
dynamicTask.startCron(key, ()->{
|
||||||
|
platformService.sendNotifyMobilePosition(platformId);
|
||||||
|
},
|
||||||
subscribeInfo.getGpsInterval() * 1000);
|
subscribeInfo.getGpsInterval() * 1000);
|
||||||
String taskOverdueKey = taskOverduePrefix + "MobilePosition_" + platformId;
|
String taskOverdueKey = taskOverduePrefix + "MobilePosition_" + platformId;
|
||||||
if (subscribeInfo.getExpires() > 0) {
|
if (subscribeInfo.getExpires() > 0) {
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
package com.genersoft.iot.vmp.gb28181.task.impl;
|
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.common.CommonCallback;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
|
|
||||||
import com.genersoft.iot.vmp.service.IPlatformService;
|
|
||||||
import com.genersoft.iot.vmp.utils.SpringBeanFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 向已经订阅(移动位置)的上级发送MobilePosition消息
|
|
||||||
* @author lin
|
|
||||||
*/
|
|
||||||
public class MobilePositionSubscribeHandlerTask implements ISubscribeTask {
|
|
||||||
|
|
||||||
|
|
||||||
private IPlatformService platformService;
|
|
||||||
private String platformId;
|
|
||||||
|
|
||||||
|
|
||||||
public MobilePositionSubscribeHandlerTask(String platformId) {
|
|
||||||
this.platformService = SpringBeanFactory.getBean("platformServiceImpl");
|
|
||||||
this.platformId = platformId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
platformService.sendNotifyMobilePosition(this.platformId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stop(CommonCallback<Boolean> callback) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue