修复目录订阅的定时刷新以及信令

This commit is contained in:
648540858
2021-11-16 18:15:33 +08:00
parent c49f6f8337
commit 5d5e5a164f
6 changed files with 15 additions and 24 deletions

View File

@@ -10,6 +10,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* 设备业务(目录订阅)
*/
@Service
public class DeviceServiceImpl implements IDeviceService {
@@ -31,9 +34,10 @@ public class DeviceServiceImpl implements IDeviceService {
CatalogSubscribeTask catalogSubscribeTask = new CatalogSubscribeTask(device, sipCommander);
catalogSubscribeTask.run();
// 提前开始刷新订阅
// TODO 暂时关闭目录订阅的定时刷新,直到此功能完善
// String cron = getCron(device.getSubscribeCycleForCatalog() - 60);
// dynamicTask.startCron(device.getDeviceId(), catalogSubscribeTask, cron);
int subscribeCycleForCatalog = device.getSubscribeCycleForCatalog();
// 设置最小值为30
subscribeCycleForCatalog = Math.max(subscribeCycleForCatalog, 30);
dynamicTask.startCron(device.getDeviceId(), catalogSubscribeTask, subscribeCycleForCatalog - 5);
return true;
}
@@ -42,21 +46,10 @@ public class DeviceServiceImpl implements IDeviceService {
if (device == null || device.getSubscribeCycleForCatalog() < 0) {
return false;
}
logger.info("移除目录订阅【{}】", device.getDeviceId());
dynamicTask.stopCron(device.getDeviceId());
device.setSubscribeCycleForCatalog(0);
sipCommander.catalogSubscribe(device, null, null);
return true;
}
public String getCron(int time) {
if (time <= 59) {
return "0/" + time +" * * * * ?";
}else if (time <= 60* 59) {
int minute = time/(60);
return "0 0/" + minute +" * * * ?";
}else if (time <= 60* 60* 59) {
int hour = time/(60*60);
return "0 0 0/" + hour +" * * ?";
}else {
return "0 0/10 * * * ?";
}
}
}