forked from drone/command-center-dashboard

罗广辉
2025-04-15 1894e98229bb29c92bddae1fd87d4786494531b2
src/hooks/useMapAggregation/useMapAggregation.js
@@ -13,6 +13,7 @@
import cesiumOperation from '@/utils/cesium-tsa'
import { getDeviceRegion, getDeviceRegionCount, getEventDetails, getMapEvents } from '@/api/home/aggregation'
import { PolyGradientMaterial } from '@/utils/cesium/Material'
import { start } from 'nprogress'
/**
 * 机巢聚合功能
 */
@@ -53,6 +54,20 @@
  const store = useStore()
  const userAreaCode = computed(() => store.state.user.userInfo.detail.areaCode)
  const selectedAreaCode = computed(() => store.state.user.selectedAreaCode)
  const eventTimeType = computed(() => store.state.home.eventTimeType)
  const eventTimeRang = computed(() => store.state.home.eventTimeRang)
  let needFly = true
  const combinedValues = computed(() => ({
    selectedAreaCode: selectedAreaCode.value,
    eventTimeType: eventTimeType.value,
    eventTimeRang: eventTimeRang.value,
  }))
  let saveParams = { area_code: '', date_enum: 'CURRENT_WEEK' }
  // 确定缩放比例
@@ -105,6 +120,7 @@
  // 事件散点
  let eventList = []
  function processChildren (childrens) {
    // console.log(childrens, '事件点')
    return (childrens || []).map(item => {
      const arr = processChildren(item.childrens)
      if (item.data) {
@@ -118,13 +134,15 @@
      if (arr.length !== 0) {
        returnObj.childrens = arr
      }
      console.log(returnObj, '111111')
      return returnObj
    })
  }
  // 获取事件聚合
  function getMapEventCount (area_code) {
    return getMapEvents({ area_code,date_enum:'CURRENT_WEEK' }).then(res => {
  function getMapEventCount (params) {
    console.log(5555555)
    return getMapEvents(params).then(res => {
      const resData = res?.data?.data
      if (resData?.data) {
        eventList = resData?.data
@@ -163,7 +181,9 @@
  const initMapData = async areaCode => {
    eventList = []
    if (!areaCode) return
    const list = type === 'device' ? await getDeviceCount(areaCode) : await getMapEventCount(areaCode)
    saveParams.area_code = areaCode
    console.log(type, '444')
    const list = type === 'device' ? await getDeviceCount(areaCode) : await getMapEventCount(saveParams)
    const splashedList = type === 'device'
      ? await getDeviceList(areaCode)
      : eventList.map(i => ({ eventId: i.id, latitude: Number(i.latitude), longitude: Number(i.longitude), type: 'event' }))
@@ -219,16 +239,20 @@
    }
  }
  watch(combinedValues, async (newValue, oldValue) => {
    if (newValue.eventTimeType) {
      saveParams = { area_code: newValue.selectedAreaCode, date_enum: store.state.home.eventTimeParams }
    }
  let needFly = true
    if (newValue.eventTimeRang) {
      saveParams = { area_code: newValue.selectedAreaCode, start_date: newValue.eventTimeRang[0], end_date: newValue.eventTimeRang[1] }
    }
  watch(
    selectedAreaCode,
    async (newValue, oldValue) => {
      needFly = true
      if (!viewer) return
      viewer.scene.postRender.removeEventListener(determineScaling)
      initMapData(newValue).then(() => {
    initMapData(newValue.selectedAreaCode).then(() => {
        viewer.scene.postRender.addEventListener(determineScaling)
      })
    },
@@ -437,10 +461,15 @@
    let clickTargets = viewer.scene.drillPick(click.position).map(item => item.id)
    if (!clickTargets.length) return
    console.log(clickTargets, 11111)
    let deviceAggregationFind = findTypeItem(clickTargets, (item) => item?.properties?.customData?._value?.data?.type === 'deviceAggregation')
    let deviceFind = findTypeItem(clickTargets, (item) => item?.properties?.customData?._value?.data?.type === 'device')
    // "event"
    let eventFind = findTypeItem(clickTargets, (item) => item?.properties?.customData?._value?.data?.type === 'event')
    // let eventFind = findTypeItem(clickTargets, (item) => item?.properties?.customData?._value?.data?.type === 'eventAggregation')
    currentEntity = deviceAggregationFind || deviceFind || eventFind
    if (!currentEntity) return
    if (!currentEntity?.position?._value) return
    // 一定要移除