航线任务 无人机实时轨迹优化显示 优化websocket优化 设备状态界面显示

This commit is contained in:
mmc
2026-06-05 15:57:36 +08:00
parent 58d251aa68
commit 9e6280866c
6 changed files with 239 additions and 188 deletions

View File

@@ -302,6 +302,15 @@ export default function DeviceStatusPage({
const timerRef = useRef<any>(null);
const runningStatus = useMemo(() => {
// 判断对象是否为空
if ((!wsDeviceInfo || Object.keys(wsDeviceInfo).length === 0) && !isUAV) {
return {};
}
if (isUAV) {
return {
...wsDeviceInfo,
};
}
const base = device?.lastRunningStatus || {};
return isUAV
@@ -376,6 +385,7 @@ export default function DeviceStatusPage({
useEffect(() => {
if (!device || !controllerRef.current || !device?.serialNumber || isUAV) return;
setWsDeviceInfo({});
controllerRef.current.connectDevice(device);

View File

@@ -67,6 +67,8 @@ export default function RobotTaskPage() {
useEffect(() => {
const controller = new DeviceController(userInfo, messageApi);
controller.init();
controllerRef.current = controller;
return () => {
if (controllerRef.current) {
@@ -440,6 +442,7 @@ export default function RobotTaskPage() {
}
}, [filterForm, stationId]);
// 监听任务池筛选条件变化
useEffect(() => {
if (stationId) {

View File

@@ -556,6 +556,16 @@ export default function WayLinePage({ onRefresh }) {
useEffect(() => {
getBoardTask();
}, [boardDrone, boardDateRange, planedevices?.length]);
const realtimePosition = React.useMemo(() => {
if (persistentDroneData?.longitude && persistentDroneData?.latitude) {
return {
lon: persistentDroneData.longitude,
lat: persistentDroneData.latitude,
heading: persistentDroneData.heading || 0,
};
}
}, [persistentDroneData]);
// 任务状态标签
const getStatusTag = (status) => {
@@ -634,6 +644,7 @@ export default function WayLinePage({ onRefresh }) {
}
};
// 执行航线按钮点击(改为图标)
const handleExecuteClick = (e, wayline) => {
e.stopPropagation();
@@ -852,7 +863,8 @@ export default function WayLinePage({ onRefresh }) {
style={{ ...cardStyle, marginBottom: 10 }}
>
<div style={{ width: '100%', height: 420, background: '#e8f3ff url(https://picsum.photos/seed/solar_map_v2/1600/1000) center/cover', position: 'relative' }}>
<CesiumMap devices={planedevices} points={points} focusLocation={focusLocation} from="device-control" />
<CesiumMap realtimePosition={realtimePosition}
points={points} focusLocation={focusLocation} from="device-control" realtimeType='plane' />
<div style={{ position: 'absolute', top: 16, left: 16, background: 'rgba(255,255,255,0.92)', backdropFilter: 'blur(8px)', padding: '14px 16px', borderRadius: 10, width: 150, boxShadow: '0 4px 12px rgba(0,0,0,0.1)' }}>
<div style={{ fontSize: fontSmall, display: 'flex', flexDirection: 'column', gap: 10 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}><span style={{ width: 14, height: 2, background: '#165DFF' }}></span> 无人机航线</div>

View File

@@ -56,7 +56,7 @@ export default class DeviceController {
document.addEventListener('visibilitychange', this.handleVisibilityChange);
// ========== 【集成】后台保活定时 ==========
this.startKeepAlive();
//this.startKeepAlive();
}
// ========== 【集成】页面切前台重连 ==========
@@ -165,16 +165,17 @@ export default class DeviceController {
token: this.userInfo.token,
});
this.hasControlRight = res?.code === 200;
this.hasControlRight = res?.code === 200 && res.data == true;
this.onHasControlRightChange?.(this.hasControlRight);
wsManager.connect(sn, this.wsUrl);
this.connectedDeviceSn = sn;
if (!this.hasControlRight) {
this.messageApi.warning('其他端正在控制');
return;
}
wsManager.connect(sn, this.wsUrl);
this.connectedDeviceSn = sn;
await this.getControl(sn);
@@ -225,7 +226,7 @@ export default class DeviceController {
this.onRequestControlStatusChange?.(false);
this.messageApi.destroy('control');
this.messageApi.error('控制请求超时');
}, 10000);
}, 20000);
}
clearControlTimeout() {
@@ -266,17 +267,18 @@ export default class DeviceController {
}
case 'switchResult': {
console.log('🔌 控制结果111111111111111:', msg);
this.clearControlTimeout();
this.isRequestControl = false;
this.onRequestControlStatusChange?.(false);
if (msg.success === false || msg.switchResult === false) {
if (msg.success === false || msg?.respond?.switchResult === false) {
this.isControlled = false;
this.onControlStatusChange?.(false);
this.messageApi.error({ key: 'control', content: msg.message || '控制失败' });
return;
}
this.isControlled = true;
this.onControlStatusChange?.(true);
this.messageApi.success({ key: 'control', content: '控制成功' });
@@ -284,8 +286,9 @@ export default class DeviceController {
}
case 'switchPermission': {
console.log('🔌 控制结果111111111111111222222222:', msg);
const platform = (msg.platform || '').toLowerCase();
if (!platform || platform === 'web' || platform === 'null') return;
if (!platform || platform === 'null') return;
this.requestDeviceId = msg.deviceId;
this.onPermissionRequest?.({