From 69d9692f6194d1e03ec81cf87ea8f0e7a62f7173 Mon Sep 17 00:00:00 2001
From: wangyimeng <421132955@qq.com>
Date: 星期三, 16 三月 2022 15:27:12 +0800
Subject: [PATCH] 删除重复字段
---
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java | 34 ++++++++++++++++------------------
1 files changed, 16 insertions(+), 18 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
index 7cee096..0fc6f4c 100644
--- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
@@ -10,6 +10,9 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+/**
+ * 璁惧涓氬姟锛堢洰褰曡闃咃級
+ */
@Service
public class DeviceServiceImpl implements IDeviceService {
@@ -27,13 +30,19 @@
if (device == null || device.getSubscribeCycleForCatalog() < 0) {
return false;
}
+ if (dynamicTask.contains(device.getDeviceId())) {
+ // 瀛樺湪鍒欏仠姝㈢幇鏈夌殑锛屽紑鍚柊鐨�
+ dynamicTask.stop(device.getDeviceId());
+ }
+ logger.info("[娣诲姞鐩綍璁㈤槄] 璁惧{}", device.getDeviceId());
// 娣诲姞鐩綍璁㈤槄
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 +51,10 @@
if (device == null || device.getSubscribeCycleForCatalog() < 0) {
return false;
}
- dynamicTask.stopCron(device.getDeviceId());
+ logger.info("绉婚櫎鐩綍璁㈤槄: {}", device.getDeviceId());
+ dynamicTask.stop(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 * * * ?";
- }
}
}
--
Gitblit v1.8.0