Browse Source

轨迹回放

chenxr3 4 years ago
parent
commit
16f7d92b0b

+ 3 - 1
ebc-middle-platform/src/conf/services.js

@ -193,7 +193,9 @@ export default {
193 193
    DEVICE_TRACK: '/device/queryOneDeviceLocationInfo' // 查询设备轨迹
194 194
  },
195 195
  trackAnalysis: {
196
    GET_TRACKANALYSIS: '/attendanceManagement/queryPageTrackRecord' // 查询轨迹分析
196
    GET_TRACKANALYSIS: '/trackManagement/queryPageTrackRecord', // 查询轨迹分析
197
    GET_SINGLE_TRACE: '/trackManagement/querySingleEmployeeTrace', // 单人轨迹回放
198
    GET_MORE_TRACE: '/trackManagement/queryMoreEmployeeTrace' // 多人轨迹回放
197 199
  },
198 200
  areaInOutRecord: {
199 201
    GET_ATTENDANCE: '/areaInOutRecord/queryPageAttendanceCount', // 分页查询考勤统计分析

+ 1 - 1
ebc-middle-platform/src/modules/attendance/track.vue

@ -6,7 +6,7 @@
6 6
          <div class="input-rule">
7 7
            <t-date-picker v-model="queryCondition.rangeDate"
8 8
                           align-right
9
                           style="width:250px;"
9
                           style="width:320px;"
10 10
                           type="dateTimeRange"
11 11
                           placeholder="选择时间段"
12 12
                           @date-change="onChange"></t-date-picker>

+ 9 - 2
ebc-middle-platform/src/modules/orientation/orientation.scss

@ -5,6 +5,7 @@
5 5
    padding-right: 0px;
6 6
    box-sizing: border-box;
7 7
    .top-container{
8
      //opacity: 0;
8 9
      display: flex;
9 10
      justify-content: space-between;
10 11
      line-height: 40px;
@ -193,7 +194,7 @@
193 194
.track-label{
194 195
  position: absolute;
195 196
  z-index: 10;
196
  left: 240px;
197
  left: 40px;
197 198
  bottom: 50px;
198 199
  top: 130px;
199 200
  background-color: #ffffff;
@ -205,6 +206,12 @@
205 206
  padding: 10px 5px 10px 5px;
206 207
  border-radius: 5px;
207 208
}
209
.track-span{
210
  padding: 5px 5px 0 8px;
211
}
212
.modal-body{
213
  padding: 0 15px 15px 15px;
214
}
208 215
.track-modal-container{
209 216
  display: flex;
210 217
  .track-modal-left{
@ -220,7 +227,7 @@
220 227
  }
221 228
  .track-modal-right{
222 229
    height: 500px;
223
    width: 1000px;
230
    width: 100%;
224 231
    margin-left: 5px;
225 232
    .hidden{
226 233
      visibility: hidden;

+ 468 - 140
ebc-middle-platform/src/modules/orientation/orientation.vue

@ -22,10 +22,6 @@
22 22
        <div class="time">当前时间:{{ nowDate | dateFormat }}</div>
23 23
      </div>
24 24
      <div class="right-content">
25
        <!-- <div>
26
          <t-input placeholder="请输入名称或终端编号"></t-input>
27
        </div>
28
        <t-button color="success" icon="search-outline"></t-button> -->
29 25
        <t-button
30 26
          color="success"
31 27
          icon="map-marker-outline"
@ -77,24 +73,33 @@
77 73
      :visibled.sync="trackModal"
78 74
      :footer-visibled="false"
79 75
      :mask-closable="false"
80
      :width="1200"
76
      :width="1400"
77
      :height="800"
78
      :cancel="stopPlayback"
81 79
      title="历史轨迹"
82 80
    >
83 81
      <div class="track-modal-container">
84
        <div class="track-modal-left">
85
          <t-input
86
            v-model="trackSearch"
87
            icon="search-outline"
88
            icon-placement="right"
89
            placeholder="请输入姓名或终端编号"
90
            style="width: 200px"
91
          ></t-input>
92
          <div>
93
            <div v-for="(item,index) in personList" :class="trackPerson.workEmployeeCode==item.workEmployeeCode?'active':''" :key="index" @click="personTrack(item)">{{ item.workEmployeeName }}</div>
94
          </div>
95
        </div>
96 82
        <div class="track-modal-right">
97
          <div style="display: flex">
83
          <t-button-group>
84
            <t-button
85
              v-for="(item, index) in trackTypeList"
86
              :class="
87
                index == trackTypeCondition.currentIndex ? 'active' : ''
88
              "
89
              :key="index"
90
              @click="changeTrackType(index)"
91
            >{{ item }}</t-button
92
            >
93
          </t-button-group>
94
          <div style="display: flex;padding: 5px 0px">
95
            <span class="track-span">人员</span>
96
            <t-select v-if="trackTypeCondition.currentIndex == 1" v-model="trackSearchs" multiple collapse-tags filterable placeholder="请选择人员" style="width: 300px" @change="personTrack()">
97
              <t-option v-for="(item, index) in personList" :key="index" :value="item">{{ item.workEmployeeName }}</t-option>
98
            </t-select>
99
            <t-select v-if="trackTypeCondition.currentIndex == 0" v-model="trackSearch" filterable placeholder="请选择人员" style="width: 200px" @change="personTrack()">
100
              <t-option v-for="(item, index) in personList" :key="index" :value="item">{{ item.workEmployeeName }}</t-option>
101
            </t-select>
102
            <span class="track-span">时间</span>
98 103
            <t-button-group>
99 104
              <t-button
100 105
                v-for="(item, index) in trackTimeList"
@ -110,37 +115,32 @@
110 115
              :class="trackQueryCondition.currentIndex === 3?'':'hidden'"
111 116
              v-model="rangeDate"
112 117
              align-right
113
              style="width:350px"
118
              style="width:300px"
114 119
              type="dateTimeRange"
115 120
              placeholder="请选择时间"
116 121
              @date-change="onChangeDate">
117 122
            </t-date-picker>
118
            <!-- <div style="display: flex;line-height:32.5px;width: 120px;">
119
              <div>速度</div>
120
              <t-select>
121
                <t-option>1x</t-option>
122
                <t-option>2x</t-option>
123
              </t-select>
124
            </div> -->
125
            <t-button color="success" icon="video-outline" @click="playback()">回放</t-button>
126
            <t-button color="secondary" icon="upload-outline" @click="toExport"
127
            >导出至Excel</t-button
128
            >
123
            <span class="track-span">速度</span>
124
            <t-select v-model="playbackRate" placeholder="回放速度" style="width: 60px;">
125
              <t-option v-for="(item, index) in speeds" :key="index" :value="item">{{ item + 'X' }}</t-option>
126
            </t-select>
127
            <t-button v-if="!playbacking" color="success" icon="video-outline" @click="playback()">回放</t-button>
128
            <t-button v-if="playbacking" color="secondary" icon="video-outline" @click="stopPlayback()">停止</t-button>
129
            <span v-if="playbacking" class="track-span">回放时刻: {{ trackTime }}</span>
129 130
          </div>
130 131
          <div>
131
            <div id="track-map" style="height: 467.5px;"></div>
132
            <div class="track-label">
132
            <div id="track-map" style="height: 610px;"></div>
133
            <div v-if="trackTypeCondition.currentIndex == 0 && timelineList.length > 0" class="track-label">
133 134
              <t-timeline :horizontal="true">
134 135
135
136
                <t-timeline-item v-for="(item,index) in timelineList" :key="index" :time="item.time" >
136
                <t-timeline-item v-for="(item,index) in timelineList" :key="index" :time="item.inTime" :color="item.color">
137 137
                  <slot>
138 138
                    <div class="card card-has-border" style="width: 100px">
139 139
                      <div class="card-block">
140
                        <span class="card-block-name">{{ item.name }}</span>
141
                        <span class="card-block-time">{{ item.duration }}</span>
140
                        <span class="card-block-name">{{ item.areaName }}</span>
141
                        <span class="card-block-time">{{ item.durationTime }}min</span>
142 142
                        <div>
143
                          <t-progress :percent="item.proportion" hide-info></t-progress>
143
                          <t-progress :percent="item.proportion" :status="item.status" hide-info></t-progress>
144 144
                        </div>
145 145
                      </div>
146 146
                    </div>
@ -213,7 +213,118 @@ export default {
213 213
  },
214 214
  data() {
215 215
    return {
216
      trackData: [{
217
        entityId: 1,
218
        name: '张三',
219
        icon: '',
220
        status: '',
221
        color: 'red',
222
        traceList: [{
223
          // entityId  人员ID
224
          // longitude  经度
225
          // latitude  维度
226
          // height  高度
227
          // createDate  定位时间
228
          // playDurationTime  播放时间
229
          // toolIndex  当前所在围栏 isStopPlay
230
          lng: 122.09930419921876,
231
          lat: 29.96089241772908,
232
          time: '2020-11-11 31312',
233
          second: 1,
234
          index: 0
235
        }, {
236
          lng: 122.09930419921876,
237
          lat: 30.06089241772908,
238
          time: '2020-11-11 2323',
239
          second: 2,
240
          index: 1
241
        }, {
242
          lng: 122.39930419921876,
243
          lat: 30.06089241772908,
244
          time: '2020-11-11 4433',
245
          second: 5,
246
          index: 2
247
        }, {
248
          lng: 122.59930419921876,
249
          lat: 30.26089241772908,
250
          time: '2020-11-11 111',
251
          second: 10,
252
          isStopPlay: true,
253
          index: 2
254
        }]
255
      }, {
256
        entityId: 2,
257
        name: '李四',
258
        icon: '',
259
        status: '',
260
        color: 'blue',
261
        traceList: [{
262
          lng: 122.59930419921876,
263
          lat: 29.96089241772908,
264
          time: '2020-11-11 233456',
265
          second: 3,
266
          index: 0
267
        }, {
268
          lng: 122.59930419921876,
269
          lat: 30.06089241772908,
270
          time: '2020-11-11 633',
271
          second: 4,
272
          index: 1
273
        }, {
274
          lng: 122.89930419921876,
275
          lat: 30.06089241772908,
276
          time: '2020-11-11 5445',
277
          second: 6,
278
          index: 2
279
        }, {
280
          lng: 122.99930419921876,
281
          lat: 30.26089241772908,
282
          time: '2020-11-11 23434',
283
          second: 8,
284
          index: 2
285
        }]
286
      }, {
287
        entityId: 3,
288
        name: '王五',
289
        icon: '',
290
        status: '',
291
        color: 'blue',
292
        traceList: [{
293
          lng: 122.59930419921876,
294
          lat: 29.96089241772908,
295
          time: '2020-11-11  242',
296
          second: 3,
297
          index: 0
298
        }, {
299
          lng: 122.59930419921876,
300
          lat: 30.06089241772908,
301
          time: '2020-11-11  1322',
302
          second: 4,
303
          index: 1
304
        }, {
305
          lng: 122.89930419921876,
306
          lat: 30.06089241772908,
307
          time: '2020-11-11 122112',
308
          second: 6,
309
          index: 2
310
        }, {
311
          lng: 122.89930419921876,
312
          lat: 30.26089241772908,
313
          time: '2020-11-11 12',
314
          second: 9,
315
          index: 2
316
        }]
317
      }],
318
      timeouts: [],
319
      speeds: [1, 4, 16, 24, 48],
320
      playbackRate: 1,
321
      playbacking: false,
322
      trackTime: '',
216 323
      map: null,
324
      layersGroup: new Ai.LayerGroup(),
325
      pointsGroup: new Ai.LayerGroup(),
326
      lineColors: ['#26B728', '#280e9e', '#dc8020', '#EAFF00',
327
        '#cc48ca', '#83b5ff', '#4D4128', '#08570c'], // 定义几种颜色多人轨迹回放使用,不够再取随机颜色
217 328
      tal: 32.465444444444444,
218 329
      switch1: true,
219 330
      pointsarr: null,
@ -230,22 +341,24 @@ export default {
230 341
        sos: 0,
231 342
        normal: 0
232 343
      },
233
      polylinearr:
234
        '122.0352 32.4444,122.0372 32.4444,122.0400 32.4366,122.2922 32.4233',
235 344
      popup: null,
236
      shadow: false,
237 345
      dataList: [
238 346
      ],
239 347
      nowDate: new Date(),
240 348
      modal: false,
241 349
      trackModal: false,
242 350
      trackSearch: '',
351
      trackSearchs: [],
243 352
      trackTimeList: ['-10min', '-1h', '本日', '自定义'],
353
      trackTypeList: ['单人模式', '多人模式'],
244 354
      trackQueryCondition: {
245 355
        currentIndex: 0
246 356
      },
357
      trackTypeCondition: {
358
        currentIndex: 0
359
      },
247 360
      trackMap: null,
248
	    trackPath: null,
361
      trackPath: null,
249 362
      rangeDate: '',
250 363
      rescueModal: false,
251 364
      formValidate: {
@ -285,26 +398,7 @@ export default {
285 398
        normal: true
286 399
      },
287 400
      personList: [],
288
      timelineList: [
289
        {
290
          time: '2020.11.30',
291
          name: '码头',
292
          duration: '15min',
293
          proportion: 25
294
        },
295
        {
296
          time: '2020.11.30',
297
          name: '1#船舶',
298
          duration: '56min',
299
          proportion: 80
300
        },
301
        {
302
          time: '2020.11.30',
303
          name: '1#风机',
304
          duration: '45min',
305
          proportion: 45
306
        }
307
      ],
401
      timelineList: [],
308 402
      rescuer: [],
309 403
      appointAlarmId: '',
310 404
      trackPerson: '',
@ -324,28 +418,28 @@ export default {
324 418
  mounted() {
325 419
    // this.getGisToken().then(() => { // 获取gistoken后加载地图
326 420
    // })
327
    this.getTagType().then(() => {
328
      this.getToolType().then(() => {
421
    this.getTagType().then(() => { // 初始化区域类型
422
      this.getToolType().then(() => { // 初始化设备类型
329 423
        this.initMap()
330 424
        this.initTrackMap()
331
        this.initStatusCount()
425
        this.initStatusCount() // 初始化人数统计数据
332 426
      })
333 427
    })
334 428
    setInterval(() => { // 当前时间
335 429
      this.nowDate = new Date()
336 430
    }, 1000)
337
    EventBus.$on('person', (msg) => { // 获取镜屏推送消息
431
    EventBus.$on('person', (msg) => { // 获取镜屏推送消息,镜屏每次只推送一个元素的变化
338 432
      msg = JSON.parse(msg)
339 433
      console.log(msg)
340 434
      this.personStatistics = msg.data.countMap
341
      if (msg.data.aggregatedMapAreaList.length === 1 && msg.data.unaggregatedEntityPositionList.length === 0){
342
        this.removeUnaggregated(msg.data.currentEntityPosition)
435
      if (msg.data.aggregatedMapAreaList.length === 1 && msg.data.unaggregatedEntityPositionList.length === 0) {
436
        this.removeUnaggregated(msg.data.currentEntityPosition) // 删除离散的人员
343 437
      }
344 438
      if (msg.data.aggregatedMapAreaList) {
345
        this.changeLocation(msg.data.aggregatedMapAreaList)
439
        this.changeLocation(msg.data.aggregatedMapAreaList) // 改变区域和设备
346 440
      }
347 441
      if (msg.data.unaggregatedEntityPositionList) {
348
        this.changeUnaggregated(msg.data.unaggregatedEntityPositionList)
442
        this.changeUnaggregated(msg.data.unaggregatedEntityPositionList) // 改变离散的人员
349 443
      }
350 444
    })
351 445
    EventBus.$on('ship', (msg) => { // 获取镜屏推送消息
@ -504,6 +598,13 @@ export default {
504 598
      })
505 599
    },
506 600
    switchChange(status) {
601
      for (var i = 0; i < 6; i++) {
602
        (function(i) {
603
          setTimeout(function() {
604
            console.log(i)
605
          }, (i + 1) * 1000)
606
        })(i)
607
      }
507 608
      if (status) {
508 609
        // this.layer.areaLayer.eachLayer((la) => {
509 610
        //   if (la.point) {
@ -749,8 +850,8 @@ export default {
749 850
    },
750 851
    removeUnaggregated(po) { // 删除不聚合的人
751 852
      this.layer.personLayer.eachLayer((la) => {
752
        var e = undefined;
753
        if (po.entityId == la.getAttributes().elementId) {
853
        var e
854
        if (po.entityId === la.getAttributes().elementId) {
754 855
          console.log('删除' + po.name)
755 856
          this.map.closePopup(la.popup)
756 857
          la.popup.remove()
@ -768,7 +869,8 @@ export default {
768 869
        case '040': // 手动告警 ------ 红色
769 870
          return 'sos'
770 871
          break
771
        case '030': // 离线 ------ 灰色
872
        case '030': // 超时离线 ------ 灰色
873
        case '035': // 关机离线报警 ------ 灰色
772 874
          return 'offline'
773 875
          break
774 876
        case '060': // 救援人员 ------ 黄色
@ -814,14 +916,26 @@ export default {
814 916
      })
815 917
    },
816 918
    changeTrackTime(index) { // 速度选择
919
      this.stopPlayback()
920
      this.trackMap.removeLayer(this.layersGroup)
921
      this.trackMap.removeLayer(this.pointsGroup)
817 922
      this.trackQueryCondition.currentIndex = index
818 923
    },
924
    changeTrackType(index) { // 模式选择
925
      this.stopPlayback()
926
      this.trackMap.removeLayer(this.layersGroup)
927
      this.trackMap.removeLayer(this.pointsGroup)
928
      this.trackTypeCondition.currentIndex = index
929
      this.trackSearch = ''
930
      this.trackSearchs = []
931
    },
819 932
    initTrackMap() { // 加载轨迹地图
820 933
      if (this.trackMap != null && this.trackMap != '') {
821 934
        this.trackMap.remove()
822 935
      }
823 936
      this.trackMap = new Ai.Map('track-map', {
824
        ak: this.$store.getters.getGisToken,
937
        // ak: this.$store.getters.getGisToken,
938
        ak: 'MTYwNzQMTAwMU1UWXdOelE1TXpnME5EYzBOU015T0RFeE1UYz0_',
825 939
        center: [39.915599, 122.406568]
826 940
      })
827 941
      var maplayer = Ai.TileLayer(GIS_SEA_LAYER_URL)
@ -833,6 +947,37 @@ export default {
833 947
      Ai.Zoom({type: 'small'}).addTo(this.trackMap)
834 948
      this.loadBindDevicePerson()
835 949
      this.loadNotBindEquipment()
950
      this.$test
951
        .post(services.alarm.LOAD_MAP_AREA_TOOL, {})
952
        .then((res) => {
953
          console.log(res)
954
          res.data.mapAreaList.forEach(e => {
955
            var typeObj = res.data.mapAreaTypeList.filter(type => {
956
              return e.businessType == type.mapAreaBusinessType
957
            })
958
            var polygon = Ai.Polygon(e.mapAreaContent, {color: typeObj[0].color, opacity: 1.0, weight: 1.2})
959
            this.trackMap.addLayer(polygon)
960
          })
961
          res.data.toolList.forEach(e => {
962
            var typeObj = res.data.toolTypeList.filter(type => {
963
              return e.resourceToolType == type.resourceToolType
964
            })
965
            var point = Ai.Point([e.latitude, e.longitude], {
966
              icon: Ai.Icon({
967
                // 设置图标URL路径
968
                iconUrl: typeObj[0].iconUrl,
969
                // 设置图标大小
970
                iconSize: [20, 20],
971
                // 设置点对象和图标的相对偏移量
972
                iconAnchor: [100, 100]
973
              })
974
            })
975
            this.trackMap.addLayer(point)
976
          })
977
        })
978
        .catch((res) => {
979
          // 请求失败处理...
980
        })
836 981
    },
837 982
    loadBindDevicePerson() {
838 983
      this.$test
@ -964,45 +1109,46 @@ export default {
964 1109
        }
965 1110
      })
966 1111
    },
967
    personTrack(item) {
1112
    personTrack() {
1113
      this.stopPlayback()
1114
      this.trackMap.removeLayer(this.layersGroup)
1115
      this.trackMap.removeLayer(this.pointsGroup)
1116
      var item
1117
      if (this.trackTypeCondition.currentIndex == 0) {
1118
        item = this.trackSearch
1119
        this.timelineList = []
1120
      } else {
1121
        item = this.trackSearchs[0]
1122
      }
1123
      if (!item) {
1124
        return
1125
      }
968 1126
      console.log(item)
969 1127
      console.log(this.trackMap.hasLayer(this.trackPath))
970 1128
      if (this.trackMap.hasLayer(this.trackPath)) {
971 1129
        this.trackMap.removeLayer(this.trackPath)
972
        this.trackPath.hideTraceFrom(this.trackMap)
973
      }
974
      this.trackPerson = item
975
      if (this.orgId !== item.orgId) {
976
        this.$test
977
          .post(services.organization.FENCE_BY_DEPARTMENT, {entityId: item.orgId})
978
          .then((res) => {
979
            this.orgId = item.orgId
980
            console.log(res)
981
            var la = new Ai.FeatureGroup()
982
            res.data.forEach(e => {
983
              var wktstr = e.mapAreaContent
984
              var areaColor = ''
985
              this.markTypes.forEach(m => {
986
                if (m.mapAreaBusinessType == e.businessType) {
987
                  areaColor = m.color
988
                }
989
              })
990
              var polygon = Ai.Polygon(wktstr, {color: areaColor, opacity: 1.0, weight: 1.2})
991
              la.addLayer(polygon)
992
            })
993
            this.trackMap.addLayer(la)
994
          })
995
          .catch((res) => {
996
          // 请求失败处理...
997
          })
998 1130
      }
999 1131
    },
1000 1132
    playback() {
1001
      if (this.trackMap.hasLayer(this.trackPath)) {
1002
        this.trackMap.removeLayer(this.trackPath)
1003
        this.trackPath.hideTraceFrom(this.trackMap)
1133
      var entityIds
1134
      if (this.trackTypeCondition.currentIndex == 0) {
1135
        if (!this.trackSearch.workEmployeeId) {
1136
          this.$Message.warning('请选择人员!')
1137
          return
1138
        }
1139
        entityIds = this.trackSearch.workEmployeeId
1140
      } else {
1141
        if (this.trackSearchs.length == 0) {
1142
          this.$Message.warning('请选择人员!')
1143
          return
1144
        }
1145
        debugger
1146
        entityIds = ''
1147
        this.trackSearchs.forEach(e => {
1148
          entityIds += e.workEmployeeId + ','
1149
        })
1150
        entityIds = entityIds.substring(0, entityIds.length - 1)
1004 1151
      }
1005
      console.log(this.trackQueryCondition.currentIndex)
1006 1152
      var params = {}
1007 1153
      if (this.trackQueryCondition.currentIndex === 3) {
1008 1154
        if (!this.rangeDate) {
@ -1010,54 +1156,236 @@ export default {
1010 1156
          return
1011 1157
        } else {
1012 1158
          params = {
1013
            entityId: this.trackPerson.workEmployeeId,
1159
            entityId: entityIds,
1014 1160
            timeType: (this.trackQueryCondition.currentIndex + 1),
1161
            playbackRate: this.playbackRate,
1015 1162
            startTime: this.rangeDate[0],
1016 1163
            endTime: this.rangeDate[1]
1017 1164
          }
1018 1165
        }
1019 1166
      } else {
1020 1167
        params = {
1021
          entityId: this.trackPerson.workEmployeeId,
1168
          entityId: entityIds,
1169
          playbackRate: this.playbackRate,
1022 1170
          timeType: (this.trackQueryCondition.currentIndex + 1)
1023 1171
        }
1024 1172
      }
1025
      console.log(this.rangeDate)
1026
      this.$test
1027
        .post(services.organization.EMPLOYEE_TRACE, params)
1028
        .then((res) => {
1029
          console.log(res)
1030
          var coords = res.data.coordArray
1031
          var defaultOptions = {
1032
            paused: false,
1033
            reverse: false,
1034
            delay: 800,
1035
            dashArray: [10, 20],
1036
            weight: 5,
1037
            opacity: 0.9,
1038
            color: '#0000ff',
1039
            pulseColor: '#FFFFFF',
1040
            playerTrack: true,
1041
            traceTitle: false,
1042
            traceIcon: new Ai.Icon({
1043
              iconUrl: '/static/images/normalworker.png',
1044
              iconSize: [16, 16],
1045
              iconAnchor: [8, 8]
1046
            }),
1047
            titleOptions: {
1048
              className: 'trace_title',
1049
              iconSize: null,
1050
              iconAnchor: [48, 57]
1051
            }
1052
          }
1053
          this.trackPath = new Ai.DynamicPath(coords, defaultOptions)
1054
          this.trackMap.addLayer(this.trackPath)
1055
          this.trackMap.setViewPort([this.trackPath])
1056
          this.trackPath.playTraceOn(this.trackMap)
1173
1174
      if (this.trackTypeCondition.currentIndex == 0) {
1175
        this.$test
1176
          .post(services.trackAnalysis.GET_SINGLE_TRACE, params)
1177
          .then((res) => {
1178
            debugger
1179
            this.timelineList = res.data.toolRecordList
1180
            this.timelineList.forEach(e => {
1181
              e.inTime = e.inTime.split(' ')[1]
1182
              e.color = 'info'
1183
              e.status = 'normal'
1184
            })
1185
            this.trackData = [res.data]
1186
            var mapOfPerson = {}
1187
            this.personList.forEach(e => {
1188
              mapOfPerson[e.workEmployeeId] = e.workEmployeeName
1189
            })
1190
            this.trackData.forEach(e => {
1191
              e.entityName = mapOfPerson[e.entityId]
1192
            })
1193
            this.startPlayback()
1194
          })
1195
          .catch((res) => {
1196
            // 请求失败处理...
1197
          })
1198
      } else {
1199
        this.$test
1200
          .post(services.trackAnalysis.GET_MORE_TRACE, params)
1201
          .then((res) => {
1202
            debugger
1203
            this.trackData = res.data
1204
            var mapOfPerson = {}
1205
            this.personList.forEach(e => {
1206
              mapOfPerson[e.workEmployeeId] = e.workEmployeeName
1207
            })
1208
            this.trackData.forEach(e => {
1209
              e.entityName = mapOfPerson[e.entityId]
1210
            })
1211
            this.startPlaybackMulti()
1212
          })
1213
          .catch((res) => {
1214
            // 请求失败处理...
1215
          })
1216
      }
1217
    },
1218
    startPlaybackMulti() {
1219
      this.playbacking = true
1220
      this.trackMap.removeLayer(this.layersGroup)
1221
      this.layersGroup = new Ai.LayerGroup() // 定义图层数组
1222
      this.trackMap.addLayer(this.layersGroup)
1223
      this.trackMap.removeLayer(this.pointsGroup)
1224
      this.pointsGroup = new Ai.LayerGroup() // 定义图层数组
1225
      this.trackMap.addLayer(this.pointsGroup)
1226
      this.trackData.forEach((e, index) => {
1227
        var point = Ai.Point([e.traceList[0].latitude, e.traceList[0].longitude], {
1228
          icon: Ai.Icon({
1229
            // 设置图标URL路径
1230
            iconUrl: 'static/images/track.png',
1231
            // 设置图标大小
1232
            iconSize: [40, 55],
1233
            // 设置点对象和图标的相对偏移量
1234
            iconAnchor: [20, 25]
1235
          })
1057 1236
        })
1058
        .catch((res) => {
1059
          // 请求失败处理...
1237
        point.entityId = e.entityId
1238
        this.pointsGroup.addLayer(point)
1239
        var popup = Ai.Popup({
1240
          maxWidth: 60,
1241
          minWidth: 50,
1242
          offset: [-3, -45],
1243
          autoClose: false,
1244
          autoPan: false,
1245
          closeButton: false
1246
        })
1247
        popup.setLatLng(point.getLatLng())
1248
        // 设置弹出框弹出内容
1249
        popup.setContent('<div style="text-align: center;color: white;">' + e.entityName + '</div>')
1250
        popup.entityId = e.entityId
1251
        this.pointsGroup.addLayer(popup)
1252
        popup.openOn(this.trackMap) // 需要先显示
1253
        var newLineWktStr = 'LINESTRING ( '
1254
        e.traceList.forEach(el => {
1255
          (function(i, that) {
1256
            var task = setTimeout(function() {
1257
              that.pointsGroup.eachLayer(layer => {
1258
                if (layer.entityId == e.entityId) {
1259
                  layer.setLatLng([el.latitude, el.longitude])
1260
                }
1261
              })
1262
              that.trackTime = el.createDate
1263
              newLineWktStr += el.longitude + ' ' + el.latitude + ','
1264
              that.getNewLine(newLineWktStr, index, e.entityId)
1265
              if (el.isStopPlay) {
1266
                that.playbacking = false
1267
              }
1268
            }, (i) * 1000)
1269
            that.timeouts.push(task)
1270
          })(el.playDurationTime, this)
1060 1271
        })
1272
      })
1273
      var arr = []
1274
      this.pointsGroup.eachLayer(layer => {
1275
        arr.push(layer)
1276
      })
1277
      this.trackMap.setViewPort(arr)
1278
      this.trackMap.setZoom(this.trackMap.getZoom() - 1)
1279
    },
1280
    stopPlayback() {
1281
      this.playbacking = false
1282
      this.timeouts.forEach(e => {
1283
        clearTimeout(e)
1284
      })
1285
      this.timeouts = []
1286
    },
1287
    startPlayback() {
1288
      for (let j = 0; j < this.timelineList.length; j++) {
1289
        this.timelineList[j].color = 'info'
1290
        this.timelineList[j].status = 'normal'
1291
      }
1292
      debugger
1293
      this.playbacking = true
1294
      this.trackMap.removeLayer(this.layersGroup)
1295
      this.layersGroup = new Ai.LayerGroup() // 定义图层数组
1296
      this.trackMap.addLayer(this.layersGroup)
1297
      var lineWktStr = 'LINESTRING ( '
1298
      this.trackData[0].traceList.forEach(e => {
1299
        lineWktStr += e.longitude + ' ' + e.latitude + ','
1300
      })
1301
      lineWktStr = lineWktStr.substring(0, lineWktStr.length - 1)
1302
      lineWktStr += ' )'
1303
      var lineLayer = new Ai.Polyline(lineWktStr, {color: 'gray', opacity: 1.0})
1304
      this.layersGroup.addLayer(lineLayer)
1305
      this.trackMap.setViewPort([lineLayer])
1306
      this.trackMap.setZoom(this.trackMap.getZoom() - 1)
1307
1308
      var point = Ai.Point([this.trackData[0].traceList[0].latitude, this.trackData[0].traceList[0].longitude], {
1309
        icon: Ai.Icon({
1310
          // 设置图标URL路径
1311
          iconUrl: 'static/images/track.png',
1312
          // 设置图标大小
1313
          iconSize: [40, 55],
1314
          // 设置点对象和图标的相对偏移量
1315
          iconAnchor: [20, 25]
1316
        })
1317
      })
1318
      var popup = Ai.Popup({
1319
        maxWidth: 60,
1320
        minWidth: 50,
1321
        offset: [-3, -45],
1322
        autoClose: false,
1323
        autoPan: false,
1324
        closeButton: false
1325
      })
1326
      popup.setLatLng(point.getLatLng())
1327
      // 设置弹出框弹出内容
1328
      popup.setContent('<div style="text-align: center;color: white;">' + this.trackData[0].entityName + '</div>')
1329
      this.trackMap.removeLayer(this.pointsGroup)
1330
      this.pointsGroup = new Ai.LayerGroup() // 定义图层数组
1331
      this.trackMap.addLayer(this.pointsGroup)
1332
      this.pointsGroup.addLayer(point)
1333
      this.pointsGroup.addLayer(popup)
1334
      popup.openOn(this.trackMap) // 需要先显示
1335
      var lastOne = this.trackData[0].traceList[this.trackData[0].traceList.length - 1]
1336
      var newLineWktStr = 'LINESTRING ( '
1337
      this.trackData[0].traceList.forEach(e => {
1338
        (function(i, that) {
1339
          var task = setTimeout(function() {
1340
            that.pointsGroup.eachLayer(layer => {
1341
              layer.setLatLng([e.latitude, e.longitude])
1342
            })
1343
            that.trackTime = e.createDate
1344
            newLineWktStr += e.longitude + ' ' + e.latitude + ','
1345
            that.getNewLine(newLineWktStr, 1, that.trackData[0].entityId)
1346
            if (e === lastOne) {
1347
              that.playbacking = false
1348
              that.timelineList[that.timelineList.length - 1].color = 'success'
1349
              that.timelineList[that.timelineList.length - 1].status = 'normal'
1350
            } else {
1351
              for (let j = 0; j < that.timelineList.length; j++) {
1352
                if (e.toolIndex > j) {
1353
                  that.timelineList[j].color = 'success'
1354
                } else {
1355
                  that.timelineList[j].color = 'info'
1356
                }
1357
                if (e.toolIndex == j) {
1358
                  that.timelineList[j].status = 'active'
1359
                } else {
1360
                  that.timelineList[j].status = 'normal'
1361
                }
1362
              }
1363
            }
1364
          }, (i) * 1000)
1365
          that.timeouts.push(task)
1366
        })(e.playDurationTime, this)
1367
      })
1368
    },
1369
    getNewLine(newLineWktStr, colorIndex, entityId) {
1370
      var color
1371
      if (colorIndex < 8) {
1372
        color = this.lineColors[colorIndex]
1373
      } else {
1374
        color = this.getRandomColor()
1375
      }
1376
      this.layersGroup.eachLayer(layer => {
1377
        if (layer.entityId == entityId) {
1378
          this.map.removeLayer(layer)
1379
        }
1380
      })
1381
      newLineWktStr = newLineWktStr.substring(0, newLineWktStr.length - 1)
1382
      newLineWktStr += ' )'
1383
      var lineLayer = new Ai.Polyline(newLineWktStr, {color: color, opacity: 1.0})
1384
      lineLayer.entityId = entityId
1385
      this.layersGroup.addLayer(lineLayer)
1386
    },
1387
    getRandomColor() { // 获取随机颜色
1388
      return '#' + Math.floor(Math.random() * 0xffffff).toString(16)
1061 1389
    }
1062 1390
  }
1063 1391
}