- 高度
- {flightData.alt}m
+ 相对高度
+ {flightData.relAlt}m
+
+
+ 绝对高度
+ {flightData.absAlt}m
@@ -1057,6 +1157,63 @@ const LeftControlPanel: React.FC
= ({
{/* 右侧相机控制 */}
+ {/* 变焦入口固定在相机按钮组内;展开时仅在该位置向上显示竖向控制 */}
+
+ {!zoomActive ? (
+
+
+
+ ) : (
+
+
+
+
+
+
+ 变焦
+ {zoomFactor.toFixed(1)}×
+
+
+
+ )}
+
+
>
diff --git a/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/BottomPanel/RightPanel.tsx b/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/BottomPanel/RightPanel.tsx
index 61e0fb2a..c0108e82 100644
--- a/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/BottomPanel/RightPanel.tsx
+++ b/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/BottomPanel/RightPanel.tsx
@@ -31,8 +31,12 @@ interface RightPanelProps {
/** 关闭面板(退出设备:会清空选中设备等) */
onClose: () => void;
onControlClick: (device: any, realtimeData: any) => void;
+ /** 一键起飞任务创建成功后切换到操控台 */
+ onTakeoffSuccess?: (device: any, realtimeData: any) => void;
onTaskPanelOpen?: (device: any, dockData: any) => void; // 打开任务管理面板回调
onRoutePlanningOpen?: (device: any) => void; // 打开航线规划面板回调(无人船)
+ onFlyToPointActivate?: (deviceSn: string, dockLat?: number, dockLng?: number, dockH?: number) => void; // 激活指点飞行
+ flyToPointState?: string; // 指点飞行状态(用于按钮禁用)
viewer?: any; // Cesium Viewer 实例
Cesium?: any; // Cesium 库
}
@@ -43,8 +47,11 @@ const RightPanel: React.FC
= ({
onMinimize,
onClose,
onControlClick,
+ onTakeoffSuccess,
onTaskPanelOpen,
onRoutePlanningOpen,
+ onFlyToPointActivate,
+ flyToPointState,
viewer,
Cesium
}) => {
@@ -171,12 +178,13 @@ const RightPanel: React.FC = ({
targetHeight: targetHeight,
});
- // 兼容两种响应格式:resp_code/resp_msg 或 code/msg
- const code = res.resp_code !== undefined ? res.resp_code : res.resp_code;
- const msg = res.resp_msg !== undefined ? res.resp_msg : res.resp_msg;
+ // 网关与服务端可能分别返回 resp_code 或 code,统一为数值后判断。
+ const code = Number(res.resp_code ?? res.code);
+ const msg = res.resp_msg ?? res.msg;
if (code === 0) {
message.success('一键起飞任务已创建,无人机将自动开机并起飞');
+ onTakeoffSuccess?.(device, realtimeData);
} else {
message.error(msg || '一键起飞任务创建失败');
}
@@ -318,13 +326,34 @@ const RightPanel: React.FC = ({
机库信息 / DOCK INFO
-
+
+
+
+
{/* 状态卡片 */}
diff --git a/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/BottomPanel/TaskPanel.tsx b/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/BottomPanel/TaskPanel.tsx
index 2f9d4e1c..4d9ab1c4 100644
--- a/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/BottomPanel/TaskPanel.tsx
+++ b/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/BottomPanel/TaskPanel.tsx
@@ -156,7 +156,7 @@ const TaskPanel: React.FC
= ({
const modalPendingPosRef = useRef({ x: 0, y: 0 });
// Tab 状态
- const [activeTab, setActiveTab] = useState('route');
+ const [activeTab, setActiveTab] = useState('task');
// 拖拽状态
const [position, setPosition] = useState({ x: 0, y: 0 });
@@ -258,8 +258,8 @@ const TaskPanel: React.FC = ({
}));
setRouteList(unifiedRoutes);
- // 默认选中第一条,并绘制到模型上(仅首次进入或未选中时)
- if (!selectedRouteId && unifiedRoutes.length > 0) {
+ // 默认选中第一条航线(仅在航线 Tab 激活时)
+ if (!selectedRouteId && unifiedRoutes.length > 0 && activeTab === 'route') {
const first = unifiedRoutes[0];
setSelectedRouteId(first.routeId);
loadWaypointsRef.current?.(first.routeId, first.routeType);
@@ -286,7 +286,7 @@ const TaskPanel: React.FC = ({
}));
setRouteList(unifiedRoutes);
- if (!selectedRouteId && unifiedRoutes.length > 0) {
+ if (!selectedRouteId && unifiedRoutes.length > 0 && activeTab === 'route') {
const first = unifiedRoutes[0];
setSelectedRouteId(first.routeId);
loadWaypointsRef.current?.(first.routeId, first.routeType);
@@ -966,7 +966,105 @@ const TaskPanel: React.FC = ({
activeKey={activeTab}
onChange={setActiveTab}
className={styles.tabs}
- items={[
+ items={[{
+ key: 'task',
+ label: 任务,
+ children: (
+
+
+
+ 任务列表
+ {missionLoading && }
+
+
+ {missionLoading && missionList.length === 0 ? (
+
加载中...
+ ) : missionList.length === 0 ? (
+
+ ) : (
+ missionList.map(mission => (
+
setSelectedMissionCode(mission.missionCode || null)}
+ >
+
+
+ {mission.missionCode}
+
+
+ {mission.missionName || mission.waylineName || '未命名任务'}
+
+
+
+ {MissionTypeMap[mission.missionType || 1]}
+
+
+ {MissionStatusMap[mission.missionStatus || 1]}
+
+ {formatTime(mission.createTime)}
+
+
+
+
+
+
+ {mission.missionStatus === MissionStatus.PENDING && mission.missionType === MissionType.WAYLINE && (
+
+
+
+ )}
+ {(mission.missionStatus === MissionStatus.DOING || mission.missionStatus === MissionStatus.UPLOADING || mission.missionStatus === MissionStatus.UPLOADED) && (
+
+
+
+ )}
+ {mission.missionStatus === MissionStatus.PENDING && (
+
+
+
+ )}
+ {(mission.missionStatus === MissionStatus.COMPLETE || mission.missionStatus === MissionStatus.CANCELED) && (
+
+
+
+ )}
+
+
+ ))
+ )}
+
+
+
+ ),
+ },
+ ,
+
{
key: 'route',
label: 航线,
@@ -1072,105 +1170,7 @@ const TaskPanel: React.FC = ({
),
- },
- {
- key: 'task',
- label:
任务,
- children: (
-
-
-
- 任务列表
- {missionLoading && }
-
-
- {missionLoading && missionList.length === 0 ? (
-
加载中...
- ) : missionList.length === 0 ? (
-
- ) : (
- missionList.map(mission => (
-
setSelectedMissionCode(mission.missionCode || null)}
- >
-
-
- {mission.missionCode}
-
-
- {mission.missionName || mission.waylineName || '未命名任务'}
-
-
-
- {MissionTypeMap[mission.missionType || 1]}
-
-
- {MissionStatusMap[mission.missionStatus || 1]}
-
- {formatTime(mission.createTime)}
-
-
-
-
-
-
- {mission.missionStatus === MissionStatus.PENDING && mission.missionType === MissionType.WAYLINE && (
-
-
-
- )}
- {(mission.missionStatus === MissionStatus.DOING || mission.missionStatus === MissionStatus.UPLOADING || mission.missionStatus === MissionStatus.UPLOADED) && (
-
-
-
- )}
- {mission.missionStatus === MissionStatus.PENDING && (
-
-
-
- )}
- {(mission.missionStatus === MissionStatus.COMPLETE || mission.missionStatus === MissionStatus.CANCELED) && (
-
-
-
- )}
-
-
- ))
- )}
-
-
-
- ),
- },
- ]}
+ }]}
/>
{/* 实时位置 */}
diff --git a/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/components/FlyToPointPanel.less b/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/components/FlyToPointPanel.less
new file mode 100644
index 00000000..8c64c478
--- /dev/null
+++ b/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/components/FlyToPointPanel.less
@@ -0,0 +1,280 @@
+.targetPanel {
+ position: absolute;
+ top: 92px;
+ right: 18px;
+ z-index: 1000;
+ width: 356px;
+ overflow: hidden;
+ color: #f3fbff;
+ background: linear-gradient(155deg, rgba(7, 21, 34, 0.98), rgba(5, 13, 24, 0.98));
+ border: 1px solid rgba(0, 212, 255, 0.42);
+ border-radius: 12px;
+ box-shadow: 0 18px 44px rgba(0, 0, 0, 0.52), inset 0 1px 0 rgba(255, 255, 255, 0.06);
+ backdrop-filter: blur(14px);
+}
+
+.header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ min-height: 70px;
+ padding: 14px 16px;
+ background: linear-gradient(90deg, rgba(0, 212, 255, 0.13), rgba(0, 212, 255, 0.02));
+ border-bottom: 1px solid rgba(0, 212, 255, 0.2);
+}
+
+.eyebrow,
+.sectionTitle,
+.label {
+ display: block;
+ color: rgba(164, 220, 239, 0.68);
+ font-size: 10px;
+ letter-spacing: 0.9px;
+}
+
+.title {
+ margin-top: 3px;
+ color: #ffffff;
+ font-size: 18px;
+ font-weight: 600;
+ letter-spacing: 0.5px;
+}
+
+.closeButton {
+ display: grid;
+ width: 30px;
+ height: 30px;
+ color: rgba(230, 248, 255, 0.72);
+ background: rgba(255, 255, 255, 0.05);
+ border: 1px solid rgba(255, 255, 255, 0.13);
+ border-radius: 6px;
+ cursor: pointer;
+ place-items: center;
+
+ &:hover {
+ color: #ffffff;
+ background: rgba(255, 77, 79, 0.18);
+ border-color: rgba(255, 77, 79, 0.65);
+ }
+}
+
+.targetSummary {
+ display: grid;
+ grid-template-columns: auto minmax(0, 1fr) auto;
+ gap: 10px;
+ align-items: center;
+ padding: 16px;
+ border-bottom: 1px solid rgba(255, 255, 255, 0.07);
+}
+
+.locationIcon {
+ display: grid;
+ width: 34px;
+ height: 34px;
+ color: #00d4ff;
+ background: rgba(0, 212, 255, 0.1);
+ border: 1px solid rgba(0, 212, 255, 0.28);
+ border-radius: 8px;
+ font-size: 17px;
+ place-items: center;
+}
+
+.coordinateBlock,
+.heightBlock {
+ min-width: 0;
+}
+
+.coordinate {
+ display: block;
+ margin-top: 4px;
+ overflow: hidden;
+ color: #72e8ff;
+ font-family: Consolas, 'Courier New', monospace;
+ font-size: 12px;
+ font-weight: 600;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.heightBlock {
+ padding-left: 12px;
+ border-left: 1px solid rgba(255, 255, 255, 0.1);
+
+ strong {
+ display: block;
+ margin-top: 3px;
+ color: #ffffff;
+ font-family: Consolas, 'Courier New', monospace;
+ font-size: 18px;
+ line-height: 1;
+ }
+
+ small {
+ color: rgba(191, 230, 241, 0.65);
+ font-size: 10px;
+ font-weight: 400;
+ }
+}
+
+.riskNotice {
+ display: flex;
+ gap: 10px;
+ margin: 14px 16px 0;
+ padding: 11px 12px;
+ background: rgba(255, 170, 0, 0.1);
+ border: 1px solid rgba(255, 170, 0, 0.38);
+ border-radius: 8px;
+
+ strong {
+ display: block;
+ color: #ffca70;
+ font-size: 13px;
+ }
+
+ p {
+ margin: 5px 0 0;
+ color: rgba(255, 235, 197, 0.75);
+ font-size: 11px;
+ line-height: 1.55;
+ }
+}
+
+.warningIcon {
+ margin-top: 2px;
+ color: #ffaa00;
+ font-size: 17px;
+}
+
+.parameterSection {
+ padding: 15px 16px 12px;
+}
+
+.sectionTitle {
+ margin-bottom: 9px;
+}
+
+.parameterGrid {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: 10px;
+}
+
+.parameterField {
+ position: relative;
+ display: block;
+ padding: 7px 10px 8px;
+ background: rgba(255, 255, 255, 0.035);
+ border: 1px solid rgba(128, 209, 235, 0.18);
+ border-radius: 7px;
+
+ > span {
+ display: block;
+ margin-bottom: 3px;
+ color: rgba(185, 223, 235, 0.64);
+ font-size: 10px;
+ }
+
+ em {
+ position: absolute;
+ right: 10px;
+ bottom: 10px;
+ color: rgba(185, 223, 235, 0.6);
+ font-size: 10px;
+ font-style: normal;
+ }
+
+ :global(.ant-input-number) {
+ width: 100%;
+ background: transparent;
+ border: 0;
+ box-shadow: none;
+
+ input {
+ height: 21px;
+ padding: 0 26px 0 0;
+ color: #ffffff;
+ font-family: Consolas, 'Courier New', monospace;
+ font-size: 16px;
+ font-weight: 600;
+ }
+ }
+}
+
+.riskCheck {
+ display: flex;
+ margin: 0 16px 14px;
+ color: rgba(230, 245, 250, 0.84);
+ font-size: 12px;
+ line-height: 1.4;
+
+ :global(.ant-checkbox) {
+ top: 2px;
+ }
+
+ :global(.ant-checkbox-inner) {
+ background: rgba(255, 255, 255, 0.03);
+ border-color: rgba(130, 222, 248, 0.6);
+ }
+
+ :global(.ant-checkbox-checked .ant-checkbox-inner) {
+ background: #00b8df;
+ border-color: #00b8df;
+ }
+
+ :global(.ant-checkbox + span) {
+ padding-inline-start: 8px;
+ }
+}
+
+.actions {
+ display: grid;
+ grid-template-columns: 88px 1fr;
+ gap: 10px;
+ padding: 13px 16px 16px;
+ background: rgba(0, 0, 0, 0.18);
+ border-top: 1px solid rgba(255, 255, 255, 0.07);
+}
+
+.discardButton,
+.sendButton {
+ height: 38px;
+ font-weight: 600;
+}
+
+.discardButton {
+ color: rgba(230, 245, 250, 0.84) !important;
+ background: rgba(255, 255, 255, 0.04) !important;
+ border-color: rgba(255, 255, 255, 0.2) !important;
+
+ &:hover {
+ color: #ffffff !important;
+ background: rgba(255, 77, 79, 0.14) !important;
+ border-color: rgba(255, 77, 79, 0.65) !important;
+ }
+}
+
+.sendButton {
+ background: linear-gradient(90deg, #009bc1, #00c7e8) !important;
+ border-color: #20d7f3 !important;
+ box-shadow: 0 0 16px rgba(0, 212, 255, 0.2);
+
+ &:hover:not(:disabled) {
+ background: linear-gradient(90deg, #00afda, #14d8f7) !important;
+ box-shadow: 0 0 20px rgba(0, 212, 255, 0.38);
+ }
+
+ &:disabled {
+ color: rgba(255, 255, 255, 0.55) !important;
+ background: rgba(68, 112, 126, 0.55) !important;
+ border-color: rgba(125, 190, 208, 0.25) !important;
+ box-shadow: none;
+ }
+}
+
+@media (max-width: 900px) {
+ .targetPanel {
+ right: 12px;
+ left: 12px;
+ width: auto;
+ }
+}
diff --git a/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/components/FlyToPointPanel.tsx b/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/components/FlyToPointPanel.tsx
new file mode 100644
index 00000000..bd15aa50
--- /dev/null
+++ b/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/components/FlyToPointPanel.tsx
@@ -0,0 +1,112 @@
+import React, { useState } from 'react';
+import { Alert, Button, Checkbox, InputNumber, Modal, Space } from 'antd';
+import { CloseOutlined, EnvironmentOutlined, SendOutlined, StopOutlined, WarningFilled } from '@ant-design/icons';
+import type { FlyToPointState, TargetPoint } from '../hooks/useFlyToPoint';
+import styles from './FlyToPointPanel.less';
+
+interface FlyToPointPanelProps {
+ visible: boolean;
+ state: FlyToPointState;
+ missionCode: string | null;
+ candidateTarget: TargetPoint | null;
+ currentTarget: TargetPoint | null;
+ distanceToTarget: number;
+ isAirborne: boolean;
+ isSending: boolean;
+ onConfirmStart: () => void;
+ onCancelStart: () => void;
+ onConfirmFly: (clearanceMeters: number, maxSpeed: number, riskAcknowledged: boolean) => void;
+ onCancelTarget: () => void;
+ onEndFlight: () => void;
+}
+
+const FlyToPointPanel: React.FC
= ({
+ visible, state, missionCode, candidateTarget, currentTarget, distanceToTarget, isAirborne, isSending,
+ onConfirmStart, onCancelStart, onConfirmFly, onCancelTarget, onEndFlight,
+}) => {
+ const [clearanceMeters, setClearanceMeters] = useState(30);
+ const [maxSpeed, setMaxSpeed] = useState(12);
+ const [riskAcknowledged, setRiskAcknowledged] = useState(false);
+
+ React.useEffect(() => {
+ if (candidateTarget) {
+ setClearanceMeters(candidateTarget.clearanceMeters);
+ setRiskAcknowledged(false);
+ }
+ }, [candidateTarget]);
+
+ const status = state === 'TAKING_OFF' ? '起飞中' : state === 'RETURNING' ? '返航中' : state === 'FLYING_TO'
+ ? `飞往已发送目标,距离 ${distanceToTarget.toFixed(0)}m` : '等待地图点选目标';
+
+ return <>
+ {state !== 'IDLE' && state !== 'COMPLETED' &&
+ 指点飞行 | {status}
+ {(state === 'WAITING_TARGET' || state === 'FLYING_TO') && } onClick={onEndFlight}>结束飞行}
+
}
+
+ 指点飞行} open={visible && state === 'IDLE'} onCancel={onCancelStart} footer={} onClick={onConfirmStart}>确认开始}>
+
+
+
+ {candidateTarget && }
+ >;
+};
+
+export default FlyToPointPanel;
diff --git a/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/hooks/useFlyToPoint.ts b/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/hooks/useFlyToPoint.ts
new file mode 100644
index 00000000..a67ee431
--- /dev/null
+++ b/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/hooks/useFlyToPoint.ts
@@ -0,0 +1,216 @@
+import { useState, useCallback, useRef, useEffect } from 'react';
+import { message } from 'antd';
+import * as missionApi from '@/services/mission';
+import type { DroneData } from './useDroneSSE';
+
+export type FlyToPointState = 'IDLE' | 'TAKING_OFF' | 'WAITING_TARGET' | 'FLYING_TO' | 'RETURNING' | 'COMPLETED';
+
+export interface TargetPoint {
+ longitude: number;
+ latitude: number;
+ candidateSurfaceHeight: number;
+ clearanceStatus: 'VERIFIED' | 'UNVERIFIED';
+ clearanceMeters: number;
+}
+
+const SAFE_HEIGHT = 5;
+const ARRIVAL_THRESHOLD = 5;
+const LANDED_THRESHOLD = 2;
+const DEFAULT_CLEARANCE = 30;
+
+export function useFlyToPoint(droneData: DroneData | null, onStarted?: (deviceSn: string) => void, isDroneInDock?: boolean) {
+ const [state, setState] = useState('IDLE');
+ const [missionCode, setMissionCode] = useState(null);
+ const [deviceSn, setDeviceSn] = useState(null);
+ const [candidateTarget, setCandidateTarget] = useState(null);
+ const [currentTarget, setCurrentTarget] = useState(null);
+ const [distanceToTarget, setDistanceToTarget] = useState(0);
+ const [isSending, setIsSending] = useState(false);
+
+ const stateRef = useRef(state);
+ const candidateRef = useRef(candidateTarget);
+ const targetRef = useRef(currentTarget);
+ const missionCodeRef = useRef(missionCode);
+ const takeoffElevationRef = useRef(0); // 记录起飞时的椭球高
+ const returnTimerRef = useRef(null); // 返航超时兜底
+ stateRef.current = state;
+ candidateRef.current = candidateTarget;
+ targetRef.current = currentTarget;
+ missionCodeRef.current = missionCode;
+
+ const startFlyToPoint = useCallback(async (sn: string, dockLat?: number, dockLng?: number, dockH?: number) => {
+ try {
+ setState('TAKING_OFF');
+ setDeviceSn(sn);
+ takeoffElevationRef.current = droneData?.elevation ?? droneData?.height ?? 0;
+ const res = await missionApi.startFlyToPoint({
+ deviceSn: sn,
+ dockLatitude: dockLat,
+ dockLongitude: dockLng,
+ dockHeight: dockH,
+ isAirborne: (droneData?.height ?? 0) > SAFE_HEIGHT || ((droneData?.elevation ?? 0) - takeoffElevationRef.current) > SAFE_HEIGHT,
+ });
+ if (res?.resp_code !== 0 || !res?.data?.missionCode) {
+ throw new Error(res?.resp_msg || '启动失败');
+ }
+ setMissionCode(res.data.missionCode);
+ if ((droneData?.height ?? 0) > SAFE_HEIGHT) setState('WAITING_TARGET');
+ onStarted?.(sn);
+ message.success('指点飞行任务已启动');
+ } catch (error: any) {
+ message.error(`开始指点飞行失败:${error?.message || '请重试'}`);
+ setState('IDLE');
+ setDeviceSn(null);
+ }
+ }, [droneData, onStarted]);
+
+ const selectTarget = useCallback((longitude: number, latitude: number, candidateSurfaceHeight: number) => {
+ if (!['TAKING_OFF', 'WAITING_TARGET', 'FLYING_TO'].includes(stateRef.current)) return;
+ // 第一版不把不可验证的模型表面伪装成已验证的安全路径。
+ setCandidateTarget({
+ longitude,
+ latitude,
+ candidateSurfaceHeight,
+ clearanceStatus: 'UNVERIFIED',
+ clearanceMeters: DEFAULT_CLEARANCE,
+ });
+ }, []);
+
+ const cancelTarget = useCallback(() => setCandidateTarget(null), []);
+
+ const confirmFly = useCallback(async (clearanceMeters: number, maxSpeed = 12, riskAcknowledged = false) => {
+ const target = candidateRef.current;
+ const code = missionCodeRef.current;
+ if (!target || !code) return;
+ if (!riskAcknowledged && target.clearanceStatus !== 'VERIFIED') {
+ message.warning('请确认路径净空尚未验证的飞行风险');
+ return;
+ }
+
+ // 高度以当前无人机椭球高度为下限,模型命中高度仅作为障碍物顶高度候选。
+ const targetEllipsoidHeight = Math.max(
+ droneData?.elevation ?? Number.NEGATIVE_INFINITY,
+ target.candidateSurfaceHeight + clearanceMeters,
+ );
+ if (!Number.isFinite(targetEllipsoidHeight)) {
+ message.error('缺少无人机高度和模型高度,无法计算安全目标高度');
+ return;
+ }
+
+ setIsSending(true);
+ try {
+ const res = await missionApi.flyToPointUpdate({
+ missionCode: code,
+ latitude: target.latitude,
+ longitude: target.longitude,
+ height: targetEllipsoidHeight,
+ maxSpeed,
+ clearanceStatus: target.clearanceStatus,
+ clearanceMeters,
+ candidateSurfaceHeight: target.candidateSurfaceHeight,
+ riskAcknowledged,
+ riskReason: target.clearanceStatus === 'VERIFIED' ? undefined : '路径净空尚未完成三维验证',
+ });
+ if (res?.resp_code !== 0) throw new Error(res?.resp_msg || '命令发送失败');
+ setCurrentTarget({ ...target, clearanceMeters });
+ setCandidateTarget(null);
+ setState('FLYING_TO');
+ message.success(currentTarget ? '已发送改飞指令' : '已发送飞往目标指令');
+ } catch (error: any) {
+ message.error(`发送目标失败:${error?.message || '请重试'}`);
+ } finally {
+ setIsSending(false);
+ }
+ }, [droneData, currentTarget]);
+
+ const endFlight = useCallback(async () => {
+ const code = missionCodeRef.current;
+ if (!code) return;
+ setState('RETURNING');
+ try {
+ const res = await missionApi.endFlyToPoint(code);
+ if (res?.resp_code !== 0) throw new Error(res?.resp_msg || '结束失败');
+ setCandidateTarget(null);
+ message.success('正在返航,等待降落');
+ } catch (error: any) {
+ message.error(`结束飞行失败:${error?.message || '请重试'}`);
+ setState(currentTarget ? 'FLYING_TO' : 'WAITING_TARGET');
+ }
+ }, [currentTarget]);
+
+ const cancel = useCallback(() => {
+ setState('IDLE');
+ setMissionCode(null);
+ setDeviceSn(null);
+ setCandidateTarget(null);
+ setCurrentTarget(null);
+ setDistanceToTarget(0);
+ }, []);
+
+ useEffect(() => {
+ // RETURNING 超时兜底:120 秒后自动完成(SSE 断流时也能正常结束)
+ if (stateRef.current === 'RETURNING' && !returnTimerRef.current) {
+ returnTimerRef.current = setTimeout(() => {
+ if (stateRef.current === 'RETURNING' && missionCodeRef.current) {
+ missionApi.completeMission(missionCodeRef.current).finally(() => {
+ setState('COMPLETED');
+ message.success('指点飞行完成(超时自动结束)');
+ });
+ }
+ }, 120_000);
+ }
+ if (stateRef.current !== 'RETURNING' && returnTimerRef.current) {
+ clearTimeout(returnTimerRef.current);
+ returnTimerRef.current = null;
+ }
+
+ if (!droneData) return;
+ const relHeight = droneData.height ?? 0;
+ const elevation = droneData.elevation ?? 0;
+ // 起飞检测:相对高度 > 5m,或椭球高相对起飞基准升高 > 5m
+ const isAirborne = relHeight > SAFE_HEIGHT || (elevation - takeoffElevationRef.current) > SAFE_HEIGHT;
+ const target = targetRef.current;
+ if (stateRef.current === 'TAKING_OFF' && isAirborne) {
+ setState('WAITING_TARGET');
+ message.success('无人机已升空,请在地图上点击候选目标');
+ }
+ if (stateRef.current === 'FLYING_TO' && target && droneData.latitude != null && droneData.longitude != null) {
+ const distance = getHorizontalDistance(droneData.latitude, droneData.longitude, target.latitude, target.longitude);
+ setDistanceToTarget(distance);
+ if (distance < ARRIVAL_THRESHOLD) {
+ setState('WAITING_TARGET');
+ setCurrentTarget(null);
+ message.success('已到达目标位置,可继续点选下一个目标');
+ }
+ }
+ // RETURNING 状态:检测无人机是否已回库
+ // elevation 回到起飞基准附近 + 相对高度接近0,判定回库
+ const elevBackToBase = Math.abs(elevation - takeoffElevationRef.current) < 3;
+ const hasLanded = relHeight < 3;
+ if (stateRef.current === 'RETURNING' && (isDroneInDock || elevBackToBase || hasLanded) && missionCodeRef.current) {
+ missionApi.completeMission(missionCodeRef.current).finally(() => {
+ setState('COMPLETED');
+ message.success('指点飞行完成,无人机已回库');
+ });
+ }
+ return () => {
+ if (returnTimerRef.current) {
+ clearTimeout(returnTimerRef.current);
+ returnTimerRef.current = null;
+ }
+ };
+ }, [droneData]);
+
+ return {
+ state, missionCode, deviceSn, candidateTarget, currentTarget, distanceToTarget, isSending,
+ startFlyToPoint, selectTarget, cancelTarget, confirmFly, endFlight, cancel,
+ isAirborne: (droneData?.height ?? 0) > SAFE_HEIGHT || ((droneData?.elevation ?? 0) - takeoffElevationRef.current) > SAFE_HEIGHT,
+ };
+}
+
+function getHorizontalDistance(lat1: number, lng1: number, lat2: number, lng2: number): number {
+ const dLat = ((lat2 - lat1) * Math.PI) / 180;
+ const dLng = ((lng2 - lng1) * Math.PI) / 180;
+ const a = Math.sin(dLat / 2) ** 2 + Math.cos((lat1 * Math.PI) / 180) * Math.cos((lat2 * Math.PI) / 180) * Math.sin(dLng / 2) ** 2;
+ return 6371000 * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
+}
diff --git a/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/hooks/useTilesetLoader.ts b/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/hooks/useTilesetLoader.ts
index 214ae9d9..9ac5171b 100644
--- a/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/hooks/useTilesetLoader.ts
+++ b/zlt-web/yingyan/src/pages/map3d/components/MapContainer/3d/hooks/useTilesetLoader.ts
@@ -93,16 +93,19 @@ export const useTilesetLoader = (): UseTilesetLoaderResult => {
});
try {
- // 处理跨域问题:非 localhost 访问时将 CDN URL 转换为代理路径
+ // 处理跨域问题:将 CDN URL 转换为代理路径(始终使用代理,避免 CORS)
let tilesetUrl = config.url;
- const isLocalhost = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
- if (!isLocalhost && tilesetUrl.includes('minicdn.goflytec.com')) {
+ if (tilesetUrl.includes('minicdn.goflytec.com')) {
tilesetUrl = tilesetUrl.replace('https://minicdn.goflytec.com', '');
console.log('[Tileset] 使用代理路径:', tilesetUrl);
}
+ // 使用 Resource 显式设置 baseUrl,确保外部 tileset 引用的相对路径正确解析
+ const resource = Cesium.Resource.createIfNeeded(tilesetUrl);
+ console.log('[Tileset] Resource URL:', resource.url, 'baseUrl:', resource.baseUrl);
+
// 创建3DTileset - 高清晰度渲染配置
- const tileset = await Cesium.Cesium3DTileset.fromUrl(tilesetUrl, {
+ const tileset = await Cesium.Cesium3DTileset.fromUrl(resource, {
// 核心清晰度控制 - 值越小越清晰(大疆司空使用约1-2)
maximumScreenSpaceError: config.style?.maximumScreenSpaceError ?? 1,
maximumMemoryUsage: config.style?.maximumMemoryUsage ?? 2048, // 增加内存以加载更多高精度瓦片
@@ -127,7 +130,7 @@ export const useTilesetLoader = (): UseTilesetLoaderResult => {
foveatedMinimumScreenSpaceErrorRelaxation: 0.0,
// 裁剪优化 - 减少移动时的清晰度降低
- cullWithChildrenBounds: true,
+ cullWithChildrenBounds: false, // 外部 tileset 引用的模型必须关闭,否则子 tileset 会被错误裁剪
cullRequestsWhileMoving: false, // 禁用移动时的请求裁剪
cullRequestsWhileMovingMultiplier: 1.0,
@@ -154,6 +157,11 @@ export const useTilesetLoader = (): UseTilesetLoaderResult => {
});
});
+ // 监听瓦片加载失败(外部 tileset 引用失败会在这里体现)
+ tileset.tileFailed.addEventListener((error: any) => {
+ console.error(`[Tileset] 模型 [${config.name}] 瓦片加载失败:`, error);
+ });
+
// 模型位置调整 - 根据当前地形类型选择对应的高度偏移
if (config.position) {
const { longitude = 0, latitude = 0, cesiumHeight, arcgisHeight } = config.position;
diff --git a/zlt-web/yingyan/src/pages/map3d/components/MapContainer/CesiumContainer.tsx b/zlt-web/yingyan/src/pages/map3d/components/MapContainer/CesiumContainer.tsx
index 0d538741..3c53bd74 100644
--- a/zlt-web/yingyan/src/pages/map3d/components/MapContainer/CesiumContainer.tsx
+++ b/zlt-web/yingyan/src/pages/map3d/components/MapContainer/CesiumContainer.tsx
@@ -9,6 +9,8 @@ import RouteEditor from '../RouteEditor';
import BoundaryEditor from '../BoundaryEditor';
import { useTilesetLoader, TilesetConfig } from './3d/hooks/useTilesetLoader';
import { useDroneSSE } from './3d/hooks/useDroneSSE';
+import { useFlyToPoint } from './3d/hooks/useFlyToPoint';
+import FlyToPointPanel from './3d/components/FlyToPointPanel';
import { getModelsByDeviceSn, convertToTilesetConfig } from '@/services/threeDModel';
import TilesetPanel from "@/pages/map3d/components/MapContainer/3d/TilesetPanel";
@@ -21,6 +23,24 @@ const DEFAULT_GLOBAL_VIEW = {
height: 19000000,
};
+const TERRAIN_LOAD_TIMEOUT_MS = 8000;
+
+function withTimeout(promise: Promise, providerName: string): Promise {
+ return new Promise((resolve, reject) => {
+ const timer = window.setTimeout(() => reject(new Error(`${providerName} 地形服务连接超时`)), TERRAIN_LOAD_TIMEOUT_MS);
+ promise.then(
+ value => {
+ window.clearTimeout(timer);
+ resolve(value);
+ },
+ error => {
+ window.clearTimeout(timer);
+ reject(error);
+ },
+ );
+ });
+}
+
interface CesiumContainerProps {
deviceList: any[];
externalSelectedDevice?: any; // 接收外部选择的设备
@@ -66,6 +86,49 @@ const CesiumContainer: React.FC = (props) => {
const [droneDeviceSn, setDroneDeviceSn] = useState('');
const { droneData, connectDroneSSE, disconnectDroneSSE, resetDroneData } = useDroneSSE();
+ // 指点飞行
+ const flyToPointStartedRef = useRef<(deviceSn: string) => void>();
+
+ // 无人机在库状态(来自实时数据)
+ const isDroneInDock = useMemo(
+ () => controlRealtimeData?.rawData?.dockData?.drone_in_dock === 1,
+ [controlRealtimeData]
+ );
+
+ const flyToPoint = useFlyToPoint(droneData, (deviceSn) => flyToPointStartedRef.current?.(deviceSn), isDroneInDock);
+ const [flyToPointStartVisible, setFlyToPointStartVisible] = useState(false);
+ const [pendingFlyDeviceSn, setPendingFlyDeviceSn] = useState(null);
+ const [pendingDockCoords, setPendingDockCoords] = useState<{lat?: number; lng?: number; height?: number}>({});
+
+ // 激活指点飞行(从 RightPanel 按钮触发,仅打开确认弹窗)
+ const handleFlyToPointActivate = useCallback((deviceSn: string, dockLat?: number, dockLng?: number, dockH?: number) => {
+ setPendingFlyDeviceSn(deviceSn);
+ setPendingDockCoords({ lat: dockLat, lng: dockLng, height: dockH });
+ setFlyToPointStartVisible(true);
+ }, []);
+
+ // 确认开始指点飞行
+ const handleFlyToPointConfirm = useCallback(() => {
+ setFlyToPointStartVisible(false);
+ if (pendingFlyDeviceSn) {
+ flyToPoint.startFlyToPoint(pendingFlyDeviceSn, pendingDockCoords.lat, pendingDockCoords.lng, pendingDockCoords.height);
+ setPendingFlyDeviceSn(null);
+ setPendingDockCoords({});
+ }
+ }, [pendingFlyDeviceSn, pendingDockCoords, flyToPoint]);
+
+ // 取消指点飞行
+ const handleFlyToPointCancel = useCallback(() => {
+ setFlyToPointStartVisible(false);
+ setPendingFlyDeviceSn(null);
+ }, []);
+
+ // 指点飞行目标标记实体 ref
+ const flyTargetEntityRef = useRef(null);
+ const flyCandidateEntityRef = useRef(null);
+ const flyToPointStateRef = useRef(flyToPoint.state);
+ flyToPointStateRef.current = flyToPoint.state;
+
// 无人机位置渲染相关引用
const droneEntityRef = useRef(null);
const flightTrackEntityRef = useRef(null);
@@ -80,6 +143,7 @@ const CesiumContainer: React.FC = (props) => {
const [modelLoading, setModelLoading] = useState(false);
const [terrainLoading, setTerrainLoading] = useState(false); // 是否正在加载高程地形
const terrainLoadedRef = useRef(false); // 是否已加载高程地形
+ const terrainRequestIdRef = useRef(0);
const {
tilesets,
loadTileset,
@@ -143,6 +207,7 @@ const CesiumContainer: React.FC = (props) => {
return 'loaded';
}
+ const requestId = ++terrainRequestIdRef.current;
setTerrainLoading(true);
console.log('开始加载高程地形...', preferredTerrainType ? `优先使用: ${preferredTerrainType}` : '');
@@ -152,9 +217,9 @@ const CesiumContainer: React.FC = (props) => {
if (preferredTerrainType === 'arcgis') {
// 优先尝试 ArcGIS
try {
- const terrainProvider = await Cesium.ArcGISTiledElevationTerrainProvider.fromUrl(
+ const terrainProvider = await withTimeout(Cesium.ArcGISTiledElevationTerrainProvider.fromUrl(
'https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer'
- );
+ ), 'ArcGIS');
console.log('高程地形加载成功: ArcGIS World Elevation (根据模型配置)');
viewerRef.current.terrainProvider = terrainProvider;
viewerRef.current.scene.globe.depthTestAgainstTerrain = true;
@@ -163,10 +228,10 @@ const CesiumContainer: React.FC = (props) => {
} catch (arcgisError) {
console.warn('ArcGIS 加载失败,尝试 Cesium Ion:', arcgisError);
try {
- const terrainProvider = await Cesium.CesiumTerrainProvider.fromIonAssetId(1, {
+ const terrainProvider = await withTimeout(Cesium.CesiumTerrainProvider.fromIonAssetId(1, {
requestVertexNormals: true,
requestWaterMask: true,
- });
+ }), 'Cesium Ion');
console.log('高程地形加载成功: Cesium World Terrain (备用)');
viewerRef.current.terrainProvider = terrainProvider;
viewerRef.current.scene.globe.depthTestAgainstTerrain = true;
@@ -181,10 +246,10 @@ const CesiumContainer: React.FC = (props) => {
} else {
// 默认优先尝试 Cesium Ion
try {
- const terrainProvider = await Cesium.CesiumTerrainProvider.fromIonAssetId(1, {
+ const terrainProvider = await withTimeout(Cesium.CesiumTerrainProvider.fromIonAssetId(1, {
requestVertexNormals: true,
requestWaterMask: true,
- });
+ }), 'Cesium Ion');
console.log('高程地形加载成功: Cesium World Terrain');
viewerRef.current.terrainProvider = terrainProvider;
viewerRef.current.scene.globe.depthTestAgainstTerrain = true;
@@ -193,9 +258,9 @@ const CesiumContainer: React.FC = (props) => {
} catch (cesiumError) {
console.warn('Cesium World Terrain 加载失败,尝试 ArcGIS:', cesiumError);
try {
- const terrainProvider = await Cesium.ArcGISTiledElevationTerrainProvider.fromUrl(
+ const terrainProvider = await withTimeout(Cesium.ArcGISTiledElevationTerrainProvider.fromUrl(
'https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer'
- );
+ ), 'ArcGIS');
console.log('高程地形加载成功: ArcGIS World Elevation');
viewerRef.current.terrainProvider = terrainProvider;
viewerRef.current.scene.globe.depthTestAgainstTerrain = true;
@@ -211,7 +276,9 @@ const CesiumContainer: React.FC = (props) => {
}
}
- setTerrainLoading(false);
+ if (terrainRequestIdRef.current === requestId) {
+ setTerrainLoading(false);
+ }
return loadedTerrainType;
}, []);
@@ -391,6 +458,18 @@ const CesiumContainer: React.FC = (props) => {
}
}, [droneDeviceSn, disconnectDroneSSE, connectDroneSSE, clearDroneLayers]);
+ flyToPointStartedRef.current = (deviceSn: string) => {
+ const device = selectedDevice?.deviceSn === deviceSn ? selectedDevice : { deviceSn };
+ setRightPanelVisible(false);
+ handleOpenControl(device, controlRealtimeData);
+ };
+
+ // 一键起飞成功后切换到操控台,便于立即查看视频和实时飞行状态。
+ const handleTakeoffSuccess = useCallback((device: any, realtimeData: any) => {
+ setRightPanelVisible(false);
+ handleOpenControl(device, realtimeData);
+ }, [handleOpenControl]);
+
// 关闭操控台 - 断开无人机SSE
const handleCloseControl = useCallback(() => {
setLeftPanelVisible(false);
@@ -936,6 +1015,47 @@ const CesiumContainer: React.FC = (props) => {
}
handler.setInputAction((movement: any) => {
+ // 指点飞行模式:优先处理地图点击
+ if (['TAKING_OFF', 'WAITING_TARGET', 'FLYING_TO'].includes(flyToPointStateRef.current)) {
+ const cartesian = viewer.scene.pickPosition(movement.position);
+ if (Cesium.defined(cartesian)) {
+ const cartographic = Cesium.Cartographic.fromCartesian(cartesian);
+ const lng = Cesium.Math.toDegrees(cartographic.longitude);
+ const lat = Cesium.Math.toDegrees(cartographic.latitude);
+ const cartographicHeight = cartographic.height; // WGS84 椭球高
+
+ // 蓝色标记表示尚未发送的候选点,避免与当前飞行目标混淆。
+ if (flyCandidateEntityRef.current) {
+ viewer.entities.remove(flyCandidateEntityRef.current);
+ }
+ flyCandidateEntityRef.current = viewer.entities.add({
+ position: Cesium.Cartesian3.fromDegrees(lng, lat, cartographicHeight),
+ point: {
+ pixelSize: 16,
+ color: Cesium.Color.CYAN,
+ outlineColor: Cesium.Color.WHITE,
+ outlineWidth: 2,
+ heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
+ },
+ label: {
+ text: '候选目标(未发送)',
+ font: '14px sans-serif',
+ fillColor: Cesium.Color.CYAN,
+ outlineColor: Cesium.Color.WHITE,
+ outlineWidth: 2,
+ style: Cesium.LabelStyle.FILL_AND_OUTLINE,
+ verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
+ pixelOffset: new Cesium.Cartesian2(0, -20),
+ },
+ });
+
+ flyToPoint.selectTarget(lng, lat, cartographicHeight);
+ return; // 不执行设备选择逻辑
+ }
+ message.info('未能获取目标表面高度,请选择可见模型或地形位置');
+ return;
+ }
+
const pickedObject = viewer.scene.pick(movement.position);
if (Cesium.defined(pickedObject) && pickedObject.id) {
const entity = pickedObject.id;
@@ -974,6 +1094,27 @@ const CesiumContainer: React.FC = (props) => {
};
}, [loading, handleDeviceSelect]);
+ useEffect(() => {
+ const viewer = viewerRef.current;
+ if (!viewer || !Cesium) return;
+ if (!flyToPoint.candidateTarget && flyCandidateEntityRef.current) {
+ viewer.entities.remove(flyCandidateEntityRef.current);
+ flyCandidateEntityRef.current = null;
+ }
+ if (flyTargetEntityRef.current) {
+ viewer.entities.remove(flyTargetEntityRef.current);
+ flyTargetEntityRef.current = null;
+ }
+ const target = flyToPoint.currentTarget;
+ if (target) {
+ flyTargetEntityRef.current = viewer.entities.add({
+ position: Cesium.Cartesian3.fromDegrees(target.longitude, target.latitude, target.candidateSurfaceHeight),
+ point: { pixelSize: 15, color: Cesium.Color.ORANGE, outlineColor: Cesium.Color.WHITE, outlineWidth: 2, heightReference: Cesium.HeightReference.CLAMP_TO_GROUND },
+ label: { text: '当前飞行目标', font: '14px sans-serif', fillColor: Cesium.Color.ORANGE, outlineColor: Cesium.Color.WHITE, outlineWidth: 2, style: Cesium.LabelStyle.FILL_AND_OUTLINE, verticalOrigin: Cesium.VerticalOrigin.BOTTOM, pixelOffset: new Cesium.Cartesian2(0, -20) },
+ });
+ }
+ }, [flyToPoint.candidateTarget, flyToPoint.currentTarget]);
+
// @ts-ignore
return (
@@ -1144,12 +1285,32 @@ const CesiumContainer: React.FC
= (props) => {
onClose={handleRightPanelClose}
onMinimize={handleRightPanelMinimize}
onControlClick={handleOpenControl}
+ onTakeoffSuccess={handleTakeoffSuccess}
onTaskPanelOpen={handleOpenTaskPanel}
onRoutePlanningOpen={handleOpenRoutePlanning}
+ onFlyToPointActivate={handleFlyToPointActivate}
+ flyToPointState={flyToPoint.state}
viewer={viewerRef.current}
Cesium={Cesium}
/>
+ {/* 指点飞行面板 */}
+
+
{/* 任务管理面板 - 左下角独立渲染 */}
=> {
+ const res = await request('/api-device/device/command/liveLensChange', { method: 'POST', data: params });
+ return res as CommandResult;
+ },
+
+ // 设置变焦倍数(2~200)
+ cameraFocalLengthSet: async (params: { deviceSn: string; zoomFactor: number }): Promise => {
+ const res = await request('/api-device/device/command/cameraFocalLengthSet', { method: 'POST', data: params });
+ return res as CommandResult;
+ },
+
// 订阅无人机遥测
subscribeDroneTelemetry: async (deviceSn: string): Promise<{ success: boolean; message?: string }> => {
try {
diff --git a/zlt-web/yingyan/src/services/mission.ts b/zlt-web/yingyan/src/services/mission.ts
index 154af610..ee4c0f11 100644
--- a/zlt-web/yingyan/src/services/mission.ts
+++ b/zlt-web/yingyan/src/services/mission.ts
@@ -6,6 +6,8 @@ import { request } from 'umi';
export enum MissionType {
WAYLINE = 1, // 航线任务
TAKEOFF = 2, // 一键起飞任务
+ BOAT_ROUTE = 3, // 无人船航线任务
+ FLY_TO_POINT = 4, // 指点飞行任务
}
/**
@@ -26,6 +28,8 @@ export enum MissionStatus {
export const MissionTypeMap: Record = {
[MissionType.WAYLINE]: '航线任务',
[MissionType.TAKEOFF]: '一键起飞',
+ [MissionType.BOAT_ROUTE]: '无人船航线',
+ [MissionType.FLY_TO_POINT]: '指点飞行',
};
/**
@@ -274,3 +278,52 @@ export async function countMissionImage(missionCode: string) {
data: { missionCode },
});
}
+
+// ==================== 指点飞行编排接口 ====================
+
+/**
+ * 开始指点飞行
+ */
+export async function startFlyToPoint(params: {
+ deviceSn: string;
+ dockLatitude?: number;
+ dockLongitude?: number;
+ dockHeight?: number;
+ isAirborne?: boolean;
+}) {
+ return request>('/api-order/mission/startFlyToPoint', {
+ method: 'POST',
+ data: params,
+ });
+}
+
+/**
+ * 更新指点飞行目标点
+ */
+export async function flyToPointUpdate(params: {
+ missionCode: string;
+ latitude: number;
+ longitude: number;
+ height: number;
+ maxSpeed?: number;
+ clearanceStatus: 'VERIFIED' | 'UNVERIFIED';
+ clearanceMeters?: number;
+ candidateSurfaceHeight?: number;
+ riskAcknowledged: boolean;
+ riskReason?: string;
+}) {
+ return request>('/api-order/mission/flyToPointUpdate', {
+ method: 'POST',
+ data: params,
+ });
+}
+
+/**
+ * 结束指点飞行
+ */
+export async function endFlyToPoint(missionCode: string) {
+ return request>('/api-order/mission/endFlyToPoint', {
+ method: 'POST',
+ data: { missionCode },
+ });
+}