From b360182f71e7b8fcccc4a1c7fd91f6b1a5f9606a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B4=AA=E6=B4=AA?= <2498601771@qq.com> Date: Wed, 6 Mar 2024 16:42:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=E8=BD=A8=E8=BF=B9?= =?UTF-8?q?=E8=BF=BD=E8=B8=AA=E9=A1=B5=E5=8F=B3=E4=BE=A7=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/location/Index.vue | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/views/location/Index.vue b/src/views/location/Index.vue index 6c72dfcf..27606909 100644 --- a/src/views/location/Index.vue +++ b/src/views/location/Index.vue @@ -685,30 +685,32 @@ export default { this.trackingSubscribers.forEach(s => { if (s.trackRecords && s.trackRecords.length > 0) { for (let i = 0; i < s.trackRecords.length; i++) { - if ((s.trackRecords[i - 1].subscriberLongitude === s.trackRecords[i].subscriberLongitude) && (s.trackRecords[i - 1].subscriberLatitude === s.trackRecords[i].subscriberLatitude)) { - // 如果连续两条地址重复,则将时间累加,并将上一条删除,键值-1继续循环 - if (s.trackRecords[i - 2]) { - const stayTime = unitConvert(s.trackRecords[i - 2].time - s.trackRecords[i].time, unitTypes.time, 's') - if (Number(stayTime[0]) === Number(Number(stayTime[0]).toFixed(0))) { - stayTime[0] = Number(stayTime[0]).toFixed(0) + if (i > 0) { + if ((s.trackRecords[i - 1].subscriberLongitude === s.trackRecords[i].subscriberLongitude) && (s.trackRecords[i - 1].subscriberLatitude === s.trackRecords[i].subscriberLatitude)) { + // 如果连续两条地址重复,则将时间累加,并将上一条删除,键值-1继续循环 + if (i > 1 && s.trackRecords[i - 2]) { + const stayTime = unitConvert(s.trackRecords[i - 2].time - s.trackRecords[i].time, unitTypes.time, 's') + if (Number(stayTime[0]) === Number(Number(stayTime[0]).toFixed(0))) { + stayTime[0] = Number(stayTime[0]).toFixed(0) + } + s.trackRecords[i].stayTime = stayTime.join(' ') + } else { + // 数据只有2条,或者第1条和第2条地点重复,删除1,合并时间 + const stayTime = unitConvert(s.trackRecords[i - 1].time - s.trackRecords[i].time, unitTypes.time, 's') + if (Number(stayTime[0]) === Number(Number(stayTime[0]).toFixed(0))) { + stayTime[0] = Number(stayTime[0]).toFixed(0) + } + s.trackRecords[i].stayTime = stayTime.join(' ') } - s.trackRecords[i].stayTime = stayTime.join(' ') + s.trackRecords.splice(i - 1, 1) + i = i - 1 } else { - // 数据只有2条,或者第1条和第2条地点重复,删除1,合并时间 const stayTime = unitConvert(s.trackRecords[i - 1].time - s.trackRecords[i].time, unitTypes.time, 's') if (Number(stayTime[0]) === Number(Number(stayTime[0]).toFixed(0))) { stayTime[0] = Number(stayTime[0]).toFixed(0) } s.trackRecords[i].stayTime = stayTime.join(' ') } - s.trackRecords.splice(i - 1, 1) - i = i - 1 - } else { - const stayTime = unitConvert(s.trackRecords[i - 1].time - s.trackRecords[i].time, unitTypes.time, 's') - if (Number(stayTime[0]) === Number(Number(stayTime[0]).toFixed(0))) { - stayTime[0] = Number(stayTime[0]).toFixed(0) - } - s.trackRecords[i].stayTime = stayTime.join(' ') } } } @@ -730,7 +732,6 @@ export default { if (this.currentShowSubscriber.trackRecords && this.currentShowSubscriber.trackRecords.length > 0) { // 六边形 const trackingPolygonSourceData = this.hexagonDataConverter(this.currentShowSubscriber.trackRecords, 'traceTracking') - console.info(this.currentShowSubscriber) this.trackingPolygonSourceData = _.cloneDeep(trackingPolygonSourceData) this.mapChart.addSource('trackingHexGrid', { type: 'geojson',