From 3b5a37c270e5b6649b9a168ee753c2b3353a257a Mon Sep 17 00:00:00 2001
From: zouyaoji <370681295@qq.com>
Date: 星期六, 06 八月 2022 11:27:02 +0800
Subject: [PATCH] 前端显示媒体服务器配置时报错修复
---
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java | 27 ++++++++++++++++++++-------
1 files changed, 20 insertions(+), 7 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 579184c..66f678a 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
@@ -86,10 +86,10 @@
redisCatchStorage.clearCatchByDeviceId(device.getDeviceId());
}
device.setUpdateTime(now);
- device.setOnline(1);
- // 绗竴娆′笂绾�
+ // 绗竴娆′笂绾� 鎴栧垯璁惧涔嬪墠鏄绾跨姸鎬�--杩涜閫氶亾鍚屾鍜岃澶囦俊鎭煡璇�
if (device.getCreateTime() == null) {
+ device.setOnline(1);
device.setCreateTime(now);
logger.info("[璁惧涓婄嚎,棣栨娉ㄥ唽]: {}锛屾煡璇㈣澶囦俊鎭互鍙婇�氶亾淇℃伅", device.getDeviceId());
deviceMapper.add(device);
@@ -97,8 +97,19 @@
commander.deviceInfoQuery(device);
sync(device);
}else {
- deviceMapper.update(device);
- redisCatchStorage.updateDevice(device);
+ if(device.getOnline() == 0){
+ device.setOnline(1);
+ device.setCreateTime(now);
+ logger.info("[璁惧涓婄嚎,绂荤嚎鐘舵�佷笅閲嶆柊娉ㄥ唽]: {}锛屾煡璇㈣澶囦俊鎭互鍙婇�氶亾淇℃伅", device.getDeviceId());
+ deviceMapper.update(device);
+ redisCatchStorage.updateDevice(device);
+ commander.deviceInfoQuery(device);
+ sync(device);
+ }else {
+ deviceMapper.update(device);
+ redisCatchStorage.updateDevice(device);
+ }
+
}
// 涓婄嚎娣诲姞璁㈤槄
@@ -125,6 +136,8 @@
device.setOnline(0);
redisCatchStorage.updateDevice(device);
deviceMapper.update(device);
+ //杩涜閫氶亾绂荤嚎
+ deviceChannelMapper.offlineByDeviceId(deviceId);
// 绂荤嚎閲婃斁鎵�鏈塻src
List<SsrcTransaction> ssrcTransactions = streamSession.getSsrcTransactionForAll(deviceId, null, null, null);
if (ssrcTransactions != null && ssrcTransactions.size() > 0) {
@@ -147,7 +160,7 @@
logger.info("[娣诲姞鐩綍璁㈤槄] 璁惧{}", device.getDeviceId());
// 娣诲姞鐩綍璁㈤槄
CatalogSubscribeTask catalogSubscribeTask = new CatalogSubscribeTask(device, sipCommander, dynamicTask);
- // 鎻愬墠寮�濮嬪埛鏂拌闃�
+ // 鍒锋柊璁㈤槄
int subscribeCycleForCatalog = Math.max(device.getSubscribeCycleForCatalog(),30);
// 璁剧疆鏈�灏忓�间负30
dynamicTask.startCron(device.getDeviceId() + "catalog", catalogSubscribeTask, (subscribeCycleForCatalog -1) * 1000);
@@ -182,8 +195,8 @@
MobilePositionSubscribeTask mobilePositionSubscribeTask = new MobilePositionSubscribeTask(device, sipCommander, dynamicTask);
// 璁剧疆鏈�灏忓�间负30
int subscribeCycleForCatalog = Math.max(device.getSubscribeCycleForMobilePosition(),30);
- // 鎻愬墠寮�濮嬪埛鏂拌闃�
- dynamicTask.startCron(device.getDeviceId() + "mobile_position" , mobilePositionSubscribeTask, (subscribeCycleForCatalog -1 ) * 1000);
+ // 鍒锋柊璁㈤槄
+ dynamicTask.startCron(device.getDeviceId() + "mobile_position" , mobilePositionSubscribeTask, (subscribeCycleForCatalog) * 1000);
return true;
}
--
Gitblit v1.8.0