accessControl.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. import { Entity, NearFarScalar, PolylineDashMaterialProperty, DistanceDisplayCondition, Cartesian3, Color, PropertyBag } from "cesium";
  2. import { getAccessInfoList, getAreaPersonList, getAccessLogList } from "@/API/accessControl";
  3. import { flyToByViewer, addNewDatasource, flyToPerspective } from "@/utils/mapUtil";
  4. import { _locate } from '@/utils'
  5. import { getViewer } from "@/store/map/mapService";
  6. import { mapGetters } from 'vuex'
  7. export default {
  8. name: 'znmj',
  9. data() {
  10. return {
  11. znmjDataSourceName: 'znmj',
  12. znmjDataSourceShow: false,
  13. znmjTagsData: [],
  14. }
  15. },
  16. computed: {
  17. ...mapGetters(['buildId', 'buildInfo']),
  18. },
  19. watch: {
  20. buildId: {
  21. handler(val) {
  22. // console.log('智能门禁图层建筑变化', val)
  23. if (!val) return
  24. setTimeout(() => {
  25. this.getZnmjTagsData()
  26. }, 2000)
  27. },
  28. immediate: true,
  29. },
  30. },
  31. mounted() {
  32. setTimeout(() => {
  33. this.initZnmj()
  34. }, 1000)
  35. },
  36. methods: {
  37. /**
  38. * 初始化
  39. */
  40. initZnmj() {
  41. this.$store.dispatch('globalConfig/pushSwitchConfig', {
  42. type: this.znmjDataSourceName,
  43. label: '安防门禁',
  44. name: '安防门禁',
  45. show: this.znmjDataSourceShow,
  46. selected: false,
  47. elements: this.znmjTagsData,
  48. })
  49. },
  50. async getZnmjTagsData() {
  51. try {
  52. let p = { enable: true, buildId: this.buildInfo.positioningBuildId }
  53. let res = await getAccessInfoList(p)
  54. // console.log('智能门禁数据', res)
  55. this.znmjTagsData = res.data.content || []
  56. this.$store.dispatch('globalConfig/updateSwitchConfig', {
  57. type: this.znmjDataSourceName,
  58. label: '安防门禁',
  59. name: '安防门禁',
  60. show: this.znmjDataSourceShow,
  61. selected: false,
  62. elements: this.znmjTagsData,
  63. })
  64. this.addZnmjTags()
  65. } catch (err) {
  66. console.log(err)
  67. }
  68. },
  69. addZnmjTags() {
  70. let dataSource = addNewDatasource('layer_' + this.znmjDataSourceName)
  71. // console.log("智能门禁基础信息", this.znmjTagsData);
  72. this.znmjTagsData.forEach(d => {
  73. d.GPSPoints = this.transPosition([{ x: d.location.x, y: d.location.y, z: d.height }])
  74. dataSource.entities.add(
  75. new Entity({
  76. id: d.id,
  77. name: d.name,
  78. show: false,
  79. position: Cartesian3.fromDegrees(...d.GPSPoints[0]),
  80. billboard: {
  81. image: '/imgs/camera/icon_ZJ_nor@2x.png',
  82. scale: 0.5, //固定值
  83. scaleByDistance: new NearFarScalar(10, 1, 10000, 1),
  84. },
  85. polyline: {
  86. positions: Cartesian3.fromDegreesArrayHeights([
  87. d.GPSPoints[0][0],
  88. d.GPSPoints[0][1],
  89. d.GPSPoints[0][2],
  90. d.GPSPoints[0][0],
  91. d.GPSPoints[0][1],
  92. 0,
  93. ]),
  94. width: 2,
  95. material: new PolylineDashMaterialProperty({
  96. color: Color.CYAN,
  97. }),
  98. },
  99. properties: new PropertyBag({
  100. type: 'znmj',
  101. details: d,
  102. isZnmj: true,
  103. }),
  104. })
  105. )
  106. })
  107. },
  108. async pushZnmjStatus(data) {
  109. if (data.id) {
  110. if (data?.buildId === this.buildInfo?.positioningBuildId) {
  111. // console.log("聚焦报警");
  112. this.animationZnmj(data)
  113. } else {
  114. const curStation = GY_STATIONS.find(e => e.positioningBuildId === data.buildId)
  115. // console.log('报警站点信息:', curStation)
  116. if (!curStation) return
  117. this.$store.dispatch('globalConfig/setMapMode', {
  118. value: '3d',
  119. })
  120. await this.$store.dispatch('model/setBuildInfoByBuildId', curStation.buildId)
  121. setTimeout(() => {
  122. this.animationZnmj(data)
  123. }, 3000)
  124. }
  125. }
  126. },
  127. animationZnmj(data) {
  128. const viewer = getViewer()
  129. const dataSource = viewer.dataSources.getByName('layer_znmj')
  130. if (dataSource.length > 0) {
  131. let item = dataSource[0].entities.getById(data.accessControl.id)
  132. // console.log(item, "地图实体数据", item.properties.details._value, '接收参数', data);
  133. if (!!item) {
  134. const { longitude, latitude } = this.buildInfo.gpsCoordinate0
  135. const gpsAlarmPoint = _locate(item.properties.details._value.location.x, item.properties.details._value.location.y, { x: longitude, y: latitude })
  136. //地图元素
  137. item.show = true
  138. setTimeout(() => {
  139. item.billboard = {
  140. image: '/imgs/camera/icon_ZJ_nor@2x.png',
  141. width: 50,
  142. height: 50,
  143. // verticalOrigin: VerticalOrigin.BOTTOM,
  144. distanceDisplayCondition: new DistanceDisplayCondition(0, 700.0),
  145. }
  146. item.position = Cartesian3.fromDegrees(gpsAlarmPoint.x, gpsAlarmPoint.y, item.properties.details._value.height)
  147. //视角漂移
  148. // flyToByViewer(item)
  149. flyToPerspective({
  150. destination: Cartesian3.fromDegrees(gpsAlarmPoint.x + 0.00026, gpsAlarmPoint.y - 0.0011, 100),
  151. orientation: {
  152. pitch: -0.549380381243696,
  153. heading: 6.181746598877237,
  154. roll: 0.0000025332551629730915, //倾斜视角坐标需要加偏移量
  155. },
  156. duration: 1.5,
  157. })
  158. //增加属性
  159. // item.properties.details._value.alarmPoint = data.alarmPoint
  160. // item.properties.details._value.alarmType = data.alarmType
  161. // item.properties.details._value.camera = data.camera
  162. // item.properties.details._value.alarmState = 1
  163. // item.properties.details._value.alarmStatus = true
  164. // item.properties.details._value.alarmPosition = [gpsAlarmPoint.x, gpsAlarmPoint.y, item.properties.details._value.height]
  165. // console.log(item.properties.details._value, "66666666666666666666666666666");
  166. //数据弹窗
  167. // this.$store.dispatch('globalConfig/updateAlarmDataObj', {
  168. // fire: [item.properties.details._value],
  169. // })
  170. //视频弹窗
  171. // if (!!data?.camera?.id) {
  172. // this.$store.dispatch('dialog/openVideoDialog', data.accessControl.ccameraID)
  173. // }
  174. }, 1000)
  175. }
  176. }
  177. },
  178. transPosition(pointList = []) {
  179. const { longitude, latitude } = this.buildInfo.gpsCoordinate0
  180. return pointList.reduce((pre, cur) => {
  181. const { x, y } = _locate(cur.x, cur.y, { x: longitude, y: latitude })
  182. pre.push([x, y, +cur.z])
  183. return pre
  184. }, [])
  185. },
  186. },
  187. }