123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- import { Entity, NearFarScalar, PolylineDashMaterialProperty, DistanceDisplayCondition, Cartesian3, Color, PropertyBag } from "cesium";
- import { getAccessInfoList, getAreaPersonList, getAccessLogList } from "@/API/accessControl";
- import { flyToByViewer, addNewDatasource, flyToPerspective } from "@/utils/mapUtil";
- import { _locate } from '@/utils'
- import { getViewer } from "@/store/map/mapService";
- import { mapGetters } from 'vuex'
- export default {
- name: 'znmj',
- data() {
- return {
- znmjDataSourceName: 'znmj',
- znmjDataSourceShow: false,
- znmjTagsData: [],
- }
- },
- computed: {
- ...mapGetters(['buildId', 'buildInfo']),
- },
- watch: {
- buildId: {
- handler(val) {
- // console.log('智能门禁图层建筑变化', val)
- if (!val) return
- setTimeout(() => {
- this.getZnmjTagsData()
- }, 2000)
- },
- immediate: true,
- },
- },
- mounted() {
- setTimeout(() => {
- this.initZnmj()
- }, 1000)
- },
- methods: {
- /**
- * 初始化
- */
- initZnmj() {
- this.$store.dispatch('globalConfig/pushSwitchConfig', {
- type: this.znmjDataSourceName,
- label: '安防门禁',
- name: '安防门禁',
- show: this.znmjDataSourceShow,
- selected: false,
- elements: this.znmjTagsData,
- })
- },
- async getZnmjTagsData() {
- try {
- let p = { enable: true, buildId: this.buildInfo.positioningBuildId }
- let res = await getAccessInfoList(p)
- // console.log('智能门禁数据', res)
- this.znmjTagsData = res.data.content || []
- this.$store.dispatch('globalConfig/updateSwitchConfig', {
- type: this.znmjDataSourceName,
- label: '安防门禁',
- name: '安防门禁',
- show: this.znmjDataSourceShow,
- selected: false,
- elements: this.znmjTagsData,
- })
- this.addZnmjTags()
- } catch (err) {
- console.log(err)
- }
- },
- addZnmjTags() {
- let dataSource = addNewDatasource('layer_' + this.znmjDataSourceName)
- // console.log("智能门禁基础信息", this.znmjTagsData);
- this.znmjTagsData.forEach(d => {
- d.GPSPoints = this.transPosition([{ x: d.location.x, y: d.location.y, z: d.height }])
- dataSource.entities.add(
- new Entity({
- id: d.id,
- name: d.name,
- show: false,
- position: Cartesian3.fromDegrees(...d.GPSPoints[0]),
- billboard: {
- image: '/imgs/camera/icon_ZJ_nor@2x.png',
- scale: 0.5, //固定值
- scaleByDistance: new NearFarScalar(10, 1, 10000, 1),
- },
- polyline: {
- positions: Cartesian3.fromDegreesArrayHeights([
- d.GPSPoints[0][0],
- d.GPSPoints[0][1],
- d.GPSPoints[0][2],
- d.GPSPoints[0][0],
- d.GPSPoints[0][1],
- 0,
- ]),
- width: 2,
- material: new PolylineDashMaterialProperty({
- color: Color.CYAN,
- }),
- },
- properties: new PropertyBag({
- type: 'znmj',
- details: d,
- isZnmj: true,
- }),
- })
- )
- })
- },
- async pushZnmjStatus(data) {
- if (data.id) {
- if (data?.buildId === this.buildInfo?.positioningBuildId) {
- // console.log("聚焦报警");
- this.animationZnmj(data)
- } else {
- const curStation = GY_STATIONS.find(e => e.positioningBuildId === data.buildId)
- // console.log('报警站点信息:', curStation)
- if (!curStation) return
- this.$store.dispatch('globalConfig/setMapMode', {
- value: '3d',
- })
- await this.$store.dispatch('model/setBuildInfoByBuildId', curStation.buildId)
- setTimeout(() => {
- this.animationZnmj(data)
- }, 3000)
- }
- }
- },
- animationZnmj(data) {
- const viewer = getViewer()
- const dataSource = viewer.dataSources.getByName('layer_znmj')
- if (dataSource.length > 0) {
- let item = dataSource[0].entities.getById(data.accessControl.id)
- // console.log(item, "地图实体数据", item.properties.details._value, '接收参数', data);
- if (!!item) {
- const { longitude, latitude } = this.buildInfo.gpsCoordinate0
- const gpsAlarmPoint = _locate(item.properties.details._value.location.x, item.properties.details._value.location.y, { x: longitude, y: latitude })
- //地图元素
- item.show = true
- setTimeout(() => {
- item.billboard = {
- image: '/imgs/camera/icon_ZJ_nor@2x.png',
- width: 50,
- height: 50,
- // verticalOrigin: VerticalOrigin.BOTTOM,
- distanceDisplayCondition: new DistanceDisplayCondition(0, 700.0),
- }
- item.position = Cartesian3.fromDegrees(gpsAlarmPoint.x, gpsAlarmPoint.y, item.properties.details._value.height)
- //视角漂移
- // flyToByViewer(item)
- flyToPerspective({
- destination: Cartesian3.fromDegrees(gpsAlarmPoint.x + 0.00026, gpsAlarmPoint.y - 0.0011, 100),
- orientation: {
- pitch: -0.549380381243696,
- heading: 6.181746598877237,
- roll: 0.0000025332551629730915, //倾斜视角坐标需要加偏移量
- },
- duration: 1.5,
- })
- //增加属性
- // item.properties.details._value.alarmPoint = data.alarmPoint
- // item.properties.details._value.alarmType = data.alarmType
- // item.properties.details._value.camera = data.camera
- // item.properties.details._value.alarmState = 1
- // item.properties.details._value.alarmStatus = true
- // item.properties.details._value.alarmPosition = [gpsAlarmPoint.x, gpsAlarmPoint.y, item.properties.details._value.height]
- // console.log(item.properties.details._value, "66666666666666666666666666666");
- //数据弹窗
- // this.$store.dispatch('globalConfig/updateAlarmDataObj', {
- // fire: [item.properties.details._value],
- // })
- //视频弹窗
- // if (!!data?.camera?.id) {
- // this.$store.dispatch('dialog/openVideoDialog', data.accessControl.ccameraID)
- // }
- }, 1000)
- }
- }
- },
- transPosition(pointList = []) {
- const { longitude, latitude } = this.buildInfo.gpsCoordinate0
- return pointList.reduce((pre, cur) => {
- const { x, y } = _locate(cur.x, cur.y, { x: longitude, y: latitude })
- pre.push([x, y, +cur.z])
- return pre
- }, [])
- },
- },
- }
|