2026-05-12 10:34:50 +08:00
|
|
|
|
import React, { useState, useEffect, useMemo, useCallback, useRef } from 'react';
|
2026-05-11 16:34:44 +08:00
|
|
|
|
import {
|
|
|
|
|
|
Row, Col, Card, Statistic, Tag, Typography,
|
|
|
|
|
|
Space, Empty, Descriptions, Badge, Progress, Button,
|
2026-05-12 10:34:50 +08:00
|
|
|
|
Divider, Select, message, Modal
|
2026-05-11 16:34:44 +08:00
|
|
|
|
} from 'antd';
|
|
|
|
|
|
import {
|
|
|
|
|
|
ThunderboltOutlined, DashboardOutlined, AimOutlined,
|
|
|
|
|
|
EnvironmentOutlined, RocketOutlined, GlobalOutlined,
|
2026-05-12 10:34:50 +08:00
|
|
|
|
VideoCameraOutlined, ControlOutlined,
|
2026-05-11 16:34:44 +08:00
|
|
|
|
} from '@ant-design/icons';
|
|
|
|
|
|
import XboxController from './XboxController';
|
|
|
|
|
|
import DroneLivePlayer from '../VolcRtcPlayer.jsx';
|
2026-05-12 10:34:50 +08:00
|
|
|
|
import { getLiveStream, getControlRight, getJurisdiction } from '../../api/device.ts';
|
2026-05-12 08:34:13 +08:00
|
|
|
|
import CesiumMap from '../Map.jsx';
|
2026-05-12 10:34:50 +08:00
|
|
|
|
import { wsManager } from '../WebSocketManager.ts';
|
|
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
|
import { RootState } from '@/src/store/index.ts';
|
|
|
|
|
|
import envConfig from '../../../env';
|
2026-05-11 16:34:44 +08:00
|
|
|
|
|
2026-05-12 10:34:50 +08:00
|
|
|
|
const { Text } = Typography;
|
|
|
|
|
|
|
|
|
|
|
|
const OBSTACLE_TYPE = {
|
|
|
|
|
|
0: '未知',
|
|
|
|
|
|
1: '人',
|
|
|
|
|
|
2: '车辆',
|
|
|
|
|
|
3: '围栏',
|
|
|
|
|
|
4: '坑洞',
|
|
|
|
|
|
5: '草丛',
|
|
|
|
|
|
};
|
2026-05-11 16:34:44 +08:00
|
|
|
|
|
|
|
|
|
|
export default function DeviceStatusPage({ devicesAll, serialNumber, onDeviceChange }) {
|
|
|
|
|
|
const [planeVideo, setPlaneVideo] = useState([]);
|
|
|
|
|
|
const [isControlled, setIsControlled] = useState(false);
|
2026-05-12 10:34:50 +08:00
|
|
|
|
const [wsDeviceInfo, setWsDeviceInfo] = useState({});
|
|
|
|
|
|
const [wsStatus, setWsStatus] = useState('disconnected');
|
|
|
|
|
|
const [isRequestControl, setIsRequestControl] = useState(false);
|
|
|
|
|
|
const connectedDeviceSnRef = useRef(null);
|
|
|
|
|
|
const requestDeviceId = useRef('');
|
|
|
|
|
|
const controlRef = useRef(false);
|
|
|
|
|
|
const { userInfo } = useSelector((state: RootState) => state.user);
|
|
|
|
|
|
const [messageApi, contextHolder] = message.useMessage();
|
|
|
|
|
|
|
|
|
|
|
|
// 权限请求弹窗相关
|
|
|
|
|
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
|
|
|
|
const [modalContent, setModalContent] = useState({ title: '', content: '' });
|
|
|
|
|
|
const [modelType, setModelType] = useState('');
|
|
|
|
|
|
const [hasControlRight, setHasContronRight] = useState(false);
|
2026-05-11 16:34:44 +08:00
|
|
|
|
|
|
|
|
|
|
// 获取选中的设备详情
|
|
|
|
|
|
const device = useMemo(() => {
|
|
|
|
|
|
const sn = serialNumber || (devicesAll?.[0]?.device_sn || devicesAll?.[0]?.serialNumber);
|
|
|
|
|
|
if (!sn) return null;
|
2026-05-12 08:34:13 +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-12 08:34:13 +08:00
|
|
|
|
return device && (device.device_sn);
|
2026-05-11 16:34:44 +08:00
|
|
|
|
}, [device]);
|
|
|
|
|
|
|
2026-05-12 10:34:50 +08:00
|
|
|
|
// 优先显示 WebSocket 推送的实时数据,如果没有则显示接口返回的 lastRunningStatus
|
|
|
|
|
|
const runningStatus = useMemo(() => {
|
|
|
|
|
|
const baseStatus = device?.lastRunningStatus || {};
|
|
|
|
|
|
if (!isUAV && Object.keys(wsDeviceInfo).length > 0) {
|
|
|
|
|
|
return {
|
|
|
|
|
|
...baseStatus,
|
|
|
|
|
|
...wsDeviceInfo
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
return baseStatus;
|
|
|
|
|
|
}, [device, wsDeviceInfo, isUAV]);
|
2026-05-11 16:34:44 +08:00
|
|
|
|
|
|
|
|
|
|
// 辅助函数:数字格式化
|
|
|
|
|
|
const fix2 = (val) => {
|
|
|
|
|
|
if (val === null || val === undefined || isNaN(val)) return '-';
|
|
|
|
|
|
return Number(val).toFixed(2);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 辅助函数:安全取值
|
|
|
|
|
|
const getVal = (val) => val === "no_rain" ? "无" : (val || '-');
|
|
|
|
|
|
|
2026-05-12 10:34:50 +08:00
|
|
|
|
// 获取权限
|
|
|
|
|
|
const getControl = useCallback((serialnum) => {
|
|
|
|
|
|
const data = { platform: "web", deviceId: serialnum };
|
|
|
|
|
|
getJurisdiction(data).then(res => {
|
|
|
|
|
|
if (res?.code == 200 && res?.data?.remoteControl == true) {
|
|
|
|
|
|
controlRef.current = true;
|
|
|
|
|
|
setIsControlled(true);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
controlRef.current = false;
|
|
|
|
|
|
setIsControlled(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
|
controlRef.current = false;
|
|
|
|
|
|
setIsControlled(false);
|
|
|
|
|
|
})
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
const showModal = (content, type) => {
|
|
|
|
|
|
setModalContent(content);
|
|
|
|
|
|
setModelType(type);
|
|
|
|
|
|
setIsModalOpen(true);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const sendPermissionRequest = (data, type) => {
|
|
|
|
|
|
const wsdata = {
|
|
|
|
|
|
type: type,
|
|
|
|
|
|
switchResult: data,
|
|
|
|
|
|
token: userInfo.token,
|
|
|
|
|
|
deviceId: type === "switchPermission" ? connectedDeviceSnRef.current : requestDeviceId.current,
|
|
|
|
|
|
userName: userInfo.username,
|
|
|
|
|
|
};
|
|
|
|
|
|
wsManager.send(wsdata);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleOk = () => {
|
|
|
|
|
|
sendPermissionRequest(true, modelType);
|
|
|
|
|
|
if (modelType === "switchPermission") {
|
|
|
|
|
|
setIsRequestControl(true);
|
|
|
|
|
|
messageApi.loading({
|
|
|
|
|
|
key: "control",
|
|
|
|
|
|
content: '权限请求中...',
|
|
|
|
|
|
duration: 0,
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
if (requestDeviceId.current === connectedDeviceSnRef.current) {
|
|
|
|
|
|
controlRef.current = false;
|
|
|
|
|
|
setIsControlled(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
setIsModalOpen(false);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleCancel = () => {
|
|
|
|
|
|
if (modelType === "switchPermission") {
|
|
|
|
|
|
setIsRequestControl(false);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
sendPermissionRequest(false, modelType);
|
|
|
|
|
|
}
|
|
|
|
|
|
setIsModalOpen(false);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// WebSocket 消息处理
|
|
|
|
|
|
const handleWsMessage = useCallback((messageData) => {
|
|
|
|
|
|
switch (messageData.type) {
|
|
|
|
|
|
case 'deviceInfo':
|
|
|
|
|
|
const deviceData = {};
|
|
|
|
|
|
messageData.data.forEach(item => {
|
|
|
|
|
|
deviceData[item.name] = item.value;
|
|
|
|
|
|
});
|
|
|
|
|
|
setWsDeviceInfo(deviceData);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'AUTH':
|
|
|
|
|
|
if (messageData.isAuth === true) {
|
|
|
|
|
|
getControl(connectedDeviceSnRef.current);
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'switchResult':
|
|
|
|
|
|
messageApi.success({
|
|
|
|
|
|
content: '权限获取成功',
|
|
|
|
|
|
key: 'control',
|
|
|
|
|
|
duration: 2,
|
|
|
|
|
|
});
|
|
|
|
|
|
setIsRequestControl(false);
|
|
|
|
|
|
controlRef.current = true;
|
|
|
|
|
|
setIsControlled(true);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'switchPermission':
|
|
|
|
|
|
console.log("平台请求权限", messageData.platform);
|
|
|
|
|
|
const rawPlatform = messageData.platform;
|
|
|
|
|
|
if (rawPlatform == "null") {
|
|
|
|
|
|
console.log("platform 为空,终止逻辑");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const platform = (messageData.platform || '').toLowerCase().trim();
|
|
|
|
|
|
if (platform === "web" || !platform) {
|
|
|
|
|
|
console.log("检测到web平台,执行return终止逻辑");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
requestDeviceId.current = messageData.deviceId;
|
|
|
|
|
|
showModal({
|
|
|
|
|
|
title: "权限请求",
|
|
|
|
|
|
content: `${messageData.platform || '未知平台'}请求控制${requestDeviceId.current === connectedDeviceSnRef.current ? "" : requestDeviceId.current}权限, 是否同意?`
|
|
|
|
|
|
}, 'switchResult');
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 'detectionReport':
|
|
|
|
|
|
const obsData = messageData.data;
|
|
|
|
|
|
if (obsData && obsData.deviceId === connectedDeviceSnRef.current) {
|
|
|
|
|
|
const type = obsData?.obstacle?.type;
|
|
|
|
|
|
const isSecure = obsData?.isSecure;
|
|
|
|
|
|
const distance = obsData?.obstacle?.distance?.toFixed(2);
|
|
|
|
|
|
if (isSecure) return;
|
|
|
|
|
|
|
|
|
|
|
|
messageApi.warning({
|
|
|
|
|
|
key: 'obstacle-warning',
|
|
|
|
|
|
content: `设备检测到${OBSTACLE_TYPE[type] ?? '未知物'},距离 ${distance}m!`,
|
|
|
|
|
|
duration: 3,
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}, [getControl, messageApi]);
|
|
|
|
|
|
|
|
|
|
|
|
// 连接设备 WebSocket
|
|
|
|
|
|
const connectDevice = useCallback(async (targetDevice) => {
|
|
|
|
|
|
if (!targetDevice || isUAV) return;
|
|
|
|
|
|
|
|
|
|
|
|
wsManager.close();
|
|
|
|
|
|
connectedDeviceSnRef.current = null;
|
|
|
|
|
|
setWsDeviceInfo({});
|
|
|
|
|
|
|
|
|
|
|
|
const token = userInfo.token;
|
|
|
|
|
|
console.log(token, "token", userInfo)
|
|
|
|
|
|
const userName = userInfo.username;
|
|
|
|
|
|
|
|
|
|
|
|
const wsUrl = envConfig.WS_URL || "wss://ri.satabot.com/ws/";
|
|
|
|
|
|
wsManager.connect(targetDevice.serialNumber || targetDevice.device_sn, wsUrl);
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
const res = await getControlRight({
|
|
|
|
|
|
userName,
|
|
|
|
|
|
sourceType: 1,
|
|
|
|
|
|
token,
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (res?.code == 200) {
|
|
|
|
|
|
connectedDeviceSnRef.current = targetDevice.serialNumber || targetDevice.device_sn;
|
|
|
|
|
|
setHasContronRight(true);
|
|
|
|
|
|
await getControl(connectedDeviceSnRef.current);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setHasContronRight(false);
|
|
|
|
|
|
messageApi.warning("其他端正在控制");
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
|
messageApi.error("权限校验失败");
|
|
|
|
|
|
}
|
|
|
|
|
|
}, [isUAV, getControl, userInfo, messageApi]);
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (device) {
|
|
|
|
|
|
connectDevice(device);
|
|
|
|
|
|
}
|
|
|
|
|
|
return () => {
|
|
|
|
|
|
wsManager.close();
|
|
|
|
|
|
};
|
|
|
|
|
|
}, [device, connectDevice]);
|
|
|
|
|
|
|
|
|
|
|
|
// 监听 WS 状态和消息
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
const unsubStatus = wsManager.onStatusChange(setWsStatus);
|
|
|
|
|
|
const unsubMsg = wsManager.onMessage(handleWsMessage);
|
|
|
|
|
|
return () => {
|
|
|
|
|
|
unsubStatus();
|
|
|
|
|
|
unsubMsg();
|
|
|
|
|
|
};
|
|
|
|
|
|
}, [handleWsMessage]);
|
|
|
|
|
|
|
2026-05-11 16:34:44 +08:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (!device?.gateway_sn) {
|
|
|
|
|
|
setPlaneVideo([]);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
const data = {
|
|
|
|
|
|
getway_sn: device?.gateway_sn,
|
|
|
|
|
|
drone_sn: device?.device_sn,
|
|
|
|
|
|
getway_camera_list: device?.gateway_camera_list ?? [],
|
|
|
|
|
|
drone_camera_list: device?.drone_camera_list ?? [],
|
|
|
|
|
|
video_expire: 7200,
|
|
|
|
|
|
quality_type: "adaptive",
|
|
|
|
|
|
}
|
|
|
|
|
|
getLiveStream(data).then(res => {
|
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
|
setPlaneVideo(res.data || []);
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}, [device]);
|
|
|
|
|
|
|
|
|
|
|
|
const handleGamepadUpdate = (state) => {
|
2026-05-12 10:34:50 +08:00
|
|
|
|
if (!isControlled || !connectedDeviceSnRef.current) return;
|
2026-05-11 16:34:44 +08:00
|
|
|
|
|
2026-05-12 10:34:50 +08:00
|
|
|
|
// 参考 DeviceControl.tsx 的逻辑发送手柄指令
|
|
|
|
|
|
const payload = {
|
|
|
|
|
|
type: 'gamepad',
|
|
|
|
|
|
deviceId: connectedDeviceSnRef.current,
|
|
|
|
|
|
data: {
|
|
|
|
|
|
axes: state.axes,
|
|
|
|
|
|
buttons: state.buttons
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
wsManager.send(payload);
|
2026-05-11 16:34:44 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2026-05-12 10:34:50 +08:00
|
|
|
|
const handleControlModal = (data) => {
|
|
|
|
|
|
if (isRequestControl) return;
|
|
|
|
|
|
if (data.control == true) {
|
|
|
|
|
|
showModal({ title: "权限请求", content: "是否请求控制权限?" }, 'switchPermission');
|
|
|
|
|
|
} else {
|
|
|
|
|
|
setIsModalOpen(false);
|
|
|
|
|
|
}
|
2026-05-11 16:34:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-05-12 08:48:33 +08:00
|
|
|
|
// 归一化地图显示的设备列表
|
|
|
|
|
|
const mapDevices = useMemo(() => {
|
|
|
|
|
|
if (!device) return [];
|
|
|
|
|
|
const normalizedDevice = {
|
|
|
|
|
|
...device,
|
|
|
|
|
|
lastRunningStatus: {
|
|
|
|
|
|
...device.lastRunningStatus,
|
2026-05-12 10:34:50 +08:00
|
|
|
|
longitude: runningStatus.longitude || device.longitude,
|
|
|
|
|
|
latitude: runningStatus.latitude || device.latitude,
|
2026-05-12 08:48:33 +08:00
|
|
|
|
},
|
|
|
|
|
|
name: device.deviceAlias || device.callsign || device.deviceName || '当前设备',
|
|
|
|
|
|
type: isUAV ? 'drone' : (device.productName?.includes('割草机') ? 'mower' : 'robot')
|
|
|
|
|
|
};
|
|
|
|
|
|
return [normalizedDevice];
|
2026-05-12 10:34:50 +08:00
|
|
|
|
}, [device, isUAV, runningStatus]);
|
|
|
|
|
|
|
|
|
|
|
|
if (!device) {
|
|
|
|
|
|
return <Empty description="请选择一个设备以查看状态" style={{ marginTop: 100 }} />;
|
|
|
|
|
|
}
|
2026-05-12 08:48:33 +08:00
|
|
|
|
|
2026-05-11 16:34:44 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<div style={{ padding: '0px' }}>
|
2026-05-12 10:34:50 +08:00
|
|
|
|
{contextHolder}
|
2026-05-11 16:34:44 +08:00
|
|
|
|
<div style={{ marginBottom: 16, display: 'flex', alignItems: 'center', gap: 12 }}>
|
|
|
|
|
|
<Text strong>选择设备:</Text>
|
|
|
|
|
|
<Select
|
|
|
|
|
|
style={{ width: 280 }}
|
|
|
|
|
|
placeholder="请选择要查看的设备"
|
|
|
|
|
|
value={device?.device_sn || device?.serialNumber}
|
|
|
|
|
|
onChange={(val) => onDeviceChange && onDeviceChange(val)}
|
|
|
|
|
|
showSearch
|
|
|
|
|
|
optionFilterProp="label"
|
|
|
|
|
|
options={devicesAll?.map(item => ({
|
|
|
|
|
|
value: item.device_sn || item.serialNumber,
|
|
|
|
|
|
label: item.deviceAlias || item.drone_callsign || item.callsign || item.deviceName || '未知设备'
|
|
|
|
|
|
}))}
|
|
|
|
|
|
/>
|
|
|
|
|
|
{device && (
|
|
|
|
|
|
<Tag color="blue" style={{ marginLeft: 8 }}>
|
|
|
|
|
|
{isUAV ? '无人机' : '机器人'}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
)}
|
2026-05-12 10:34:50 +08:00
|
|
|
|
{wsStatus === 'connected' && (
|
|
|
|
|
|
<Badge
|
|
|
|
|
|
status="processing"
|
|
|
|
|
|
color="#52c41a"
|
|
|
|
|
|
text="实时连接中"
|
|
|
|
|
|
style={{ color: '#52c41a' }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
)} </div>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
|
|
|
|
|
|
<Row gutter={[16, 16]}>
|
|
|
|
|
|
{/* 左侧:视频和地图 */}
|
|
|
|
|
|
<Col xs={24} lg={16}>
|
|
|
|
|
|
<Card
|
|
|
|
|
|
title={<><VideoCameraOutlined /> 实时视频监控 - {device.deviceAlias || device.callsign || '监控画面'}</>}
|
|
|
|
|
|
bordered={false}
|
|
|
|
|
|
style={{ borderRadius: 12, marginBottom: 16 }}
|
|
|
|
|
|
bodyStyle={{ padding: 12 }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<div style={{
|
|
|
|
|
|
display: 'grid',
|
|
|
|
|
|
gap: '8px',
|
|
|
|
|
|
gridTemplateColumns: planeVideo.length > 1 ? '1fr 1fr' : '1fr',
|
|
|
|
|
|
gridTemplateRows: planeVideo.length > 2 ? '1fr 1fr' : '1fr',
|
|
|
|
|
|
height: 450,
|
|
|
|
|
|
background: '#000',
|
|
|
|
|
|
borderRadius: 8,
|
|
|
|
|
|
overflow: 'hidden'
|
|
|
|
|
|
}}>
|
|
|
|
|
|
{planeVideo.length > 0 ? (
|
|
|
|
|
|
planeVideo.map((stream, index) => (
|
|
|
|
|
|
<div key={index} style={{
|
|
|
|
|
|
position: 'relative',
|
|
|
|
|
|
gridColumn: (planeVideo.length === 3 && index === 0) ? 'span 2' : 'span 1'
|
|
|
|
|
|
}}>
|
|
|
|
|
|
<DroneLivePlayer streamData={stream} />
|
|
|
|
|
|
<div style={{
|
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
|
top: 8,
|
|
|
|
|
|
left: 8,
|
|
|
|
|
|
background: 'rgba(0,0,0,0.5)',
|
|
|
|
|
|
color: '#fff',
|
|
|
|
|
|
padding: '2px 8px',
|
|
|
|
|
|
borderRadius: 4,
|
|
|
|
|
|
fontSize: 12
|
|
|
|
|
|
}}>
|
2026-05-12 08:34:13 +08:00
|
|
|
|
{stream?.camera_position === 'indoor' ? '库内监控' : `画面 ${index + 1}`}
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
))
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#666', gridColumn: 'span 2' }}>
|
|
|
|
|
|
暂无实时画面
|
|
|
|
|
|
</div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
|
|
<Card
|
|
|
|
|
|
title={<><GlobalOutlined /> 位置态势图</>}
|
|
|
|
|
|
bordered={false}
|
|
|
|
|
|
style={{ borderRadius: 12 }}
|
|
|
|
|
|
bodyStyle={{ padding: 12, height: 400 }}
|
|
|
|
|
|
>
|
2026-05-12 08:48:33 +08:00
|
|
|
|
<CesiumMap devices={mapDevices} />
|
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 /> 电池电量</>}>
|
|
|
|
|
|
<Progress
|
|
|
|
|
|
percent={device.capacity_percent || 0}
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
status={(device.capacity_percent || 0) < 20 ? 'exception' : 'active'}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label={<><EnvironmentOutlined /> 飞行高度</>}>
|
|
|
|
|
|
<Text strong style={{ fontSize: 16 }}>{fix2(device.height)} m</Text>
|
|
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Descriptions.Item label="环境风速">
|
|
|
|
|
|
<Text>{fix2(device.wind_speed)} m/s</Text>
|
|
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="环境温度">
|
|
|
|
|
|
<Text>{fix2(device.environment_temperature)} ℃</Text>
|
|
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Descriptions.Item label="降雨状态">
|
|
|
|
|
|
<Tag color={device.rainfall === 'no_rain' ? 'green' : 'red'}>{getVal(device.rainfall)}</Tag>
|
|
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="返航距离">
|
|
|
|
|
|
<Text>{fix2(device.home_distance)} m</Text>
|
|
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Descriptions.Item label="GPS 卫星数">
|
|
|
|
|
|
<Badge count={device.position_state?.gps_number || 0} style={{ backgroundColor: '#1890ff' }} />
|
|
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="RTK 卫星数">
|
|
|
|
|
|
<Badge count={device.position_state?.rtk_number || 0} style={{ backgroundColor: '#52c41a' }} />
|
|
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Descriptions.Item label="RTK 状态" span={2}>
|
|
|
|
|
|
<Tag color={device.position_state?.is_fixed === 'fixing_successful' ? 'success' : 'warning'}>
|
|
|
|
|
|
{device.position_state?.is_fixed === 'fixing_successful' ? 'RTK 已固定' : '未固定'}
|
|
|
|
|
|
</Tag>
|
|
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
</Descriptions>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
/* 机器人特有面板 */
|
|
|
|
|
|
<Descriptions column={2} size="small" layout="vertical">
|
|
|
|
|
|
<Descriptions.Item label={<><ThunderboltOutlined /> 电池电量</>}>
|
|
|
|
|
|
<Progress
|
|
|
|
|
|
percent={runningStatus.battery || 0}
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
status={(runningStatus.battery || 0) < 20 ? 'exception' : 'active'}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</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>
|
|
|
|
|
|
|
|
|
|
|
|
<Descriptions.Item label="左电机电流">
|
2026-05-12 10:34:50 +08:00
|
|
|
|
<Text>{fix2(runningStatus?.leftCurrent)} A</Text>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="右电机电流">
|
2026-05-12 10:34:50 +08:00
|
|
|
|
<Text>{fix2(runningStatus?.rightCurrent)} A</Text>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="左轮速度">
|
2026-05-12 10:34:50 +08:00
|
|
|
|
<Text>{fix2(runningStatus?.leftMeasureSpeed)} m/s</Text>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="右轮速度">
|
2026-05-12 10:34:50 +08:00
|
|
|
|
<Text>{fix2(runningStatus?.rightMeasureSpeed)} m/s</Text>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Descriptions.Item label="左电机温度">
|
2026-05-12 10:34:50 +08:00
|
|
|
|
<Text>{fix2(runningStatus?.leftMotorTemp)} ℃</Text>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="右电机温度">
|
2026-05-12 10:34:50 +08:00
|
|
|
|
<Text>{fix2(runningStatus?.rightMotorTemp)} ℃</Text>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Descriptions.Item label="主控温度">
|
2026-05-12 10:34:50 +08:00
|
|
|
|
<Text>{fix2(runningStatus?.chipTemp)} ℃</Text>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="卫星数量">
|
|
|
|
|
|
<Badge showZero={true}
|
|
|
|
|
|
count={runningStatus?.satelliteCnt || 0} style={{ backgroundColor: '#52c41a' }} />
|
|
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
|
|
|
|
|
|
<Descriptions.Item label="偏航角 (Yaw)">
|
2026-05-12 10:34:50 +08:00
|
|
|
|
<Text>{fix2(runningStatus?.yaw)}°</Text>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
<Descriptions.Item label="俯仰角 (Pitch)">
|
2026-05-12 10:34:50 +08:00
|
|
|
|
<Text>{fix2(runningStatus?.pitch)}°</Text>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Descriptions.Item>
|
|
|
|
|
|
</Descriptions>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</Card>
|
2026-05-12 08:34:13 +08:00
|
|
|
|
{!isUAV && (
|
2026-05-11 16:34:44 +08:00
|
|
|
|
<Card
|
|
|
|
|
|
title={<><ControlOutlined /> 远程控制</>}
|
|
|
|
|
|
bordered={false}
|
|
|
|
|
|
style={{ borderRadius: 12, background: '#0f172a' }}
|
|
|
|
|
|
headStyle={{ color: '#fff', borderBottom: '1px solid #1e293b' }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<XboxController
|
|
|
|
|
|
onGamepadUpdate={handleGamepadUpdate}
|
|
|
|
|
|
handleControlModal={handleControlModal}
|
|
|
|
|
|
isControlled={isControlled}
|
|
|
|
|
|
/>
|
2026-05-12 10:34:50 +08:00
|
|
|
|
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</Card>
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
2026-05-12 10:34:50 +08:00
|
|
|
|
|
|
|
|
|
|
<Modal
|
|
|
|
|
|
title={modalContent.title}
|
|
|
|
|
|
open={isModalOpen}
|
|
|
|
|
|
onOk={handleOk}
|
|
|
|
|
|
onCancel={handleCancel}
|
|
|
|
|
|
okText="确定"
|
|
|
|
|
|
cancelText="取消"
|
|
|
|
|
|
>
|
|
|
|
|
|
<p>{modalContent.content}</p>
|
|
|
|
|
|
</Modal>
|
2026-05-11 16:34:44 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|