一公司人员定位
parent
abdc5a6b76
commit
5ca3e60ec3
|
@ -366,6 +366,7 @@ export default {
|
|||
],
|
||||
myEntityCollection: {},
|
||||
poinEntity: {},
|
||||
mqttPoint: {},
|
||||
gangkouActive: '',
|
||||
centerOptionsList: [
|
||||
{ label: '秦皇岛西', AREA: '2' },
|
||||
|
@ -1333,7 +1334,7 @@ export default {
|
|||
},
|
||||
|
||||
// 过滤经纬度为空
|
||||
filterNull(arr) {
|
||||
filterNull(arr = []) {
|
||||
return arr.filter(item => item.LONGITUDE && item.LATITUDE)
|
||||
},
|
||||
|
||||
|
@ -1634,6 +1635,8 @@ export default {
|
|||
this.clearAllBottomOptionsItemsEntityCollection()
|
||||
this.dragAreaEntity(this.branchPoint)
|
||||
this.toCenter(this.parentCenter)
|
||||
this.destroyConnection()
|
||||
this.clearMqttPoint()
|
||||
} else if (!this.CORP_INFO_ID) {
|
||||
this.gangkouActive = ''
|
||||
this.area = ''
|
||||
|
@ -1677,8 +1680,8 @@ export default {
|
|||
this.carLocArr = []
|
||||
}
|
||||
if (this.gangkouActive === '00003' && this.CORP_INFO_ID === '035958e685cf4850bc40151c5e0617a6' && urlType === 'peoplePosition') {
|
||||
this.destroyConnection()
|
||||
this.onePerLocArr = []
|
||||
this.doUnSubscribe()
|
||||
this.clearMqttPoint('1698584148364034050/UwbBQ/')
|
||||
}
|
||||
this.bottomOptionsList[pindex].list[index].check = false
|
||||
if (this.gangkouActive === '00004') {
|
||||
|
@ -1698,7 +1701,7 @@ export default {
|
|||
}
|
||||
|
||||
if (this.gangkouActive === '00003' && this.CORP_INFO_ID === '035958e685cf4850bc40151c5e0617a6' && urlType === 'peoplePosition') {
|
||||
this.createConnection()
|
||||
!this.connecting ? this.createConnection() : this.doSubscribe()
|
||||
} else {
|
||||
requestFN(
|
||||
pointUrl,
|
||||
|
@ -1943,14 +1946,13 @@ export default {
|
|||
// 创建连接
|
||||
createConnection() {
|
||||
try {
|
||||
this.connecting = true
|
||||
const { protocol, host, port, endpoint, ...options } = this.connection
|
||||
const connectUrl = `${protocol}://${host}:${port}${endpoint}`
|
||||
this.client = mqtt.connect(connectUrl, options)
|
||||
|
||||
if (this.client.on) {
|
||||
this.client.on('connect', () => {
|
||||
this.connecting = false
|
||||
this.connecting = true
|
||||
console.log('Connection succeeded!')
|
||||
|
||||
this.doSubscribe()
|
||||
|
@ -1959,8 +1961,16 @@ export default {
|
|||
this.client.on('error', error => {
|
||||
console.log('Connection failed', error)
|
||||
})
|
||||
this.mqttMessage()
|
||||
}
|
||||
} catch (error) {
|
||||
this.connecting = false
|
||||
console.log('mqtt.connect error', error)
|
||||
}
|
||||
},
|
||||
mqttMessage() {
|
||||
this.client.on('message', (topic, message) => {
|
||||
console.info(message)
|
||||
// console.info(message)
|
||||
// if(this.intOne === 0){
|
||||
// this.receiveNews = this.receiveNews.concat(message)
|
||||
// console.log(`Received message ${message} from topic ${topic}`)
|
||||
|
@ -1992,6 +2002,7 @@ export default {
|
|||
}
|
||||
this.onePerLocArr.push(perLoc)
|
||||
ry_drag.addEntity(perLoc)
|
||||
this.mqttPoint[this.subscription.topic.substring(0, this.subscription.topic.lastIndexOf('+')) + item.deviceCode] = item.deviceCode
|
||||
}
|
||||
// this.intOne++
|
||||
// } else if(this.intOne < 5){
|
||||
|
@ -2000,10 +2011,12 @@ export default {
|
|||
// this.intOne = 0
|
||||
// }
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
this.connecting = false
|
||||
console.log('mqtt.connect error', error)
|
||||
},
|
||||
clearMqttPoint(prefix) {
|
||||
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])
|
||||
}
|
||||
},
|
||||
// 订阅
|
||||
|
@ -2018,6 +2031,15 @@ export default {
|
|||
console.log('Subscribe to topics res', res)
|
||||
})
|
||||
},
|
||||
// 取消订阅
|
||||
doUnSubscribe() {
|
||||
const { topic } = this.subscription
|
||||
this.client.unsubscribe(topic, error => {
|
||||
if (error) {
|
||||
console.log('Subscribe to topics error', error)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
handleOnReConnect() {
|
||||
this.retryTimes += 1
|
||||
|
@ -2132,6 +2154,7 @@ export default {
|
|||
const index = ninePerLoc.findIndex(item1 => {
|
||||
return item1.id.toString() === item.cardId.toString()
|
||||
})
|
||||
this.isPointWithinTheArea(this.pointBox, )
|
||||
if (index !== -1) {
|
||||
ninePerLoc[index].x = item.longitude
|
||||
ninePerLoc[index].y = item.latitude
|
||||
|
|
Loading…
Reference in New Issue