From 14699711028f0d157eddfb0432e26ab91f1b4493 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 22 十一月 2022 15:02:25 +0800
Subject: [PATCH] 支持配置设备上线时自动更新查询通道,修复通道刷新进度展示

---
 src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java |   20 +++++----
 web_src/src/components/dialog/SyncChannelProgress.vue                   |   48 ++++++++++--------------
 src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java               |   10 +++++
 src/main/resources/all-application.yml                                  |    2 +
 4 files changed, 43 insertions(+), 37 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
index ca204d9..eeee438 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java
@@ -41,6 +41,8 @@
 
     private Boolean gbSendStreamStrict = Boolean.FALSE;
 
+    private Boolean syncChannelOnDeviceOnline = Boolean.FALSE;
+
     private String serverId = "000000";
 
     private String thirdPartyGBIdReg = "[\\s\\S]*";
@@ -186,4 +188,12 @@
     public void setGbSendStreamStrict(Boolean gbSendStreamStrict) {
         this.gbSendStreamStrict = gbSendStreamStrict;
     }
+
+    public Boolean getSyncChannelOnDeviceOnline() {
+        return syncChannelOnDeviceOnline;
+    }
+
+    public void setSyncChannelOnDeviceOnline(Boolean syncChannelOnDeviceOnline) {
+        this.syncChannelOnDeviceOnline = syncChannelOnDeviceOnline;
+    }
 }
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 ac48e4d..d25e537 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
@@ -1,6 +1,7 @@
 package com.genersoft.iot.vmp.service.impl;
 
 import com.genersoft.iot.vmp.conf.DynamicTask;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager;
 import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
@@ -12,7 +13,6 @@
 import com.genersoft.iot.vmp.service.IDeviceService;
 import com.genersoft.iot.vmp.service.IMediaServerService;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
 import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
 import com.genersoft.iot.vmp.storager.dao.PlatformChannelMapper;
@@ -78,7 +78,7 @@
     TransactionDefinition transactionDefinition;
 
     @Autowired
-    private IVideoManagerStorage storage;
+    private UserSetting userSetting;
 
     @Autowired
     private ISIPCommander commander;
@@ -120,16 +120,18 @@
             if(device.getOnline() == 0){
                 device.setOnline(1);
                 device.setCreateTime(now);
-                logger.info("[璁惧涓婄嚎,绂荤嚎鐘舵�佷笅閲嶆柊娉ㄥ唽]: {}锛屾煡璇㈣澶囦俊鎭互鍙婇�氶亾淇℃伅", device.getDeviceId());
                 deviceMapper.update(device);
                 redisCatchStorage.updateDevice(device);
-                try {
-                    commander.deviceInfoQuery(device);
-                } catch (InvalidArgumentException | SipException | ParseException e) {
-                    logger.error("[鍛戒护鍙戦�佸け璐 鏌ヨ璁惧淇℃伅: {}", e.getMessage());
+                if (userSetting.getSyncChannelOnDeviceOnline()) {
+                    logger.info("[璁惧涓婄嚎,绂荤嚎鐘舵�佷笅閲嶆柊娉ㄥ唽]: {}锛屾煡璇㈣澶囦俊鎭互鍙婇�氶亾淇℃伅", device.getDeviceId());
+                    try {
+                        commander.deviceInfoQuery(device);
+                    } catch (InvalidArgumentException | SipException | ParseException e) {
+                        logger.error("[鍛戒护鍙戦�佸け璐 鏌ヨ璁惧淇℃伅: {}", e.getMessage());
+                    }
+                    sync(device);
+                    // TODO 濡傛灉璁惧涓嬬殑閫氶亾绾ц仈鍒颁簡鍏朵粬骞冲彴锛岄偅涔堥渶瑕佸彂閫佷簨浠舵垨鑰卬otify缁欎笂绾у钩鍙�
                 }
-                sync(device);
-                // TODO 濡傛灉璁惧涓嬬殑閫氶亾绾ц仈鍒颁簡鍏朵粬骞冲彴锛岄偅涔堥渶瑕佸彂閫佷簨浠舵垨鑰卬otify缁欎笂绾у钩鍙�
             }else {
                 if (deviceChannelMapper.queryAllChannels(device.getDeviceId()).size() == 0) {
                     logger.info("[璁惧涓婄嚎]: {}锛岄�氶亾鏁颁负0,鏌ヨ閫氶亾淇℃伅", device.getDeviceId());
diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml
index 3303915..e8b28d0 100644
--- a/src/main/resources/all-application.yml
+++ b/src/main/resources/all-application.yml
@@ -195,6 +195,8 @@
     # 鍥芥爣绾ц仈鍙戞祦涓ユ牸妯″紡锛屼弗鏍兼ā寮忎細浣跨敤涓巗dp淇℃伅涓竴鑷寸殑绔彛鍙戞祦锛岀鍙e叡浜玬edia.rtp.port-range锛岃繖浼氭崯澶变竴浜涙�ц兘锛�
     # 闈炰弗鏍兼ā寮忎娇鐢ㄩ殢鏈虹鍙e彂娴侊紝鎬ц兘鏇村ソ锛� 榛樿鍏抽棴
     gb-send-stream-strict: false
+    # 璁惧涓婄嚎鏃舵槸鍚﹁嚜鍔ㄥ悓姝ラ�氶亾
+    sync-channel-on-device-online: false
 
 # 鍏抽棴鍦ㄧ嚎鏂囨。锛堢敓浜х幆澧冨缓璁叧闂級
 springdoc:
diff --git a/web_src/src/components/dialog/SyncChannelProgress.vue b/web_src/src/components/dialog/SyncChannelProgress.vue
index c972a46..e1c9fe0 100644
--- a/web_src/src/components/dialog/SyncChannelProgress.vue
+++ b/web_src/src/components/dialog/SyncChannelProgress.vue
@@ -63,37 +63,29 @@
           }
 
           if (res.data.data != null) {
-            if (res.data.syncIng) {
+            if (res.data.data.syncIng) {
               if (res.data.data.total == 0) {
-                if (res.data.data.errorMsg !== null ){
-                  this.msg = res.data.data.errorMsg;
-                  this.syncStatus = "exception"
-                }else {
-                  this.msg = `绛夊緟鍚屾涓璥;
-                  this.timmer = setTimeout(this.getProgress, 300)
-                }
-              }else  {
-                if (res.data.data.total == res.data.data.current) {
-                  this.syncStatus = "success"
-                  this.percentage = 100;
-                  this.msg = '鍚屾鎴愬姛';
-                }else {
-                  if (res.data.data.errorMsg !== null ){
-                    this.msg = res.data.data.errorMsg;
-                    this.syncStatus = "exception"
-                  }else {
-                    this.total = res.data.data.total;
-                    this.current = res.data.data.current;
-                    this.percentage = Math.floor(Number(res.data.data.current)/Number(res.data.data.total)* 10000)/100;
-                    this.msg = `鍚屾涓�...[${res.data.data.current}/${res.data.data.total}]`;
-                    this.timmer = setTimeout(this.getProgress, 300)
-                  }
-                }
+                this.msg = `绛夊緟鍚屾涓璥;
+                this.timmer = setTimeout(this.getProgress, 300)
+              }else {
+                this.total = res.data.data.total;
+                this.current = res.data.data.current;
+                this.percentage = Math.floor(Number(res.data.data.current)/Number(res.data.data.total)* 10000)/100;
+                this.msg = `鍚屾涓�...[${res.data.data.current}/${res.data.data.total}]`;
+                this.timmer = setTimeout(this.getProgress, 300)
               }
             }else {
-              this.syncStatus = "success"
-              this.percentage = 100;
-              this.msg = '鍚屾鎴愬姛';
+              if (res.data.data.errorMsg){
+                this.msg = res.data.data.errorMsg;
+                this.syncStatus = "exception"
+              }else {
+                this.syncStatus = "success"
+                this.percentage = 100;
+                this.msg = '鍚屾鎴愬姛';
+                setTimeout(()=>{
+                  this.showDialog = false;
+                }, 3000)
+              }
             }
           }
         }else {

--
Gitblit v1.8.0