From c5b16e058dd1d517abea9a475897d9333c6e2e2e Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期三, 19 十月 2022 10:04:04 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/wvp-28181-2.0' into wvp-28181-2.0

---
 src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java   |   27 +++++++++++--
 sql/mysql.sql                                                             |    1 
 web_src/src/components/CloudRecord.vue                                    |   22 ++++++++--
 src/main/java/com/genersoft/iot/vmp/gb28181/conf/SipLoggerPass.java       |    1 
 README.md                                                                 |    3 -
 src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java |    8 ++-
 6 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/README.md b/README.md
index 45b1964..050c138 100644
--- a/README.md
+++ b/README.md
@@ -156,7 +156,6 @@
 
 # 鎺堟潈鍗忚
 鏈」鐩嚜鏈変唬鐮佷娇鐢ㄥ鏉剧殑MIT鍗忚锛屽湪淇濈暀鐗堟潈淇℃伅鐨勬儏鍐典笅鍙互鑷敱搴旂敤浜庡悇鑷晢鐢ㄣ�侀潪鍟嗕笟鐨勯」鐩�� 浣嗘槸鏈」鐩篃闆剁鐨勪娇鐢ㄤ簡涓�浜涘叾浠栫殑寮�婧愪唬鐮侊紝鍦ㄥ晢鐢ㄧ殑鎯呭喌涓嬭鑷鏇夸唬鎴栧墧闄わ紱 鐢变簬浣跨敤鏈」鐩�屼骇鐢熺殑鍟嗕笟绾犵悍鎴栦镜鏉冭涓轰竴姒備笌鏈」鐩強寮�鍙戣�呮棤鍏筹紝璇疯嚜琛屾壙鎷呮硶寰嬮闄┿�� 鍦ㄤ娇鐢ㄦ湰椤圭洰浠g爜鏃讹紝涔熷簲璇ュ湪鎺堟潈鍗忚涓悓鏃惰〃鏄庢湰椤圭洰渚濊禆鐨勭涓夋柟搴撶殑鍗忚
-
 # 鑷磋阿
 鎰熻阿浣滆�匸澶忔](https://github.com/xia-chu) 鎻愪緵杩欎箞妫掔殑寮�婧愭祦濯掍綋鏈嶅姟妗嗘灦,骞跺湪寮�鍙戣繃绋嬩腑缁欎簣鏀寔涓庡府鍔┿��     
 鎰熻阿浣滆�匸dexter langhuihui](https://github.com/langhuihui) 寮�婧愯繖涔堝ソ鐢ㄧ殑WEB鎾斁鍣ㄣ��     
@@ -166,7 +165,7 @@
 [hotcoffie](https://github.com/hotcoffie) [xiaomu](https://github.com/nikmu) [TristingChen](https://github.com/TristingChen)
 [chenparty](https://github.com/chenparty) [Hotleave](https://github.com/hotleave) [ydwxb](https://github.com/ydwxb)
 [ydpd](https://github.com/ydpd) [szy833](https://github.com/szy833) [ydwxb](https://github.com/ydwxb) [Albertzhu666](https://github.com/Albertzhu666)
-[mk1990](https://github.com/mk1990)
+[mk1990](https://github.com/mk1990) [SaltFish001](https://github.com/SaltFish001)
 
 ps: 鍒氬鍔犱簡杩欎釜鍚嶅崟锛岃偗瀹氶仐婕忎簡涓�浜涘ぇ浣紝娆㈣繋澶т浆鑱旂郴鎴戞坊鍔犮��
 
diff --git a/sql/mysql.sql b/sql/mysql.sql
index 6b937e5..e3e9e23 100644
--- a/sql/mysql.sql
+++ b/sql/mysql.sql
@@ -48,6 +48,7 @@
                           `ssrcCheck` int DEFAULT '0',
                           `geoCoordSys` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
                           `treeType` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
+                          `mediaServerId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT 'auto',
                           `custom_name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
                           `password` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
                           PRIMARY KEY (`id`),
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/conf/SipLoggerPass.java b/src/main/java/com/genersoft/iot/vmp/gb28181/conf/SipLoggerPass.java
index f8d6485..18dd151 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/conf/SipLoggerPass.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/conf/SipLoggerPass.java
@@ -6,6 +6,7 @@
 
 /**
  * sip鏃ュ織鏍煎紡鍖�
+ * 鏆備笉浣跨敤
  */
 public class SipLoggerPass implements StackLogger {
 
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 7ba2c4e..23a342b 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
@@ -118,6 +118,7 @@
             }
             sync(device);
         }else {
+
             if(device.getOnline() == 0){
                 device.setOnline(1);
                 device.setCreateTime(now);
@@ -132,6 +133,11 @@
                 sync(device);
                 // TODO 濡傛灉璁惧涓嬬殑閫氶亾绾ц仈鍒颁簡鍏朵粬骞冲彴锛岄偅涔堥渶瑕佸彂閫佷簨浠舵垨鑰卬otify缁欎笂绾у钩鍙�
             }else {
+                if (deviceChannelMapper.queryAllChannels(device.getDeviceId()).size() == 0) {
+                    logger.info("[璁惧涓婄嚎]: {}锛岄�氶亾鏁颁负0,鏌ヨ閫氶亾淇℃伅", device.getDeviceId());
+                    sync(device);
+                }
+
                 deviceMapper.update(device);
                 redisCatchStorage.updateDevice(device);
             }
@@ -362,10 +368,10 @@
                 return null;
             }
             // 浣跨敤琛屾斂鍖哄垝灞曠ず鏍�
-            if (parentId.length() > 10) {
-                // TODO 鍙兘鏄鏀垮尯鍒掍笌涓氬姟鍒嗙粍娣锋潅鐨勬儏褰�
-                return null;
-            }
+//            if (parentId.length() > 10) {
+//                // TODO 鍙兘鏄鏀垮尯鍒掍笌涓氬姟鍒嗙粍娣锋潅鐨勬儏褰�
+//                return null;
+//            }
 
             if (parentId.length() == 10 ) {
                 if (onlyCatalog) {
@@ -380,7 +386,18 @@
             List<DeviceChannel> channelsForCivilCode = deviceChannelMapper.getChannelsWithCivilCodeAndLength(deviceId, parentId, parentId.length() + 2);
             if (!onlyCatalog) {
                 List<DeviceChannel> channels = deviceChannelMapper.getChannelsByCivilCode(deviceId, parentId);
-                channelsForCivilCode.addAll(channels);
+
+                for(DeviceChannel channel : channels) {
+                    boolean flag = false;
+                    for(DeviceChannel deviceChannel : channelsForCivilCode) {
+                        if(channel.getChannelId().equals(deviceChannel.getChannelId())) {
+                            flag = true;
+                        }
+                    }
+                    if(!flag) {
+                        channelsForCivilCode.add(channel);
+                    }
+                }
             }
             List<BaseTree<DeviceChannel>> trees = transportChannelsToTree(channelsForCivilCode, parentId);
             return trees;
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
index 3ef412d..9b2a099 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
@@ -71,7 +71,7 @@
             "WHERE " +
             "dc.deviceId = #{deviceId} " +
             " <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
-            " <if test='parentChannelId != null'> AND dc.parentId=#{parentChannelId} </if> " +
+            " <if test='parentChannelId != null'> AND (dc.parentId=#{parentChannelId} OR dc.civilCode = #{parentChannelId}) </if> " +
             " <if test='online == true' > AND dc.status=1</if>" +
             " <if test='online == false' > AND dc.status=0</if>" +
             " <if test='hasSubChannel == true' >  AND dc.subCount > 0 </if>" +
@@ -309,8 +309,10 @@
             "select * " +
             "from device_channel " +
             "where deviceId=#{deviceId}" +
-            " <if test='parentId != null' > and left(channelId, ${parentId.length()}) = #{parentId}</if>" +
-            " <if test='length != null' > and length(channelId)=${length}</if>" +
+            " <if test='parentId != null and length != null' > and parentId = #{parentId} or left(channelId, ${parentId.length()}) = #{parentId} and length(channelId)=${length} </if>" +
+            " <if test='parentId == null and length != null' > and parentId = #{parentId} or length(channelId)=${length} </if>" +
+            " <if test='parentId == null and length == null' > and parentId = #{parentId} </if>" +
+            " <if test='parentId != null and length == null' > and parentId = #{parentId} or left(channelId, ${parentId.length()}) = #{parentId} </if>" +
             " </script>"})
     List<DeviceChannel> getChannelsWithCivilCodeAndLength(String deviceId, String parentId, Integer length);
 
diff --git a/web_src/src/components/CloudRecord.vue b/web_src/src/components/CloudRecord.vue
index 4784e05..b046fc9 100644
--- a/web_src/src/components/CloudRecord.vue
+++ b/web_src/src/components/CloudRecord.vue
@@ -109,14 +109,25 @@
           that.mediaServerList = data.data;
           if (that.mediaServerList.length > 0) {
             that.mediaServerId = that.mediaServerList[0].id
-            let port = that.mediaServerList[0].httpPort;
-            if (location.protocol === "https:" && that.mediaServerList[0].httpSSlPort) {
-              port = that.mediaServerList[0].httpSSlPort
-            }
-            that.mediaServerPath = location.protocol + "//" + that.mediaServerList[0].streamIp + ":" + port
+            that.setMediaServerPath(that.mediaServerId);
             that.getRecordList();
           }
         })
+      },
+      setMediaServerPath: function (serverId) {
+        let that = this;
+        let i;
+        for (i = 0; i < that.mediaServerList.length; i++) {
+          if (serverId === that.mediaServerList[i].id) {
+            break;
+          }
+        }
+        let port = that.mediaServerList[i].httpPort;
+        if (location.protocol === "https:" && that.mediaServerList[i].httpSSlPort) {
+          port = that.mediaServerList[i].httpSSlPort
+        }
+        that.mediaServerPath = location.protocol + "//" + that.mediaServerList[i].streamIp + ":" + port
+        console.log(that.mediaServerPath)
       },
       getRecordList: function (){
         let that = this;
@@ -146,6 +157,7 @@
           console.log(val)
           this.total = 0;
           this.recordList = [];
+          this.setMediaServerPath(val);
           this.getRecordList();
       },
       showRecordDetail(row){

--
Gitblit v1.8.0