2026-05-28 15:17:00 +08:00
|
|
|
|
import React, { useState, useEffect, useRef, useMemo } from 'react';
|
2026-05-11 10:47:51 +08:00
|
|
|
|
import {
|
|
|
|
|
|
Layout, Card, Row, Col, Statistic, Tag, Button, Table,
|
|
|
|
|
|
Typography, Space, Progress, Badge, Timeline, message,
|
2026-06-12 17:34:35 +08:00
|
|
|
|
Select, Modal, Space as AntSpace,
|
2026-08-06 10:47:34 +08:00
|
|
|
|
Input, Tooltip
|
2026-05-11 10:47:51 +08:00
|
|
|
|
} from 'antd';
|
|
|
|
|
|
import {
|
|
|
|
|
|
EnvironmentOutlined, RobotOutlined, BranchesOutlined,
|
|
|
|
|
|
ThunderboltOutlined, CheckCircleOutlined, PauseOutlined,
|
|
|
|
|
|
RocketOutlined, SyncOutlined, WarningOutlined,
|
|
|
|
|
|
CloudOutlined, ClockCircleOutlined, ReloadOutlined,
|
|
|
|
|
|
AimOutlined, ApiOutlined, SettingOutlined,
|
|
|
|
|
|
PlusOutlined, ArrowRightOutlined,
|
2026-05-18 17:25:41 +08:00
|
|
|
|
EditOutlined, FullscreenOutlined, InfoCircleOutlined,
|
|
|
|
|
|
CarOutlined
|
2026-05-11 10:47:51 +08:00
|
|
|
|
} from '@ant-design/icons';
|
2026-08-04 16:11:27 +08:00
|
|
|
|
import { useNavigate } from 'react-router-dom';
|
|
|
|
|
|
|
|
|
|
|
|
// 组件内
|
2026-05-11 10:47:51 +08:00
|
|
|
|
|
2026-05-26 15:49:22 +08:00
|
|
|
|
|
2026-07-07 16:06:40 +08:00
|
|
|
|
|
2026-05-11 14:59:36 +08:00
|
|
|
|
import DroneLivePlayer from '../VolcRtcPlayer.jsx';
|
2026-05-25 10:30:20 +08:00
|
|
|
|
import DroneVideoPlayer from './DroneVideoPlayer';
|
2026-05-12 11:11:30 +08:00
|
|
|
|
import AgoraTextTest from '../AgoraRtc.tsx';
|
2026-05-22 13:50:50 +08:00
|
|
|
|
import { useWebRTCPlayer } from '../useWebRTCStream.tsx';
|
2026-06-15 13:57:41 +08:00
|
|
|
|
import VideoPlayer from '../VideoPlayer.tsx';
|
2026-05-22 14:14:30 +08:00
|
|
|
|
import CesiumMap from '../Map.jsx';
|
2026-08-06 10:47:34 +08:00
|
|
|
|
import DeviceParamModal from './DeviceParamModal';
|
|
|
|
|
|
import { getUAVState, getSiteDevice, getSiteUAVList, getsinglePlan, getRobotTaskList, getDeviceTotalData, updateDeviceAliasApi, hasPermission } from '@/api/device.ts';
|
2026-06-02 13:50:00 +08:00
|
|
|
|
import dayjs from 'dayjs';
|
2026-06-01 17:14:55 +08:00
|
|
|
|
import { useMqtt } from '@/hooks/useMqtt';
|
2026-06-02 09:03:04 +08:00
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
|
import { RootState } from '@/store';
|
2026-06-02 13:50:00 +08:00
|
|
|
|
import envConfig from '../../../env';
|
2026-06-12 17:34:35 +08:00
|
|
|
|
import utils from '@/lib/utils.ts';
|
2026-08-12 11:29:44 +08:00
|
|
|
|
import { useTranslation } from 'react-i18next';
|
2026-05-11 10:47:51 +08:00
|
|
|
|
|
|
|
|
|
|
const { Content } = Layout;
|
|
|
|
|
|
const { Text, Title } = Typography;
|
|
|
|
|
|
|
|
|
|
|
|
const taskTimeline = [
|
|
|
|
|
|
{ time: '10:24:18', color: 'blue', text: 'UAV-C01 开始执行清洗航线 C-05', status: '任务开始' },
|
|
|
|
|
|
{ time: '10:21:35', color: 'orange', text: 'RBT-01 开始执行巡检航线 P-02', status: '任务开始' },
|
|
|
|
|
|
{ time: '10:18:02', color: 'green', text: 'GR-02 开始除草作业 G-01', status: '任务开始' },
|
|
|
|
|
|
{ time: '10:15:47', color: 'gray', text: 'UAV-C02 任务待命就绪', status: '待命就绪' },
|
|
|
|
|
|
{ time: '10:12:33', color: 'blue', text: 'UAV-C01 再次返机补水', status: '返机补给' },
|
|
|
|
|
|
{ time: '09:58:10', color: 'green', text: 'RBT-02 完成巡检航线 P-01', status: '任务完成' },
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-08-03 16:40:27 +08:00
|
|
|
|
export default function DeviceOverviewPage() {
|
2026-08-12 11:29:44 +08:00
|
|
|
|
const { t } = useTranslation();
|
2026-06-02 09:03:04 +08:00
|
|
|
|
const { userInfo } = useSelector((state: RootState) => state.user);
|
2026-08-04 16:33:52 +08:00
|
|
|
|
const { stationId, currentStation } = useSelector((state: RootState) => state.station);
|
2026-06-02 09:03:04 +08:00
|
|
|
|
|
2026-05-22 15:53:15 +08:00
|
|
|
|
const [zoomedVideo, setZoomedVideo] = useState(null);
|
|
|
|
|
|
const [mowerView, setMowerView] = useState('front');
|
2026-06-01 17:14:55 +08:00
|
|
|
|
const [videoSource, setVideoSource] = useState('drone');
|
2026-05-27 15:08:26 +08:00
|
|
|
|
const [uavState, setUavState] = useState(null);
|
2026-06-01 17:14:55 +08:00
|
|
|
|
const [persistentDroneData, setPersistentDroneData] = useState(null);
|
|
|
|
|
|
const [persistentHostData, setPersistentHostData] = useState(null);
|
2026-06-02 09:03:04 +08:00
|
|
|
|
const [devices, setDevices] = useState([]);
|
|
|
|
|
|
const [planedevices, setPlaneDevices] = useState([]);
|
|
|
|
|
|
const [devicesAll, setDevicesAll] = useState([]);
|
2026-06-02 13:50:00 +08:00
|
|
|
|
const [taskStats, setTaskStats] = useState({ completed: 12, total: 15 });
|
2026-06-03 14:16:31 +08:00
|
|
|
|
const [deviceStatistics, setDeviceStatistics] = useState(null);
|
2026-08-03 16:40:27 +08:00
|
|
|
|
const [currentSelectedRobot, setCurrentSelectedRobot] = useState(null);
|
2026-06-02 09:03:04 +08:00
|
|
|
|
|
2026-06-12 17:34:35 +08:00
|
|
|
|
// 编辑机器人弹窗相关
|
|
|
|
|
|
const [editRobotModalOpen, setEditRobotModalOpen] = useState(false);
|
|
|
|
|
|
const [currentEditRobot, setCurrentEditRobot] = useState(null);
|
|
|
|
|
|
const [editAliasInput, setEditAliasInput] = useState('');
|
|
|
|
|
|
const [editLoading, setEditLoading] = useState(false);
|
2026-08-06 10:47:34 +08:00
|
|
|
|
|
|
|
|
|
|
// 设备参数弹窗相关
|
|
|
|
|
|
const [paramModalOpen, setParamModalOpen] = useState(false);
|
|
|
|
|
|
const [currentParamDevice, setCurrentParamDevice] = useState<any>(null);
|
|
|
|
|
|
|
2026-08-04 16:11:27 +08:00
|
|
|
|
const navigate = useNavigate();
|
2026-08-06 13:39:14 +08:00
|
|
|
|
const [robotPlayActive, setRobotPlayActive] = useState<boolean>(false);
|
2026-08-04 16:11:27 +08:00
|
|
|
|
|
2026-08-12 11:29:44 +08:00
|
|
|
|
const logs = [
|
|
|
|
|
|
{ time: '10:24:35', device: 'UAV-C01', type: '命令', desc: '起飞指令下发,开始作业' },
|
|
|
|
|
|
{ time: '10:21:40', device: 'RBT-01', type: '命令', desc: '开始巡检任务 P-02' },
|
|
|
|
|
|
{ time: '10:20:11', device: 'UAV-C02', type: '命令', desc: '转入待命状态' },
|
|
|
|
|
|
{ time: '10:18:05', device: 'GR-02', type: '命令', desc: '除草作业开始 G-01' },
|
|
|
|
|
|
{ time: '10:12:35', device: 'UAV-C01', type: t('constants.sourceAlert'), desc: '返航补水' },
|
|
|
|
|
|
{ time: '10:05:22', device: 'RBT-01', type: '事件', desc: '电量较低,建议回充', level: '低电量' },
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-06-12 17:34:35 +08:00
|
|
|
|
|
2026-06-02 09:03:04 +08:00
|
|
|
|
// 获取数据
|
|
|
|
|
|
const fetchAllData = async () => {
|
|
|
|
|
|
if (!stationId) return;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 1. 同时发请求
|
|
|
|
|
|
const [deviceRes, planeRes] = await Promise.all([
|
2026-08-04 16:33:52 +08:00
|
|
|
|
getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1, orgId: currentStation?.orgId }),
|
2026-06-02 09:03:04 +08:00
|
|
|
|
getSiteUAVList(stationId),
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 处理普通设备
|
|
|
|
|
|
const devData = deviceRes?.code === 200 ? (deviceRes.rows || []) : [];
|
|
|
|
|
|
|
|
|
|
|
|
// 3. 处理无人机 + 自动补全地图需要的字段(关键改动)
|
|
|
|
|
|
let planeData = planeRes?.code === 200 ? (planeRes?.rows || []) : [];
|
|
|
|
|
|
|
|
|
|
|
|
planeData = planeData.map(item => ({
|
|
|
|
|
|
...item,
|
|
|
|
|
|
type: 'plane',
|
|
|
|
|
|
lastRunningStatus: {
|
|
|
|
|
|
longitude: item.longitude || 0,
|
|
|
|
|
|
latitude: item.latitude || 0,
|
|
|
|
|
|
},
|
|
|
|
|
|
deviceAlias: item.drone_callsign || item.device_sn
|
2026-08-12 11:29:44 +08:00
|
|
|
|
|| t('constants.uav'),
|
2026-06-02 09:03:04 +08:00
|
|
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
setDevices(devData);
|
|
|
|
|
|
setPlaneDevices(planeData);
|
|
|
|
|
|
|
|
|
|
|
|
// 合并所有设备
|
|
|
|
|
|
const all = [...devData, ...planeData];
|
|
|
|
|
|
setDevicesAll(all);
|
|
|
|
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
console.error('数据请求失败', err);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2026-08-04 16:11:27 +08:00
|
|
|
|
const onViewStatus = (sn) => {
|
|
|
|
|
|
navigate(`/devices/status?sn=${sn}`);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2026-06-03 14:16:31 +08:00
|
|
|
|
|
2026-06-02 09:03:04 +08:00
|
|
|
|
|
2026-06-12 17:34:35 +08:00
|
|
|
|
// 打开编辑弹窗
|
|
|
|
|
|
const openEditRobotModal = (record) => {
|
|
|
|
|
|
// 仅机器人允许编辑,无人机直接提示
|
|
|
|
|
|
const isRobot = !record.gateway_sn && !record.drone_callsign;
|
|
|
|
|
|
if (!isRobot) {
|
|
|
|
|
|
message.info('仅支持编辑机器人设备别名');
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
setCurrentEditRobot(record);
|
|
|
|
|
|
setEditAliasInput(record.deviceAlias || record.deviceName || '');
|
|
|
|
|
|
setEditRobotModalOpen(true);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 确认保存别名
|
|
|
|
|
|
const handleSaveRobotAlias = async () => {
|
|
|
|
|
|
if (!currentEditRobot || !editAliasInput.trim()) {
|
|
|
|
|
|
utils.message.warning('设备别名不能为空');
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
setEditLoading(true);
|
|
|
|
|
|
try {
|
|
|
|
|
|
const data = {
|
|
|
|
|
|
deviceId: currentEditRobot.serialNumber,
|
|
|
|
|
|
deviceAlias: editAliasInput.trim()
|
|
|
|
|
|
}
|
|
|
|
|
|
const sn = currentEditRobot.device_sn || currentEditRobot.serialNumber;
|
|
|
|
|
|
const res = await updateDeviceAliasApi(data);
|
|
|
|
|
|
if (res.code === 200 && res.data == true) {
|
|
|
|
|
|
fetchAllData();
|
|
|
|
|
|
utils.message.success('别名修改成功');
|
|
|
|
|
|
|
|
|
|
|
|
setEditRobotModalOpen(false);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
utils.message.error('修改失败,请重试');
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
console.error('修改别名报错', err);
|
|
|
|
|
|
utils.message.error('接口异常,修改失败');
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
setEditLoading(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-06-02 09:03:04 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
fetchAllData();
|
2026-06-02 15:42:58 +08:00
|
|
|
|
}, [stationId]);
|
2026-06-02 13:50:00 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
fetchTaskStats();
|
|
|
|
|
|
}, [devicesAll.length]);
|
|
|
|
|
|
|
|
|
|
|
|
// 获取今日任务统计
|
|
|
|
|
|
const fetchTaskStats = async () => {
|
|
|
|
|
|
if (!stationId) return;
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
const todayStart = dayjs().startOf('day').unix();
|
|
|
|
|
|
const todayEnd = dayjs().endOf('day').unix();
|
|
|
|
|
|
|
|
|
|
|
|
let completedCount = 0;
|
|
|
|
|
|
let totalCount = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// 1. 获取无人机今日任务
|
|
|
|
|
|
if (planedevices?.length > 0) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const sns = planedevices.map(item => item.gateway_sn);
|
|
|
|
|
|
const droneRes = await getsinglePlan({ sns, beginAt: todayStart, endAt: todayEnd });
|
|
|
|
|
|
if (droneRes?.code === 200 && droneRes.data) {
|
|
|
|
|
|
let droneTasks = [];
|
|
|
|
|
|
Object.values(droneRes.data).forEach((item: any) => {
|
|
|
|
|
|
if (item.list) droneTasks = droneTasks.concat(item.list);
|
|
|
|
|
|
});
|
|
|
|
|
|
totalCount += droneTasks.length;
|
|
|
|
|
|
// 计算无人机完成的任务
|
|
|
|
|
|
completedCount += droneTasks.filter(t =>
|
|
|
|
|
|
['success', 'completed', 'executed', 'FINISH', 'COMPLETED'].includes(t.status)
|
|
|
|
|
|
).length;
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
console.error('获取无人机任务统计失败', err);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 获取机器人今日任务
|
|
|
|
|
|
try {
|
|
|
|
|
|
const robotRes = await getRobotTaskList({ siteId: String(stationId) });
|
|
|
|
|
|
if (robotRes?.code == 200 && robotRes.data) {
|
|
|
|
|
|
const todayRobotTasks = robotRes.data.filter((t: any) => {
|
|
|
|
|
|
// 简单判断是今日的任务
|
|
|
|
|
|
if (t.createTime) {
|
|
|
|
|
|
const taskTime = dayjs(t.createTime);
|
|
|
|
|
|
return taskTime.isAfter(dayjs().startOf('day')) && taskTime.isBefore(dayjs().endOf('day'));
|
|
|
|
|
|
}
|
|
|
|
|
|
return true; // 默认都算
|
|
|
|
|
|
});
|
|
|
|
|
|
totalCount += todayRobotTasks.length;
|
|
|
|
|
|
// 计算机器人完成的任务
|
|
|
|
|
|
completedCount += todayRobotTasks.filter((t: any) =>
|
|
|
|
|
|
['FINISH', 'FINISHED', 'COMPLETED', 'completed'].includes(t.taskStaus)
|
|
|
|
|
|
).length;
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
console.error('获取机器人任务统计失败', err);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setTaskStats({ completed: completedCount, total: totalCount });
|
|
|
|
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
console.error('获取任务统计失败', err);
|
|
|
|
|
|
setTaskStats({ completed: 12, total: 15 });
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2026-06-01 15:44:02 +08:00
|
|
|
|
|
2026-06-01 17:14:55 +08:00
|
|
|
|
// 当前选中设备(切换时才变)
|
|
|
|
|
|
const selectedDevice = useMemo(() => {
|
2026-08-03 16:40:27 +08:00
|
|
|
|
const sn = currentSelectedRobot || (devicesAll?.[0]?.device_sn || devicesAll?.[0]?.serialNumber);
|
2026-05-12 08:34:13 +08:00
|
|
|
|
return devicesAll?.find(item => (item.device_sn || item.serialNumber) === sn) || null;
|
2026-08-03 16:40:27 +08:00
|
|
|
|
}, [devicesAll, currentSelectedRobot]);
|
2026-05-12 08:34:13 +08:00
|
|
|
|
|
2026-05-22 15:53:15 +08:00
|
|
|
|
const isUAV = !!selectedDevice?.gateway_sn;
|
2026-06-03 14:16:31 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (isUAV || !selectedDevice?.serialNumber) return;
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
deviceId: selectedDevice?.serialNumber,
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
getDeviceTotalData(params).then((res) => {
|
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
|
setDeviceStatistics(res.data || {})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}, [selectedDevice])
|
2026-05-22 15:53:15 +08:00
|
|
|
|
|
2026-06-01 17:14:55 +08:00
|
|
|
|
// ======================== 核心优化:视频用设备对象(绝不随MQTT刷新)========================
|
|
|
|
|
|
const videoDevice = useMemo(() => {
|
|
|
|
|
|
if (!selectedDevice) return null;
|
|
|
|
|
|
return { ...selectedDevice };
|
|
|
|
|
|
}, [selectedDevice]); // 只有切设备才变 → 视频不闪
|
|
|
|
|
|
|
|
|
|
|
|
// ======================== UI显示用(MQTT实时更新)========================
|
|
|
|
|
|
const realtimeDevice = useMemo(() => {
|
|
|
|
|
|
if (!selectedDevice) return null;
|
|
|
|
|
|
return {
|
|
|
|
|
|
...selectedDevice,
|
|
|
|
|
|
...uavState,
|
|
|
|
|
|
...persistentHostData,
|
|
|
|
|
|
...persistentDroneData,
|
|
|
|
|
|
};
|
|
|
|
|
|
}, [selectedDevice, uavState, persistentHostData, persistentDroneData?.wind_speed]);
|
|
|
|
|
|
|
|
|
|
|
|
// MQTT消息处理
|
|
|
|
|
|
const handleMqttMessage = (topic, message) => {
|
2026-06-02 10:08:23 +08:00
|
|
|
|
|
2026-06-01 17:14:55 +08:00
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
const parsed = JSON.parse(message);
|
|
|
|
|
|
if (parsed.data?.host) {
|
|
|
|
|
|
const { host } = parsed.data;
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是无人机数据还是机场数据:无人机数据有 battery 字段
|
|
|
|
|
|
const isDroneData = host.battery !== undefined;
|
|
|
|
|
|
|
|
|
|
|
|
if (isDroneData) {
|
|
|
|
|
|
// 处理无人机数据
|
|
|
|
|
|
setPersistentDroneData(prevData => {
|
|
|
|
|
|
const newData = { ...prevData };
|
|
|
|
|
|
|
|
|
|
|
|
// 无人机特有字段
|
|
|
|
|
|
if (host.battery?.capacity_percent !== undefined) {
|
|
|
|
|
|
newData.capacity_percent = host.battery.capacity_percent;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.attitude_head !== undefined) {
|
|
|
|
|
|
newData.heading = host.attitude_head;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.horizontal_speed !== undefined) {
|
|
|
|
|
|
newData.horizontal_speed = host.horizontal_speed;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.vertical_speed !== undefined) {
|
|
|
|
|
|
newData.vertical_speed = host.vertical_speed;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.total_flight_time !== undefined) {
|
|
|
|
|
|
newData.total_flight_time = host.total_flight_time;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.total_flight_sorties !== undefined) {
|
|
|
|
|
|
newData.total_flight_sorties = host.total_flight_sorties;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.mode_code !== undefined) {
|
|
|
|
|
|
newData.mode_code = host.mode_code;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 通用字段
|
|
|
|
|
|
if (host.height !== undefined) {
|
|
|
|
|
|
newData.height = host.height;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.wind_speed !== undefined) {
|
|
|
|
|
|
newData.wind_speed = host.wind_speed;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.position_state !== undefined) {
|
|
|
|
|
|
newData.position_state = host.position_state;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.longitude !== undefined) {
|
|
|
|
|
|
newData.longitude = host.longitude;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.latitude !== undefined) {
|
|
|
|
|
|
newData.latitude = host.latitude;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return newData;
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 处理机场数据
|
|
|
|
|
|
setPersistentHostData(prevData => {
|
|
|
|
|
|
const newData = { ...prevData };
|
|
|
|
|
|
|
|
|
|
|
|
// 机场特有字段
|
|
|
|
|
|
if (host.drone_charge_state?.capacity_percent !== undefined) {
|
|
|
|
|
|
newData.capacity_percent = host.drone_charge_state.capacity_percent;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.air_conditioner?.air_conditioner_state !== undefined) {
|
|
|
|
|
|
newData.air_conditioner_state = host.air_conditioner.air_conditioner_state;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.air_conditioner_state !== undefined) {
|
|
|
|
|
|
newData.air_conditioner_state = host.air_conditioner_state;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 通用字段
|
|
|
|
|
|
if (host.environment_temperature !== undefined) {
|
|
|
|
|
|
newData.environment_temperature = host.environment_temperature;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.wind_speed !== undefined) {
|
|
|
|
|
|
newData.wind_speed = host.wind_speed;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.rainfall !== undefined) {
|
|
|
|
|
|
newData.rainfall = host.rainfall === 0 ? 'no_rain' : 'rain';
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.humidity !== undefined) {
|
|
|
|
|
|
newData.humidity = host.humidity;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.drone_in_dock !== undefined) {
|
|
|
|
|
|
newData.drone_in_dock = host.drone_in_dock;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.cover_state !== undefined) {
|
|
|
|
|
|
newData.cover_state = host.cover_state;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.temperature !== undefined) {
|
|
|
|
|
|
newData.temperature = host.temperature;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (host.home_distance !== undefined) {
|
|
|
|
|
|
newData.home_distance = host.home_distance;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return newData;
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
console.error('MQTT解析失败', err);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// MQTT订阅
|
|
|
|
|
|
const mqttTopics = useMemo(() => {
|
|
|
|
|
|
if (!isUAV || !selectedDevice) return [];
|
|
|
|
|
|
const topics = [];
|
|
|
|
|
|
if (selectedDevice.device_sn) {
|
|
|
|
|
|
topics.push(`thing/product/${selectedDevice.device_sn}/osd`);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (selectedDevice.gateway_sn && selectedDevice.gateway_sn !== selectedDevice.device_sn) {
|
|
|
|
|
|
topics.push(`thing/product/${selectedDevice.gateway_sn}/osd`);
|
|
|
|
|
|
}
|
|
|
|
|
|
return topics;
|
|
|
|
|
|
}, [selectedDevice]);
|
|
|
|
|
|
|
|
|
|
|
|
useMqtt({
|
|
|
|
|
|
url: envConfig.mqtt_url,
|
|
|
|
|
|
topic: mqttTopics,
|
|
|
|
|
|
onMessage: handleMqttMessage,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 机器人视频
|
2026-08-06 13:39:14 +08:00
|
|
|
|
// 机器人视频:只有 robotPlayActive = true 才真正拉流
|
2026-05-22 15:53:15 +08:00
|
|
|
|
const { video: robotVideo, error, ready } = useWebRTCPlayer(
|
2026-08-06 13:39:14 +08:00
|
|
|
|
(!isUAV && robotPlayActive) ? (selectedDevice?.serialNumber || '') : '',
|
|
|
|
|
|
(!isUAV && robotPlayActive)
|
|
|
|
|
|
? `webrtc://1.95.137.212/live/livestream/${selectedDevice?.serialNumber}`
|
|
|
|
|
|
: ''
|
2026-05-22 15:53:15 +08:00
|
|
|
|
);
|
|
|
|
|
|
|
2026-08-06 10:47:34 +08:00
|
|
|
|
const getDevivePermisstion = (data) => {
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
deviceId: data.serialNumber,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
hasPermission(params).then(res => {
|
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
|
if (res.data) {
|
|
|
|
|
|
setCurrentParamDevice(data);
|
|
|
|
|
|
setParamModalOpen(true);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
utils.message.error('无权限');
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-01 17:14:55 +08:00
|
|
|
|
// 顶部统计卡片
|
2026-06-03 11:06:44 +08:00
|
|
|
|
|
|
|
|
|
|
//feStatus; 1任务中 / 2空闲
|
2026-06-01 17:14:55 +08:00
|
|
|
|
const dynamicTopCards = useMemo(() => {
|
2026-05-11 14:59:36 +08:00
|
|
|
|
const totalDrones = planedevices?.length || 0;
|
|
|
|
|
|
const onlineDrones = planedevices?.filter(d => d.onlineStatus === 1).length || 0;
|
2026-07-06 14:09:05 +08:00
|
|
|
|
const totalRobots = 1;
|
2026-08-12 11:29:44 +08:00
|
|
|
|
//const totalRobots = devicesAll?.filter(d => d.productName?.includes(t('constants.inspection'))).length || 0;
|
2026-06-03 11:06:44 +08:00
|
|
|
|
|
|
|
|
|
|
//key 0 有任务 1 无任务
|
|
|
|
|
|
const activeRobots = 0;
|
2026-07-06 14:09:05 +08:00
|
|
|
|
const totalMowers = 1;
|
2026-08-12 11:29:44 +08:00
|
|
|
|
//const totalMowers = devicesAll?.filter(d => d.productName?.includes(t('constants.mower'))).length || 0;
|
2026-06-03 11:06:44 +08:00
|
|
|
|
const activeMowers = devices?.filter(d => d.feStatus == 1).length || 0; // 作业中状态数量
|
|
|
|
|
|
const washDroneStandby = planedevices?.[0]?.modeStatistics?.["0"] || 0;
|
|
|
|
|
|
//key 设备状态:{"0":"空闲中","1":"现场调试","2":"远程调试","3":"固件升级中","4":"作业中"}
|
2026-06-02 13:50:00 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 今日任务执行统计
|
|
|
|
|
|
const completedTasks = taskStats.completed;
|
|
|
|
|
|
const totalTasks = taskStats.total;
|
|
|
|
|
|
const completionRate = totalTasks > 0 ? Math.round((completedTasks / totalTasks) * 100) : 0;
|
|
|
|
|
|
|
2026-05-11 14:59:36 +08:00
|
|
|
|
return [
|
2026-06-02 14:15:16 +08:00
|
|
|
|
{
|
|
|
|
|
|
title: '无人机机场状态',
|
|
|
|
|
|
icon: <EnvironmentOutlined style={{ color: '#165DFF', fontSize: 24 }} />,
|
|
|
|
|
|
value: `${onlineDrones} / ${totalDrones}`,
|
|
|
|
|
|
sub: `可调度 ${onlineDrones} 架`,
|
|
|
|
|
|
color: '#165DFF',
|
|
|
|
|
|
iconBg: '#E8F3FF'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2026-08-12 11:29:44 +08:00
|
|
|
|
title: t('home.inspectionRobot'),
|
2026-06-02 14:15:16 +08:00
|
|
|
|
icon: <RobotOutlined style={{ color: '#13c2c2', fontSize: 24 }} />,
|
|
|
|
|
|
value: `${totalRobots} 台`,
|
|
|
|
|
|
sub: `执行中 ${activeRobots}`,
|
|
|
|
|
|
color: '#13c2c2',
|
|
|
|
|
|
iconBg: '#E6FFFA'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '除草机器人',
|
|
|
|
|
|
icon: <CarOutlined style={{ color: '#722ED1', fontSize: 24 }} />,
|
|
|
|
|
|
value: `${totalMowers} 台`,
|
2026-06-03 11:06:44 +08:00
|
|
|
|
sub: `任务中 ${activeMowers}`,
|
2026-06-02 14:15:16 +08:00
|
|
|
|
color: '#722ED1',
|
|
|
|
|
|
iconBg: '#F9F0FF'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '清洗无人机',
|
|
|
|
|
|
icon: <CloudOutlined style={{ color: '#eb2f96', fontSize: 24 }} />,
|
|
|
|
|
|
value: `${totalDrones} 架`,
|
|
|
|
|
|
sub: `待命 ${washDroneStandby}`,
|
|
|
|
|
|
color: '#eb2f96',
|
|
|
|
|
|
iconBg: '#FFF1F3'
|
|
|
|
|
|
},
|
|
|
|
|
|
//{
|
|
|
|
|
|
// title: '设备平均电量',
|
|
|
|
|
|
// icon: <ThunderboltOutlined style={{ color: '#52c41a', fontSize: 24 }} />,
|
|
|
|
|
|
// value: `${finalAvgBattery}%`,
|
|
|
|
|
|
// sub: '',
|
|
|
|
|
|
// color: '#52c41a',
|
|
|
|
|
|
// iconBg: '#E8FFEA'
|
|
|
|
|
|
//},
|
|
|
|
|
|
{
|
|
|
|
|
|
title: '今日任务执行',
|
|
|
|
|
|
icon: <CheckCircleOutlined style={{ color: '#2f54eb', fontSize: 24 }} />,
|
|
|
|
|
|
value: `${completedTasks} / ${totalTasks}`,
|
|
|
|
|
|
sub: `完成率 ${completionRate}%`,
|
|
|
|
|
|
color: '#2f54eb',
|
|
|
|
|
|
iconBg: '#E8F3FF'
|
|
|
|
|
|
},
|
2026-05-11 14:59:36 +08:00
|
|
|
|
];
|
2026-06-02 13:50:00 +08:00
|
|
|
|
}, [devicesAll, planedevices, persistentDroneData, uavState, taskStats]);
|
2026-05-11 14:59:36 +08:00
|
|
|
|
|
2026-06-01 17:14:55 +08:00
|
|
|
|
// 设备调度列表
|
|
|
|
|
|
const dynamicScheduleList = useMemo(() => {
|
|
|
|
|
|
return devicesAll?.map((d, index) => ({
|
2026-06-03 11:06:44 +08:00
|
|
|
|
...d,
|
2026-05-11 14:59:36 +08:00
|
|
|
|
id: d.deviceId || index,
|
|
|
|
|
|
name: d.deviceAlias || d.deviceName || d.callsign || '未知设备',
|
2026-08-12 11:29:44 +08:00
|
|
|
|
type: d.productName || t('constants.uav'),
|
|
|
|
|
|
status: d.onlineStatus === 1 ? t('devices.online') : t('devices.offline'),
|
|
|
|
|
|
mode: d.feStatus == 1 ? '作业中' : d.feStatus == 2 ? t('devices.idle') : d.mode_code == 0 ? t('devices.idle') : d.mode_code == 1 ? '现场调试' : d.mode_code == 2 ? '远程调试' : d.mode_code == 3 ? '固件升级中' : '作业中',
|
2026-06-01 17:14:55 +08:00
|
|
|
|
capacity_percent: d.capacity_percent || 100,
|
2026-05-11 14:59:36 +08:00
|
|
|
|
position: d.position || '站内',
|
|
|
|
|
|
task: d.status === 4 ? '待命' : '作业中',
|
2026-06-03 11:06:44 +08:00
|
|
|
|
comm: d.rssi ? `${d.rssi}dBm` : '良好',
|
|
|
|
|
|
|
2026-06-01 17:14:55 +08:00
|
|
|
|
})) || [];
|
2026-05-11 14:59:36 +08:00
|
|
|
|
}, [devicesAll]);
|
|
|
|
|
|
|
2026-05-11 10:47:51 +08:00
|
|
|
|
const handleStart = () => message.success('任务已启动');
|
|
|
|
|
|
const handlePause = () => message.info('任务已暂停');
|
|
|
|
|
|
const handleReturn = () => message.info('返航指令已下发');
|
|
|
|
|
|
const handleRecharge = () => message.info('回充指令已下发');
|
|
|
|
|
|
const handleEmergencyStop = () => message.error('已触发急停!');
|
2026-05-22 15:53:15 +08:00
|
|
|
|
|
2026-05-11 11:59:17 +08:00
|
|
|
|
const fix2 = (val) => {
|
|
|
|
|
|
if (val === null || val === undefined || isNaN(val)) return '-';
|
|
|
|
|
|
return Number(val).toFixed(2);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-05-11 14:59:36 +08:00
|
|
|
|
const getVal = (val) => val == "no_rain" ? "无" : (val || '-');
|
2026-05-11 11:59:17 +08:00
|
|
|
|
|
2026-05-11 14:59:36 +08:00
|
|
|
|
const handleDeviceChange = (id) => {
|
2026-08-03 16:40:27 +08:00
|
|
|
|
setCurrentSelectedRobot(id);
|
2026-08-06 13:39:14 +08:00
|
|
|
|
setRobotPlayActive(false);
|
2026-05-11 11:59:17 +08:00
|
|
|
|
};
|
2026-05-11 10:47:51 +08:00
|
|
|
|
|
2026-06-01 17:14:55 +08:00
|
|
|
|
// 获取无人机状态
|
2026-05-27 15:08:26 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
const fetchUavState = async () => {
|
|
|
|
|
|
if (isUAV && selectedDevice?.gateway_sn && selectedDevice?.device_sn) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await getUAVState({
|
|
|
|
|
|
sn: selectedDevice.gateway_sn,
|
|
|
|
|
|
droneSn: selectedDevice.device_sn
|
|
|
|
|
|
});
|
2026-06-01 17:14:55 +08:00
|
|
|
|
if (res.code === 200) setUavState(res.data);
|
2026-05-27 15:08:26 +08:00
|
|
|
|
} catch (err) {
|
|
|
|
|
|
console.error('获取无人机状态失败', err);
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setUavState(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2026-06-01 15:44:02 +08:00
|
|
|
|
fetchUavState();
|
2026-06-02 15:42:58 +08:00
|
|
|
|
}, [selectedDevice]);
|
2026-05-27 15:08:26 +08:00
|
|
|
|
|
2026-05-11 10:47:51 +08:00
|
|
|
|
return (
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<div style={{ background: '#f5f7fa', minHeight: '100%' }}>
|
|
|
|
|
|
<div style={{ padding: '4px 0px 8px' }}>
|
|
|
|
|
|
<Typography.Title level={4} style={{ margin: 0, fontSize: 'clamp(14px, 1.2vw, 18px)' }}>装备总览</Typography.Title>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<Content style={{ margin: '0 8', }}>
|
|
|
|
|
|
<Row gutter={[12, 12]} style={{ marginBottom: 8, flexWrap: 'wrap' }}>
|
|
|
|
|
|
{dynamicTopCards.map((card, idx) => (
|
|
|
|
|
|
<Col key={idx} style={{ minWidth: '200px', flex: '1 0 auto', maxWidth: "260px" }}>
|
|
|
|
|
|
<Card
|
|
|
|
|
|
bordered={false}
|
|
|
|
|
|
bodyStyle={{ padding: '20px 20px', display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between' }}
|
|
|
|
|
|
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', height: 101 }}
|
|
|
|
|
|
>
|
|
|
|
|
|
{/* 左侧文字区域 */}
|
|
|
|
|
|
<div style={{ flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'flex-start' }}>
|
|
|
|
|
|
<div style={{ fontSize: 14, color: '#86909C', marginBottom: 8, fontWeight: 500 }}>
|
|
|
|
|
|
{card.title}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style={{ fontSize: 28, fontWeight: 700, color: card.color, lineHeight: 1, marginBottom: 8 }}>
|
|
|
|
|
|
{card.value}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{/* 底部环比/备注 */}
|
|
|
|
|
|
{card.sub && <div style={{ fontSize: 12, color: '#86909C', fontWeight: 500 }}>
|
|
|
|
|
|
{card.sub}
|
|
|
|
|
|
</div>}
|
2026-05-11 10:47:51 +08:00
|
|
|
|
</div>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
|
|
|
|
|
|
{/* 右侧圆形图标区域 */}
|
|
|
|
|
|
<div
|
|
|
|
|
|
style={{
|
|
|
|
|
|
width: 48,
|
|
|
|
|
|
height: 48,
|
|
|
|
|
|
borderRadius: '50%',
|
|
|
|
|
|
backgroundColor: card.iconBg || '#f0f7ff',
|
|
|
|
|
|
display: 'flex',
|
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
|
flexShrink: 0,
|
|
|
|
|
|
marginLeft: 8
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
{card.icon}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
|
|
|
|
<Row gutter={[8, 8]}>
|
|
|
|
|
|
<Col xs={24} lg={14}>
|
|
|
|
|
|
<Card title={<><EnvironmentOutlined /> 装备协同态势图</>} extra={<Button type="text" icon={<SettingOutlined />} />} bordered={false} style={{ borderRadius: 8, marginBottom: 8 }} bodyStyle={{ padding: 0 }}>
|
|
|
|
|
|
<div style={{ width: '100%', height: 350, borderRadius: 8, position: 'relative', overflow: 'hidden' }}>
|
|
|
|
|
|
<div style={{ position: 'absolute', zIndex: 9999, top: 12, left: 12, background: 'rgba(255,255,255,0.95)', borderRadius: 6, padding: 8 }}>
|
|
|
|
|
|
<div style={{ fontSize: 11, fontWeight: 60, marginBottom: 4 }}>图例说明</div>
|
|
|
|
|
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 4, fontSize: 10 }}>
|
|
|
|
|
|
<div><span style={{ color: '#1890ff' }}>———</span> 巡检航线</div>
|
|
|
|
|
|
<div><span style={{ color: '#fa8c16' }}>———</span> 机器人路径</div>
|
|
|
|
|
|
<div><span style={{ color: '#52c41a' }}>———</span> 清洗路径</div>
|
|
|
|
|
|
<div>🚗 机器位置</div>
|
|
|
|
|
|
<div>✈️ 无人机位置</div>
|
|
|
|
|
|
<div><span style={{ color: '#1890ff' }}>●</span> 补给/充电点</div>
|
|
|
|
|
|
<div><span style={{ color: '#ff4d4f' }}>■</span> 障碍/禁入区</div>
|
|
|
|
|
|
</div>
|
2026-05-11 10:47:51 +08:00
|
|
|
|
</div>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<CesiumMap devices={devicesAll} />
|
2026-06-02 14:15:16 +08:00
|
|
|
|
</div>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
</Card>
|
2026-06-02 14:15:16 +08:00
|
|
|
|
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<Card title={<><SettingOutlined /> 装备调度列表</>} bordered={false} style={{ borderRadius: 8, marginBottom: 8 }}>
|
|
|
|
|
|
<Table rowKey={(record) => record.id || record.serialNumber || record.device_sn} size="small" pagination={false}
|
|
|
|
|
|
columns={[
|
|
|
|
|
|
{ title: '装备名称', dataIndex: 'name', width: 140 },
|
2026-08-12 11:29:44 +08:00
|
|
|
|
{ title: t('common.type'), dataIndex: 'type', width: 90 },
|
2026-08-03 14:38:28 +08:00
|
|
|
|
{
|
2026-08-12 11:29:44 +08:00
|
|
|
|
title: t('workOrder.currentStatus'),
|
2026-08-03 14:38:28 +08:00
|
|
|
|
dataIndex: 'onlineStatus',
|
|
|
|
|
|
width: 70,
|
|
|
|
|
|
render: (s) => {
|
2026-08-12 11:29:44 +08:00
|
|
|
|
const text = s === 1 ? t('devices.online') : t('devices.offline');
|
2026-08-03 14:38:28 +08:00
|
|
|
|
const color = s === 1 ? 'success' : 'default';
|
|
|
|
|
|
return <Tag color={color} style={{ margin: 0 }}>{text}</Tag>;
|
|
|
|
|
|
}
|
|
|
|
|
|
}, {
|
|
|
|
|
|
title: '模式', dataIndex: 'mode', width: 70, render: (text) => {
|
|
|
|
|
|
let color = 'default';
|
|
|
|
|
|
if (text === '作业中') color = 'processing';
|
2026-08-12 11:29:44 +08:00
|
|
|
|
if (text === t('devices.idle')) color = 'success';
|
2026-08-03 14:38:28 +08:00
|
|
|
|
if (text === '空闲中') color = 'success';
|
|
|
|
|
|
if (text === '现场调试') color = 'warning';
|
|
|
|
|
|
if (text === '远程调试') color = 'warning';
|
|
|
|
|
|
if (text === '固件升级中') color = 'error';
|
|
|
|
|
|
return <Tag color={color} style={{ margin: 0 }}>{text}</Tag>;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2026-08-12 11:29:44 +08:00
|
|
|
|
title: t('devices.batteryLevel'),
|
2026-08-03 14:38:28 +08:00
|
|
|
|
dataIndex: 'lastRunningStatus',
|
|
|
|
|
|
width: 70,
|
|
|
|
|
|
render: (lastRunningStatus) => {
|
|
|
|
|
|
const v = lastRunningStatus?.battery || 100;
|
|
|
|
|
|
return <Progress
|
|
|
|
|
|
percent={v}
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
status={v < 40 ? 'exception' : 'active'}
|
|
|
|
|
|
/>;
|
|
|
|
|
|
}
|
2026-08-12 11:29:44 +08:00
|
|
|
|
}, { title: t('aiAnalysis.location'), dataIndex: 'position', width: 90 },
|
2026-08-03 14:38:28 +08:00
|
|
|
|
//{ title: '当前任务', dataIndex: 'task', width: 100 },
|
|
|
|
|
|
{ title: '通讯状态', dataIndex: 'comm', width: 100, render: v => <Badge status={v.includes('-') ? 'warning' : 'success'} text={v} /> },
|
|
|
|
|
|
{
|
2026-08-12 11:29:44 +08:00
|
|
|
|
title: t('roles.actions'),
|
2026-08-03 14:38:28 +08:00
|
|
|
|
key: 'action',
|
2026-08-06 10:47:34 +08:00
|
|
|
|
width: 150,
|
2026-08-03 14:38:28 +08:00
|
|
|
|
//fixed: 'right',
|
|
|
|
|
|
render: (_, record) => (
|
|
|
|
|
|
<Space size={4}>
|
2026-08-03 16:40:27 +08:00
|
|
|
|
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<Button
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
icon={<EditOutlined />}
|
|
|
|
|
|
onClick={() => openEditRobotModal(record)}
|
2026-08-12 11:29:44 +08:00
|
|
|
|
title={t('roles.edit')}
|
2026-08-03 14:38:28 +08:00
|
|
|
|
/>
|
2026-08-06 10:47:34 +08:00
|
|
|
|
<Tooltip title="设备参数设置">
|
|
|
|
|
|
<Button
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
icon={<SettingOutlined />}
|
|
|
|
|
|
onClick={() => {
|
|
|
|
|
|
getDevivePermisstion(record);
|
|
|
|
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Tooltip>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
</Space>
|
|
|
|
|
|
)
|
|
|
|
|
|
}]}
|
|
|
|
|
|
dataSource={dynamicScheduleList}
|
|
|
|
|
|
scroll={{ x: 'max-content', y: 280 }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
|
|
<Card title={<><SettingOutlined /> <span >控制日志 / 告警记录</span></>} bordered={false} style={{ borderRadius: 8 }} extra={<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><Button size="small" style={{ borderRadius: 4, border: '1px solid #d9d9d9' }}>全部级别 ▼</Button></div>}>
|
|
|
|
|
|
<Table rowKey="time" size="small" pagination={false} dataSource={logs} scroll={{ x: 'max-content' }}
|
|
|
|
|
|
columns={[
|
2026-08-12 11:29:44 +08:00
|
|
|
|
{ title: t('common.time'), dataIndex: 'time', width: 90, render: t => <span style={{ fontSize: 13 }}>{t}</span> },
|
2026-08-03 14:38:28 +08:00
|
|
|
|
{ title: '设备', dataIndex: 'device', width: 100, render: t => <span style={{ fontSize: 13 }}>{t}</span> },
|
2026-08-12 11:29:44 +08:00
|
|
|
|
{ title: t('common.type'), dataIndex: 'type', width: 70, render: r => { let c = '#52c41a'; if (r === t('constants.sourceAlert')) c = '#fa8c16'; if (t === 'events') c = '#1890ff'; return <div style={{ display: 'flex', alignItems: 'center', gap: 4 }}><span style={{ width: 10, height: 10, borderRadius: 2, background: c }} /><span style={{ fontSize: 13 }}>{t}</span></div> } },
|
|
|
|
|
|
{ title: t('common.description'), dataIndex: 'desc', render: t => <span style={{ fontSize: 13 }}>{t}</span> },
|
2026-08-03 14:38:28 +08:00
|
|
|
|
{ title: '', width: 70, render: (_, r) => r.level ? <Tag color="red" style={{ fontSize: 11, margin: 0 }}>{r.level}</Tag> : null }
|
|
|
|
|
|
]}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<div style={{ textAlign: 'center', marginTop: 8 }}><Button type="link" size="small" style={{ fontSize: 13, color: '#1890ff' }}>查看更多日志</Button></div>
|
2026-05-11 10:47:51 +08:00
|
|
|
|
</Card>
|
2026-05-14 09:37:15 +08:00
|
|
|
|
</Col>
|
2026-05-11 11:59:17 +08:00
|
|
|
|
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<Col xs={24} lg={10}>
|
|
|
|
|
|
|
|
|
|
|
|
<Card title={<><SettingOutlined style={{ marginRight: 6, }} /> 设备控制面板</>} bordered={false} style={{ borderRadius: 8, marginBottom: 8 }} bodyStyle={{ padding: 12, paddingBottom: 0 }}>
|
|
|
|
|
|
<Select
|
|
|
|
|
|
style={{ width: "80%", marginBottom: 8 }}
|
|
|
|
|
|
placeholder="请选择设备"
|
|
|
|
|
|
value={selectedDevice?.device_sn || selectedDevice?.serialNumber}
|
|
|
|
|
|
onChange={handleDeviceChange}
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
showSearch
|
|
|
|
|
|
allowClear
|
|
|
|
|
|
optionFilterProp="label"
|
|
|
|
|
|
filterOption={(input, option) =>
|
|
|
|
|
|
String(option?.label || "").toLowerCase().includes(input.toLowerCase())
|
|
|
|
|
|
}
|
|
|
|
|
|
options={[
|
2026-08-12 11:29:44 +08:00
|
|
|
|
{ label: <span>devices.robot</span>, options: devices.map(item => ({ value: item.device_sn || item.serialNumber, label: item.deviceAlias || item.deviceName || '未知设备' })) },
|
|
|
|
|
|
{ label: <span>constants.uav</span>, options: planedevices.map(item => ({ value: item.device_sn, label: item.drone_callsign || item.callsign || '未知设备' })) },
|
2026-08-03 14:38:28 +08:00
|
|
|
|
]}
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
{selectedDevice && (
|
|
|
|
|
|
<Row gutter={8}>
|
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
|
<div style={{ marginBottom: 12 }}>
|
|
|
|
|
|
<div style={{ display: 'flex', alignItems: 'center', gap: 6, marginBottom: 12, flexWrap: "wrap" }}>
|
2026-08-12 11:29:44 +08:00
|
|
|
|
{selectedDevice.deviceType === 'drone' || selectedDevice.deviceName?.includes(t('constants.uav')) || selectedDevice.drone_callsign ? (
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<span style={{ fontSize: 20, color: '#1890ff' }}><RocketOutlined /></span>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<span style={{ fontSize: 20, color: '#1890ff' }}><CarOutlined /></span>
|
|
|
|
|
|
)}
|
|
|
|
|
|
<span style={{ fontSize: 14, fontWeight: 600 }}>{selectedDevice.deviceAlias || selectedDevice.drone_callsign || selectedDevice.callsign || selectedDevice.deviceName}</span>
|
|
|
|
|
|
<Tag color={selectedDevice.onlineStatus === 1 ? "success" : "default"} size="small" style={{ margin: 0 }}>
|
2026-08-12 11:29:44 +08:00
|
|
|
|
{selectedDevice.onlineStatus == 1 ? t('devices.online') : t('devices.offline')}
|
2026-08-03 14:38:28 +08:00
|
|
|
|
</Tag>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
type="primary" size="small" ghost icon={<InfoCircleOutlined />}
|
|
|
|
|
|
style={{ borderRadius: 4, fontSize: 11, marginLeft: 'auto' }}
|
2026-08-03 16:40:27 +08:00
|
|
|
|
onClick={() => onViewStatus(selectedDevice.device_sn || selectedDevice.serialNumber)}
|
2026-08-03 14:38:28 +08:00
|
|
|
|
>详情</Button>
|
2026-05-11 11:59:17 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 4 }}>
|
|
|
|
|
|
<div style={{ display: 'flex', alignItems: 'center', gap: 4 }}>
|
|
|
|
|
|
<span style={{ color: '#52c41a' }}><ThunderboltOutlined /></span>
|
|
|
|
|
|
<span style={{ fontSize: 12 }}>电量 {fix2(realtimeDevice?.capacity_percent || realtimeDevice?.lastRunningStatus?.battery || 100)}%</span>
|
2026-05-22 15:53:15 +08:00
|
|
|
|
</div>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
{realtimeDevice?.environment_temperature && (
|
|
|
|
|
|
<div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>
|
2026-08-12 11:29:44 +08:00
|
|
|
|
<span style={{ fontSize: 12 }}>{t('home.temperature')}</span>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<span style={{ color: '#faad14' }}>{fix2(realtimeDevice.environment_temperature || 25)}℃</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
2026-05-11 11:59:17 +08:00
|
|
|
|
</div>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
|
|
|
|
|
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 6, marginBottom: 12, maxHeight: "160px", overflow: "auto", scrollbarWidth: 'thin', scrollbarColor: '#ccc transparent' }}>
|
|
|
|
|
|
{selectedDevice.productName && (
|
2026-05-11 14:59:36 +08:00
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<span style={{ color: '#666', fontSize: 12 }}>产品类型</span>
|
|
|
|
|
|
<span style={{ fontSize: 12 }}>{getVal(selectedDevice.productName)}</span>
|
2026-05-11 14:59:36 +08:00
|
|
|
|
</div>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
)}
|
|
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', gap: 8 }}>
|
|
|
|
|
|
<span style={{ color: '#666', fontSize: 12, whiteSpace: 'nowrap' }}>设备SN</span>
|
|
|
|
|
|
<span style={{ fontSize: 12, wordBreak: 'break-all', whiteSpace: 'normal', textAlign: 'right', maxWidth: '70%' }}>
|
|
|
|
|
|
{getVal(selectedDevice.device_sn || selectedDevice.serialNumber)}
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{selectedDevice.activeTime && (
|
2026-05-11 14:59:36 +08:00
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<span style={{ color: '#666', fontSize: 12 }}>激活时间</span>
|
|
|
|
|
|
<span style={{ fontSize: 12 }}>{selectedDevice.activeTime}</span>
|
2026-05-27 15:08:26 +08:00
|
|
|
|
</div>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
)}
|
|
|
|
|
|
{selectedDevice.firmwareVersion && (
|
2026-05-27 15:08:26 +08:00
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<span style={{ color: '#666', fontSize: 12 }}>固件版本</span>
|
|
|
|
|
|
<span style={{ fontSize: 12 }}>v{selectedDevice.firmwareVersion}</span>
|
2026-05-11 14:59:36 +08:00
|
|
|
|
</div>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
)}
|
2026-08-12 11:29:44 +08:00
|
|
|
|
{(selectedDevice.productName?.includes(t('constants.uav')) || selectedDevice.device_sn) && (
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<>
|
|
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
|
|
|
|
<span style={{ color: '#666', fontSize: 12 }}>飞行高度</span>
|
|
|
|
|
|
<span style={{ fontSize: 12 }}>{fix2(realtimeDevice?.height)} m</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
|
|
|
|
<span style={{ color: '#666', fontSize: 12 }}>飞行风速</span>
|
|
|
|
|
|
<span style={{ fontSize: 12 }}>{fix2(realtimeDevice?.wind_speed)} m/s</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
|
|
|
|
|
<span style={{ color: '#666', fontSize: 12 }}>rtk数量</span>
|
|
|
|
|
|
<span style={{ fontSize: 12 }}>
|
|
|
|
|
|
<Badge
|
|
|
|
|
|
showZero={true}
|
|
|
|
|
|
count={realtimeDevice?.position_state?.rtk_number || 0}
|
|
|
|
|
|
style={{ backgroundColor: '#52c41a', transform: 'scale(0.8)' }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
2026-05-11 11:59:17 +08:00
|
|
|
|
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<div style={{ display: 'flex', justifyContent: "space-between", flexWrap: 'wrap', gap: 6 }}>
|
|
|
|
|
|
<Button type="primary" style={{ borderRadius: 8, flex: 1 }} onClick={handleStart}>启动</Button>
|
2026-08-12 11:29:44 +08:00
|
|
|
|
<Button style={{ borderRadius: 8, flex: 1 }} onClick={handlePause}>{t('video.pause')}</Button>
|
|
|
|
|
|
<Button type="primary" style={{ borderRadius: 8, flex: 1 }} onClick={handleReturn}>{t('devices.returnHome')}</Button>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<Button style={{ flex: 1, background: '#52c41a', borderColor: '#52c41a', color: "#fff", borderRadius: 8, }} onClick={handleRecharge}>回充</Button>
|
|
|
|
|
|
</div>
|
2026-05-11 11:59:17 +08:00
|
|
|
|
</div>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
</Col>
|
|
|
|
|
|
|
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
|
<div style={{ marginBottom: 8 }}>
|
|
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 4 }}>
|
|
|
|
|
|
<span style={{ fontSize: 14, fontWeight: 500, color: "#666" }}>实时画面</span>
|
|
|
|
|
|
{isUAV && (
|
|
|
|
|
|
<Select
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
style={{ width: 120 }}
|
|
|
|
|
|
value={videoSource}
|
|
|
|
|
|
onChange={setVideoSource}
|
|
|
|
|
|
options={[
|
|
|
|
|
|
{ label: '机场视频', value: 'station' },
|
|
|
|
|
|
{ label: '无人机视频', value: 'drone' },
|
|
|
|
|
|
]}
|
|
|
|
|
|
/>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
2026-05-22 13:50:50 +08:00
|
|
|
|
|
2026-08-03 14:38:28 +08:00
|
|
|
|
{/* ✅ 关键:videoDevice 绝不随MQTT更新,视频永不闪烁 */}
|
|
|
|
|
|
<div style={{ width: '100%', height: 160, borderRadius: 8, position: 'relative', overflow: 'hidden', background: '#000' }}>
|
|
|
|
|
|
{isUAV ? (
|
|
|
|
|
|
<DroneVideoPlayer
|
|
|
|
|
|
device={videoDevice}
|
|
|
|
|
|
height={160}
|
|
|
|
|
|
showSourceSelect={false}
|
|
|
|
|
|
videoSource={videoSource}
|
|
|
|
|
|
onSourceChange={setVideoSource}
|
2026-05-18 17:25:41 +08:00
|
|
|
|
/>
|
2026-05-22 13:50:50 +08:00
|
|
|
|
) : (
|
2026-08-06 13:39:14 +08:00
|
|
|
|
robotPlayActive ? (
|
|
|
|
|
|
robotVideo ? (
|
|
|
|
|
|
<VideoPlayer
|
|
|
|
|
|
deviceId={selectedDevice?.device_sn || selectedDevice?.serialNumber}
|
|
|
|
|
|
idx={mowerView === 'front' ? 1 : mowerView === 'back' ? 2 : mowerView === 'left' ? 3 : 4}
|
|
|
|
|
|
className="w-full h-full object-contain"
|
|
|
|
|
|
video={robotVideo}
|
|
|
|
|
|
error={error}
|
|
|
|
|
|
ready={ready}
|
|
|
|
|
|
/>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<div style={{ color: '#ccc', display: 'flex', height: '100%', alignItems: 'center', justifyContent: 'center' }}>
|
|
|
|
|
|
视频加载中...
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)
|
2026-08-03 14:38:28 +08:00
|
|
|
|
) : (
|
2026-08-06 13:39:14 +08:00
|
|
|
|
// ========== 未点击播放时:显示播放大按钮 ==========
|
|
|
|
|
|
<div
|
|
|
|
|
|
onClick={() => setRobotPlayActive(true)}
|
|
|
|
|
|
style={{
|
|
|
|
|
|
width: '100%',
|
|
|
|
|
|
height: '100%',
|
|
|
|
|
|
display: 'flex',
|
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
|
cursor: 'pointer',
|
|
|
|
|
|
background: '#000',
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<div
|
|
|
|
|
|
style={{
|
|
|
|
|
|
width: 48,
|
|
|
|
|
|
height: 48,
|
|
|
|
|
|
borderRadius: '50%',
|
|
|
|
|
|
background: 'rgba(255,255,255,0.25)',
|
|
|
|
|
|
display: 'flex',
|
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
|
justifyContent: 'center',
|
|
|
|
|
|
color: '#fff',
|
|
|
|
|
|
fontSize: 22,
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
▶
|
|
|
|
|
|
</div>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
)
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
2026-08-06 13:39:14 +08:00
|
|
|
|
{!isUAV && robotPlayActive && (
|
|
|
|
|
|
<div style={{ marginTop: 6, textAlign: 'right' }}>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
danger
|
|
|
|
|
|
onClick={() => {
|
|
|
|
|
|
setRobotPlayActive(false);
|
|
|
|
|
|
}}
|
|
|
|
|
|
>停止视频</Button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-05-11 10:47:51 +08:00
|
|
|
|
</div>
|
2026-05-11 11:59:17 +08:00
|
|
|
|
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<div style={{ display: 'flex', gap: 12, flexWrap: 'wrap' }}>
|
|
|
|
|
|
<Button size="large" style={{ flex: 1, borderRadius: 8 }}>切换手动</Button>
|
|
|
|
|
|
<Button danger size="large" style={{ flex: 1, borderRadius: 8 }} onClick={handleEmergencyStop}>急停</Button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
)}
|
2026-05-11 15:15:19 +08:00
|
|
|
|
</Card>
|
|
|
|
|
|
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<Card title={<><ApiOutlined /> AI分析与操作建议</>} bordered={false} style={{ borderRadius: 12, marginBottom: 8 }}>
|
|
|
|
|
|
<Row gutter={16} style={{ marginBottom: 8 }}>
|
|
|
|
|
|
<Col span={6}><div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '6px 12px 4px', borderRadius: 12, border: '1px solid #e8e8e8' }}><div style={{ width: 30, height: 30, borderRadius: '50%', background: 'rgba(255,77,79,0.15)', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#ff4d4f', fontSize: 20 }}><span role="img" aria-label="hotspot">🔥</span></div><div><div style={{ fontSize: 11, color: '#666' }}>热斑疑似</div><div style={{ fontSize: 22, fontWeight: 700, color: '#222' }}>2 <span style={{ fontSize: 12 }}>处</span></div></div></div></Col>
|
|
|
|
|
|
<Col span={6}><div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '6px 12px 4px', borderRadius: 12, border: '1px solid #e8e8e8' }}><div style={{ width: 30, height: 30, borderRadius: '50%', background: 'rgba(82,196,26,0.15)', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#52c41a', fontSize: 16 }}><BranchesOutlined /></div><div><div style={{ fontSize: 11, color: '#666' }}>杂草高发区</div><div style={{ fontSize: 22, fontWeight: 700, color: '#222' }}>3 <span style={{ fontSize: 12 }}>块</span></div></div></div></Col>
|
|
|
|
|
|
<Col span={6}><div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '6px 12px 4px', borderRadius: 12, border: '1px solid #e8e8e8' }}><div style={{ width: 30, height: 30, borderRadius: '50%', background: 'rgba(24,144,255,0.15)', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#1890ff', fontSize: 16 }}><CloudOutlined /></div><div><div style={{ fontSize: 11, color: '#666' }}>组件风险区</div><div style={{ fontSize: 22, fontWeight: 700, color: '#222' }}>4 <span style={{ fontSize: 12 }}>块</span></div></div></div></Col>
|
|
|
|
|
|
<Col span={6}><div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '6px 12px 4px', borderRadius: 12, border: '1px solid #e8e8e8' }}><div style={{ width: 30, height: 30, borderRadius: '50%', background: 'rgba(255,77,79,0.15)', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#ff4d4f', fontSize: 16 }}><WarningOutlined /></div><div><div style={{ fontSize: 11, color: '#666' }}>围栏异常</div><div style={{ fontSize: 22, fontWeight: 700, color: '#ff4d4f' }}>1 <span style={{ fontSize: 12 }}>处</span></div></div></div></Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
<Row gutter={16}>
|
|
|
|
|
|
<Col span={14}>
|
|
|
|
|
|
<div style={{ marginBottom: 12 }}>
|
|
|
|
|
|
<div style={{ fontSize: 16, fontWeight: 600, color: '#1890ff', marginBottom: 8 }}>建议操作</div>
|
|
|
|
|
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 2, padding: '4px', borderRadius: 12, border: '1px solid #e8e8e8' }}>
|
|
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}><div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><span style={{ color: '#1890ff' }}>⦿</span><span style={{ fontSize: 16 }}>优先执行巡检航线 P-03</span></div><ArrowRightOutlined style={{ color: '#666' }} /></div>
|
|
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}><div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><span style={{ color: '#1890ff' }}>⦿</span><span style={{ fontSize: 16 }}>先行安排除草任务 G-02</span></div><ArrowRightOutlined style={{ color: '#666' }} /></div>
|
|
|
|
|
|
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}><div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><span style={{ color: '#1890ff' }}>⦿</span><span style={{ fontSize: 16 }}>建议生成清洗工单</span></div><ArrowRightOutlined style={{ color: '#666' }} /></div>
|
|
|
|
|
|
</div>
|
2026-05-14 15:15:50 +08:00
|
|
|
|
</div>
|
2026-05-11 15:15:19 +08:00
|
|
|
|
</Col>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<Col span={10}>
|
|
|
|
|
|
<div style={{ display: 'flex', flexDirection: 'column', paddingBottom: "12px", gap: 16, height: '100%', justifyContent: "end" }}>
|
|
|
|
|
|
<div style={{ display: 'flex', gap: 12, flexWrap: "wrap" }}>
|
|
|
|
|
|
<Button type="primary" size="middle" style={{ flex: 1, borderRadius: 8, fontSize: 14 }}>生成任务</Button>
|
|
|
|
|
|
<Button size="middle" style={{ flex: 1, borderRadius: 8, fontSize: 14, border: '1px solid #1890ff', color: '#1890ff' }}>AI优化路径</Button>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<Button type="primary" size="middle" style={{ borderRadius: 8, fontSize: 14 }}>一键联动作业</Button>
|
2026-05-14 15:15:50 +08:00
|
|
|
|
</div>
|
2026-05-11 15:15:19 +08:00
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
</Card>
|
2026-06-12 17:34:35 +08:00
|
|
|
|
|
2026-08-12 11:29:44 +08:00
|
|
|
|
{(selectedDevice?.productName?.includes(t('constants.uav')) || selectedDevice?.device_sn) && (
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<Card title="环境与飞行条件" bordered={false} style={{ borderRadius: 12, marginBottom: 8 }}>
|
|
|
|
|
|
<div style={{ display: "flex", justifyContent: "space-between", gap: 12, alignItems: "center" }}>
|
|
|
|
|
|
<div style={{ display: "flex", border: "1px solid #e8e8e8", borderRadius: 12, overflow: "hidden", flex: 1 }}>
|
|
|
|
|
|
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px", borderRight: "1px solid #e8e8e8" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>风速</div><div style={{ fontSize: 14, fontWeight: 700, color: '#222', marginTop: 2 }}>{fix2(realtimeDevice?.wind_speed)} m/s</div></div>
|
2026-08-12 11:29:44 +08:00
|
|
|
|
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px", borderRight: "1px solid #e8e8e8" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>{t('home.temperature')}</div><div style={{ fontSize: 14, fontWeight: 700, color: '#222', marginTop: 2 }}>{fix2(realtimeDevice?.environment_temperature)}℃</div></div>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px", borderRight: "1px solid #e8e8e8" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>降雨</div><div style={{ fontSize: 14, fontWeight: 700, color: '#222', marginTop: 2 }}>{getVal(realtimeDevice?.rainfall)}</div></div>
|
|
|
|
|
|
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>RTK</div><div style={{ fontSize: 14, fontWeight: 700, color: '#52c41a', marginTop: 2 }}>{realtimeDevice?.position_state?.is_fixed === 'fixing_successful' ? '固定' : '未固定'}</div></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style={{ width: 110, padding: '12px 4px', borderRadius: 8, background: '#f6ffed', border: '1px solid #b7eb8f', textAlign: 'center', display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', gap: 4 }}>
|
|
|
|
|
|
<div className="flex items-center gap-1">
|
|
|
|
|
|
<div style={{ fontSize: 12, fontWeight: 700, color: '#52c41a' }}>适宜执行</div>
|
|
|
|
|
|
<div style={{ width: 18, height: 18, borderRadius: '50%', background: '#52c41a', display: 'flex', alignItems: 'center', justifyContent: 'center' }}><CheckCircleOutlined style={{ fontSize: 12, color: '#fff' }} /></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style={{ fontSize: 11, color: '#666' }}>可正常作业</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
)}
|
2026-06-15 11:30:32 +08:00
|
|
|
|
|
2026-08-12 11:29:44 +08:00
|
|
|
|
{(!selectedDevice?.productName?.includes(t('constants.uav')) && !selectedDevice?.device_sn) && (
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<Card title={<div style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 14, fontWeight: 600 }}><RobotOutlined style={{ color: '#165DFF' }} />机器人作业状态</div>} bordered={false} style={{ borderRadius: 12, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', border: '1px solid #f0f0f0' }}>
|
|
|
|
|
|
<Row gutter={16} style={{ alignItems: 'center' }}>
|
|
|
|
|
|
<Col span={8}>
|
|
|
|
|
|
<div style={{ padding: '12px 16px', borderRadius: 10, background: '#F7F8FA', textAlign: 'center', border: '1px solid transparent', transition: 'all 0.2s' }}
|
|
|
|
|
|
onMouseEnter={e => {
|
|
|
|
|
|
e.currentTarget.style.background = '#E8F3FF';
|
|
|
|
|
|
e.currentTarget.style.borderColor = '#165DFF';
|
|
|
|
|
|
}}
|
|
|
|
|
|
onMouseLeave={e => {
|
|
|
|
|
|
e.currentTarget.style.background = '#F7F8FA';
|
|
|
|
|
|
e.currentTarget.style.borderColor = 'transparent';
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Statistic
|
|
|
|
|
|
title={<span style={{ fontSize: 11, color: '#666666', fontWeight: 400 }}>累计作业里程</span>}
|
|
|
|
|
|
value={deviceStatistics?.distance ? Number(deviceStatistics.distance).toFixed(2) : Number(deviceStatistics?.workArea / 0.7 || 0).toFixed(2)}
|
|
|
|
|
|
suffix="m"
|
|
|
|
|
|
valueStyle={{ fontSize: 20, fontWeight: 700, color: '#165DFF', marginTop: 4 }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col span={8}>
|
|
|
|
|
|
<div style={{ padding: '12px 16px', borderRadius: 10, background: '#F7F8FA', textAlign: 'center', border: '1px solid transparent', transition: 'all 0.2s' }}
|
|
|
|
|
|
onMouseEnter={e => {
|
|
|
|
|
|
e.currentTarget.style.background = '#E8F3FF';
|
|
|
|
|
|
e.currentTarget.style.borderColor = '#165DFF';
|
|
|
|
|
|
}}
|
|
|
|
|
|
onMouseLeave={e => {
|
|
|
|
|
|
e.currentTarget.style.background = '#F7F8FA';
|
|
|
|
|
|
e.currentTarget.style.borderColor = 'transparent';
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Statistic
|
|
|
|
|
|
title={<span style={{ fontSize: 11, color: '#666666', fontWeight: 400 }}>累计作业面积</span>}
|
|
|
|
|
|
value={Number(deviceStatistics?.workArea || 0).toFixed(2)}
|
|
|
|
|
|
suffix="㎡"
|
|
|
|
|
|
valueStyle={{ fontSize: 20, fontWeight: 700, color: '#165DFF', marginTop: 4 }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
<Col span={8}>
|
|
|
|
|
|
<div style={{ padding: '12px 16px', borderRadius: 10, background: '#F7F8FA', textAlign: 'center', border: '1px solid transparent', transition: 'all 0.2s' }}
|
|
|
|
|
|
onMouseEnter={e => {
|
|
|
|
|
|
e.currentTarget.style.background = '#E8F3FF';
|
|
|
|
|
|
e.currentTarget.style.borderColor = '#165DFF';
|
|
|
|
|
|
}}
|
|
|
|
|
|
onMouseLeave={e => {
|
|
|
|
|
|
e.currentTarget.style.background = '#F7F8FA';
|
|
|
|
|
|
e.currentTarget.style.borderColor = 'transparent';
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<Statistic
|
|
|
|
|
|
title={<span style={{ fontSize: 11, color: '#666666', fontWeight: 400 }}>累计作业时长</span>}
|
|
|
|
|
|
value={Number(deviceStatistics?.time || 0).toFixed(2)}
|
|
|
|
|
|
suffix="min"
|
|
|
|
|
|
valueStyle={{ fontSize: 20, fontWeight: 700, color: '#165DFF', marginTop: 4 }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
)}
|
2026-06-12 17:34:35 +08:00
|
|
|
|
|
2026-08-03 14:38:28 +08:00
|
|
|
|
<Card title={<><ClockCircleOutlined /> 任务执行时间线</>} bordered={false} style={{ borderRadius: 12 }} extra={<div style={{ fontSize: 12, color: '#666' }}></div>}>
|
|
|
|
|
|
<Timeline mode="left">
|
|
|
|
|
|
{taskTimeline.map((item, idx) => (
|
|
|
|
|
|
<Timeline.Item key={idx} color={item.color} label={<div style={{ fontSize: 11, color: '#999' }}>{item.time}</div>}>
|
|
|
|
|
|
<div style={{ fontSize: 13 }}>{item.text}</div>
|
|
|
|
|
|
<div style={{ fontSize: 11, color: '#999' }}>{item.status}</div>
|
|
|
|
|
|
</Timeline.Item>
|
|
|
|
|
|
))}
|
|
|
|
|
|
</Timeline>
|
|
|
|
|
|
<div style={{ textAlign: 'center', marginTop: 12 }}><Button type="link">查看更多</Button></div>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
|
|
|
|
{/* 机器人编辑别名弹窗 */}
|
|
|
|
|
|
<Modal
|
|
|
|
|
|
title="编辑机器人设备信息"
|
|
|
|
|
|
open={editRobotModalOpen}
|
|
|
|
|
|
onCancel={() => setEditRobotModalOpen(false)}
|
|
|
|
|
|
confirmLoading={editLoading}
|
|
|
|
|
|
onOk={handleSaveRobotAlias}
|
|
|
|
|
|
maskClosable={false}
|
|
|
|
|
|
>
|
|
|
|
|
|
{currentEditRobot && (
|
|
|
|
|
|
<div style={{ padding: '8px 0' }}>
|
|
|
|
|
|
<div style={{ marginBottom: 16 }}>
|
|
|
|
|
|
<Typography.Text strong>设备SN:</Typography.Text>
|
|
|
|
|
|
<Typography.Text copyable>
|
|
|
|
|
|
{currentEditRobot.device_sn || currentEditRobot.serialNumber}
|
|
|
|
|
|
</Typography.Text>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div style={{ marginBottom: 16 }}>
|
|
|
|
|
|
<Typography.Text strong>设备类型:</Typography.Text>
|
2026-08-12 11:29:44 +08:00
|
|
|
|
<Typography.Text>{currentEditRobot.productName || t('constants.locationUnknown')}</Typography.Text>
|
2026-08-03 14:38:28 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div style={{ marginBottom: 8 }}>
|
|
|
|
|
|
<Typography.Text strong>设备别名 <span style={{ color: 'red' }}>*</span></Typography.Text>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<Input
|
|
|
|
|
|
value={editAliasInput}
|
|
|
|
|
|
onChange={e => setEditAliasInput(e.target.value)}
|
|
|
|
|
|
placeholder="请输入自定义设备别名"
|
|
|
|
|
|
maxLength={30}
|
|
|
|
|
|
allowClear
|
|
|
|
|
|
/>
|
|
|
|
|
|
<div style={{ marginTop: 8, fontSize: 12, color: '#999' }}>
|
|
|
|
|
|
别名用于设备列表、控制面板展示,便于快速区分设备
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Modal>
|
2026-06-12 17:34:35 +08:00
|
|
|
|
|
2026-08-06 10:47:34 +08:00
|
|
|
|
{/* 设备参数查看与修改弹窗(通用组件) */}
|
|
|
|
|
|
<DeviceParamModal
|
|
|
|
|
|
open={paramModalOpen}
|
|
|
|
|
|
device={currentParamDevice}
|
|
|
|
|
|
onCancel={() => {
|
|
|
|
|
|
setParamModalOpen(false);
|
|
|
|
|
|
setCurrentParamDevice(null);
|
|
|
|
|
|
}}
|
|
|
|
|
|
onSuccess={() => {
|
|
|
|
|
|
fetchAllData();
|
|
|
|
|
|
}}
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
2026-08-03 14:38:28 +08:00
|
|
|
|
</Content>
|
|
|
|
|
|
</div>
|
2026-05-11 10:47:51 +08:00
|
|
|
|
);
|
|
|
|
|
|
}
|