Merge remote-tracking branch 'origin/liujun-2024-04-12-一公司人员定位' into liujun-2024-04-12-一公司人员定位
commit
6b631223eb
|
@ -1116,8 +1116,8 @@ export default {
|
|||
},
|
||||
subscription: {
|
||||
// '+'是通配符
|
||||
// topic: '+/+/+/alarm',
|
||||
topic: '+/UwbBQ/+/prop',
|
||||
topic1: '+/+/+/alarm',
|
||||
qos: 0
|
||||
},
|
||||
|
||||
|
@ -1468,6 +1468,11 @@ export default {
|
|||
}
|
||||
// var cartesian = this.getCatesian3FromPX(movement.position)
|
||||
}, Cesium.ScreenSpaceEventType.LEFT_CLICK)
|
||||
viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_DOUBLE_CLICK)
|
||||
viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(Cesium.ScreenSpaceEventType.RIGHT_CLICK)
|
||||
document.addEventListener('contextmenu', function(event) {
|
||||
event.preventDefault()
|
||||
})
|
||||
this.handler.setInputAction(movement => {
|
||||
const pick = viewer.scene.pick(movement.position)
|
||||
if (Cesium.defined(pick) && (pick.id.id)) {
|
||||
|
@ -1479,6 +1484,7 @@ export default {
|
|||
const point_id = pick.id._monitoItems.data.id
|
||||
const corpInfoId = pick.id._monitoItems.data.corpInfoId
|
||||
if (point_type === '标记点peoplePositionOne') {
|
||||
this.removeTrajectory()
|
||||
this.addTrajectory(point_id, corpInfoId)
|
||||
}
|
||||
} else {
|
||||
|
@ -1494,22 +1500,24 @@ export default {
|
|||
corpId: corpInfoId
|
||||
}
|
||||
).then((data) => {
|
||||
console.log(data.list)
|
||||
const positions = []
|
||||
for (let i = 0; i < data.list.length; i++) {
|
||||
positions.push(Cesium.Cartesian3.fromDegrees(data.list[i].XAxis, data.list[i].YAxis))
|
||||
if (data.list) {
|
||||
const positions = []
|
||||
for (let i = 0; i < data.list.length; i++) {
|
||||
positions.push(Cesium.Cartesian3.fromDegrees(data.list[i].XAxis, data.list[i].YAxis))
|
||||
}
|
||||
const entity = new Cesium.Entity({
|
||||
id: 'trajectory',
|
||||
polyline: { positions, width: 5.0, material: Cesium.Color.RED }
|
||||
})
|
||||
const collection = new Cesium.CustomDataSource('trajectoryEntityCollection')
|
||||
collection.entities.add(entity)
|
||||
viewer.dataSources.add(collection)
|
||||
this.trajectoryEntityCollection = collection
|
||||
}
|
||||
const entity = new Cesium.Entity({
|
||||
id: 'trajectory',
|
||||
polyline: { positions, width: 5.0, material: Cesium.Color.RED }
|
||||
})
|
||||
const collection = new Cesium.CustomDataSource('trajectoryEntityCollection')
|
||||
collection.entities.add(entity)
|
||||
viewer.dataSources.add(collection)
|
||||
this.trajectoryEntityCollection = collection
|
||||
})
|
||||
},
|
||||
removeTrajectory() {
|
||||
if (Object.keys(this.trajectoryEntityCollection).length === 0) return
|
||||
viewer.dataSources.remove(this.trajectoryEntityCollection)
|
||||
this.trajectoryEntityCollection = {}
|
||||
},
|
||||
|
@ -2060,6 +2068,7 @@ export default {
|
|||
if (this.gangkouActive === '00003' && this.CORP_INFO_ID === '035958e685cf4850bc40151c5e0617a6' && urlType === 'peoplePosition') {
|
||||
this.doUnSubscribe()
|
||||
this.clearMqttPoint('+/UwbBQ/')
|
||||
this.removeTrajectory()
|
||||
}
|
||||
this.bottomOptionsList[pindex].list[index].check = false
|
||||
if (this.gangkouActive === '00004') {
|
||||
|
@ -2578,45 +2587,55 @@ export default {
|
|||
},
|
||||
mqttMessage(CORP_INFO_ID) {
|
||||
this.client.on('message', (topic, message) => {
|
||||
// created by liu jun mqtt返回的参数可能是一个数组
|
||||
let peopleList = JSON.parse(message)
|
||||
if (!Array.isArray(peopleList)) {
|
||||
peopleList = [peopleList]
|
||||
}
|
||||
for (let i = 0; i < peopleList.length; i++) {
|
||||
const item = peopleList[i]
|
||||
// 如果不是人员信息则跳过
|
||||
// UwbBQ是人员定位卡的id(UwbJiZhan这是基站的id)
|
||||
if (item.productKey !== 'UwbBQ') {
|
||||
continue
|
||||
if (topic.indexOf('UwbBQ') !== -1 && topic.indexOf('prop') !== -1) {
|
||||
// created by liu jun mqtt返回的参数可能是一个数组
|
||||
let peopleList = JSON.parse(message)
|
||||
if (!Array.isArray(peopleList)) {
|
||||
peopleList = [peopleList]
|
||||
}
|
||||
// 将地图上剩余的点与最新的定位人员点进行对比更新地图上已存在的点新增地图上之前没有的点
|
||||
const index = this.onePerLocArr.findIndex(item1 => {
|
||||
return item1.id.toString() === item.deviceCode.toString()
|
||||
})
|
||||
const x = item.properties[2].value
|
||||
const y = item.properties[3].value
|
||||
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.deviceCode,
|
||||
x: x,
|
||||
y: y,
|
||||
icon_type: 'img4_0' + pointColor,
|
||||
data_id: item.deviceCode,
|
||||
point_type: '标记点peoplePositionOne',
|
||||
label: '人员定位',
|
||||
corpInfoId: CORP_INFO_ID
|
||||
for (let i = 0; i < peopleList.length; i++) {
|
||||
const item = peopleList[i]
|
||||
// 如果不是人员信息则跳过
|
||||
// UwbBQ是人员定位卡的id(UwbJiZhan这是基站的id)
|
||||
if (item.productKey !== 'UwbBQ') {
|
||||
continue
|
||||
}
|
||||
// 将地图上剩余的点与最新的定位人员点进行对比更新地图上已存在的点新增地图上之前没有的点
|
||||
const index = this.onePerLocArr.findIndex(item1 => {
|
||||
return item1.id.toString() === item.deviceCode.toString()
|
||||
})
|
||||
const x = item.properties[2].value
|
||||
const y = item.properties[3].value
|
||||
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.deviceCode,
|
||||
x: x,
|
||||
y: y,
|
||||
icon_type: 'img4_0' + pointColor,
|
||||
data_id: item.deviceCode,
|
||||
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.deviceCode] = item.deviceCode
|
||||
}
|
||||
this.onePerLocArr.push(perLoc)
|
||||
ry_drag.addEntity(perLoc)
|
||||
this.mqttPoint[this.subscription.topic.substring(0, this.subscription.topic.lastIndexOf('+')) + item.deviceCode] = item.deviceCode
|
||||
}
|
||||
} else if (topic.indexOf('alarm') !== -1) {
|
||||
const formatMessage = JSON.parse(message)
|
||||
this.$notify({
|
||||
title: '报警信息',
|
||||
dangerouslyUseHTMLString: true,
|
||||
message: `部门:${formatMessage.deptName}<br/>类型:${formatMessage.identifierName}`,
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
@ -2638,8 +2657,8 @@ export default {
|
|||
},
|
||||
// 订阅
|
||||
doSubscribe() {
|
||||
const { topic, qos } = this.subscription
|
||||
this.client.subscribe(topic, { qos }, (error, res) => {
|
||||
const { topic, topic1, qos } = this.subscription
|
||||
this.client.subscribe([topic, topic1], { qos }, (error, res) => {
|
||||
if (error) {
|
||||
console.log('Subscribe to topics error', error)
|
||||
return
|
||||
|
@ -2650,8 +2669,8 @@ export default {
|
|||
},
|
||||
// 取消订阅
|
||||
doUnSubscribe() {
|
||||
const { topic } = this.subscription
|
||||
this.client.unsubscribe(topic, error => {
|
||||
const { topic, topic1 } = this.subscription
|
||||
this.client.unsubscribe([topic, topic1], error => {
|
||||
if (error) {
|
||||
console.log('Subscribe to topics error', error)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue