2026-05-20 15:12:51 +08:00
|
|
|
|
import React, {
|
|
|
|
|
|
useState,
|
|
|
|
|
|
useEffect,
|
|
|
|
|
|
useMemo,
|
|
|
|
|
|
useRef,
|
|
|
|
|
|
useCallback,
|
|
|
|
|
|
} from 'react';
|
|
|
|
|
|
|
2026-05-11 16:34:44 +08:00
|
|
|
|
import {
|
2026-05-20 15:12:51 +08:00
|
|
|
|
Row,
|
|
|
|
|
|
Col,
|
|
|
|
|
|
Card,
|
|
|
|
|
|
Tag,
|
|
|
|
|
|
Typography,
|
|
|
|
|
|
Space,
|
|
|
|
|
|
Empty,
|
|
|
|
|
|
Descriptions,
|
|
|
|
|
|
Badge,
|
|
|
|
|
|
Progress,
|
|
|
|
|
|
Button,
|
|
|
|
|
|
Select,
|
|
|
|
|
|
message,
|
|
|
|
|
|
Modal,
|
2026-05-11 16:34:44 +08:00
|
|
|
|
} from 'antd';
|
2026-05-20 15:12:51 +08:00
|
|
|
|
|
2026-05-11 16:34:44 +08:00
|
|
|
|
import {
|
2026-05-20 15:12:51 +08:00
|
|
|
|
DashboardOutlined,
|
|
|
|
|
|
GlobalOutlined,
|
|
|
|
|
|
VideoCameraOutlined,
|
|
|
|
|
|
ControlOutlined,
|
|
|
|
|
|
CameraOutlined,
|
|
|
|
|
|
ThunderboltOutlined,
|
|
|
|
|
|
EnvironmentOutlined,
|
2026-05-11 16:34:44 +08:00
|
|
|
|
} from '@ant-design/icons';
|
2026-05-20 15:12:51 +08:00
|
|
|
|
|
2026-05-27 15:08:26 +08:00
|
|
|
|
import {
|
2026-05-28 15:17:00 +08:00
|
|
|
|
getsinglePlan,
|
2026-05-27 15:08:26 +08:00
|
|
|
|
getsinglePlanTrack,
|
|
|
|
|
|
getFlightTaskDetail,
|
|
|
|
|
|
getUAVState,
|
|
|
|
|
|
} from '../../api/device.ts';
|
|
|
|
|
|
|
2026-05-11 16:34:44 +08:00
|
|
|
|
import XboxController from './XboxController';
|
2026-05-25 10:30:20 +08:00
|
|
|
|
import DroneVideoPlayer from './DroneVideoPlayer';
|
2026-05-12 08:34:13 +08:00
|
|
|
|
import CesiumMap from '../Map.jsx';
|
2026-05-12 10:34:50 +08:00
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
|
import { RootState } from '@/src/store/index.ts';
|
2026-05-12 17:31:34 +08:00
|
|
|
|
import { useWebRTCPlayer } from '../useWebRTCStream.tsx';
|
|
|
|
|
|
import VideoPlayer from '../VideoPlayer.tsx';
|
2026-05-20 15:12:51 +08:00
|
|
|
|
import DeviceController from './DeviceController';
|
2026-05-22 08:03:30 +08:00
|
|
|
|
import { DatePicker } from 'antd';
|
|
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
|
const { RangePicker } = DatePicker;
|
2026-05-12 11:11:30 +08:00
|
|
|
|
|
2026-05-12 10:34:50 +08:00
|
|
|
|
const { Text } = Typography;
|
|
|
|
|
|
|
2026-05-20 15:12:51 +08:00
|
|
|
|
export default function DeviceStatusPage({
|
|
|
|
|
|
devicesAll,
|
|
|
|
|
|
serialNumber,
|
|
|
|
|
|
onDeviceChange,
|
2026-06-01 15:44:02 +08:00
|
|
|
|
mqttDroneData,
|
2026-05-20 15:12:51 +08:00
|
|
|
|
}) {
|
|
|
|
|
|
const { userInfo } = useSelector((state: RootState) => state.user);
|
2026-06-01 15:44:02 +08:00
|
|
|
|
const [persistentDroneData, setPersistentDroneData] = useState(null); // 持久化无人机数据
|
|
|
|
|
|
|
|
|
|
|
|
// 当MQTT数据更新时,更新持久化数据(只在有新数据时更新)
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (mqttDroneData && mqttDroneData.host) {
|
|
|
|
|
|
const { host } = mqttDroneData;
|
|
|
|
|
|
setPersistentDroneData({
|
|
|
|
|
|
// 无人机状态数据映射
|
|
|
|
|
|
capacity_percent: host.drone_charge_state?.capacity_percent,
|
|
|
|
|
|
environment_temperature: host.environment_temperature,
|
|
|
|
|
|
height: host.height,
|
|
|
|
|
|
wind_speed: host.wind_speed,
|
|
|
|
|
|
rainfall: host.rainfall === 0 ? 'no_rain' : 'rain',
|
|
|
|
|
|
position_state: host.position_state,
|
|
|
|
|
|
longitude: host.longitude,
|
|
|
|
|
|
latitude: host.latitude,
|
|
|
|
|
|
heading: host.heading,
|
|
|
|
|
|
humidity: host.humidity,
|
|
|
|
|
|
drone_in_dock: host.drone_in_dock,
|
|
|
|
|
|
cover_state: host.cover_state,
|
|
|
|
|
|
temperature: host.temperature,
|
|
|
|
|
|
home_distance: host.home_distance,
|
|
|
|
|
|
air_conditioner_state: host.air_conditioner_state,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}, [mqttDroneData]);
|
|
|
|
|
|
|
|
|
|
|
|
// 优先使用持久化数据,保持显示稳定
|
|
|
|
|
|
const currentDroneData = React.useMemo(() => {
|
|
|
|
|
|
return persistentDroneData;
|
|
|
|
|
|
}, [persistentDroneData]);
|
2026-05-20 15:12:51 +08:00
|
|
|
|
|
|
|
|
|
|
const [messageApi, contextHolder] = message.useMessage();
|
|
|
|
|
|
|
|
|
|
|
|
const controllerRef = useRef<DeviceController | null>(null);
|
2026-05-11 16:34:44 +08:00
|
|
|
|
|
|
|
|
|
|
const [isControlled, setIsControlled] = useState(false);
|
2026-05-20 15:12:51 +08:00
|
|
|
|
const [hasControlRight, setHasControlRight] = useState(false);
|
|
|
|
|
|
const [connecting, setConnecting] = useState(false);
|
2026-05-12 10:34:50 +08:00
|
|
|
|
const [wsStatus, setWsStatus] = useState('disconnected');
|
2026-05-20 15:12:51 +08:00
|
|
|
|
const [wsDeviceInfo, setWsDeviceInfo] = useState({});
|
2026-05-22 08:03:30 +08:00
|
|
|
|
const [selectedDrone, setSelectedDrone] = useState(null);
|
|
|
|
|
|
const [taskList, setTaskList] = useState([]);
|
|
|
|
|
|
|
|
|
|
|
|
// 👇 加上这两个
|
|
|
|
|
|
const [queryTimeRange, setQueryTimeRange] = useState([]); // 时间范围
|
|
|
|
|
|
const [startTimestamp, setStartTimestamp] = useState(''); // 开始时间戳
|
|
|
|
|
|
const [endTimestamp, setEndTimestamp] = useState(''); // 结束时间戳
|
2026-05-12 10:34:50 +08:00
|
|
|
|
|
|
|
|
|
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
2026-05-20 15:12:51 +08:00
|
|
|
|
const [modalContent, setModalContent] = useState({
|
|
|
|
|
|
title: '',
|
|
|
|
|
|
content: '',
|
|
|
|
|
|
});
|
2026-05-12 17:31:34 +08:00
|
|
|
|
|
2026-05-20 15:12:51 +08:00
|
|
|
|
const [mowerView, setMowerView] = useState('front');
|
2026-05-27 15:08:26 +08:00
|
|
|
|
const [uavState, setUavState] = useState<any>(null);
|
2026-05-28 15:17:00 +08:00
|
|
|
|
const [points, setPoints] = useState([]);
|
2026-05-27 15:08:26 +08:00
|
|
|
|
const timerRef = useRef<any>(null);
|
2026-05-12 17:31:34 +08:00
|
|
|
|
|
2026-05-11 16:34:44 +08:00
|
|
|
|
const device = useMemo(() => {
|
2026-05-20 15:12:51 +08:00
|
|
|
|
const sn =
|
|
|
|
|
|
serialNumber ||
|
|
|
|
|
|
devicesAll?.[0]?.device_sn ||
|
|
|
|
|
|
devicesAll?.[0]?.serialNumber;
|
|
|
|
|
|
|
2026-05-11 16:34:44 +08:00
|
|
|
|
if (!sn) return null;
|
2026-05-20 15:12:51 +08:00
|
|
|
|
|
|
|
|
|
|
return devicesAll?.find(
|
|
|
|
|
|
(d) => (d.device_sn || d.serialNumber) === sn,
|
|
|
|
|
|
);
|
2026-05-11 16:34:44 +08:00
|
|
|
|
}, [devicesAll, serialNumber]);
|
|
|
|
|
|
|
|
|
|
|
|
const isUAV = useMemo(() => {
|
2026-05-20 15:12:51 +08:00
|
|
|
|
return !!device?.device_sn;
|
2026-05-11 16:34:44 +08:00
|
|
|
|
}, [device]);
|
|
|
|
|
|
|
2026-05-12 10:34:50 +08:00
|
|
|
|
const runningStatus = useMemo(() => {
|
2026-05-20 15:12:51 +08:00
|
|
|
|
const base = device?.lastRunningStatus || {};
|
|
|
|
|
|
|
|
|
|
|
|
return isUAV
|
|
|
|
|
|
? base
|
|
|
|
|
|
: {
|
|
|
|
|
|
...base,
|
|
|
|
|
|
...wsDeviceInfo,
|
2026-05-12 10:34:50 +08:00
|
|
|
|
};
|
|
|
|
|
|
}, [device, wsDeviceInfo, isUAV]);
|
2026-05-11 16:34:44 +08:00
|
|
|
|
|
2026-05-20 15:12:51 +08:00
|
|
|
|
const { video: robotVideo, error, ready } = useWebRTCPlayer(
|
2026-05-28 15:17:00 +08:00
|
|
|
|
!isUAV ? serialNumber : '',
|
2026-05-22 09:32:36 +08:00
|
|
|
|
`webrtc://1.95.137.212/live/livestream/${serialNumber}`,
|
2026-05-20 15:12:51 +08:00
|
|
|
|
);
|
2026-05-11 16:34:44 +08:00
|
|
|
|
const getVal = (val) => val === "no_rain" ? "无" : (val || '-');
|
|
|
|
|
|
|
2026-05-12 10:34:50 +08:00
|
|
|
|
|
2026-05-20 15:12:51 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
const controller = new DeviceController(userInfo, messageApi);
|
|
|
|
|
|
|
|
|
|
|
|
controller.onDeviceInfoUpdate = setWsDeviceInfo;
|
|
|
|
|
|
controller.onControlStatusChange = setIsControlled;
|
|
|
|
|
|
controller.onHasControlRightChange = setHasControlRight;
|
|
|
|
|
|
controller.onRequestControlStatusChange = setConnecting;
|
|
|
|
|
|
controller.onWsStatusChange = setWsStatus;
|
2026-05-12 10:34:50 +08:00
|
|
|
|
|
2026-05-20 15:12:51 +08:00
|
|
|
|
controller.onPermissionRequest = (content) => {
|
|
|
|
|
|
setModalContent(content);
|
|
|
|
|
|
setIsModalOpen(true);
|
2026-05-12 10:34:50 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2026-05-20 15:12:51 +08:00
|
|
|
|
controller.init();
|
2026-05-12 10:34:50 +08:00
|
|
|
|
|
2026-05-20 15:12:51 +08:00
|
|
|
|
controllerRef.current = controller;
|
2026-05-12 10:34:50 +08:00
|
|
|
|
|
2026-05-20 15:12:51 +08:00
|
|
|
|
return () => {
|
|
|
|
|
|
controller.destroy();
|
|
|
|
|
|
controllerRef.current = null;
|
|
|
|
|
|
};
|
|
|
|
|
|
}, [userInfo, messageApi]);
|
2026-05-12 10:34:50 +08:00
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2026-05-28 15:17:00 +08:00
|
|
|
|
if (!device || !controllerRef.current || !device?.serialNumber) return;
|
2026-05-12 10:34:50 +08:00
|
|
|
|
|
2026-05-20 15:12:51 +08:00
|
|
|
|
controllerRef.current.connectDevice(device);
|
2026-05-28 15:17:00 +08:00
|
|
|
|
}, [device?.serialNumber]);
|
2026-05-12 10:34:50 +08:00
|
|
|
|
|
2026-05-27 15:08:26 +08:00
|
|
|
|
// 定时获取无人机状态
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
const fetchUavState = async () => {
|
|
|
|
|
|
if (isUAV && device?.gateway_sn && device?.device_sn) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await getUAVState({
|
|
|
|
|
|
sn: device.gateway_sn,
|
|
|
|
|
|
droneSn: device.device_sn
|
|
|
|
|
|
});
|
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
|
setUavState(res.data);
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
console.error('获取无人机状态失败', err);
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setUavState(null);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-06-01 15:44:02 +08:00
|
|
|
|
fetchUavState();
|
2026-05-28 15:17:00 +08:00
|
|
|
|
}, [isUAV, device]);
|
2026-05-27 15:08:26 +08:00
|
|
|
|
|
2026-05-28 15:17:00 +08:00
|
|
|
|
// 获取执行中任务的轨迹
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
const fetchExecutingTaskTrack = async () => {
|
|
|
|
|
|
if (isUAV && device?.gateway_sn) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const todayStart = dayjs().startOf('day').unix();
|
|
|
|
|
|
const todayEnd = dayjs().endOf('day').unix();
|
|
|
|
|
|
const sns = [device.gateway_sn];
|
|
|
|
|
|
|
|
|
|
|
|
const res = await getsinglePlan({ sns, beginAt: todayStart, endAt: todayEnd });
|
|
|
|
|
|
if (res?.code === 200 && res.data) {
|
|
|
|
|
|
let combinedList = [];
|
|
|
|
|
|
Object.values(res.data).forEach((item: any) => {
|
|
|
|
|
|
if (item.list) combinedList = combinedList.concat(item.list);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 筛选出执行中的任务
|
|
|
|
|
|
const executingTask = combinedList.find(t =>
|
|
|
|
|
|
['executing', 'running', 'restored'].includes(t.status)
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if (executingTask) {
|
|
|
|
|
|
const trackRes = await getsinglePlanTrack(executingTask);
|
|
|
|
|
|
if (trackRes.code === 0 && trackRes.data.track?.points?.length) {
|
|
|
|
|
|
const trackPoints = trackRes.data.track.points.map(item => ({
|
|
|
|
|
|
lon: item.longitude || item.lon,
|
|
|
|
|
|
lat: item.latitude || item.lat
|
|
|
|
|
|
}));
|
|
|
|
|
|
setPoints(trackPoints);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setPoints([]);
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setPoints([]);
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setPoints([]);
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
console.error('获取执行中任务轨迹失败', err);
|
|
|
|
|
|
setPoints([]);
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setPoints([]);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2026-05-27 15:08:26 +08:00
|
|
|
|
|
2026-05-28 15:17:00 +08:00
|
|
|
|
fetchExecutingTaskTrack();
|
2026-05-27 15:08:26 +08:00
|
|
|
|
}, [isUAV, device]);
|
|
|
|
|
|
|
2026-05-12 08:48:33 +08:00
|
|
|
|
const mapDevices = useMemo(() => {
|
2026-05-28 15:17:00 +08:00
|
|
|
|
if (!device) return null;
|
|
|
|
|
|
|
2026-06-01 15:44:02 +08:00
|
|
|
|
// 优先使用持久化MQTT数据,其次使用uavState
|
|
|
|
|
|
const lng = currentDroneData?.longitude ?? uavState?.longitude ?? runningStatus.longitude ?? device.longitude;
|
|
|
|
|
|
const lat = currentDroneData?.latitude ?? uavState?.latitude ?? runningStatus.latitude ?? device.latitude;
|
2026-05-20 15:12:51 +08:00
|
|
|
|
|
|
|
|
|
|
return {
|
2026-05-12 08:48:33 +08:00
|
|
|
|
...device,
|
|
|
|
|
|
lastRunningStatus: {
|
|
|
|
|
|
...device.lastRunningStatus,
|
2026-05-28 15:17:00 +08:00
|
|
|
|
longitude: lng,
|
|
|
|
|
|
latitude: lat,
|
2026-05-12 08:48:33 +08:00
|
|
|
|
},
|
2026-05-28 15:17:00 +08:00
|
|
|
|
// 让地图取最新经纬度
|
|
|
|
|
|
longitude: lng,
|
|
|
|
|
|
latitude: lat,
|
|
|
|
|
|
name: device.deviceAlias || device.callsign || device.deviceName || '设备',
|
2026-05-20 15:12:51 +08:00
|
|
|
|
type: isUAV
|
|
|
|
|
|
? 'drone'
|
|
|
|
|
|
: device.productName?.includes('割草机')
|
|
|
|
|
|
? 'mower'
|
|
|
|
|
|
: 'robot',
|
2026-05-12 08:48:33 +08:00
|
|
|
|
};
|
2026-06-01 15:44:02 +08:00
|
|
|
|
}, [device, isUAV, runningStatus, uavState, currentDroneData]);
|
2026-05-28 15:17:00 +08:00
|
|
|
|
const realtimeDevice = useMemo(() => {
|
|
|
|
|
|
if (!device) return null;
|
|
|
|
|
|
return {
|
|
|
|
|
|
...device,
|
2026-06-01 15:44:02 +08:00
|
|
|
|
...uavState,
|
|
|
|
|
|
...currentDroneData, // 持久化数据最后覆盖,确保优先显示
|
2026-05-28 15:17:00 +08:00
|
|
|
|
};
|
2026-06-01 15:44:02 +08:00
|
|
|
|
}, [device, uavState, currentDroneData]);
|
2026-05-12 10:34:50 +08:00
|
|
|
|
|
2026-05-20 15:12:51 +08:00
|
|
|
|
const handleGamepadUpdate = useCallback((state) => {
|
|
|
|
|
|
controllerRef.current?.sendGamepad(state);
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
const handleControlModal = useCallback(() => {
|
|
|
|
|
|
controllerRef.current?.requestControl();
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
const handleOk = () => {
|
|
|
|
|
|
controllerRef.current?.sendPermissionRequest(
|
|
|
|
|
|
true,
|
|
|
|
|
|
'switchResult',
|
|
|
|
|
|
);
|
2026-05-20 17:19:25 +08:00
|
|
|
|
controllerRef.current.setIsControlled(false);
|
2026-05-20 15:12:51 +08:00
|
|
|
|
|
|
|
|
|
|
setIsModalOpen(false);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleCancel = () => {
|
2026-05-20 17:19:25 +08:00
|
|
|
|
|
2026-05-20 15:12:51 +08:00
|
|
|
|
controllerRef.current?.sendPermissionRequest(
|
|
|
|
|
|
false,
|
|
|
|
|
|
'switchResult',
|
|
|
|
|
|
);
|
2026-05-20 17:19:25 +08:00
|
|
|
|
controllerRef.current.setIsControlled(true);
|
2026-05-20 15:12:51 +08:00
|
|
|
|
|
|
|
|
|
|
setIsModalOpen(false);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const fix2 = (val) => {
|
|
|
|
|
|
if (val === null || val === undefined || isNaN(val)) {
|
|
|
|
|
|
return '-';
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return Number(val).toFixed(2);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-05-12 10:34:50 +08:00
|
|
|
|
if (!device) {
|
2026-05-20 15:12:51 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<Empty
|
|
|
|
|
|
description="请选择设备"
|
|
|
|
|
|
style={{ marginTop: 100 }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
);
|
2026-05-12 10:34:50 +08:00
|
|
|
|
}
|
2026-05-12 08:48:33 +08:00
|
|
|
|
|
2026-05-11 16:34:44 +08:00
|
|
|
|
return (
|
2026-05-20 15:12:51 +08:00
|
|
|
|
<div style={{ padding: 0 }}>
|
2026-05-12 10:34:50 +08:00
|
|
|
|
{contextHolder}
|
2026-05-20 15:12:51 +08:00
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
|
style={{
|
|
|
|
|
|
marginBottom: 16,
|
|
|
|
|
|
display: 'flex',
|
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
|
gap: 12,
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
<Text strong>选择设备:</Text>
|
2026-05-20 15:12:51 +08:00
|
|
|
|
|
2026-05-11 16:34:44 +08:00
|
|
|
|
<Select
|
|
|
|
|
|
style={{ width: 280 }}
|
|
|
|
|
|
value={device?.device_sn || device?.serialNumber}
|
2026-05-20 15:12:51 +08:00
|
|
|
|
onChange={(val) => onDeviceChange?.(val)}
|
2026-05-11 16:34:44 +08:00
|
|
|
|
showSearch
|
|
|
|
|
|
optionFilterProp="label"
|
2026-05-21 17:04:21 +08:00
|
|
|
|
options={[
|
|
|
|
|
|
{
|
|
|
|
|
|
label: <span>机器人</span>,
|
|
|
|
|
|
title: 'manager',
|
|
|
|
|
|
options: devicesAll.filter(item => item.serialNumber).map(item => ({
|
|
|
|
|
|
value: item.device_sn || item.serialNumber,
|
|
|
|
|
|
label: item.deviceAlias || item.deviceName || '未知设备'
|
|
|
|
|
|
})),
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
label: <span>无人机</span>,
|
|
|
|
|
|
title: 'engineer',
|
2026-05-25 15:26:28 +08:00
|
|
|
|
options: devicesAll.filter(item => item.gateway_sn).map(item => ({
|
2026-05-21 17:04:21 +08:00
|
|
|
|
value: item.device_sn,
|
|
|
|
|
|
label: item.drone_callsign || item.callsign || '未知设备'
|
|
|
|
|
|
})),
|
|
|
|
|
|
},
|
|
|
|
|
|
]}
|
2026-05-11 16:34:44 +08:00
|
|
|
|
/>
|
2026-05-20 15:12:51 +08:00
|
|
|
|
|
|
|
|
|
|
<Tag color="blue">
|
|
|
|
|
|
{isUAV ? '无人机' : '机器人'}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
|
2026-05-21 17:04:21 +08:00
|
|
|
|
|
2026-05-12 17:31:34 +08:00
|
|
|
|
</div>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
|
|
|
|
|
|
<Row gutter={[16, 16]}>
|
|
|
|
|
|
<Col xs={24} lg={16}>
|
|
|
|
|
|
<Card
|
2026-05-20 15:12:51 +08:00
|
|
|
|
title={
|
|
|
|
|
|
<>
|
|
|
|
|
|
<VideoCameraOutlined />
|
|
|
|
|
|
实时视频监控
|
|
|
|
|
|
</>
|
|
|
|
|
|
}
|
2026-05-11 16:34:44 +08:00
|
|
|
|
bordered={false}
|
2026-05-20 15:12:51 +08:00
|
|
|
|
style={{ borderRadius: 12 }}
|
2026-05-11 16:34:44 +08:00
|
|
|
|
bodyStyle={{ padding: 12 }}
|
|
|
|
|
|
>
|
2026-05-12 17:31:34 +08:00
|
|
|
|
{!isUAV && (
|
2026-05-20 15:12:51 +08:00
|
|
|
|
<Space style={{ marginBottom: 12 }}>
|
2026-05-12 17:31:34 +08:00
|
|
|
|
<Button type={mowerView === 'front' ? 'primary' : 'default'} icon={<CameraOutlined />} onClick={() => setMowerView('front')}>前视</Button>
|
|
|
|
|
|
<Button type={mowerView === 'back' ? 'primary' : 'default'} onClick={() => setMowerView('back')}>后视</Button>
|
|
|
|
|
|
<Button type={mowerView === 'left' ? 'primary' : 'default'} onClick={() => setMowerView('left')}>左视</Button>
|
|
|
|
|
|
<Button type={mowerView === 'right' ? 'primary' : 'default'} onClick={() => setMowerView('right')}>右视</Button>
|
2026-05-22 08:03:30 +08:00
|
|
|
|
{/*<Button type={mowerView === 'top' ? 'primary' : 'default'} onClick={() => setMowerView('top')}>顶视</Button>*/}
|
2026-05-12 17:31:34 +08:00
|
|
|
|
<Button type={mowerView === 'all' ? 'primary' : 'default'} onClick={() => setMowerView('all')}>全景</Button>
|
|
|
|
|
|
</Space>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
2026-05-20 15:12:51 +08:00
|
|
|
|
<div
|
|
|
|
|
|
style={{
|
2026-05-27 14:30:46 +08:00
|
|
|
|
height: 450,
|
2026-05-20 15:12:51 +08:00
|
|
|
|
borderRadius: 8,
|
|
|
|
|
|
overflow: 'hidden',
|
|
|
|
|
|
display: 'flex',
|
2026-05-27 14:30:46 +08:00
|
|
|
|
// flexWrap: 'wrap', // 左右排布不换行
|
2026-05-20 15:12:51 +08:00
|
|
|
|
}}
|
|
|
|
|
|
>
|
2026-05-12 17:31:34 +08:00
|
|
|
|
{isUAV ? (
|
2026-05-25 10:30:20 +08:00
|
|
|
|
<DroneVideoPlayer
|
2026-05-28 15:17:00 +08:00
|
|
|
|
device={realtimeDevice}
|
|
|
|
|
|
|
2026-05-25 10:30:20 +08:00
|
|
|
|
height={450}
|
2026-05-28 15:17:00 +08:00
|
|
|
|
|
2026-05-27 14:30:46 +08:00
|
|
|
|
dualVideo={true}
|
|
|
|
|
|
showSourceSelect={false}
|
2026-05-25 10:30:20 +08:00
|
|
|
|
defaultSource="drone"
|
|
|
|
|
|
/>
|
2026-05-20 15:12:51 +08:00
|
|
|
|
) : robotVideo ? (
|
2026-05-22 08:03:30 +08:00
|
|
|
|
// 全景模式 = 4 分屏
|
|
|
|
|
|
mowerView === 'all' ? (
|
|
|
|
|
|
<div style={{
|
|
|
|
|
|
display: 'grid',
|
|
|
|
|
|
gridTemplateColumns: '1fr 1fr',
|
|
|
|
|
|
width: '100%',
|
|
|
|
|
|
height: '100%'
|
|
|
|
|
|
}}>
|
|
|
|
|
|
{/* 前 */}
|
|
|
|
|
|
<div style={{ position: 'relative', border: '1px solid #222' }}>
|
|
|
|
|
|
<VideoPlayer
|
|
|
|
|
|
deviceId={serialNumber}
|
|
|
|
|
|
idx={1}
|
|
|
|
|
|
className="w-full h-full object-contain"
|
|
|
|
|
|
video={robotVideo}
|
|
|
|
|
|
error={error}
|
|
|
|
|
|
ready={ready}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<div style={{ position: 'absolute', top: 4, left: 8, color: '#fff', fontSize: 12, background: '#0006', padding: '2px 6px', borderRadius: 4 }}>前视</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{/* 后 */}
|
|
|
|
|
|
<div style={{ position: 'relative', border: '1px solid #222' }}>
|
|
|
|
|
|
<VideoPlayer
|
|
|
|
|
|
deviceId={serialNumber}
|
|
|
|
|
|
idx={2}
|
|
|
|
|
|
className="w-full h-full object-contain"
|
|
|
|
|
|
video={robotVideo}
|
|
|
|
|
|
error={error}
|
|
|
|
|
|
ready={ready}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<div style={{ position: 'absolute', top: 4, left: 8, color: '#fff', fontSize: 12, background: '#0006', padding: '2px 6px', borderRadius: 4 }}>后视</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{/* 左 */}
|
|
|
|
|
|
<div style={{ position: 'relative', border: '1px solid #222' }}>
|
|
|
|
|
|
<VideoPlayer
|
|
|
|
|
|
deviceId={serialNumber}
|
|
|
|
|
|
idx={3}
|
|
|
|
|
|
className="w-full h-full object-contain"
|
|
|
|
|
|
video={robotVideo}
|
|
|
|
|
|
error={error}
|
|
|
|
|
|
ready={ready}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<div style={{ position: 'absolute', top: 4, left: 8, color: '#fff', fontSize: 12, background: '#0006', padding: '2px 6px', borderRadius: 4 }}>左视</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
{/* 右 */}
|
|
|
|
|
|
<div style={{ position: 'relative', border: '1px solid #222' }}>
|
|
|
|
|
|
<VideoPlayer
|
|
|
|
|
|
deviceId={serialNumber}
|
|
|
|
|
|
idx={4}
|
|
|
|
|
|
className="w-full h-full object-contain"
|
|
|
|
|
|
video={robotVideo}
|
|
|
|
|
|
error={error}
|
|
|
|
|
|
ready={ready}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<div style={{ position: 'absolute', top: 4, left: 8, color: '#fff', fontSize: 12, background: '#0006', padding: '2px 6px', borderRadius: 4 }}>右视</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
// 单画面模式
|
|
|
|
|
|
<VideoPlayer
|
|
|
|
|
|
deviceId={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}
|
|
|
|
|
|
/>
|
|
|
|
|
|
)
|
2026-05-11 16:34:44 +08:00
|
|
|
|
) : (
|
2026-05-20 15:12:51 +08:00
|
|
|
|
<div style={{ color: '#ccc', margin: 'auto' }}>
|
|
|
|
|
|
视频加载中...
|
|
|
|
|
|
</div>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
|
|
<Card
|
2026-05-20 15:12:51 +08:00
|
|
|
|
title={
|
|
|
|
|
|
<>
|
|
|
|
|
|
<GlobalOutlined />
|
|
|
|
|
|
位置态势图
|
|
|
|
|
|
</>
|
|
|
|
|
|
}
|
2026-05-11 16:34:44 +08:00
|
|
|
|
bordered={false}
|
|
|
|
|
|
style={{ borderRadius: 12 }}
|
2026-05-20 15:12:51 +08:00
|
|
|
|
bodyStyle={{
|
|
|
|
|
|
padding: 12,
|
|
|
|
|
|
height: 400,
|
|
|
|
|
|
}}
|
2026-05-11 16:34:44 +08:00
|
|
|
|
>
|
2026-05-28 15:17:00 +08:00
|
|
|
|
<CesiumMap devices={[mapDevices]} points={points} />
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Card>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
|
|
|
|
|
|
<Col xs={24} lg={8}>
|
|
|
|
|
|
<Card
|
|
|
|
|
|
title={<><DashboardOutlined /> {isUAV ? '无人机状态' : '机器人状态'}详情</>}
|
|
|
|
|
|
bordered={false}
|
|
|
|
|
|
style={{ borderRadius: 12, marginBottom: 16 }}
|
|
|
|
|
|
extra={<Tag color={device.onlineStatus === 1 ? 'success' : 'default'}>{device.onlineStatus === 1 ? '在线' : '离线'}</Tag>}
|
|
|
|
|
|
>
|
|
|
|
|
|
{isUAV ? (
|
|
|
|
|
|
<Descriptions column={2} size="small" layout="vertical">
|
|
|
|
|
|
<Descriptions.Item label={<><ThunderboltOutlined /> 电池电量</>}>
|
2026-06-01 15:44:02 +08:00
|
|
|
|
<Progress percent={(currentDroneData || uavState || device).capacity_percent || 0} size="small" status={((currentDroneData || uavState || device).capacity_percent || 0) < 20 ? 'exception' : 'active'} />
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label={<><EnvironmentOutlined /> 飞行高度</>}>
|
2026-06-01 15:44:02 +08:00
|
|
|
|
<Text strong style={{ fontSize: 16 }}>{fix2((currentDroneData || uavState || device).height)} m</Text>
|
|
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="环境风速"><Text>{fix2((currentDroneData || uavState || device).wind_speed)} m/s</Text></Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="环境温度"><Text>{fix2((currentDroneData || uavState || device).environment_temperature)} ℃</Text></Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="环境湿度">
|
|
|
|
|
|
<Text>{(currentDroneData?.humidity) || '-'}{currentDroneData?.humidity ? '%' : ''}</Text>
|
|
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="机场温度">
|
|
|
|
|
|
<Text>{fix2(currentDroneData?.temperature)} ℃</Text>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="降雨状态">
|
2026-06-01 15:44:02 +08:00
|
|
|
|
<Tag color={(currentDroneData || uavState || device).rainfall === 'no_rain' ? 'green' : 'red'}>{getVal((currentDroneData || uavState || device).rainfall)}</Tag>
|
|
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="返航距离"><Text>{fix2((currentDroneData || uavState || device).home_distance)} m</Text></Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="航向角">
|
|
|
|
|
|
<Text>{fix2(currentDroneData?.heading)}°</Text>
|
|
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="无人机位置">
|
|
|
|
|
|
<Tag color="blue">
|
|
|
|
|
|
{currentDroneData?.drone_in_dock === 1 ? '在库' : '外出'}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="机库状态">
|
|
|
|
|
|
<Tag color={currentDroneData?.cover_state === 1 ? 'processing' : 'default'}>
|
|
|
|
|
|
{currentDroneData?.cover_state === 1 ? '舱门打开' : '舱门关闭'}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="机场空调">
|
|
|
|
|
|
<Tag color={currentDroneData?.air_conditioner_state === 1 ? 'success' : 'default'}>
|
|
|
|
|
|
{currentDroneData?.air_conditioner_state === 1 ? '开启' : '关闭'}
|
|
|
|
|
|
</Tag>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="GPS 卫星数">
|
2026-06-01 15:44:02 +08:00
|
|
|
|
<Badge count={(currentDroneData || uavState || device).position_state?.gps_number || 0} style={{ backgroundColor: '#1890ff' }} />
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="RTK 卫星数">
|
2026-06-01 15:44:02 +08:00
|
|
|
|
<Badge count={(currentDroneData || uavState || device).position_state?.rtk_number || 0} style={{ backgroundColor: '#52c41a' }} />
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="RTK 状态" span={2}>
|
2026-06-01 15:44:02 +08:00
|
|
|
|
<Tag color={(currentDroneData || uavState || device).position_state?.is_fixed === 'fixing_successful' ? 'success' : 'warning'}>
|
|
|
|
|
|
{(currentDroneData || uavState || device).position_state?.is_fixed === 'fixing_successful' ? 'RTK 已固定' : '未固定'}
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Tag>
|
|
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
</Descriptions>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<Descriptions column={2} size="small" layout="vertical">
|
|
|
|
|
|
<Descriptions.Item label={<><ThunderboltOutlined /> 电池电量</>}>
|
2026-05-12 17:31:34 +08:00
|
|
|
|
<Progress percent={runningStatus.battery || 0} size="small" status={(runningStatus.battery || 0) < 20 ? 'exception' : 'active'} />
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label={<><DashboardOutlined /> 系统电压</>}>
|
2026-05-12 10:34:50 +08:00
|
|
|
|
<Text strong style={{ fontSize: 16 }}>{fix2(runningStatus.voltage)} V</Text>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions.Item>
|
2026-05-12 17:31:34 +08:00
|
|
|
|
<Descriptions.Item label="左电机电流"><Text>{fix2(runningStatus?.leftCurrent)} A</Text></Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="右电机电流"><Text>{fix2(runningStatus?.rightCurrent)} A</Text></Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="左轮速度"><Text>{fix2(runningStatus?.leftMeasureSpeed)} m/s</Text></Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="右轮速度"><Text>{fix2(runningStatus?.rightMeasureSpeed)} m/s</Text></Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="左电机温度"><Text>{fix2(runningStatus?.leftMotorTemp)} ℃</Text></Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="右电机温度"><Text>{fix2(runningStatus?.rightMotorTemp)} ℃</Text></Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="主控温度"><Text>{fix2(runningStatus?.chipTemp)} ℃</Text></Descriptions.Item>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
<Descriptions.Item label="卫星数量">
|
2026-05-12 17:31:34 +08:00
|
|
|
|
<Badge showZero count={runningStatus?.satelliteCnt || 0} style={{ backgroundColor: '#52c41a' }} />
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions.Item>
|
2026-05-12 17:31:34 +08:00
|
|
|
|
<Descriptions.Item label="偏航角 (Yaw)"><Text>{fix2(runningStatus?.yaw)}°</Text></Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="俯仰角 (Pitch)"><Text>{fix2(runningStatus?.pitch)}°</Text></Descriptions.Item>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Card>
|
2026-05-12 08:34:13 +08:00
|
|
|
|
{!isUAV && (
|
2026-05-11 16:34:44 +08:00
|
|
|
|
<Card
|
2026-05-20 15:12:51 +08:00
|
|
|
|
title={
|
|
|
|
|
|
<>
|
|
|
|
|
|
<ControlOutlined />
|
|
|
|
|
|
远程控制
|
|
|
|
|
|
</>
|
|
|
|
|
|
}
|
2026-05-11 16:34:44 +08:00
|
|
|
|
bordered={false}
|
2026-05-20 15:12:51 +08:00
|
|
|
|
style={{
|
|
|
|
|
|
borderRadius: 12,
|
|
|
|
|
|
background: '#0f172a',
|
|
|
|
|
|
}}
|
|
|
|
|
|
headStyle={{ color: '#fff' }}
|
2026-05-11 16:34:44 +08:00
|
|
|
|
>
|
|
|
|
|
|
<XboxController
|
|
|
|
|
|
onGamepadUpdate={handleGamepadUpdate}
|
|
|
|
|
|
handleControlModal={handleControlModal}
|
|
|
|
|
|
isControlled={isControlled}
|
2026-05-20 15:12:51 +08:00
|
|
|
|
hasControlRight={hasControlRight}
|
|
|
|
|
|
isConnecting={connecting}
|
2026-05-11 16:34:44 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
2026-05-12 10:34:50 +08:00
|
|
|
|
|
|
|
|
|
|
<Modal
|
|
|
|
|
|
open={isModalOpen}
|
|
|
|
|
|
onOk={handleOk}
|
|
|
|
|
|
onCancel={handleCancel}
|
2026-05-20 15:12:51 +08:00
|
|
|
|
title={modalContent.title}
|
2026-05-12 10:34:50 +08:00
|
|
|
|
okText="确定"
|
|
|
|
|
|
cancelText="取消"
|
|
|
|
|
|
>
|
|
|
|
|
|
<p>{modalContent.content}</p>
|
|
|
|
|
|
</Modal>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|