地图编辑 增加障碍物 障碍物支持修改半径 返航 分区 障碍物 支持修改名称

This commit is contained in:
mmc
2026-10-28 17:15:58 +08:00
parent 3e2fa95a30
commit 91c01e249f
5 changed files with 1394 additions and 101 deletions

View File

@@ -93,9 +93,15 @@ export default function RuleConfigManagement() {
setLoading(true);
try {
const res = await selectRuleBySiteId({ siteId: stationId });
const list = res?.data || res?.rows || [];
setRuleList(list);
setFilteredList(list);
if (res.code == 200) {
const list = res?.data || res?.rows || [];
setRuleList(list);
setFilteredList(list);
} else {
setRuleList([]);
setFilteredList([]);
}
} catch (err) {
utils.message.error(t('systemSetting.operationFailed'));
} finally {
@@ -319,8 +325,8 @@ export default function RuleConfigManagement() {
render: (val: any) => <Tag color={val === 1 || val === true ? 'orange' : 'default'}>{val === 1 || val === true ? t('common.yes') : t('common.no')}</Tag>,
},
{
title: t('common.actions'),
key: 'action',
title: t('common.actions'),
key: 'action',
width: 220,
fixed: 'right' as const,
render: (_: any, record: any) => (

File diff suppressed because it is too large Load Diff

View File

@@ -159,6 +159,9 @@ export default class DeviceController {
}
if (msg?.type == 'device_status_changed') {
this.deviceStatusChangedMsg?.(msg);
}
};
ws.onerror = () => {

View File

@@ -0,0 +1,636 @@
import React, { useState, useEffect, useMemo, useRef } from 'react';
import {
Row, Col, Card, Typography, Space, Table, Tag, Progress, Badge,
List, Avatar, Button, Statistic, Timeline, Empty, message,
Select
} from 'antd';
import {
LayoutGrid, PlayCircle, CheckCircle, AlertCircle,
TrendingUp, Bell, PieChart, Activity, Video,
Clock, Map as MapIcon, Box, Zap, AlertTriangle,
X
} from 'lucide-react';
import {
EnvironmentOutlined,
VideoCameraOutlined,
SyncOutlined,
FullscreenOutlined,
RobotOutlined,
RocketOutlined,
WarningOutlined
} from '@ant-design/icons';
import { UniversalLineChart, UniversalPieChart } from '../components/recharts';
import CesiumMap from '../components/Map';
import { useSelector } from 'react-redux';
import { RootState } from '../store';
import { useTranslation } from 'react-i18next';
import dayjs from 'dayjs';
import { getRobotTaskList, getSiteDevice, getDeviceTastPool, getSiteDeviceTaskHistory } from '../api/device';
import { getAlarmList, getAlarmStatistics } from '../api/alarmApi';
import { alarmTypeMap } from '@/constants.js';
import { useNavigate } from 'react-router-dom';
import DeviceController from '../components/devices/DeviceController';
import VideoPlayer from '../components/VideoPlayer';
import { log } from 'console';
const { Title, Text } = Typography;
// 浅色主题卡片组件
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' }) => (
<Card
title={
<Space>
{icon}
<span style={{ fontSize: 16, fontWeight: 600, color: '#262626' }}>{title}</span>
</Space>
}
extra={extra}
variant="borderless"
style={{
background: '#fff',
boxShadow: '0 2px 12px rgba(0,0,0,0.04)',
borderRadius: 12,
marginBottom: 8,
height: height || 'auto',
display: 'flex',
flexDirection: 'column'
}}
styles={{
header: { borderBottom: '1px solid #f0f0f0', padding: '12px 20px', minHeight: 48 },
body: { padding: 16, flex: 1, overflow: bodyOverflow }
}}
>
{children}
</Card>
);
const TaskMonitorPage: React.FC = () => {
const { t } = useTranslation();
const { stationId, currentStation } = useSelector((state: RootState) => state.station);
const navigate = useNavigate();
const { userInfo } = useSelector((state: RootState) => state.user);
const [loading, setLoading] = useState(false);
const [taskList, setTaskList] = useState([]);
const [alarmList, setAlarmList] = useState([]);
const [alarmStats, setAlarmStats] = useState<any>(null);
const [devices, setDevices] = useState([]);
const [taskListHis, setTaskHistoryLisy] = useState<any>([]);
const [realtimeMap, setRealtimeMap] = useState<any>({});
// 当前选中的车辆:列表高亮与地图信息浮窗共用此状态
const [selectedDeviceSerial, setSelectedDeviceSerial] = useState<string | null>(null);
const [focusLocation, setFocusLocation] = useState<any>(null);
const [messageApi, contextHolder] = message.useMessage();
const controllerRef = useRef<DeviceController | null>(null);
// 初始化实时数据控制器
useEffect(() => {
if (!userInfo || !stationId) return;
const controller = new DeviceController(userInfo, messageApi, stationId);
controller.initMapPush((rtMap: any) => setRealtimeMap(rtMap || {}));
controllerRef.current = controller;
return () => {
controller.closeMapPush();
};
}, [userInfo, stationId]);
// 获取基础数据
const fetchData = async () => {
if (!stationId) return;
setLoading(true);
try {
const [taskRes, alarmRes, alarmStatRes, deviceRes, taskHistoreList] = await Promise.all([
getRobotTaskList({ siteId: String(stationId), pageNum: 1, pageSize: 999 }),
getAlarmList({ siteId: stationId, pageNum: 1, pageSize: 9999 }),
getAlarmStatistics({ siteId: stationId }),
getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1, orgId: currentStation?.orgId }),
getSiteDeviceTaskHistory({
siteId: stationId,
orgId: currentStation?.orgId,
pageNum: 1,
pageSize: 99999999
})
]);
if (taskRes.code === 200) setTaskList(taskRes.data || []);
if (alarmRes.code === 200) setAlarmList(alarmRes.rows || []);
if (alarmStatRes.code === 200) setAlarmStats(alarmStatRes.data || null);
if (deviceRes.code === 200) setDevices(deviceRes.rows || []);
if (taskHistoreList.code == 200) setTaskHistoryLisy(taskHistoreList.rows || []);
} catch (err) {
console.error('Fetch monitoring data failed', err);
} finally {
setLoading(false);
}
};
useEffect(() => {
fetchData();
//const timer = setInterval(fetchData, 60000); // 每分钟刷新一次
//return () => clearInterval(timer);
}, [stationId]);
const mapDevices = useMemo(() => {
const base = [...devices];
const knownKeys = new Set();
base.forEach((d: any) => {
const k = d?.serialNumber ?? d?.device_sn ?? d?.id;
if (k != null && k !== '') knownKeys.add(String(k));
});
const extras = (Array.isArray(realtimeMap) ? realtimeMap : [])
.filter((rt: any) =>
Number.isFinite(Number(rt.lng)) &&
Number.isFinite(Number(rt.lat)) &&
!(Number(rt.lng) === 0 && Number(rt.lat) === 0) &&
!knownKeys.has(String(rt.id))
)
.map((rt: any) => ({
id: rt.id,
name: rt.name || rt.alias || `设备-${String(rt.id).slice(-4)}`,
serialNumber: rt.id,
deviceType: 'ROBOT',
type: 'ROBOT',
category: 'robot',
typeText: '机器人',
status: rt.status,
onlineStatus: rt.status,
longitude: rt.lng,
latitude: rt.lat,
heading: rt.yaw,
batteryLevel: rt.battery,
updateTime: rt.updateTime,
feStatus: rt.feStatus,
taskId: rt.t,
isRealtimeOnly: true,
// 同步写入 locationMessage / lastRunningStatus,确保 Map.jsx 设备渲染 useEffect 能读到实时坐标
locationMessage: { longitude: rt.lng, latitude: rt.lat, heading: rt.yaw, batteryLevel: rt.battery },
lastRunningStatus: { longitude: rt.lng, latitude: rt.lat, heading: rt.yaw, batteryLevel: rt.battery },
raw: { ...rt },
}));
const all = [...base, ...extras];
return all.filter((d: any) =>
(d?.lastRunningStatus?.latitude && d?.lastRunningStatus?.longitude) ||
(d?.locationMessage?.latitude && d?.locationMessage?.longitude) ||
(d?.longitude && d?.latitude)
);
}, [devices, realtimeMap]);
// 计算统计数据
const taskSummary = useMemo(() => {
const todayTasks = taskList.filter(t => dayjs(t.createTime).isSame(dayjs(), 'day'));
return {
pending: todayTasks.filter(t => t.taskStaus === 'NEW').length,
running: todayTasks.filter(t => t.taskStaus === 'EXECUTING').length,
completed: todayTasks.filter(t => ['FINISH', 'FINISHED'].includes(t.taskStaus)).length,
failed: todayTasks.filter(t => t.taskStaus === 'FAILED').length,
total: todayTasks.length
};
}, [taskList]);
const deviceStats = useMemo(() => {
const total = devices.length;
const online = devices.filter(d => d.onlineStatus === 1).length;
// feStatus: 1=作业中, 2=空闲
const working = devices.filter(d => String(d.feStatus) === '1').length;
const idle = devices.filter(d => String(d.feStatus) === '2').length;
const alarm = alarmList.length;
return { total, online, working, idle, alarm };
}, [devices, realtimeMap, alarmList]);
const selectedDevice: any = useMemo(
() => devices.find((device: any) => device.serialNumber === selectedDeviceSerial) || null,
[devices, selectedDeviceSerial]
);
const selectedRealtime: any = selectedDevice ? (realtimeMap[selectedDevice.serialNumber] || {}) : {};
const trendData = useMemo(() => {
const countMap: Record<string, number> = {};
(taskListHis ?? []).forEach((item: any) => {
const date = dayjs(item.createTime).format('YYYY-MM-DD');
if (item.taskStaus === 'FINISH') {
countMap[date] = (countMap[date] ?? 0) + 1;
} else {
countMap[date] ??= 0;
}
});
return Object.entries(countMap)
.map(([date, value]) => ({ date, value }))
.sort((a, b) => a.date.localeCompare(b.date));
}, [taskListHis]);
const pieData = useMemo(() => {
if (!alarmList?.length) return [];
const counter = {};
alarmList.forEach(a => {
const t = a.alarmType || 'OTHER_DEVICE_FAULT';
counter[t] = (counter[t] || 0) + 1;
});
const colorMap = { UAV_FAULT: '#ff4d4f', MOWER_FAULT: '#faad14', OTHER_DEVICE_FAULT: '#722ed1', SERVER_FAILURE: '#1890ff', SYSTEM_ERROR: '#8c8c8c' };
return Object.keys(counter).map(t => ({
name: alarmTypeMap[t] || t,
value: counter[t],
color: colorMap[t] || '#8c8c8c',
})).filter(d => d.value > 0);
}, [alarmList]);
const columnHeight = 'calc(100vh - 52px)';
return (
<div style={{
background: 'linear-gradient(135deg, #f3faff 0%, #eaf6ff 48%, #f5fbff 100%)',
minHeight: '100vh',
boxSizing: 'border-box',
color: '#183b5b'
}}>
{contextHolder}
<div style={{ padding: '0 0 16px' }}>
<Title level={4} style={{ margin: 0, color: '#17456d', letterSpacing: 1 }}>任务监控指挥中心</Title>
</div>
<Row gutter={12} style={{ height: columnHeight }}>
{/* 左侧面板 */}
<Col span={5} style={{ height: '100%', display: 'flex', flexDirection: 'column', minWidth: 0 }}>
<MonitorCard title="任务总览" icon={<LayoutGrid size={18} color="#1890ff" />} height="30%">
<Row gutter={8}>
{[
{ label: '待部署', value: taskSummary.pending, color: '#faad14', bg: '#fff7e6' },
{ label: '进行中', value: taskSummary.running, color: '#1890ff', bg: '#e6f7ff' },
{ label: '已完成', value: taskSummary.completed, color: '#52c41a', bg: '#f6ffed' },
{ label: '故障', value: taskSummary.failed, color: '#ff4d4f', bg: '#fff1f0' }
].map((item, index) => (
<Col span={6} key={index}>
<div style={{
background: item.bg,
padding: '8px 4px',
borderRadius: 8,
textAlign: 'center',
border: `1px solid ${item.color}22`
}}>
<div style={{ fontSize: 20, fontWeight: 700, color: item.color }}>{item.value}</div>
<div style={{ fontSize: 11, color: '#8c8c8c' }}>{item.label}</div>
</div>
</Col>
))}
</Row>
<div style={{ marginTop: 16 }}>
{taskList.slice(0, 2).map((task, idx) => (
<div key={idx} style={{ background: '#f8faff', padding: '10px 12px', borderRadius: 8, marginBottom: 8, border: '1px solid #e6f7ff' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', fontSize: 13, marginBottom: 4 }}>
<span style={{ fontWeight: 500, color: '#262626' }}>{task.planName}</span>
<span style={{ color: '#1890ff', fontWeight: 600 }}>{Math.floor(Math.random() * 40 + 60)}%</span>
</div>
<Progress percent={Math.floor(Math.random() * 40 + 60)} size="small" showInfo={false} strokeColor="#1890ff" />
<div style={{ fontSize: 11, color: '#8c8c8c', marginTop: 4 }}>
<Clock size={10} style={{ marginRight: 4 }} />
{dayjs(task.createTime).format('HH:mm:ss')} 下发
</div>
</div>
))}
</div>
</MonitorCard>
<MonitorCard title="任务完成趋势" icon={<TrendingUp size={18} color="#1890ff" />} height="22%">
{trendData.length > 0 ? (
<div style={{ display: 'flex', alignItems: 'center', width: '100%', justifyContent: 'center', gap: 12 }}>
<UniversalLineChart
data={trendData}
xKey="date"
height={140}
series={[{ key: 'value', name: '完成数', color: '#1890ff' }]}
/>
</div>) : (<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无任务数据" style={{ height: '100%', display: 'flex', alignItems: 'center', margin: 0, justifyContent: 'center', flexDirection: 'column' }} />)}
</MonitorCard>
<MonitorCard title="告警中心" icon={<Bell size={18} color="#ff4d4f" />} extra={<Space size={8}><Badge count={alarmList.filter(a => a.handleStatus === 1).length} overflowCount={99} /><Button type="link" size="small" onClick={() => navigate('/alerts/all')}>查看更多</Button></Space>} height="25%">
<List
size="small"
dataSource={alarmList.filter(a => a.handleStatus === 1).slice(0, 3)}
renderItem={(item: any) => (
<List.Item style={{ padding: '8px 0' }}>
<div style={{ display: 'flex', alignItems: 'flex-start', gap: 10, width: '100%' }}>
<AlertTriangle size={16} color={item.alarmLevel === 'ERROR' ? '#ff4d4f' : '#faad14'} style={{ marginTop: 2 }} />
<div style={{ flex: 1 }}>
<div style={{ fontSize: 13, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
<span style={{ fontWeight: 500, color: '#262626' }}>{item.alarmTitle}</span>
<Tag color={item.alarmLevel === 'ERROR' ? 'red' : 'orange'} size="small" style={{ margin: 0, borderRadius: 4 }}>
{item.alarmLevel === 'ERROR' ? '紧急' : '重要'}
</Tag>
</div>
<div style={{ fontSize: 11, color: '#8c8c8c', marginTop: 4 }}>
{item.deviceName} | {dayjs(item.alarmTime).format('HH:mm:ss')}
</div>
</div>
</div>
</List.Item>
)}
locale={{ emptyText: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无未处理告警" /> }}
/>
</MonitorCard>
<MonitorCard title="告警统计" icon={<PieChart size={18} color="#1890ff" />} height="30%" >
{pieData.length > 0 ? (
<div style={{ display: 'flex', alignItems: 'center', width: '100%', justifyContent: 'center', gap: 12 }}>
<UniversalPieChart
data={pieData}
width={140}
height={140}
innerRadius={30}
outerRadius={52}
/>
{/*<div style={{ flex: 1, paddingLeft: 4, minWidth: 0 }}>
{pieData.map((item, idx) => (
<div key={idx} style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', fontSize: 12, marginBottom: 6 }}>
<Space size={6}><Badge color={item.color} /><span style={{ color: '#595959' }}>{item.name}</span></Space>
<span style={{ fontWeight: 600, color: '#262626' }}>{item.value}</span>
</div>
))}
</div>*/}
</div>) : (<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无告警数据" style={{ height: '100%', display: 'flex', alignItems: 'center', margin: 0, justifyContent: 'center', flexDirection: 'column' }} />)}
</MonitorCard>
</Col>
{/* 中间面板 */}
<Col span={14} style={{ height: '100%', display: 'flex', flexDirection: 'column', minWidth: 0 }}>
{/* 顶部车辆统计栏 */}
<div style={{
background: '#fff',
boxShadow: '0 2px 12px rgba(0,0,0,0.04)',
borderRadius: 12,
padding: '16px 24px',
display: 'flex',
justifyContent: 'space-between',
marginBottom: 8
}}>
{[
{ label: '机器总数', value: deviceStats.total, online: deviceStats.online, offline: deviceStats.total - deviceStats.online, icon: <Box color="#1890ff" />, bg: '#e6f7ff' },
{ label: '在线总数', value: deviceStats.online, subLeft: { label: '空闲', value: deviceStats.idle, color: '#1890ff' }, subRight: { label: '工作中', value: deviceStats.working, color: '#52c41a' }, icon: <Activity color="#52c41a" />, bg: '#f6ffed' },
{ label: '告警车辆', value: deviceStats.alarm, online: deviceStats.alarm, offline: 0, icon: <AlertCircle color="#ff4d4f" />, bg: '#fff1f0' }
].map((item, index) => (
<div key={index} style={{ display: 'flex', alignItems: 'center', gap: 16 }}>
<div style={{ width: 48, height: 48, borderRadius: 12, background: item.bg, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
{item.icon}
</div>
<div>
<div style={{ fontSize: 13, color: '#8c8c8c' }}>{item.label}</div>
<div style={{ display: 'flex', alignItems: 'baseline', gap: 8 }}>
<span style={{ fontSize: 24, fontWeight: 700, color: '#262626' }}>{item.value}</span>
<span style={{ fontSize: 12, color: '#595959' }}>
{item.subLeft ? (
<>
{item.subLeft.label}: <span style={{ color: item.subLeft.color, fontWeight: 600 }}>{item.subLeft.value}</span> |
{item.subRight.label}: <span style={{ color: item.subRight.color, fontWeight: 600 }}>{item.subRight.value}</span>
</>
) : (
<>
在线: <span style={{ color: '#52c41a', fontWeight: 600 }}>{item.online}</span> |
离线: <span style={{ color: '#ff4d4f', fontWeight: 600 }}>{item.offline}</span>
</>
)}
</span>
</div>
</div>
</div>
))}
</div>
{/* 地图区域 */}
<div style={{
flex: 1,
background: '#fff',
borderRadius: 12,
boxShadow: '0 2px 12px rgba(0,0,0,0.04)',
position: 'relative',
overflow: 'hidden',
border: '1px solid #f0f0f0'
}}>
<CesiumMap from="taskMonitor" mapLayer={currentStation?.siteMapName} focusLocation={focusLocation}
devices={mapDevices}
/>
{/* 选中车辆的信息浮窗;不接管地图内部交互,只叠加展示详情 */}
{selectedDevice && (
<div className="vehicle-map-popup" role="dialog" aria-label="车辆详情">
<div className="vehicle-map-popup__header">
<div className="vehicle-map-popup__identity">
<Avatar size={38} shape="square" icon={selectedDevice.deviceType === 'UAV' ? <RocketOutlined /> : <RobotOutlined />} style={{ background: '#e6f7ff', color: '#0788ed', borderRadius: 10 }} />
<div><div className="vehicle-map-popup__title">{selectedDevice.deviceAlias || selectedDevice.deviceName || '车辆'}</div><div className="vehicle-map-popup__serial">{selectedDevice.serialNumber || '--'}</div></div>
</div>
<Button type="text" size="small" aria-label="关闭车辆详情" icon={<X size={18} />} onClick={() => setSelectedDeviceSerial(null)} />
</div>
<div className="vehicle-map-popup__body">
<div className="vehicle-map-popup__row"><span>当前状态</span><strong className={selectedRealtime.status === 'EXECUTING' ? 'is-running' : ''}>{selectedRealtime.status === 'EXECUTING' ? '执行中' : '待命'}</strong></div>
<div className="vehicle-map-popup__row"><span>剩余电量</span><strong className={(selectedRealtime.battery ?? 85) < 20 ? 'is-low-battery' : ''}>{selectedRealtime.battery ?? 85}%</strong></div>
<div className="vehicle-map-popup__row"><span>当前任务</span><strong>{selectedRealtime.currentTaskName || '常规巡检'}</strong></div>
<div className="vehicle-map-popup__row"><span>设备类型</span><strong>{selectedDevice.deviceTypeName || selectedDevice.deviceType || '车辆'}</strong></div>
<div className="vehicle-map-popup__row"><span>任务进度</span><strong>{selectedRealtime.taskProgress ?? 0}%</strong></div>
</div>
</div>
)}
{/* 地图上的图例 */}
<div style={{ position: 'absolute', bottom: 20, left: 20, display: 'flex', gap: 12, zIndex: 10 }}>
{[
{ label: '巡逻车辆', color: '#1890ff' },
{ label: '作业车辆', color: '#52c41a' },
{ label: '异常告警', color: '#ff4d4f' }
].map((item, index) => (
<div key={index} style={{ display: 'flex', alignItems: 'center', gap: 6, fontSize: 12, background: 'rgba(255,255,255,0.9)', padding: '4px 12px', borderRadius: 20, boxShadow: '0 2px 8px rgba(0,0,0,0.1)' }}>
<div style={{ width: 8, height: 8, background: item.color, borderRadius: '50%' }} />
<span style={{ color: '#595959' }}>{item.label}</span>
</div>
))}
</div>
</div>
</Col>
{/* 右侧面板 */}
<Col span={5} style={{ height: '100%', display: 'flex', flexDirection: 'column', minWidth: 0 }}>
<MonitorCard title="实时车辆状态" icon={<Activity size={18} color="#1890ff" />} height="35%">
<List
size="small"
dataSource={devices.filter(d => d.deviceType !== 'CAMERA')}
renderItem={(item: any) => {
const rt = realtimeMap[item.serialNumber] || {};
return (
<List.Item
className={`vehicle-status-item ${selectedDeviceSerial === item.serialNumber ? 'is-selected' : ''}`}
style={{ padding: '10px', borderRadius: 10, marginBottom: 6, cursor: 'pointer', transition: 'all 180ms ease' }}
onClick={() => {
setSelectedDeviceSerial(item.serialNumber);
const pos = item.lastRunningStatus || item.locationMessage || {};
const lon = Number(pos.longitude ?? pos.lng);
const lat = Number(pos.latitude ?? pos.lat);
if (Number.isFinite(lon) && Number.isFinite(lat)) {
setFocusLocation({ lon, lat, type: item.deviceType === 'UAV' ? 'drone' : 'robot', });
}
}}
aria-pressed={selectedDeviceSerial === item.serialNumber}
tabIndex={0}
onKeyDown={(event: any) => { if (event.key === 'Enter' || event.key === ' ') { setSelectedDeviceSerial(item.serialNumber); const pos = item.lastRunningStatus || item.locationMessage || {}; const lon = Number(pos.longitude ?? pos.lng); const lat = Number(pos.latitude ?? pos.lat); if (Number.isFinite(lon) && Number.isFinite(lat)) setFocusLocation({ lon, lat, type: item.deviceType === 'UAV' ? 'drone' : 'robot', height: 800 }); } }}
>
<div style={{ display: 'flex', gap: 12, width: '100%' }}>
<Avatar shape="square" size={44} icon={item.deviceType === 'UAV' ? <RocketOutlined /> : <RobotOutlined />} style={{ background: '#f0f7ff', color: '#1890ff' }} />
<div style={{ flex: 1 }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 4 }}>
<span style={{ fontWeight: 600, fontSize: 14, color: '#262626' }}>{item.deviceAlias || item.deviceName}</span>
<Tag color={rt.status === 'EXECUTING' ? 'green' : 'default'} style={{ margin: 0, borderRadius: 4 }}>
{rt.status === 'EXECUTING' ? '进行中' : '待命'}
</Tag>
</div>
<div
style={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
gap: 8,
fontSize: 12,
color: '#8c8c8c',
minWidth: 0,
}}
> <span>任务: {rt.currentTaskName || '常规巡检'}</span>
<span
style={{
color: rt.battery < 20 ? '#ff4d4f' : '#faad14',
display: 'inline-flex',
alignItems: 'center',
gap: 2,
whiteSpace: 'nowrap',
flexShrink: 0,
lineHeight: 1,
}}
>
<Zap size={10} style={{ flexShrink: 0 }} />
{rt.battery ?? 85}%
</span>
</div>
<Progress percent={rt.taskProgress || Math.floor(Math.random() * 100)} size="small" showInfo={false} strokeColor="#52c41a" style={{ marginTop: 6 }} />
</div>
</div>
</List.Item>
);
}}
/>
</MonitorCard>
<MonitorCard title="实时监控画面" icon={<Video size={18} color="#1890ff" />} extra={<Badge status="processing" text="实时" />} height="35%">
<div style={{
position: 'relative',
background: '#000',
borderRadius: 8,
overflow: 'hidden',
height: 'calc(100% - 40px)',
marginBottom: 8
}}>
<VideoPlayer
deviceId={devices.find(d => d.deviceType === 'ROBOT' || d.deviceType === 'CLEANING')?.serialNumber}
idx={1}
className="w-full h-full object-cover"
/>
</div>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 8 }}>
{['前视', '后视', '左视', '右视'].map((v, i) => (
<Button key={i} size="small" type={i === 0 ? 'primary' : 'default'} style={{ fontSize: 11, height: 28 }}>{v}</Button>
))}
</div>
</MonitorCard>
<MonitorCard title="任务记录" icon={<Clock size={18} color="#1890ff" />} height="30%">
{taskListHis.filter(t => ['FINISH', 'FINISHED'].includes(t.taskStaus)).length > 0 ? (<Timeline
mode="left"
pending={false}
style={{ marginTop: 8 }}
items={taskListHis.slice(0, 100).map((task, idx) => ({
color: '#52c41a',
children: (
<div>
<div style={{ display: 'flex', justifyContent: 'space-between', fontSize: 12, color: '#8c8c8c' }}>
<span style={{ color: '#1890ff', fontWeight: 500 }}>{task.deviceAlias || task.deviceId}</span>
<span>{task.createTime}</span>
</div>
<div style={{ fontSize: 13, marginTop: 2, color: '#262626' }}>{task.planName}</div>
<Tag color="green" size="small" style={{ fontSize: 10, marginTop: 4, borderRadius: 4 }}>{task.taskStausTranslate}</Tag>
</div>
)
}))}
/>
) : (<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无已完成任务" style={{ marginTop: 16 }} />)}
</MonitorCard>
</Col>
</Row>
<style>{`
.ant-card-head {
border-bottom: 1px solid #e5f2fc !important;
background: linear-gradient(90deg, rgba(230,247,255,.75), rgba(255,255,255,.45));
}
.vehicle-status-item {
border: 1px solid transparent !important;
background: rgba(246, 251, 255, .8);
}
.vehicle-status-item:hover {
background: #e6f7ff !important;
border-color: #91d5ff !important;
box-shadow: 0 4px 12px rgba(24, 144, 255, .12);
transform: translateY(-1px);
}
.vehicle-status-item.is-selected, .vehicle-status-item.is-selected:hover {
background: linear-gradient(100deg, #d6efff 0%, #f0faff 100%) !important;
border-color: #40a9ff !important;
box-shadow: inset 3px 0 0 #1890ff, 0 4px 14px rgba(24, 144, 255, .16);
}
.vehicle-map-popup {
position: absolute; top: 18%; right: 16px; z-index: 20; width: min(340px, calc(100% - 32px));
background: rgba(255,255,255,.97); border: 1px solid #b7e3ff; border-radius: 14px;
box-shadow: 0 12px 36px rgba(22, 119, 190, .2); overflow: hidden; backdrop-filter: blur(10px);
animation: vehiclePopupIn 180ms ease-out;
}
.vehicle-map-popup__header { display:flex; align-items:center; justify-content:space-between; gap:8px; padding: 12px 14px; border-bottom:1px solid #e6f4ff; background:linear-gradient(100deg,#f0f9ff,#fff); }
.vehicle-map-popup__identity { display:flex; align-items:center; gap:10px; min-width:0; }
.vehicle-map-popup__title { color:#087bd0; font-size:16px; font-weight:700; overflow-wrap:anywhere; }
.vehicle-map-popup__serial { color:#8a9daf; font-size:11px; margin-top:2px; }
.vehicle-map-popup__body { padding: 8px 14px 12px; }
.vehicle-map-popup__row { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; padding:8px 0; border-bottom:1px dashed #e6f4ff; font-size:13px; }
.vehicle-map-popup__row:last-child { border-bottom:0; }
.vehicle-map-popup__row span { color:#647d91; flex-shrink:0; }
.vehicle-map-popup__row strong { color:#20384d; text-align:right; overflow-wrap:anywhere; }
.vehicle-map-popup__row strong.is-running { color:#18a058; }
.vehicle-map-popup__row strong.is-low-battery { color:#f5222d; }
@keyframes vehiclePopupIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
@media (max-width: 1200px) { .vehicle-map-popup { top: 12px; right: 12px; width: min(300px, calc(100% - 24px)); } }
.ant-timeline-item-tail {
border-inline-start: 2px solid #f0f0f0 !important;
}
.ant-list-item {
border-block-end: 1px solid #f5f5f5 !important;
}
.ant-progress-inner {
background-color: #f5f5f5 !important;
}
.ant-statistic-title {
color: #8c8c8c !important;
font-size: 13px !important;
}
.ant-statistic-content {
font-weight: 700 !important;
}
`}</style>
</div>
);
};
export default TaskMonitorPage;

View File

@@ -1,4 +1,4 @@
import React, { lazy, Suspense } from 'react';
import React, { lazy, Suspense } from 'react';
import type { RouteObject } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
@@ -32,6 +32,7 @@ const WayLineTask = lazy(() => import('../components/devices/WayLinePage'));
const RobotTask = lazy(() => import('../components/devices/RobotTaskPage'));
const MapEditorPage = lazy(() => import('../components/devices/MapEditorPage'));
const DevicesOverview = lazy(() => import('../components/devices/DeviceOverviewPage'));
const TaskMonitorPage = lazy(() => import('../pages/TaskMonitorPage'));
const BasicSettings = lazy(() => import('../components/SystemSetting/BasicSettings'));
const UserRolePage = lazy(() => import('../components/SystemSetting/UserPage'));
@@ -113,6 +114,10 @@ export const routes: RouteObject[] = [
path: 'devices/overview',
element: withSuspense(DevicesOverview)
},
{
path: 'devices/taskMonitor',
element: withSuspense(TaskMonitorPage)
},
{
path: 'devices/status',
element: withSuspense(DeviceStatus)