From c9bf16eb5322b9f3f3713166b5f2efc1a4448d58 Mon Sep 17 00:00:00 2001 From: liujun Date: Mon, 20 May 2024 13:51:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B9=9D=E5=85=AC=E5=8F=B8=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/map/dialog/index.vue | 4 +- src/views/map/dialog/peoplePositionYGS.vue | 2 +- src/views/map/index.vue | 66 +++++++++++++++++++++- static/config.js | 3 +- 4 files changed, 68 insertions(+), 7 deletions(-) diff --git a/src/views/map/dialog/index.vue b/src/views/map/dialog/index.vue index fccbc87..bf31cdf 100644 --- a/src/views/map/dialog/index.vue +++ b/src/views/map/dialog/index.vue @@ -48,8 +48,8 @@ - - + + diff --git a/src/views/map/dialog/peoplePositionYGS.vue b/src/views/map/dialog/peoplePositionYGS.vue index b0d1478..10191ed 100644 --- a/src/views/map/dialog/peoplePositionYGS.vue +++ b/src/views/map/dialog/peoplePositionYGS.vue @@ -41,7 +41,7 @@ 定位卡电量 - {{ info?otherInfo.data[3].currentValBody.val:'' }} + {{ info?(otherInfo?otherInfo.data[3].currentValBody.val:'*'):'' }} 部门 diff --git a/src/views/map/index.vue b/src/views/map/index.vue index 26ad6ec..73009bd 100644 --- a/src/views/map/index.vue +++ b/src/views/map/index.vue @@ -1762,6 +1762,10 @@ export default { this.clearMqttPoint('+/UwbBQ/') this.removeTrajectory() } + if (this.gangkouActive === '00003' && this.CORP_INFO_ID === '21590a00ea5e462e9ee44dd332dddc26' && urlType === 'peoplePosition') { + this.clearRYDWPoint('+/UwbBQ/') + this.removeTrajectory() + } this.bottomOptionsList[pindex].list[index].check = false if (this.gangkouActive === '00004') { this.cfdBottomOptionsList[pindex].list[index].check = false @@ -1782,6 +1786,9 @@ export default { if (this.gangkouActive === '00003' && this.CORP_INFO_ID === '035958e685cf4850bc40151c5e0617a6' && urlType === 'peoplePosition') { !this.connecting ? this.createConnection(this.CORP_INFO_ID) : this.doSubscribe() + } else if (this.gangkouActive === '00003' && this.CORP_INFO_ID === '21590a00ea5e462e9ee44dd332dddc26' && urlType === 'peoplePosition') { + // websocket实时获取人员定位 + this.initRYDWWebsocket('21590a00ea5e462e9ee44dd332dddc26') } else { requestFN( pointUrl, @@ -2042,7 +2049,7 @@ export default { }, // 查询当前点位是否在区域内 - isPointxyWithinTheArea(pointBox, x, y) { + isPointxyWithinTheArea(pointBox = {}, x, y) { if (this.forEachIsPointInPolygon(pointBox.redList, x, y)) { return '_1' } else if (this.forEachIsPointInPolygon(pointBox.orangeList, x, y)) { @@ -2153,6 +2160,15 @@ export default { delete this.mqttPoint[key] } }, + clearRYDWPoint(prefix) { + this.fwebsocket.close() + for (const mqttPointKey in this.mqttPoint) { + const key = prefix ? prefix + this.mqttPoint[mqttPointKey] : mqttPointKey + viewer.entities.removeById(this.mqttPoint[key]) + this.onePerLocArr = this.onePerLocArr.filter(item => item.data_id !== this.mqttPoint[key]) + delete this.mqttPoint[key] + } + }, // 订阅 doSubscribe() { const { topic, topic1, qos } = this.subscription @@ -2316,6 +2332,50 @@ export default { } } }, + // 九公司人员定位websocket + initRYDWWebsocket(CORP_INFO_ID) { + // eslint-disable-next-line no-unused-vars + const _this = this + if (window.WebSocket) { + const wsUrl = config.NoDwSysUrl + '/ltLocation/DW_' + new Date().getTime() + '_98' + _this.fwebsocket = new WebSocket(encodeURI(wsUrl)) + _this.fwebsocket.onmessage = function(message) { + console.info('接收消息') + const peopleList = JSON.parse(message.data).data.data + for (let i = 0; i < peopleList.length; i++) { + const item = peopleList[i] + if ((!item) || (item.ts === 1)) continue + // 将地图上剩余的点与最新的定位人员点进行对比 更新地图上已存在的点 新增地图上之前没有的点 + const index = _this.onePerLocArr.findIndex(item1 => { + return item1.id.toString() === item.id.toString() + }) + const x = item.lon + const y = item.lat + const pointColor = _this.isPointxyWithinTheArea(this.pointBox, x, y) + if (index !== -1) { + _this.onePerLocArr[index].x = x + _this.onePerLocArr[index].y = y + _this.onePerLocArr[index].icon_type = 'img4_0' + pointColor + ry_drag.getPosition(this.onePerLocArr[index]) + } else { + const perLoc = { + id: item.id, + x: x, + y: y, + icon_type: 'img4_0' + pointColor, + data_id: item.id, + point_type: '标记点peoplePositionOne', + label: '人员定位', + corpInfoId: CORP_INFO_ID + } + _this.onePerLocArr.push(perLoc) + ry_drag.addEntity(perLoc) + _this.mqttPoint[_this.subscription.topic.substring(0, _this.subscription.topic.lastIndexOf('+')) + item.id] = item.id + } + } + } + } + }, radomPer(mockData) { for (const item of mockData.data) { item.longitude += 0.0003 * Math.random() @@ -2551,7 +2611,7 @@ export default { }) }, // 查询当前点位是否在区域内 - isPointWithinTheArea(pointBox, point) { + isPointWithinTheArea(pointBox = {}, point) { if (this.forEachIsPointInPolygon(pointBox.redList, point.x, point.y)) { point.color = 'red' } else if (this.forEachIsPointInPolygon(pointBox.orangeList, point.x, point.y)) { @@ -2564,7 +2624,7 @@ export default { }, // 循环判断某个点是否在某些区域内。只要在任意一个区域内。则返回true - forEachIsPointInPolygon(polygonList, lng, lat) { + forEachIsPointInPolygon(polygonList = [], lng, lat) { return polygonList.some(item => { return this.isPointInPolygon(item.position, lng, lat) }) diff --git a/static/config.js b/static/config.js index b50dcfe..e50846a 100644 --- a/static/config.js +++ b/static/config.js @@ -9,5 +9,6 @@ const config = { weburlWaiwang: 'https://qgqy.qhdsafety.com/', // 服务器外网地址 httpurlWaiwang: 'https://qgqy.qhdsafety.com/qa-prevention-gwj/', // , fileUrlWaiwang: 'https://qgqy.qhdsafety.com/file/', // 服务器外网 附件地址, - publicKey: 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2zCyUYSD0pNrbtaYdvGfHfWoRV+fo/2N9O2PLLz/jZvMkigkq4eAq4JO+Ek0wDHI9WxP6iTSLYCHhIOs9CQTPvyldJFm8riZtQZlBTD8Plkb3rjrgwTqbBi3w3+HKYdkSvGFXJIdSOPbpXnj5BzN8vlVaybs24R/vpUzG9178lwIDAQAB' + publicKey: 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC2zCyUYSD0pNrbtaYdvGfHfWoRV+fo/2N9O2PLLz/jZvMkigkq4eAq4JO+Ek0wDHI9WxP6iTSLYCHhIOs9CQTPvyldJFm8riZtQZlBTD8Plkb3rjrgwTqbBi3w3+HKYdkSvGFXJIdSOPbpXnj5BzN8vlVaybs24R/vpUzG9178lwIDAQAB', + NoDwSysUrl: 'ws://192.168.151.27:9002' // 人员定位系统websocket地址 }