Newer
Older
cockpit_hxrq_front / src / views / maps / storageTopic.vue
StephanieGitHub on 8 Apr 2021 12 KB ADD: 新增储量专题,优化储量专题
<!--
 * @Description: 储量专题
 * @Author: 王晓颖
 * @Date: 2021-04-08
 -->
<template>
  <div id="centerDiv" class="mapcontainer">
    <!--时钟-->
    <clock/>
    <!--天气-->
    <weather/>
    <!--选择区-->
    <select-all-storage @change="selectChange" />
    <!--统计结果显示-->
    <div class="label-container">
      <div class="label-div">
        <div class="label">
          {{ liquidFactoryData.name | liquidNameFilter }}
        </div>
        <div class="value">
          {{ liquidFactoryData.value }}
        </div>
      </div>
      <div class="label-div">
        <div class="label">
          {{ gasStationData.name | gasNameFilter }}
        </div>
        <div class="value">
          {{ gasStationData.value }}
        </div>
      </div>
    </div>

    <!--地图-->
    <Map :url="configUrl" @onload="onMapload" />
    <div class="map-btn-group">
      <select-button :select="heatShow" name="热力图" icon="icon-heat" @click="showHeat"/>
      <select-button :select="positionShow" name="点位分布" icon="icon-position" @click="showPosition"/>
      <select-button :select="stationShow" name="管理处" icon="icon-station" @click="showStation"/>
    </div>
    <!--遮罩-->
    <div class="mask">航天二院203所</div>
  </div>
</template>

<script>
import Map from '@/components/Map/MarsMap.vue'
import 'mars3d-heatmap'
import axios from 'axios'
import Weather from '@/components/weather/weather'
import Clock from '@/components/clock/Clock'
import SelectAllStorage from './components/selectAllStorage'
import SelectButton from '@/components/SelectTool/components/selectButton'
import { getTimes } from '@/utils/dateutils'
export default {
  name: 'Index',
  components: {
    SelectAllStorage,
    Weather,
    Clock,
    Map,
    SelectButton
  },
  filters: {
    liquidNameFilter(val) {
      return val + '液化工厂'
    },
    gasNameFilter(val) {
      return val + '加气站'
    }
  },

  data() {
    return {
      map: null, // 地图
      configUrl: 'static/config/config.json',
      alpha: 100, // 透明度
      underground: null, // ?
      factoryShow: true, // 显示液化工厂
      gasStationShow: true, // 显示加气站
      positionShow: true, // 显示位置
      liquidFactoryData: {
        name: '全部',
        value: 196
      },
      gasStationData: {
        name: '全部',
        value: 196
      }, // 统计版展示数据
      threatLevel: {
        '1': 'A级',
        '2': 'B级',
        '3': 'C级',
        '4': '问题'
      }, // 隐患等级
      liquidFactory: [], // 液化工厂数据
      gasStation: [], // 加气站

      stationLayer: null, // 管理站图层
      hqaLayer: null, // 液化工厂热力图
      threatLayer: null, // 液化工厂分布图层
      pointColorArr: ['#f33349', '#f79a2c', '#f2fa19', '#95e40c', '#1ffee6'],
      graphicLayer: null // 管理站标签图层
    }
  },
  methods: {
    // 地图构造完成回调
    onMapload(map) {
      // 以下为演示代码
      this.map = map
      // 背景透明
      this.map._viewer.scene.backgroundColor = new this.Cesium.Color(0.0, 0.0, 0.0, 0.0)
      this.map._viewer.scene.globe.baseColor.alpha = 0
    },
    // 液化工厂位置
    addFactoryPosition() {
      axios.get('static/config/liquidFactory.json').then((res) => {
        res = res.data
        if (res.code === 200) {
          // 获取液化工厂数据
          this.liquidFactory = res.data[0].data
          this.liquidFactoryData.value = res.data[0].total
          // 加气站数据
          this.gasStation = res.data[1].data
          this.gasStationData.value = res.data[1].total
          // 添加点位
          this.addFeatures(this.liquidFactory, 'liquidFactory')
          // this.addFeatures(this.gasStation, 'gasStation')
        }
      })
    },
    // 添加隐患点储量柱状图
    addFeatures(arr, type) {
      const { mars3d, Cesium, threatLevel } = this
      if (type == 'liquidFactory') {
        const factoryStorageLayer = new mars3d.layer.GraphicLayer()
        this.factoryStorageLayer = factoryStorageLayer
        this.map.addLayer(factoryStorageLayer)
        for (const item of arr) {
          const position = [parseFloat(item.value[0]), parseFloat(item.value[0])]
          const realData = item.liquid_level
          const totalData = item.contain
          const html = `${item['company']}<br/>
                        <span style="color:#63AEFF">容量:${realData}</span><br/>
                        <span style="color:#FFB861">储量:${totalData}</span>`
          this.addColumn(factoryStorageLayer, position, realData, totalData, '#63AEFF', html)
        }
      } else if (type === 'gasStation') {

      }
    },
    // 添加柱子
    addColumn(graphicLayer, position, realData, totalData, color = '#63AEFF', html) {
      var graphic1 = new this.mars3d.graphic.CylinderEntity({
        position: position,
        style: {
          length: realData,
          topRadius: 6000.0,
          bottomRadius: 6000.0,
          material: color
        }
      })
      var graphic2 = new this.mars3d.graphic.CylinderEntity({
        position: position,
        style: {
          length: totalData,
          topRadius: 6000.0,
          bottomRadius: 6000.0,
          material: color
        }
      })
      graphicLayer.addGraphic(graphic1)
      graphicLayer.addGraphic(graphic2)
      graphic1.bindTooltip(html)
      graphic2.bindTooltip(html)
    },
    // 添加文字
    addText(graphicLayer, data, position, height) {
      const { mars3d, Cesium } = this
      var primitive = new mars3d.graphic.LabelPrimitive({
        position: Cesium.Cartesian3.fromDegrees(position[0], position[1], height),
        style: {
          text: data,
          font_size: 18,
          font_family: '楷体',
          style: Cesium.LabelStyle.FILL_AND_OUTLINE,
          fillColor: Cesium.Color.fromCssColorString('#00ff00'),
          outlineColor: Cesium.Color.BLACK,
          outlineWidth: 1,
          horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
          verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
          pixelOffset: new Cesium.Cartesian2(0, -20)
        }
      })
      graphicLayer.addGraphic(primitive)
    },
    // 管理处
    addStation() {
      const { mars3d } = this
      const stationLayer = new mars3d.layer.ModelLayer({
        name: '管理处',
        url: './static/gltf/house02.gltf',
        // url: './static/gltf/qwe.gltf',
        style: {
          scale: 20,
          heading: 0,
          minimumPixelSize: 30,
          clampToGround: false
        },
        positions: this.manageStations.map(item => {
          return { lng: item.x, lat: item.y, alt: 0 }
        })
      })
      this.stationLayer = stationLayer
      this.map.addLayer(stationLayer)
    },
    // 选框发生变化
    selectChange({ area, state, time, level }) {
      area = area === '全部' ? '' : area
      time = time === '全部' ? '' : time
      level = level === '全部' ? '' : level
      // 解析时间
      let beginTime = ''
      let endTime = ''
      if (time) {
        const result = getTimes(time)
        beginTime = result.beginDate
        endTime = result.endDate
      }
      this.boardData.name = area
      // 查询数据
      let count = 0
      debugger
      for (const hca of this.highConsequence) {
        let flag = true // 标记是否合格
        // 比较区域
        if (area && hca['所属管理处'] && hca['所属管理处'].indexOf(area) === -1) {
          flag = false
        }
        // 比较时间
        if (time) {
          const real_date = new Date(hca['识别时间'])
          if (real_date && (real_date < beginTime || real_date > endTime)) {
            flag = false
          }
        }
        // 比较级别
        if (level && hca['隐患等级'] && hca['隐患等级'] === level) {
          flag = false
        }
        if (flag) {
          count++
        }
      }
      this.boardData.value = count
    },
    // 自定义的弹窗
    addStationDiv() {
      const { Cesium, mars3d } = this
      const graphicLayer = new mars3d.layer.GraphicLayer()
      this.graphicLayer = graphicLayer
      this.map.addLayer(graphicLayer)
      for (const station of this.highConsequenceStation) {
        var graphic = new mars3d.graphic.DivGraphic({
          position: Cesium.Cartesian3.fromDegrees(station.x, station.y, 10100),
          style: {
            html: `<div class="divpoint divpoint-theme-29baf1">
                    <div class="divpoint-wrap">
                        <div class="area">
                            <div class="arrow-lt"></div>
                            <div class="b-t"></div>
                            <div class="b-r"></div>
                            <div class="b-b"></div>
                            <div class="b-l"></div>
                            <div class="arrow-rb"></div>
                            <div class="label-wrap">
                                <div class="title">${station.name}</div>
                                <div class="label-content">
                                    <div class="data-li">
                                        <div class="data-label">液化工厂数量:</div>
                                        <div class="data-value"><span class="label-num">${station.count}</span><span class="label-unit">个</span>
                                        </div>
                                    </div>
                                    <div class="data-li">
                                        <div class="data-label">经度:</div>
                                        <div class="data-value"><span class="label-num">${station.x}</span>
                                        </div>
                                    </div>
                                    <div class="data-li">
                                        <div class="data-label">纬度:</div>
                                        <div class="data-value"><span class="label-num">${station.y}</span>
                                        </div>
                                    </div>
                                    `,
            // anchor: [0, 0],
            horizontalOrigin: Cesium.HorizontalOrigin.LEFT,
            verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
            distanceDisplayCondition: new Cesium.DistanceDisplayCondition(10000, 500000), // 按视距距离显示
            scaleByDistance: new Cesium.NearFarScalar(10000, 1.0, 500000, 0.1),
            clampToGround: true,
            heightReference: Cesium.HeightReference.CLAMP_TO_GROUND
          },
          pointerEvents: false // false时不允许拾取和触发任意鼠标事件,但可以穿透div缩放地球
        })
        graphicLayer.addGraphic(graphic)
        graphic.testPoint = false // 打开测试点,与DIV点进行对比位置调整css
      }
    },
    // 是否显示热力图
    showHeat(show) {
      // 现在正在显示
      if (show) { // 移除
        this.heatShow = false
        this.map.removeLayer(this.hqaLayer, true)
      } else {
        this.heatShow = true
        this.addWaterHeat()
      }
    },
    // 显示管理处
    showStation(show) {
      // 现在正在显示
      if (show) { // 移除
        this.stationShow = false
        this.map.removeLayer(this.stationLayer, true)
        this.map.removeLayer(this.graphicLayer, true)
      } else {
        this.stationShow = true
        this.addStation()
        this.addStationDiv()
      }
    },
    // 显示隐患分布
    showPosition(show) {
      if (show) { // 移除
        this.positionShow = false
        this.map.removeLayer(this.threatLayer, true)
      } else {
        this.positionShow = true
        this.addThreatPosition()
      }
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .label-container{
    position: absolute;
    top: 6.5rem;
    left:31rem;
    z-index:100;
    .label-div{
      color: white;
      padding:1.5rem 2.5rem 1rem 2.5rem;
      background-image: url("../../assets/button_images/board-box1.png");
      background-size: 100% 100%;
      margin-bottom: 20px;
      .label{
        margin-bottom: 1rem;
        font-size:1rem;
      }
      .value{
        font-family: DS-DigitalBold;
        font-size:2rem;
      }
    }
  }
  .map-btn-group{
    position: absolute;
    bottom:3rem;
    left:50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
  }
</style>

<style rel="stylesheet/scss" lang="scss">
  /*整个容器*/
  .mapcontainer {
    position: relative;
    height: 100%;
    width: 100%;
    background-color: transparent;
    /*background-color: #051151;*/
  }
  /*logo遮罩*/
  .mask{
    position: fixed;
    padding-left:10px;
    padding-right:10px;
    bottom:0px;
    left:0px;
    background-color:#000000;
    color:#ffffff;
    line-height:2
  }

</style>