完善告警事件列表展示

This commit is contained in:
renna 2025-07-18 10:24:07 +08:00
parent c5b3fca87c
commit 573fe982ca
2 changed files with 200 additions and 62 deletions

View File

@ -14,12 +14,11 @@
/> />
<!-- 告警/预警提示框 --> <!-- 告警/预警提示框 -->
<!-- <AlertNotificationSystem <AlarmNotification
:alert-message="alertMessage" ref="alarmNotification"
:alert-type="alertType" @close="handleAlarmClose"
@show="handleAlertShow"
/> />
-->
<!-- 车辆动画系统 --> <!-- 车辆动画系统 -->
<VehicleAnimationSystem <VehicleAnimationSystem
ref="animationSystem" ref="animationSystem"
@ -59,7 +58,7 @@ import VehicleAnimationSystem from './VehicleAnimationSystem.vue';
import VehicleLabelSystem from './VehicleLabelSystem.vue'; import VehicleLabelSystem from './VehicleLabelSystem.vue';
import VehicleDetailPopup from './VehicleDetailPopup.vue'; import VehicleDetailPopup from './VehicleDetailPopup.vue';
import WeatherStationPopup from './WeatherStationPopup.vue'; import WeatherStationPopup from './WeatherStationPopup.vue';
// import AlertNotificationSystem from './AlertNotificationSystem.vue'; import AlarmNotification from '../info/AlarmNotification.vue'; //
import VehicleStyleManager from './VehicleStyleManager.vue'; import VehicleStyleManager from './VehicleStyleManager.vue';
// //
@ -94,6 +93,7 @@ const props = defineProps({
const animationSystem = ref(null); const animationSystem = ref(null);
const labelSystem = ref(null); const labelSystem = ref(null);
const styleManager = ref(null); const styleManager = ref(null);
const alarmNotification = ref(null); //
// //
const weatherStationVisible = ref(true); const weatherStationVisible = ref(true);
@ -161,6 +161,118 @@ let alertTimer = null;
// //
const violationStatusTimers = ref({}); const violationStatusTimers = ref({});
//
const alarmList = ref([]); //
const maxAlarmCount = 100; //
const alarmVisible = ref(true); //
//
function addAlarm(alarm) {
// alarm
const completeAlarm = {
id: `alarm-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, // ID
carId: alarm.carId || alarm.vehicleId || alarm.objectId || '未知车辆',
carType: alarm.carType || alarm.vehicleType || alarm.objectType || '未知类型',
time: alarm.time || formatTimeRange(new Date()),
description: alarm.description || '未知告警',
date: alarm.date || formatDateTime(new Date()),
level: alarm.level || 'medium', // high, medium, low
type: alarm.type || 'other', // car(), report(), speed(), other
...alarm //
};
//
alarmList.value.unshift(completeAlarm);
//
if (alarmList.value.length > maxAlarmCount) {
alarmList.value = alarmList.value.slice(0, maxAlarmCount);
}
//
updateAlarmNotification();
return completeAlarm.id; // ID便
}
//
function updateAlarm(alarmId, updates) {
const index = alarmList.value.findIndex(alarm => alarm.id === alarmId);
if (index !== -1) {
alarmList.value[index] = { ...alarmList.value[index], ...updates };
updateAlarmNotification();
return true;
}
return false;
}
//
function removeAlarm(alarmId) {
const index = alarmList.value.findIndex(alarm => alarm.id === alarmId);
if (index !== -1) {
alarmList.value.splice(index, 1);
updateAlarmNotification();
return true;
}
return false;
}
//
function clearAlarms() {
alarmList.value = [];
updateAlarmNotification();
}
//
function updateAlarmNotification() {
if (alarmNotification.value) {
alarmNotification.value.updateAlarmList(alarmList.value);
}
}
//
function toggleAlarmNotification() {
alarmVisible.value = !alarmVisible.value;
if (alarmNotification.value) {
if (alarmVisible.value) {
alarmNotification.value.show();
} else {
alarmNotification.value.hide();
}
}
}
//
function handleAlarmClose() {
alarmVisible.value = false;
console.log('告警面板已关闭');
}
// T10:20-10:25
function formatTimeRange(date, durationMinutes = 5) {
const startTime = new Date(date);
const endTime = new Date(date);
endTime.setMinutes(endTime.getMinutes() + durationMinutes);
const startHour = startTime.getHours().toString().padStart(2, '0');
const startMinute = startTime.getMinutes().toString().padStart(2, '0');
const endHour = endTime.getHours().toString().padStart(2, '0');
const endMinute = endTime.getMinutes().toString().padStart(2, '0');
return `T${startHour}:${startMinute}-${endHour}:${endMinute}`;
}
// 2025-03-19 10:30
function formatDateTime(date) {
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
const hour = date.getHours().toString().padStart(2, '0');
const minute = date.getMinutes().toString().padStart(2, '0');
return `${year}-${month}-${day} ${hour}:${minute}`;
}
// //
function handleAlertShow({ message, type, duration = 5000 }) { function handleAlertShow({ message, type, duration = 5000 }) {
if (alertTimer) { if (alertTimer) {
@ -814,6 +926,17 @@ function handlePathConflictAlert(payload) {
const warningMessage = `预警:${message}`; const warningMessage = `预警:${message}`;
showAlert(warningMessage, 'warning', 8000); showAlert(warningMessage, 'warning', 8000);
//
addAlarm({
carId: vehicleId,
carType: vehicles.value[vehicleId]?.type || '未知类型',
time: `${formatTimeRange(new Date())}${otherVehicleId}发生冲`,
description: '突预警',
level: 'medium',
type: 'car',
rawData: payload
});
// //
if (vehicles.value[vehicleId]) { if (vehicles.value[vehicleId]) {
vehicles.value[vehicleId].warning = true; vehicles.value[vehicleId].warning = true;
@ -834,6 +957,17 @@ function handlePathConflictAlert(payload) {
const alertMessage = `⚠️ 告警:${message}`; const alertMessage = `⚠️ 告警:${message}`;
showAlert(alertMessage, 'alarm', 10000); showAlert(alertMessage, 'alarm', 10000);
//
addAlarm({
carId: vehicleId,
carType: vehicles.value[vehicleId]?.type || '未知类型',
time: `${formatTimeRange(new Date())}${otherVehicleId}发生冲`,
description: '突告警',
level: 'high',
type: 'car',
rawData: payload
});
// //
if (vehicles.value[vehicleId]) { if (vehicles.value[vehicleId]) {
vehicles.value[vehicleId].alarm = true; vehicles.value[vehicleId].alarm = true;
@ -906,6 +1040,20 @@ function handleSpeedViolation(vehicleId, payload) {
// //
showAlert(`⚠️ 超速告警:${vehicleId} ${description}`, 'warning', 8000); showAlert(`⚠️ 超速告警:${vehicleId} ${description}`, 'warning', 8000);
//
addAlarm({
carId: vehicleId,
carType: vehicles.value[vehicleId]?.type || '未知类型',
time: `${formatTimeRange(new Date())}超速行驶`,
description: `,速度达到${actualValue}km/h`,
level: actualValue > limitValue * 1.5 ? 'high' : 'medium', // 50%
type: 'speed',
limitValue: limitValue,
actualValue: actualValue,
ruleName: ruleName,
rawData: payload
});
// //
if (vehicles.value[vehicleId]) { if (vehicles.value[vehicleId]) {
// //
@ -1018,6 +1166,17 @@ function handleUnauthorizedEntry(vehicleId, payload) {
// //
showAlert(`⚠️ 越界告警:${vehicleId} ${description}`, 'critical', 10000); showAlert(`⚠️ 越界告警:${vehicleId} ${description}`, 'critical', 10000);
//
addAlarm({
carId: vehicleId,
carType: vehicles.value[vehicleId]?.type || '未知类型',
time: `${formatTimeRange(new Date())}越界`,
description: '越界告警',
level: 'high',
type: 'access',
rawData: payload
});
// //
if (vehicles.value[vehicleId]) { if (vehicles.value[vehicleId]) {
vehicles.value[vehicleId].critical = true; vehicles.value[vehicleId].critical = true;
@ -1496,6 +1655,40 @@ defineExpose({
removeAircraftRoute(flightNo) { removeAircraftRoute(flightNo) {
return removeAircraftRoute(flightNo); return removeAircraftRoute(flightNo);
},
//
showAlarmNotification(message, type, duration) {
if (alarmNotification.value) {
alarmNotification.value.showNotification(message, type, duration);
}
},
hideAlarmNotification() {
if (alarmNotification.value) {
alarmNotification.value.hideNotification();
}
},
handleAlarmClose() {
//
console.log('告警通知组件已关闭');
},
addAlarm(alarm) {
return addAlarm(alarm);
},
updateAlarm(alarmId, updates) {
return updateAlarm(alarmId, updates);
},
removeAlarm(alarmId) {
return removeAlarm(alarmId);
},
clearAlarms() {
return clearAlarms();
},
updateAlarmNotification() {
return updateAlarmNotification();
},
toggleAlarmNotification() {
return toggleAlarmNotification();
} }
}); });

View File

@ -72,62 +72,7 @@ import { ref, computed } from 'vue';
const activeTab = ref('all'); const activeTab = ref('all');
// //
const alarmList = ref([ const alarmList = ref([]);
{
carId: 'QN001',
carType: '驱鸟车',
time: 'T10:20—10: 25与JD5949发生冲',
description: '突告警',
date: '2025-03-19 10:30',
level: 'high',
type: 'car'
},
{
carId: 'QN001',
carType: '驱鸟车',
time: 'T10:20—10: 25与JD5949发生冲',
description: '突告警',
date: '2025-03-19 10:30',
level: 'high',
type: 'car'
},
{
carId: 'QN001',
carType: '驱鸟车',
time: 'T10:20—10: 25闯入电子围',
description: '栏监控区域,发生告警',
date: '2025-03-19 10:30',
level: 'medium',
type: 'report'
},
{
carId: 'QN001',
carType: '驱鸟车',
time: 'T10:20—10: 25闯入电子围',
description: '栏监控区域,发生告警',
date: '2025-03-19 10:30',
level: 'medium',
type: 'report'
},
{
carId: 'QN002',
carType: '牵引车',
time: 'T10:15—10: 18超速行驶',
description: '速度达到85km/h',
date: '2025-03-19 10:18',
level: 'high',
type: 'speed'
},
{
carId: 'QN003',
carType: '摆渡车',
time: 'T10:22—10: 25超速行驶',
description: '速度达到78km/h',
date: '2025-03-19 10:25',
level: 'medium',
type: 'speed'
}
]);
// //
const filteredAlarms = computed(() => { const filteredAlarms = computed(() => {