diff --git a/pc-cattle-transportation/src/views/earlywarning/warningDetailDialog.vue b/pc-cattle-transportation/src/views/earlywarning/warningDetailDialog.vue index 35dda7d..1ba4bfc 100644 --- a/pc-cattle-transportation/src/views/earlywarning/warningDetailDialog.vue +++ b/pc-cattle-transportation/src/views/earlywarning/warningDetailDialog.vue @@ -377,7 +377,47 @@ -
+
+

最新定位

+ + + {{ formatTimestamp(latestPoint.locTime) }} + + + {{ latestPoint.lat }} + + + {{ latestPoint.lng }} + + + {{ latestPoint.speed ?? '--' }} + + + {{ latestPoint.direction ?? '--' }} + + +
+ +
+

轨迹查询分段({{ segmentStats.length }})

+ + + + + + + + + + + +
+ +

停留点分析(15分钟)

@@ -468,6 +508,8 @@ const playTimer = ref(null); // 播放定时器 const currentPlayIndex = ref(0); // 当前播放到的轨迹点索引 const trackBMapGL = ref(null); // 保存 BMapGL 实例,避免重复加载 const stayPoints = ref([]); // 停留点列表 +const latestPoint = ref(null); // 最新轨迹点 +const segmentStats = ref([]); const yingyanMeta = reactive({ entityName: '', startTime: null, @@ -491,6 +533,11 @@ const isLocationWarning = computed(() => { return isLocWarning; }); +const isStaticTrack = computed(() => { + const status = Number(warningData.status || 0); + return status >= 3; +}); + const dialogTitle = computed(() => { return `${warningData.warningTypeDesc || '预警'}详情`; }); @@ -816,6 +863,25 @@ const formatDuration = (seconds) => { return parts.join('') || `${sec}秒`; }; +function parseLatestPoint(point) { + if (!point) { + return null; + } + const lng = parseFloat(point.longitude ?? point.lng ?? 0); + const lat = parseFloat(point.latitude ?? point.lat ?? 0); + if (Number.isNaN(lng) || Number.isNaN(lat) || (lng === 0 && lat === 0)) { + return null; + } + + return { + lng, + lat, + locTime: point.locTime ?? point.loc_time ?? null, + speed: point.speed ?? null, + direction: point.direction ?? null, + }; +} + // 关闭对话框 const handleClose = () => { // 清理地图实例 @@ -850,11 +916,17 @@ const handleTrackClick = async () => { ElMessage.warning('运单ID不存在,无法查看轨迹'); return; } + console.info('[TRACK] 开始轨迹定位流程', { + deliveryId: warningData.deliveryId, + status: warningData.status, + estimatedDepartureTime: warningData.estimatedDepartureTime, + }); trackDialogVisible.value = true; trackLoading.value = true; trackMapShow.value = false; trackPath.value = []; + latestPoint.value = null; isPlaying.value = false; currentPlayIndex.value = 0; @@ -913,6 +985,8 @@ const getDeliveryStatus = async () => { const loadYingyanTrack = async () => { stayPoints.value = []; trackPath.value = []; + latestPoint.value = null; + segmentStats.value = []; trackMapShow.value = false; yingyanMeta.entityName = ''; yingyanMeta.startTime = null; @@ -925,7 +999,10 @@ const loadYingyanTrack = async () => { try { const res = await getYingyanTrack({ deliveryId: warningData.deliveryId }); + console.info('[TRACK] 后端轨迹接口响应', res); if (res.code === 200 && res.data) { + segmentStats.value = Array.isArray(res.data.segmentStats) ? res.data.segmentStats : []; + console.info('[TRACK] 分段统计', segmentStats.value); const rawPoints = Array.isArray(res.data.trackPoints) ? res.data.trackPoints : []; trackPath.value = rawPoints .map(item => { @@ -946,9 +1023,18 @@ const loadYingyanTrack = async () => { yingyanMeta.entityName = res.data.entityName || ''; yingyanMeta.startTime = res.data.startTime || null; yingyanMeta.endTime = res.data.endTime || null; + latestPoint.value = parseLatestPoint(res.data.latestPoint); + console.info('[TRACK] 轨迹点数量', trackPath.value.length); if (trackPath.value.length > 0) { trackMapShow.value = true; + } else if (latestPoint.value) { + trackPath.value.push({ + lng: latestPoint.value.lng, + lat: latestPoint.value.lat, + locTime: latestPoint.value.locTime || null, + }); + trackMapShow.value = true; } else { ElMessage.warning('暂无有效轨迹点'); } @@ -1340,6 +1426,28 @@ defineExpose({ margin-top: 20px; } +.latest-point-panel { + margin-top: 20px; + + h4 { + margin: 0 0 10px 0; + font-size: 15px; + font-weight: 600; + color: #303133; + } +} + +.segment-stats { + margin-top: 20px; + + h4 { + margin: 0 0 10px 0; + font-size: 15px; + font-weight: 600; + color: #303133; + } +} + .staypoint-section { margin-top: 20px; diff --git a/pc-cattle-transportation/src/views/entry/details.vue b/pc-cattle-transportation/src/views/entry/details.vue index 8897862..8bdd7be 100644 --- a/pc-cattle-transportation/src/views/entry/details.vue +++ b/pc-cattle-transportation/src/views/entry/details.vue @@ -1,11 +1,7 @@