diff --git a/src/components/devices/DeviceStatusPage.tsx b/src/components/devices/DeviceStatusPage.tsx
index 8096dd0..95719ac 100644
--- a/src/components/devices/DeviceStatusPage.tsx
+++ b/src/components/devices/DeviceStatusPage.tsx
@@ -734,6 +734,7 @@ export default function DeviceStatusPage() {
const handleGamepadUpdate = useCallback((state) => {
// 无控制权限时:不发送消息,且只发起一次权限申请(避免手柄/方向盘高频更新刷屏)
if (!isControlled) {
+ messageApi.warning("请获取控制权限");
//if (!hasRequestedControlRef.current && !connecting) {
// hasRequestedControlRef.current = true;
// handleControlModal();
@@ -741,9 +742,12 @@ export default function DeviceStatusPage() {
//return;
}
console.log(realtimePosition?.controlMode, "现在的控制controlmode")
- if (realtimePosition?.controlMode && (realtimePosition?.controlMode != 3 || realtimePosition?.controlMode != 0)) {
+ if (
+ realtimePosition?.controlMode != 3 &&
+ realtimePosition?.controlMode != 0 &&
+ realtimePosition?.controlMode != null
+ ) {
messageApi.warning(t('devices.noRemoteControl'));
- //return;
}
console.log('Gamepad state updated:', state);
// 记录方向盘 xy 坐标,用于倒车影像叠加层
@@ -756,7 +760,11 @@ export default function DeviceStatusPage() {
const gamepadWarnRef = useRef(0);
const blockIfGamepadConnected = useCallback(() => {
// 没连接手柄 或 还没获取控制权限 → 不拦截(没控制权限本来就发不出消息)
- if (!isGamepadConnected || !isControlled) return false;
+ if (!isGamepadConnected) return false;
+ if (!isControlled) {
+ messageApi.warning("请获取控制权限");
+ return false;
+ }
const now = Date.now();
if (now - gamepadWarnRef.current > 2000) {
gamepadWarnRef.current = now;
diff --git a/src/components/devices/RobotTaskPage.tsx b/src/components/devices/RobotTaskPage.tsx
index b4c4a6c..7ac0f98 100644
--- a/src/components/devices/RobotTaskPage.tsx
+++ b/src/components/devices/RobotTaskPage.tsx
@@ -1,186 +1,186 @@
-import React, { useState, useEffect, useMemo } from 'react';
-import { Row, Col, Card, Space, Typography, Select, Empty } from 'antd';
-import { Car, Satellite, LayoutGrid, CheckCircle2, AlertCircle, TrendingUp } from 'lucide-react';
-import { getSiteDevice, getSiteUAVList } from '../../api/device';
-import { useSelector } from 'react-redux';
-import { RootState } from '@/src/store';
-import { useTranslation } from 'react-i18next';
-import { WayLineView } from './WayLineView';
-import { TaskPlanningView } from './TaskPlanningView';
-import type { ViewStats } from './WayLineView';
-
-const { Text } = Typography;
-
-// ==================== 合并页面:任务规划 + 地图编辑 + 航线任务 ====================
-interface MachineOption {
- value: string;
- label: string;
- group: 'robot' | 'plane';
-}
-
-export default function RobotTaskPage() {
- const { t } = useTranslation();
- const { stationId, currentStation } = useSelector((state: RootState) => state.station);
-
- const [machineOptions, setMachineOptions] = useState
([]);
- const [selectedMachine, setSelectedMachine] = useState(undefined);
- const [selectedGroup, setSelectedGroup] = useState<'robot' | 'plane' | undefined>(undefined);
- const [robotStats, setRobotStats] = useState({});
- const [droneStats, setDroneStats] = useState({});
- const [robotOnline, setRobotOnline] = useState({ online: 0, total: 0 });
-
- // 顶部统一机器列表:机器人 + 无人机合并
- useEffect(() => {
- if (!stationId) return;
- let ignore = false;
- const loadMachines = async () => {
- try {
- const [robotRes, planeRes] = await Promise.all([
- getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1, orgId: currentStation?.orgId }),
- getSiteUAVList(stationId),
- ]);
- if (ignore) return;
- const robots = robotRes?.code === 200 ? (robotRes.rows || []) : [];
- const planes = planeRes?.code === 200 ? (planeRes.rows || []) : [];
- const options: MachineOption[] = [
- ...robots
- .filter((r) => !!r.serialNumber)
- .map((r) => ({ value: r.serialNumber, label: r.deviceAlias || r.deviceName || r.serialNumber, group: 'robot' as const })),
- ...planes
- .filter((p) => !!p.device_sn)
- .map((p) => ({ value: p.device_sn, label: p.drone_callsign || p.device_sn, group: 'plane' as const })),
- ];
- setMachineOptions(options);
- // 初始化时默认选中机器人分组的第一个(无机器人时取第一个选项)
- const firstRobot = options.find((o) => o.group === 'robot') || options[0];
- if (firstRobot) {
- setSelectedMachine((prev) => prev || firstRobot.value);
- setSelectedGroup((prev) => prev || firstRobot.group);
- }
- setRobotOnline({
- online: robots.filter((r) => r.onlineStatus == 1).length,
- total: robots.length,
- });
- } catch (err) {
- console.error('获取机器列表失败', err);
- }
- };
- loadMachines();
- return () => { ignore = true; };
- }, [stationId, currentStation?.orgId]);
-
- const handleMachineChange = (value: string | undefined) => {
- setSelectedMachine(value);
- const hit = machineOptions.find((o) => o.value === value);
- setSelectedGroup(hit?.group);
- };
-
- // 分组下拉:仅有对应机器时才显示该分组
- const groupedOptions = useMemo(() => {
- const groups: { label: string; options: { value: string; label: string }[] }[] = [];
- const robots = machineOptions.filter((o) => o.group === 'robot');
- const planes = machineOptions.filter((o) => o.group === 'plane');
- if (robots.length) {
- groups.push({ label: t('devices.robot'), options: robots.map((o) => ({ value: o.value, label: o.label })) });
- }
- if (planes.length) {
- groups.push({ label: t('devices.drone'), options: planes.map((o) => ({ value: o.value, label: o.label })) });
- }
- return groups;
- }, [machineOptions]);
-
- const cardStyle = { borderRadius: 12, border: 'none', boxShadow: '0 2px 12px rgba(0,0,0,0.04)' };
-
- // 顶部统计卡:机器人任务 + 无人机航线任务数据合并
- const mergedCards = useMemo(() => {
- const planTotal = (robotStats.planTotal || 0) + (droneStats.planTotal || 0);
- const working = (robotStats.working || 0) + (droneStats.working || 0);
- const finishCount = (robotStats.finishCount || 0) + (droneStats.finishCount || 0);
- const totalCount = (robotStats.totalCount || 0) + (droneStats.totalCount || 0);
- const completionRate = totalCount ? Math.round((finishCount / totalCount) * 100) : 0;
- const onlineRate = robotOnline.total ? Math.round((robotOnline.online / robotOnline.total) * 100) : 0;
- return [
- { title: t('devices.statTodayPlan'), value: planTotal, unit: t('devices.unitPlan'), desc: t('devices.statInProgress'), icon: , color: '#165DFF' },
- { title: t('devices.statWorkingRobots'), value: working, unit: t('devices.unitRobot'), desc: t('devices.statWorking'), icon: , color: '#165DFF' },
- { title: t('devices.statTotalDistance'), value: '12.5', unit: 'km', trend: t('devices.vsYesterday', { value: '+1.2' }), trendColor: '#00B42A', icon: , color: '#722ED1' },
- { title: t('devices.statCompletionRate'), value: completionRate, unit: '%', trend: t('devices.vsYesterday', { value: '+5%' }), trendColor: '#00B42A', icon: , color: '#00B42A' },
- { title: t('devices.statAlerts'), value: '0', unit: t('devices.unitTimes'), trend: t('devices.vsYesterday', { value: '-1' }), trendColor: '#00B42A', icon: , color: '#F53F3F' },
- { title: t('devices.statOnlineRate'), value: `${onlineRate}`, unit: '%', desc: t('devices.good'), icon: , color: '#165DFF' },
- ] as { title: string; value: any; unit: string; desc?: string; trend?: string; trendColor?: string; icon: React.ReactElement; color: string }[];
- }, [robotStats, droneStats, robotOnline, t]);
-
- return (
-
-
-
- {t('devices.robotTask')}
-
-
- {t('devices.mapEditor.selectRobot')}
-
-
-
-
-
-
- {mergedCards.map((item, index) => (
-
-
-
-
- {React.cloneElement(item.icon as React.ReactElement, { size: 18 })}
-
-
-
{item.title}
-
- {item.value}
- {item.unit}
-
-
- {item.trend || item.desc}
-
-
-
-
-
- ))}
-
-
- {!selectedMachine ? (
-
-
- ) : selectedGroup === 'plane' ? (
-
- ) : (
-
- )}
-
-
- );
-}
-
+import React, { useState, useEffect, useMemo } from 'react';
+import { Row, Col, Card, Space, Typography, Select, Empty } from 'antd';
+import { Car, Satellite, LayoutGrid, CheckCircle2, AlertCircle, TrendingUp } from 'lucide-react';
+import { getSiteDevice, getSiteUAVList } from '../../api/device';
+import { useSelector } from 'react-redux';
+import { RootState } from '@/src/store';
+import { useTranslation } from 'react-i18next';
+import { WayLineView } from './WayLineView';
+import { TaskPlanningView } from './TaskPlanningView';
+import type { ViewStats } from './WayLineView';
+
+const { Text } = Typography;
+
+// ==================== 合并页面:任务规划 + 地图编辑 + 航线任务 ====================
+interface MachineOption {
+ value: string;
+ label: string;
+ group: 'robot' | 'plane';
+}
+
+export default function RobotTaskPage() {
+ const { t } = useTranslation();
+ const { stationId, currentStation } = useSelector((state: RootState) => state.station);
+
+ const [machineOptions, setMachineOptions] = useState([]);
+ const [selectedMachine, setSelectedMachine] = useState(undefined);
+ const [selectedGroup, setSelectedGroup] = useState<'robot' | 'plane' | undefined>(undefined);
+ const [robotStats, setRobotStats] = useState({});
+ const [droneStats, setDroneStats] = useState({});
+ const [robotOnline, setRobotOnline] = useState({ online: 0, total: 0 });
+
+ // 顶部统一机器列表:机器人 + 无人机合并
+ useEffect(() => {
+ if (!stationId) return;
+ let ignore = false;
+ const loadMachines = async () => {
+ try {
+ const [robotRes, planeRes] = await Promise.all([
+ getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1, orgId: currentStation?.orgId }),
+ getSiteUAVList(stationId),
+ ]);
+ if (ignore) return;
+ const robots = robotRes?.code === 200 ? (robotRes.rows || []) : [];
+ const planes = planeRes?.code === 200 ? (planeRes.rows || []) : [];
+ const options: MachineOption[] = [
+ ...robots
+ .filter((r) => !!r.serialNumber)
+ .map((r) => ({ value: r.serialNumber, label: r.deviceAlias || r.deviceName || r.serialNumber, group: 'robot' as const })),
+ ...planes
+ .filter((p) => !!p.device_sn)
+ .map((p) => ({ value: p.device_sn, label: p.drone_callsign || p.device_sn, group: 'plane' as const })),
+ ];
+ setMachineOptions(options);
+ // 初始化时默认选中机器人分组的第一个(无机器人时取第一个选项)
+ const firstRobot = options.find((o) => o.group === 'robot') || options[0];
+ if (firstRobot) {
+ setSelectedMachine(firstRobot.value);
+ setSelectedGroup(firstRobot.group);
+ }
+ setRobotOnline({
+ online: robots.filter((r) => r.onlineStatus == 1).length,
+ total: robots.length,
+ });
+ } catch (err) {
+ console.error('获取机器列表失败', err);
+ }
+ };
+ loadMachines();
+ return () => { ignore = true; };
+ }, [stationId, currentStation?.orgId]);
+
+ const handleMachineChange = (value: string | undefined) => {
+ setSelectedMachine(value);
+ const hit = machineOptions.find((o) => o.value === value);
+ setSelectedGroup(hit?.group);
+ };
+
+ // 分组下拉:仅有对应机器时才显示该分组
+ const groupedOptions = useMemo(() => {
+ const groups: { label: string; options: { value: string; label: string }[] }[] = [];
+ const robots = machineOptions.filter((o) => o.group === 'robot');
+ const planes = machineOptions.filter((o) => o.group === 'plane');
+ if (robots.length) {
+ groups.push({ label: t('devices.robot'), options: robots.map((o) => ({ value: o.value, label: o.label })) });
+ }
+ if (planes.length) {
+ groups.push({ label: t('devices.drone'), options: planes.map((o) => ({ value: o.value, label: o.label })) });
+ }
+ return groups;
+ }, [machineOptions]);
+
+ const cardStyle = { borderRadius: 12, border: 'none', boxShadow: '0 2px 12px rgba(0,0,0,0.04)' };
+
+ // 顶部统计卡:机器人任务 + 无人机航线任务数据合并
+ const mergedCards = useMemo(() => {
+ const planTotal = (robotStats.planTotal || 0) + (droneStats.planTotal || 0);
+ const working = (robotStats.working || 0) + (droneStats.working || 0);
+ const finishCount = (robotStats.finishCount || 0) + (droneStats.finishCount || 0);
+ const totalCount = (robotStats.totalCount || 0) + (droneStats.totalCount || 0);
+ const completionRate = totalCount ? Math.round((finishCount / totalCount) * 100) : 0;
+ const onlineRate = robotOnline.total ? Math.round((robotOnline.online / robotOnline.total) * 100) : 0;
+ return [
+ { title: t('devices.statTodayPlan'), value: planTotal, unit: t('devices.unitPlan'), desc: t('devices.statInProgress'), icon: , color: '#165DFF' },
+ { title: t('devices.statWorkingRobots'), value: working, unit: t('devices.unitRobot'), desc: t('devices.statWorking'), icon: , color: '#165DFF' },
+ { title: t('devices.statTotalDistance'), value: '12.5', unit: 'km', trend: t('devices.vsYesterday', { value: '+1.2' }), trendColor: '#00B42A', icon: , color: '#722ED1' },
+ { title: t('devices.statCompletionRate'), value: completionRate, unit: '%', trend: t('devices.vsYesterday', { value: '+5%' }), trendColor: '#00B42A', icon: , color: '#00B42A' },
+ { title: t('devices.statAlerts'), value: '0', unit: t('devices.unitTimes'), trend: t('devices.vsYesterday', { value: '-1' }), trendColor: '#00B42A', icon: , color: '#F53F3F' },
+ { title: t('devices.statOnlineRate'), value: `${onlineRate}`, unit: '%', desc: t('devices.good'), icon: , color: '#165DFF' },
+ ] as { title: string; value: any; unit: string; desc?: string; trend?: string; trendColor?: string; icon: React.ReactElement; color: string }[];
+ }, [robotStats, droneStats, robotOnline, t]);
+
+ return (
+
+
+
+ {t('devices.robotTask')}
+
+
+ {t('devices.mapEditor.selectRobot')}
+
+
+
+
+
+
+ {mergedCards.map((item, index) => (
+
+
+
+
+ {React.cloneElement(item.icon as React.ReactElement, { size: 18 })}
+
+
+
{item.title}
+
+ {item.value}
+ {item.unit}
+
+
+ {item.trend || item.desc}
+
+
+
+
+
+ ))}
+
+
+ {!selectedMachine ? (
+
+
+ ) : selectedGroup === 'plane' ? (
+
+ ) : (
+
+ )}
+
+
+ );
+}
+
diff --git a/src/components/devices/TaskPlanningView.tsx b/src/components/devices/TaskPlanningView.tsx
index 1857ce4..7fe0b6a 100644
--- a/src/components/devices/TaskPlanningView.tsx
+++ b/src/components/devices/TaskPlanningView.tsx
@@ -340,11 +340,49 @@ export function TaskPlanningView({ selectedMachineSn, embedded = false, onStatsC
}, []);
+ // 切换场站时统一清理旧场站残留:地图画线、机器、实时数据、任务执行状态等
+ useEffect(() => {
+ if (!stationId) return;
+
+ // 清空地图上所有画的线、打点、规划点、规划区域
+ setPolyPoints([]);
+ setPoints([]);
+ setProPoints({});
+ setRouteMode('');
+ setClearNavLine(v => v + 1);
+ setClearPlanLine(v => v + 1);
+ setNum(v => v + 1);
+ setFocusLocation(null);
+
+ // 清空上一个场站的设备/实时数据
+ setDevices([]);
+ setRealtimeMap({});
+
+ // 清空上一个场站的任务执行与机器状态
+ setExecute(false);
+ setExecutingRobot(null);
+ setShowVideo(false);
+ setRunningPoolTask(null);
+ setExcuteStatus('stop');
+
+ // 清空上一个场站的任务下发选择
+ setDispatchRouteIds([]);
+ setDispatchRobotSns([]);
+ setSelectedRouteForExecute(null);
+ setSelectedRobotForExecute(null);
+ setExecuteModalVisible(false);
+
+ // 清空地图编辑器区域选中
+ setEditorType(null);
+ }, [stationId]);
+
// 全量设备实时状态 WebSocket(mapPush):实时数据统一从这里获取,退出页面断开连接
useEffect(() => {
if (!userInfo || !stationId || !controllerRef.current) return;
const controller = controllerRef.current;
controller.siteId = stationId;
+ // 切换场站时先清空上一站的实时缓存,避免跨站脏数据残留
+ setRealtimeMap({});
controller.initMapPush((rtMap: any) => setRealtimeMap(rtMap || {}));
return () => {
controller.closeMapPush?.();
diff --git a/src/components/devices/deviceController.js b/src/components/devices/deviceController.js
index c044296..130f1c5 100644
--- a/src/components/devices/deviceController.js
+++ b/src/components/devices/deviceController.js
@@ -51,6 +51,7 @@ export default class DeviceController {
this.onIsExecuting = null;
this.handleArrivedPoint = null;
this.onDetectionReport = null;
+ this.onDeviceErrorPush = null;
// 全量设备实时状态(mapPush)连接
this.mapPushWs = null;
@@ -172,6 +173,53 @@ export default class DeviceController {
this.deviceStatusChangedMsg?.(msg);
}
+ if (msg?.type == 'device_error_push') {
+ console.log('device_error_push', msg);
+ const list = Array.isArray(msg?.alarms)
+ ? msg.alarms
+ : Array.isArray(msg?.data?.alarms)
+ ? msg.data.alarms
+ : Array.isArray(msg?.data) ? msg.data : [];
+ const levelMap = { 1: 'ERROR', 2: 'WARNING', 3: 'INFO', 4: 'INFO' };
+ // 后端 LocalDateTime 以数组 [年,月,日,时,分,秒,纳秒] 下发,需单独转换
+ const formatAlarmTime = (time) => {
+ if (time === null || time === undefined || time === '') return '';
+ if (Array.isArray(time)) {
+ const [y, mo, d, h = 0, mi = 0, se = 0] = time;
+ if (!y) return '';
+ const dt = dayjs(new Date(y, mo - 1, d, h, mi, se));
+ return dt.isValid() ? dt.format('YYYY-MM-DD HH:mm:ss') : '';
+ }
+ const dt = dayjs(time);
+ return dt.isValid() ? dt.format('YYYY-MM-DD HH:mm:ss') : String(time);
+ };
+ // alarmTitle 若为编码(如 SAFETY_FAULT_HEARTBEAT_TIMEOUT),改用 alarmContent 中文描述
+ const isAlarmCode = (val) => typeof val === 'string' && /^[A-Z][A-Z0-9_]*$/.test(val);
+ const alarms = list.map((a) => {
+ if (!a || typeof a !== 'object') return null;
+ // 统一告警级别:后端 ErrorLevel 1严重/2重要/3一般/4提示 → ERROR/WARNING/INFO
+ const rawLevel = a.alertLevel ?? a.alarmLevel;
+ const alertLevel = typeof rawLevel === 'number'
+ ? (levelMap[rawLevel] || 'INFO')
+ : String(rawLevel || 'INFO').toUpperCase();
+ const rawTitle = a.alarmTitle;
+ const alarmTitle = (isAlarmCode(rawTitle) ? (a.alarmContent || rawTitle) : (rawTitle || a.alarmContent)) || a.alarmNo || '';
+ return {
+ ...a,
+ alertLevel,
+ alarmTitle,
+ handleStatus: a.handleStatus ?? 1,
+ alarmTime: formatAlarmTime(a.alarmTime),
+ };
+ }).filter(Boolean);
+ if (alarms.length) {
+ this.onDeviceErrorPush?.({
+ deviceId: msg?.deviceId || msg?.data?.deviceId,
+ alarms,
+ });
+ }
+ }
+
if (msg?.type == 'route_post') {
console.log('route_post');
this.onRoutePost?.(msg);
diff --git a/src/locales/zh/index.ts b/src/locales/zh/index.ts
index 22ae8c6..8099709 100644
--- a/src/locales/zh/index.ts
+++ b/src/locales/zh/index.ts
@@ -1878,6 +1878,7 @@ const zh = {
handled: '已处理',
restored: '已恢复',
ignored: '已忽略',
+ ignore: "忽略",
unableToHandle: '无法处理',
manufacturerHandling: '厂家处理中',
falseAlarm: '误报',
diff --git a/src/pages/TaskMonitorPage.tsx b/src/pages/TaskMonitorPage.tsx
index 98fe4fb..91eacba 100644
--- a/src/pages/TaskMonitorPage.tsx
+++ b/src/pages/TaskMonitorPage.tsx
@@ -28,7 +28,7 @@ import { RootState } from '../store';
import { useTranslation } from 'react-i18next';
import dayjs from 'dayjs';
import { getRobotTaskList, getSiteDevice, getDeviceTastPool, getSiteDeviceTaskHistory, getRouteByTask, getSingleRouteList, getTaskPath } from '../api/device';
-import { getAlarmList, getAlarmStatistics } from '../api/alarmApi';
+import { getAlarmList, getAlarmStatistics, handleAlarm } from '../api/alarmApi';
import { alarmTypeMap } from '@/constants.js';
import { useNavigate } from 'react-router-dom';
import DeviceController from '../components/devices/DeviceController';
@@ -51,6 +51,41 @@ const TASK_STATUS_MAP: Record = {
const getTaskStatusStyle = (status?: string) =>
TASK_STATUS_MAP[String(status || '').toUpperCase()] || { text: status || '--', color: 'default' };
+// 告警时间兼容:Java LocalDateTime 数组 / ISO 字符串 / 时间戳
+const formatAlarmTime = (value: any, fmt = 'HH:mm:ss') => {
+ if (value === null || value === undefined || value === '') return '';
+ if (Array.isArray(value)) {
+ const [y, mo, d, h = 0, mi = 0, se = 0] = value;
+ if (!y) return '';
+ const dt = dayjs(new Date(y, mo - 1, d, h, mi, se));
+ return dt.isValid() ? dt.format(fmt) : '';
+ }
+ const dt = dayjs(value);
+ return dt.isValid() ? dt.format(fmt) : String(value);
+};
+
+// 告警标题:alarmTitle 是编码(如 SAFETY_FAULT_HEARTBEAT_TIMEOUT)时改用 alarmContent
+const isAlarmCode = (value: any) => typeof value === 'string' && /^[A-Z][A-Z0-9_]*$/.test(value);
+const getAlarmTitleText = (record: any) => {
+ const title = record?.alarmTitle;
+ return (isAlarmCode(title) ? record?.alarmContent : (title || record?.alarmContent)) || record?.alarmNo || '';
+};
+
+// 告警级别展示:严重 / 重要 / 提示
+const ALARM_LEVEL_ALIAS: Record = {
+ '1': 'ERROR', '2': 'WARNING', '3': 'INFO', '4': 'INFO',
+ CRITICAL: 'ERROR', MAJOR: 'WARNING', MINOR: 'INFO',
+};
+const ALARM_LEVEL_META: Record = {
+ ERROR: { text: '严重', color: '#ff4d4f', tag: 'red' },
+ WARNING: { text: '重要', color: '#faad14', tag: 'orange' },
+ INFO: { text: '提示', color: '#1677ff', tag: 'blue' },
+};
+const resolveAlarmLevel = (record: any) => {
+ const raw = String(record?.alertLevel ?? record?.alarmLevel ?? 'INFO').toUpperCase();
+ return ALARM_LEVEL_ALIAS[raw] || raw;
+};
+
// 浅色主题卡片组件
const MonitorCard: React.FC<{ title: string; icon: React.ReactNode; children: React.ReactNode; extra?: React.ReactNode; height?: number | string; bodyOverflow?: string }> = ({ title, icon, children, extra, height, bodyOverflow = 'auto' }) => (
{
controller.deviceStatusChangedMsg = refreshData;
controller.initMapPush((rtMap: any) => setRealtimeMap(rtMap || {}));
controller.onDetectionReport = handleDetectionReport;
+ // 全局推送的新告警:合并到列表顶部
+ controller.onDeviceErrorPush = (payload: any) => {
+ const incoming: any[] = Array.isArray(payload?.alarms) ? payload.alarms : [];
+ if (!incoming.length) return;
+ setAlarmList((prev: any[]) => {
+ const incomingIds = new Set(incoming.map((a) => a.id));
+ return [...incoming, ...prev.filter((a) => !incomingIds.has(a.id))].slice(0, 5);
+ });
+ };
controllerRef.current = controller;
return () => {
controller.closeMapPush();
};
}, [userInfo, stationId]);
+ // 手动处理告警:handleStatus=2 表示已关闭
+ const handleAlarmItem = async (record: any) => {
+ const alarmId = record?.id;
+ if (!alarmId) return;
+ try {
+ const res = await handleAlarm({ alarmId, handleStatus: 2 });
+ if (res?.code === 200) {
+ utils.message.success('处理成功');
+ setAlarmList((prev: any[]) => prev.filter((a) => a.id !== alarmId));
+ } else {
+ utils.message.error(res?.msg || '处理失败');
+ }
+ } catch (err) {
+ console.error('处理告警失败', err);
+ utils.message.error('处理失败');
+ }
+ };
+
const fetchRouteDetail = async (id) => {
try {
const params = {
@@ -569,28 +631,36 @@ const TaskMonitorPage: React.FC = () => {
- } extra={ a.handleStatus === 1).length} overflowCount={99} />} height="25%">
+ } extra={ a.handleStatus !== 2).length} overflowCount={99} />} height="25%">
a.handleStatus === 1).slice(0, 3)}
- renderItem={(item: any) => (
-
-
-
-
-
- {item.alarmTitle}
-
- {item.alarmLevel === 'ERROR' ? '紧急' : '重要'}
-
-
-
- {item.deviceName} | {dayjs(item.alarmTime).format('HH:mm:ss')}
+ dataSource={alarmList.filter((a: any) => a.handleStatus !== 2).slice(0, 3)}
+ renderItem={(item: any) => {
+ const level = resolveAlarmLevel(item);
+ const meta = ALARM_LEVEL_META[level] || ALARM_LEVEL_META.INFO;
+ const title = getAlarmTitleText(item);
+ return (
+
+
+
+
+
+
+ {title || '--'}
+
+
+ {meta.text}
+
+
+
+
+ {item.deviceAlias || item.deviceName || item.deviceId || '--'} | {item.alarmTime}
+
-
-
- )}
+
+ );
+ }}
locale={{ emptyText:
}}
/>