Procházet zdrojové kódy

Merge remote-tracking branch 'origin/visu_water' into visu_water

JX.LI před 2 roky
rodič
revize
2e68ecc92e
3 změnil soubory, kde provedl 166 přidání a 13 odebrání
  1. 11 7
      src/components/TVWall.vue
  2. 102 2
      src/components/vBottomMenu.vue
  3. 53 4
      src/views/monitor.vue

+ 11 - 7
src/components/TVWall.vue

@@ -380,7 +380,12 @@ export default {
       this.TVWallVisible = true
 
     },
-    showTVWall() {
+    showTVWall(tvListJson, bfArray) {
+      if(tvListJson){
+        this.preview(tvListJson, bfArray);
+        this.TVWallVisible = true;
+        return;
+      }
       // let that=this;
       /** ----------------------------------大华摄像头预览开始------------------------------------- */
       this.ws.addEventListener('connectStateChange', data => {
@@ -429,7 +434,7 @@ export default {
       this.$modal.msgWarning('请重新安装客户端')
     },
     /** 预览按钮操作 */
-    preview() {
+    preview(tvListJson, bfArray) {
       getTVWallList().then(newres => {
         getDahuaVideoServer().then(newResponse => {
           this.ws.detectConnectQt().then(res => {
@@ -453,7 +458,7 @@ export default {
                 if (res) {
                   this.alertLoginSuccess()
                   this.activePanel = 'key2'
-                  this.create(newres.data)
+                  this.create(tvListJson?tvListJson:newres.data, bfArray);
                 } else {
                   this.alertLoginFailed()
                 }
@@ -501,7 +506,7 @@ export default {
       })
     },
 
-    create(tvListJson) { // 调用创建控件接口
+    create(tvListJson, bfArray) { // 调用创建控件接口
       let _this = this
       const params = [
         {
@@ -522,9 +527,8 @@ export default {
       ]
       this.setPos()
       this.customizeTree(tvListJson);
-      setTimeout(function () {
-        _this.ws.createCtrl(params);
-      }, 3000);
+      _this.ws.createCtrl(params);
+      _this.playRealMonitorVideo(bfArray);
     },
     setPos() {
       let target = document.getElementById(this.domId)

+ 102 - 2
src/components/vBottomMenu.vue

@@ -496,8 +496,14 @@
 				searchFB: '',
 				filterchang: '', //林场搜索
 				btmCurrent: '',
-
-				eventWarn: false, //webSocket事件问题警报标记
+        websock: '',
+        wsuri:'ws://127.0.0.1:10012/messagePush/',
+        wsuri2:'ws://127.0.0.1:10005/taskPush/',
+        setIntervalWesocketPush: null,
+        websockSid: {
+          userId: ''
+        },
+        eventWarn: false, //webSocket事件问题警报标记
 			}
 		},
 		created() {
@@ -506,7 +512,99 @@
 				this.deptOptionsLiandong = response.data
 			})
 		},
+    mounted() {
+      this.websockSid.userId=Cookies.get("userId")
+    },
 		methods: {
+      initWebSocket(wsurl,userId) {        //初始化weosocket
+        //const wsuri = 'ws://127.0.0.1:10003/eventPush/' + userId + '/' + eventTypeDl + '/' + eventType
+        const wsuri = wsurl+userId
+        // const wsuri = 'ws://172.28.20.82:10012/taskPush/'+userId
+        this.websock = new WebSocket(wsuri)
+        console.log('建立websocket连接'+wsuri)
+        this.websock.onopen = this.websocketonopen
+        this.websock.onmessage = this.websocketonmessage
+        this.websock.onerror = this.websocketonerror
+      },
+      websocketonopen() { //连接建立之后执行send方法发送数据
+        console.log('websocket连接成功')
+        this.weosocket = true
+        this.sendPing()
+      },
+      websocketonerror() { //连接建立失败重连
+        this.initWebSocket(this.wsuri,this.websockSid.userId)
+      },
+      websocketonmessage(e) { //数据接收
+        console.log('接收数据', e.data)
+        // let data = "{\"fromId\":\"farming\"}";
+        // 处理收到的消息
+        this.handleWebSoceketEvent(e.data)
+      },
+      handleWebSoceketEvent(val) {
+        let that = this
+        let data = JSON.parse(val)
+        console.log('数据数据数据数据',data)
+        /**
+         * that.markersList.filter( item => data.eventCode == item.parameter).length == 0 如果地图中不存在当前事件则添加
+         * eventPush: 事件列表消息
+         * */
+        let  message=data.centermessageTPushrecord
+        let message2=data.centertaskTTask
+        if (null!=message)
+        {
+          console.log(message)
+          this.messageList.push(message)
+          this.messageCount++
+        }else if (null!=message2)
+        {
+          this.taskList.push(message2)
+          this.taskCount ++
+        }
+
+
+
+        // if (data.tag == "eventPush" && that.markersList.filter( item => data.eventCode == item.parameter).length == 0) {
+        //   getEventPush({eventCode: data.eventCode}).then((res) => {
+        //     if (res.data != undefined) {
+        //       //插入到第一条
+        //       this.eventList.unshift(res.data)
+        //       // 插入后删除最后一条 保证列表中为10条数据
+        //       if (this.eventList.length > 9)
+        //         this.eventList.splice(10, 1)
+        //       // 将收到的数据在地图上添加
+        //       this.getWebSocketEvent(res.data)
+        //     }
+        //   })
+        // }
+
+        console.log(data)
+      },
+
+
+      websocketsend(Data) { //数据发送
+        this.websock.send(Data)
+      },
+      websocketclose(e) { //关闭
+        console.log('断开连接', e)
+        // clearInterval(this.setIntervalWesocketPush)
+        this.weosocket = false
+      },
+      /**发送心跳
+       * @param {number} time 心跳间隔毫秒 默认5000
+       * @param {string} ping 心跳名称 默认字符串ping
+       */
+      sendPing(time = 60000, ping = {
+        'fromId': 'farming'
+      }) {
+        clearInterval(this.setIntervalWesocketPush)
+        this.setIntervalWesocketPush = setInterval(() => {
+          if (this.weosocket) {
+            this.websock.send(JSON.stringify(ping))
+          } else {
+            // this.initWebSocket()
+          }
+        }, time)
+      },
 			filterbanNode(value, data) {
 				//树搜索
 				if (!value) return true
@@ -696,6 +794,7 @@
 					this.taskList = res.data
 					this.taskCount = res.data.length
 				})
+        this.initWebSocket(this.wsuri2,this.websockSid.userId)
 			},
       selectMessageById(id) {
         selectMessageById(id).then(response => {
@@ -715,6 +814,7 @@
           this.messageList = response.data
           this.messageCount = response.data.length
         });
+        this.initWebSocket(this.wsuri,this.websockSid.userId)
       },
 			handleCheckedCitiesChangeBan(value) {
 				this.choseLayerSwitchingList(this.banCheckList)

+ 53 - 4
src/views/monitor.vue

@@ -288,6 +288,44 @@ export default {
     }
   },
   methods: {
+    /* 电视墙替换开始 */
+    showTVWall(channelCode, channelName) {
+      // let channelCode = '6044981090191552';
+      // let channelName = '复兴大桥中段-交通事故';
+      let tvListJson = [
+        {
+          'switchTab': '1',
+          'treeLabels': [
+            {
+              'labelCode': '123456',
+              'labelName': '视频场景',
+              'parentLabelCode': null
+            },
+            {
+              'labelCode': 'd941adbbd3e64dac92cc448dec5293cd',
+              'labelName': channelName,
+              'parentLabelCode': 123456
+            }
+          ],
+          'labelChannels': [{
+            'channelDates': [{
+              'channelCode': channelCode,
+              'channelName': channelName,
+              'channelSn': null,
+              'cameraType': 1,
+              'online': 1
+            }],
+            'labelCode': 'd941adbbd3e64dac92cc448dec5293cd'
+          }]
+        }
+      ]
+      this.$refs.TVWall.showTVWall(tvListJson, [{"channelId": channelCode}]);
+      this.$refs.supermap.isEditableLayers = false;
+      this.$refs.bottomMenu.showChild = false;
+      this.$refs.bottomMenu.showBanChild = false;
+      this.$refs.bottomMenu.showChangChild = false;
+    },
+    /* 电视墙替换结束 */
     /** 部门树*/
 // 查询部门下拉树结构
     getTreeselect() {
@@ -446,8 +484,11 @@ export default {
               isAggregation: false
             }
             if (res.data.visuForestCloudCameraBOList[i].channelCode != null) {
-              markersMap.parameter = {code:res.data.visuForestCloudCameraBOList[i].cameraCode,
-                type:res.data.visuForestCloudCameraBOList[i].cameraFactory}
+              markersMap.parameter = {
+                code:res.data.visuForestCloudCameraBOList[i].cameraCode,
+                name:res.data.visuForestCloudCameraBOList[i].cameraName,
+                type:res.data.visuForestCloudCameraBOList[i].cameraFactory
+              }
             } else {
               markersMap.parameter = []
             }
@@ -546,8 +587,11 @@ export default {
               isAggregation: false
             }
             if (res.data[i].channelCode != null) {
-              markersMap.parameter = {code:res.data[i].cameraCode,
-                type:res.data[i].cameraFactory}
+              markersMap.parameter = {
+                code:res.data[i].cameraCode,
+                name:res.data[i].cameraName,
+                type:res.data[i].cameraFactory
+              }
             } else {
               markersMap.parameter = []
             }
@@ -653,6 +697,11 @@ export default {
     },
     /** 预览按钮操作 */
     preview(cameraParam) {
+      this.showTVWall(cameraParam.code, cameraParam.name);
+    },
+
+    /** 预览按钮操作 */
+    preview_废弃(cameraParam) {
       if(cameraParam.type=='1'){
         getDahuaVideoServer().then(newResponse => {
           console.log(newResponse)