feat: 可视化大屏展示
This commit is contained in:
@@ -0,0 +1,227 @@
|
||||
import { request } from 'umi';
|
||||
import { deviceApi } from './device';
|
||||
import { listMission, MissionStatus } from './mission';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
/**
|
||||
* 大屏统计服务
|
||||
* 聚合设备和任务统计数据
|
||||
*/
|
||||
|
||||
export interface DeviceStats {
|
||||
total: number;
|
||||
online: number;
|
||||
offline: number;
|
||||
fault: number;
|
||||
onlineRate: number;
|
||||
byType: { type: string; name: string; count: number }[];
|
||||
}
|
||||
|
||||
export interface TaskStats {
|
||||
total: number;
|
||||
pending: number;
|
||||
running: number;
|
||||
completed: number;
|
||||
failed: number;
|
||||
todayNew: number;
|
||||
successRate: number;
|
||||
}
|
||||
|
||||
export interface TrendItem {
|
||||
date: string;
|
||||
created?: number;
|
||||
completed?: number;
|
||||
failed?: number;
|
||||
online?: number;
|
||||
total?: number;
|
||||
}
|
||||
|
||||
export interface AlertItem {
|
||||
id: string;
|
||||
type: 'device_offline' | 'task_failed' | 'low_battery' | 'device_fault';
|
||||
deviceSn?: string;
|
||||
deviceName?: string;
|
||||
taskId?: number;
|
||||
taskName?: string;
|
||||
message: string;
|
||||
level: 'warning' | 'error' | 'critical';
|
||||
timestamp: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备统计
|
||||
*/
|
||||
export async function getDeviceStats(params?: { tenantId?: string; includeChildren?: boolean }): Promise<DeviceStats> {
|
||||
try {
|
||||
const res = await deviceApi.deviceList({ page: 1, limit: 1000, ...params });
|
||||
const devices = res.data || [];
|
||||
|
||||
const online = devices.filter((d: any) => d.status === 1 || d.boundStatus === 1).length;
|
||||
const offline = devices.filter((d: any) => d.status === 0 || d.boundStatus === 0).length;
|
||||
const fault = devices.filter((d: any) => d.status === -1).length;
|
||||
const total = devices.length;
|
||||
|
||||
// 按类型分组
|
||||
const typeMap: Record<string, number> = {};
|
||||
devices.forEach((d: any) => {
|
||||
const type = d.deviceType || 'unknown';
|
||||
typeMap[type] = (typeMap[type] || 0) + 1;
|
||||
});
|
||||
|
||||
const typeNameMap: Record<string, string> = {
|
||||
drone: '无人机',
|
||||
dock: '机库',
|
||||
camera: '摄像头',
|
||||
unknown: '其他',
|
||||
};
|
||||
|
||||
const byType = Object.entries(typeMap).map(([type, count]) => ({
|
||||
type,
|
||||
name: typeNameMap[type] || type,
|
||||
count,
|
||||
}));
|
||||
|
||||
return {
|
||||
total,
|
||||
online,
|
||||
offline,
|
||||
fault,
|
||||
onlineRate: total > 0 ? Math.round((online / total) * 100) : 0,
|
||||
byType,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取设备统计失败:', error);
|
||||
return {
|
||||
total: 0,
|
||||
online: 0,
|
||||
offline: 0,
|
||||
fault: 0,
|
||||
onlineRate: 0,
|
||||
byType: [],
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务统计
|
||||
*/
|
||||
export async function getTaskStats(params?: {
|
||||
tenantId?: string;
|
||||
includeChildren?: boolean;
|
||||
statType?: 'day' | 'month' | 'year';
|
||||
date?: string;
|
||||
}): Promise<TaskStats> {
|
||||
try {
|
||||
const statType = params?.statType || 'day';
|
||||
const baseDate = params?.date ? dayjs(params.date) : dayjs();
|
||||
const start = baseDate.startOf(statType);
|
||||
const end = baseDate.endOf(statType);
|
||||
|
||||
const res: any = await listMission({
|
||||
page: 1,
|
||||
limit: 1000,
|
||||
tenantId: params?.tenantId,
|
||||
includeChildren: params?.includeChildren,
|
||||
startDate: start.format('YYYY-MM-DD'),
|
||||
endDate: end.format('YYYY-MM-DD'),
|
||||
});
|
||||
|
||||
const missions = res?.data || [];
|
||||
|
||||
const missionsInRange = missions.filter((m: any) => {
|
||||
if (!m?.createTime) return true;
|
||||
const createdAt = dayjs(m.createTime);
|
||||
if (!createdAt.isValid()) return true;
|
||||
const createdAtMs = createdAt.valueOf();
|
||||
return createdAtMs >= start.valueOf() && createdAtMs <= end.valueOf();
|
||||
});
|
||||
|
||||
const total = missionsInRange.length;
|
||||
const pending = missionsInRange.filter((m: any) => m.missionStatus === MissionStatus.PENDING).length;
|
||||
const running = missionsInRange.filter((m: any) => m.missionStatus === MissionStatus.DOING).length;
|
||||
const completed = missionsInRange.filter((m: any) =>
|
||||
m.missionStatus === MissionStatus.COMPLETE ||
|
||||
m.missionStatus === MissionStatus.UPLOADED
|
||||
).length;
|
||||
const failed = missionsInRange.filter((m: any) => m.missionStatus === MissionStatus.CANCELED).length;
|
||||
|
||||
// 统计区间内新增(与筛选范围保持一致)
|
||||
const todayNew = total;
|
||||
|
||||
return {
|
||||
total,
|
||||
pending,
|
||||
running,
|
||||
completed,
|
||||
failed,
|
||||
todayNew,
|
||||
successRate: total > 0 ? Math.round((completed / total) * 100) : 0,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取任务统计失败:', error);
|
||||
return {
|
||||
total: 0,
|
||||
pending: 0,
|
||||
running: 0,
|
||||
completed: 0,
|
||||
failed: 0,
|
||||
todayNew: 0,
|
||||
successRate: 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取趋势数据(模拟)
|
||||
*/
|
||||
export async function getTrendData(days: number = 7): Promise<{ taskTrend: TrendItem[]; deviceTrend: TrendItem[] }> {
|
||||
const taskTrend: TrendItem[] = [];
|
||||
const deviceTrend: TrendItem[] = [];
|
||||
|
||||
for (let i = days - 1; i >= 0; i--) {
|
||||
const date = new Date();
|
||||
date.setDate(date.getDate() - i);
|
||||
const dateStr = date.toISOString().split('T')[0];
|
||||
|
||||
taskTrend.push({
|
||||
date: dateStr,
|
||||
created: Math.floor(Math.random() * 20) + 5,
|
||||
completed: Math.floor(Math.random() * 15) + 3,
|
||||
failed: Math.floor(Math.random() * 3),
|
||||
});
|
||||
|
||||
deviceTrend.push({
|
||||
date: dateStr,
|
||||
online: Math.floor(Math.random() * 30) + 70,
|
||||
total: 100,
|
||||
});
|
||||
}
|
||||
|
||||
return { taskTrend, deviceTrend };
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟告警数据
|
||||
*/
|
||||
export function getMockAlerts(): AlertItem[] {
|
||||
return [
|
||||
{
|
||||
id: '1',
|
||||
type: 'device_offline',
|
||||
deviceSn: 'DRONE001',
|
||||
deviceName: '巡检无人机A',
|
||||
message: '设备离线超过5分钟',
|
||||
level: 'warning',
|
||||
timestamp: new Date().toISOString(),
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
type: 'low_battery',
|
||||
deviceSn: 'DRONE002',
|
||||
deviceName: '巡检无人机B',
|
||||
message: '电池电量低于20%',
|
||||
level: 'warning',
|
||||
timestamp: new Date(Date.now() - 300000).toISOString(),
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
import { request } from 'umi';
|
||||
|
||||
export interface DeviceItem {
|
||||
deviceSn?: string;
|
||||
deviceName?: string;
|
||||
boundStatus?: number;
|
||||
createTime?: string;
|
||||
status?: number; // 0-离线 1-在线
|
||||
deviceType?: string; // drone/dock/camera
|
||||
}
|
||||
|
||||
export interface TakeoffParams {
|
||||
deviceSn: string;
|
||||
targetLatitude: number;
|
||||
targetLongitude: number;
|
||||
targetHeight?: number;
|
||||
securityTakeoffHeight?: number;
|
||||
rthMode?: number;
|
||||
rthAltitude?: number;
|
||||
rcLostAction?: number;
|
||||
commanderModeLostAction?: number;
|
||||
commanderFlightMode?: number;
|
||||
commanderFlightHeight?: number;
|
||||
flightId?: string;
|
||||
maxSpeed?: number;
|
||||
flightSafetyAdvanceCheck?: number;
|
||||
}
|
||||
|
||||
export interface StickControlParams {
|
||||
deviceSn: string;
|
||||
roll?: number;
|
||||
pitch?: number;
|
||||
throttle?: number;
|
||||
yaw?: number;
|
||||
}
|
||||
|
||||
export interface GimbalControlParams {
|
||||
deviceSn: string;
|
||||
pitchSpeed?: number;
|
||||
yawSpeed?: number;
|
||||
locked?: boolean;
|
||||
}
|
||||
|
||||
export interface CommandResult {
|
||||
code?: number;
|
||||
msg?: string;
|
||||
resp_code?: number;
|
||||
resp_msg?: string;
|
||||
data?: string;
|
||||
}
|
||||
|
||||
function normalizeResponse(response: any): { code: number; msg: string; data?: any } {
|
||||
const code = response.resp_code !== undefined ? response.resp_code : response.code;
|
||||
const msg = response.resp_msg !== undefined ? response.resp_msg : response.msg;
|
||||
const data = response.data;
|
||||
return { code: code !== undefined ? code : 1, msg: msg || '', data };
|
||||
}
|
||||
|
||||
export const deviceApi = {
|
||||
// 设备列表
|
||||
deviceList: async (params: { page?: number; limit?: number; [k:string]: any }) => {
|
||||
const res = await request('/api-device/device', { method: 'GET', params });
|
||||
return { data: (res as any).data, total: (res as any).count } as { data: DeviceItem[]; total: number };
|
||||
},
|
||||
|
||||
// 航线列表
|
||||
wayline: async (params: { current?: number; pageSize?: number; [k:string]: any }) => {
|
||||
const { current, pageSize, ...rest } = params || {};
|
||||
const res = await request('/api-device/wayline', { method: 'GET', params: { page: current, limit: pageSize, ...rest } });
|
||||
return { data: (res as any).data, total: (res as any).count };
|
||||
},
|
||||
|
||||
// 一键起飞
|
||||
takeoff: async (params: TakeoffParams): Promise<CommandResult> => {
|
||||
const res = await request('/api-device/device/command/takeoff', { method: 'POST', data: params });
|
||||
return normalizeResponse(res);
|
||||
},
|
||||
|
||||
// 一键返航
|
||||
returnHome: async (deviceSn: string): Promise<CommandResult> => {
|
||||
const res = await request('/api-device/device/command/return', { method: 'POST', params: { deviceSn } });
|
||||
return normalizeResponse(res);
|
||||
},
|
||||
|
||||
// 取消返航
|
||||
cancelReturnHome: async (deviceSn: string): Promise<CommandResult> => {
|
||||
const res = await request('/api-device/device/command/return/cancel', { method: 'POST', params: { deviceSn } });
|
||||
return res as CommandResult;
|
||||
},
|
||||
|
||||
// 暂停
|
||||
pause: async (deviceSn: string): Promise<CommandResult> => {
|
||||
const res = await request('/api-device/device/command/pause', { method: 'POST', params: { deviceSn } });
|
||||
return res as CommandResult;
|
||||
},
|
||||
|
||||
// 恢复
|
||||
resume: async (deviceSn: string): Promise<CommandResult> => {
|
||||
const res = await request('/api-device/device/command/resume', { method: 'POST', params: { deviceSn } });
|
||||
return res as CommandResult;
|
||||
},
|
||||
|
||||
// 拍照
|
||||
takePhoto: async (deviceSn: string): Promise<CommandResult> => {
|
||||
const res = await request('/api-device/device/command/photo', { method: 'POST', params: { deviceSn } });
|
||||
return res as CommandResult;
|
||||
},
|
||||
|
||||
// 开始录像
|
||||
startRecording: async (deviceSn: string): Promise<CommandResult> => {
|
||||
const res = await request('/api-device/device/command/recording/start', { method: 'POST', params: { deviceSn } });
|
||||
return res as CommandResult;
|
||||
},
|
||||
|
||||
// 停止录像
|
||||
stopRecording: async (deviceSn: string): Promise<CommandResult> => {
|
||||
const res = await request('/api-device/device/command/recording/stop', { method: 'POST', params: { deviceSn } });
|
||||
return res as CommandResult;
|
||||
},
|
||||
|
||||
// 切换相机模式(0=拍照模式,1=录像模式)
|
||||
switchCameraMode: async (deviceSn: string, cameraMode: number): Promise<CommandResult> => {
|
||||
const res = await request('/api-device/device/command/camera/mode', { method: 'POST', params: { deviceSn, cameraMode } });
|
||||
return res as CommandResult;
|
||||
},
|
||||
|
||||
// 进入DRC模式
|
||||
enterDrcMode: async (deviceSn: string): Promise<CommandResult> => {
|
||||
const res = await request('/api-device/device/command/drc/enter', { method: 'POST', params: { deviceSn } });
|
||||
return res as CommandResult;
|
||||
},
|
||||
|
||||
// 杆量控制
|
||||
stickControl: async (params: StickControlParams): Promise<CommandResult> => {
|
||||
const res = await request('/api-device/device/command/drc/stick', { method: 'POST', data: params });
|
||||
return res as CommandResult;
|
||||
},
|
||||
|
||||
// 云台控制
|
||||
gimbalControl: async (params: GimbalControlParams): Promise<CommandResult> => {
|
||||
const res = await request('/api-device/device/command/gimbal', { method: 'POST', data: params });
|
||||
return res as CommandResult;
|
||||
},
|
||||
|
||||
// 订阅无人机遥测
|
||||
subscribeDroneTelemetry: async (deviceSn: string): Promise<{ success: boolean; message?: string }> => {
|
||||
try {
|
||||
const res = await request(`/api-device/sse/drone-telemetry/${deviceSn}/subscribe`, { method: 'POST' });
|
||||
return { success: true, message: res as string };
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message };
|
||||
}
|
||||
},
|
||||
|
||||
// 取消订阅
|
||||
unsubscribeDroneTelemetry: async (deviceSn: string): Promise<{ success: boolean; message?: string }> => {
|
||||
try {
|
||||
const res = await request(`/api-device/sse/drone-telemetry/${deviceSn}/unsubscribe`, { method: 'POST' });
|
||||
return { success: true, message: res as string };
|
||||
} catch (error: any) {
|
||||
return { success: false, message: error.message };
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,144 @@
|
||||
/**
|
||||
* 设备实时控制服务
|
||||
* 用于云台控制和摇杆控制
|
||||
* 使用HTTP API实现(替代WebSocket)
|
||||
*/
|
||||
|
||||
import { request } from 'umi';
|
||||
|
||||
export interface StickControlData {
|
||||
/** 横滚通道(624-1424,1024为中值,控制左右平移) */
|
||||
roll?: number;
|
||||
/** 俯仰通道(624-1424,1024为中值,控制前后平移) */
|
||||
pitch?: number;
|
||||
/** 升降通道(624-1424,1024为悬停,控制升降) */
|
||||
throttle?: number;
|
||||
/** 偏航通道(624-1424,1024为中值,控制左右旋转) */
|
||||
yaw?: number;
|
||||
}
|
||||
|
||||
export interface GimbalControlData {
|
||||
/** 云台 pitch 速度(度/秒) */
|
||||
pitchSpeed?: number;
|
||||
/** 云台 yaw 速度(度/秒) */
|
||||
yawSpeed?: number;
|
||||
/** 是否锁定机头:false=仅云台转,true=机身一起转 */
|
||||
locked?: boolean;
|
||||
}
|
||||
|
||||
type StatusHandler = (connected: boolean) => void;
|
||||
|
||||
class DeviceControlService {
|
||||
private statusHandlers: StatusHandler[] = [];
|
||||
private currentDeviceSn: string | null = null;
|
||||
private isActive = false;
|
||||
|
||||
/**
|
||||
* 连接设备(标记为活跃状态)
|
||||
*/
|
||||
connect(deviceSn: string): void {
|
||||
this.currentDeviceSn = deviceSn;
|
||||
this.isActive = true;
|
||||
console.log('[ControlHTTP] 已连接设备:', deviceSn);
|
||||
this.notifyStatusHandlers(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 断开连接(标记为非活跃状态)
|
||||
*/
|
||||
disconnect(): void {
|
||||
console.log('[ControlHTTP] 断开连接');
|
||||
this.isActive = false;
|
||||
this.currentDeviceSn = null;
|
||||
this.notifyStatusHandlers(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送摇杆控制指令
|
||||
*/
|
||||
sendStickControl(data: StickControlData): boolean {
|
||||
if (!this.currentDeviceSn || !this.isActive) {
|
||||
console.warn('[ControlHTTP] 未连接设备');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 使用异步请求,不等待响应(提高控制频率)
|
||||
request('/api-device/device/command/drc/stick', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
deviceSn: this.currentDeviceSn,
|
||||
roll: data.roll ?? 1024,
|
||||
pitch: data.pitch ?? 1024,
|
||||
throttle: data.throttle ?? 1024,
|
||||
yaw: data.yaw ?? 1024,
|
||||
gimbalPitch: 1024,
|
||||
},
|
||||
}).catch(e => {
|
||||
console.warn('[ControlHTTP] 摇杆指令发送失败:', e);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送云台控制指令
|
||||
*/
|
||||
sendGimbalControl(data: GimbalControlData): boolean {
|
||||
if (!this.currentDeviceSn || !this.isActive) {
|
||||
console.warn('[ControlHTTP] 未连接设备');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 使用异步请求,不等待响应
|
||||
request('/api-device/device/command/gimbal', {
|
||||
method: 'POST',
|
||||
data: {
|
||||
deviceSn: this.currentDeviceSn,
|
||||
pitchSpeed: data.pitchSpeed ?? 0,
|
||||
yawSpeed: data.yawSpeed ?? 0,
|
||||
locked: data.locked ?? false,
|
||||
},
|
||||
}).catch(e => {
|
||||
console.warn('[ControlHTTP] 云台指令发送失败:', e);
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否已连接
|
||||
*/
|
||||
isConnected(): boolean {
|
||||
return this.isActive && this.currentDeviceSn !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前设备SN
|
||||
*/
|
||||
getCurrentDeviceSn(): string | null {
|
||||
return this.currentDeviceSn;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加状态处理器
|
||||
*/
|
||||
onStatusChange(handler: StatusHandler): () => void {
|
||||
this.statusHandlers.push(handler);
|
||||
return () => {
|
||||
this.statusHandlers = this.statusHandlers.filter(h => h !== handler);
|
||||
};
|
||||
}
|
||||
|
||||
private notifyStatusHandlers(connected: boolean): void {
|
||||
this.statusHandlers.forEach(handler => {
|
||||
try {
|
||||
handler(connected);
|
||||
} catch (e) {
|
||||
console.error('[ControlHTTP] 状态处理器错误:', e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 导出单例(保持与原WebSocket版本相同的接口名)
|
||||
export const deviceControlWs = new DeviceControlService();
|
||||
@@ -0,0 +1,59 @@
|
||||
import { request } from 'umi';
|
||||
import { encryptPassword } from '@/utils/rsaUtil';
|
||||
|
||||
export interface LoginParams {
|
||||
username: string;
|
||||
password: string;
|
||||
tenantId?: string;
|
||||
deviceId?: string;
|
||||
clientId?: string;
|
||||
clientSecret?: string;
|
||||
validCode?: string;
|
||||
}
|
||||
|
||||
// 获取当前用户信息
|
||||
export async function currentUser(): Promise<any> {
|
||||
const res = await request('/api-user/users/current', { method: 'GET' });
|
||||
const mapped: any = res as any;
|
||||
if (typeof mapped?.success !== 'undefined') {
|
||||
if (mapped.success) return mapped.data;
|
||||
return { resp_msg: mapped.msg } as any;
|
||||
}
|
||||
return mapped;
|
||||
}
|
||||
|
||||
// 退出登录
|
||||
export async function outLogin(): Promise<any> {
|
||||
return request('/api-uaa/oauth/logout', { method: 'POST' });
|
||||
}
|
||||
|
||||
// 登录
|
||||
export async function login(body: LoginParams): Promise<any> {
|
||||
const encPwd = encryptPassword(body.password || '');
|
||||
|
||||
if (!encPwd) {
|
||||
throw new Error('密码加密失败,请刷新页面重试');
|
||||
}
|
||||
|
||||
const grantType = 'password_code';
|
||||
|
||||
const requestData = {
|
||||
userName: body.username,
|
||||
password: encPwd,
|
||||
grantType,
|
||||
clientId: body.clientId,
|
||||
validCode: body.validCode,
|
||||
deviceId: body.deviceId,
|
||||
};
|
||||
|
||||
const res = await request('/api-uaa/oauth/login', {
|
||||
method: 'POST',
|
||||
data: requestData,
|
||||
});
|
||||
const mapped: any = res as any;
|
||||
if (typeof mapped?.success !== 'undefined') {
|
||||
if (mapped.success) return mapped.data;
|
||||
return { resp_msg: mapped.msg } as any;
|
||||
}
|
||||
return mapped;
|
||||
}
|
||||
@@ -0,0 +1,276 @@
|
||||
import { request } from 'umi';
|
||||
|
||||
/**
|
||||
* 任务类型枚举
|
||||
*/
|
||||
export enum MissionType {
|
||||
WAYLINE = 1, // 航线任务
|
||||
TAKEOFF = 2, // 一键起飞任务
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务状态枚举
|
||||
*/
|
||||
export enum MissionStatus {
|
||||
PENDING = 1, // 待执行
|
||||
CANCELED = 2, // 已取消
|
||||
COMPLETE = 3, // 已完成
|
||||
DOING = 4, // 执行中
|
||||
UPLOADING = 5, // 图片上传中
|
||||
UPLOADED = 6, // 图片上传完成
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务类型描述映射
|
||||
*/
|
||||
export const MissionTypeMap: Record<number, string> = {
|
||||
[MissionType.WAYLINE]: '航线任务',
|
||||
[MissionType.TAKEOFF]: '一键起飞',
|
||||
};
|
||||
|
||||
/**
|
||||
* 任务状态描述映射
|
||||
*/
|
||||
export const MissionStatusMap: Record<number, string> = {
|
||||
[MissionStatus.PENDING]: '待执行',
|
||||
[MissionStatus.CANCELED]: '已取消',
|
||||
[MissionStatus.COMPLETE]: '已完成',
|
||||
[MissionStatus.DOING]: '执行中',
|
||||
[MissionStatus.UPLOADING]: '上传中',
|
||||
[MissionStatus.UPLOADED]: '上传完成',
|
||||
};
|
||||
|
||||
/**
|
||||
* 任务状态颜色映射
|
||||
*/
|
||||
export const MissionStatusColorMap: Record<number, string> = {
|
||||
[MissionStatus.PENDING]: 'default',
|
||||
[MissionStatus.CANCELED]: 'error',
|
||||
[MissionStatus.COMPLETE]: 'success',
|
||||
[MissionStatus.DOING]: 'processing',
|
||||
[MissionStatus.UPLOADING]: 'warning',
|
||||
[MissionStatus.UPLOADED]: 'success',
|
||||
};
|
||||
|
||||
/**
|
||||
* 任务实体接口
|
||||
*/
|
||||
export interface Mission {
|
||||
id?: number;
|
||||
missionCode?: string;
|
||||
missionName?: string;
|
||||
missionType?: number;
|
||||
missionTypeDesc?: string;
|
||||
tourismId?: number;
|
||||
deviceSn?: string;
|
||||
waylineId?: string;
|
||||
waylineName?: string;
|
||||
missionStatus?: number;
|
||||
missionStatusDesc?: string;
|
||||
targetLatitude?: number;
|
||||
targetLongitude?: number;
|
||||
targetHeight?: number;
|
||||
creatorId?: number;
|
||||
creatorName?: string;
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
remark?: string;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务图片实体接口
|
||||
*/
|
||||
export interface MissionImage {
|
||||
id?: number;
|
||||
missionCode?: string;
|
||||
tourismId?: number;
|
||||
deviceSn?: string;
|
||||
fileId?: string;
|
||||
filePath?: string;
|
||||
fileType?: string;
|
||||
viewUrl?: string;
|
||||
latitude?: number;
|
||||
longitude?: number;
|
||||
altitude?: number;
|
||||
shootTime?: string;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建任务请求参数
|
||||
*/
|
||||
export interface CreateMissionParams {
|
||||
deviceSn: string;
|
||||
missionType?: number;
|
||||
missionName?: string;
|
||||
tourismId?: number;
|
||||
waylineId?: string;
|
||||
waylineName?: string;
|
||||
targetLatitude?: number;
|
||||
targetLongitude?: number;
|
||||
targetHeight?: number;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询任务列表请求参数
|
||||
*/
|
||||
export interface ListMissionParams {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
deviceSn?: string;
|
||||
missionStatus?: number;
|
||||
missionType?: number;
|
||||
tourismId?: number;
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
tenantId?: string;
|
||||
includeChildren?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建任务
|
||||
*/
|
||||
export async function saveMission(params: CreateMissionParams | any) {
|
||||
return request<API.Result<Mission>>('/api-order/mission/saveMission', {
|
||||
method: 'POST',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行任务(下发到设备)
|
||||
*/
|
||||
export async function executeMission(missionCode: string) {
|
||||
return request<API.Result<string>>('/api-order/mission/executeMission', {
|
||||
method: 'POST',
|
||||
data: { missionCode },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询任务列表
|
||||
*/
|
||||
export async function listMission(params: ListMissionParams) {
|
||||
return request<API.PageResult<Mission>>('/api-order/mission/listMission', {
|
||||
method: 'POST',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务详情
|
||||
*/
|
||||
export async function getMission(missionCode: string) {
|
||||
return request<API.Result<Mission>>('/api-order/mission/getMission', {
|
||||
method: 'POST',
|
||||
data: { missionCode },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新任务状态
|
||||
*/
|
||||
export async function updateMissionStatus(missionCode: string, status: number) {
|
||||
return request<API.Result<string>>('/api-order/mission/updateMissionStatus', {
|
||||
method: 'POST',
|
||||
data: { missionCode, status },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消任务
|
||||
*/
|
||||
export async function cancelMission(missionCode: string) {
|
||||
return request<API.Result<string>>('/api-order/mission/cancelMission', {
|
||||
method: 'POST',
|
||||
data: { missionCode },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成任务
|
||||
*/
|
||||
export async function completeMission(missionCode: string) {
|
||||
return request<API.Result<string>>('/api-order/mission/completeMission', {
|
||||
method: 'POST',
|
||||
data: { missionCode },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除任务
|
||||
*/
|
||||
export async function deleteMission(missionCode: string) {
|
||||
return request<API.Result<string>>('/api-order/mission/deleteMission', {
|
||||
method: 'POST',
|
||||
data: { missionCode },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存任务图片记录
|
||||
*/
|
||||
export async function saveMissionImage(params: Partial<MissionImage>) {
|
||||
return request<API.Result<MissionImage>>('/api-order/mission/image/saveMissionImage', {
|
||||
method: 'POST',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询任务图片列表
|
||||
*/
|
||||
export async function listMissionImage(missionCode: string) {
|
||||
return request<API.Result<MissionImage[]>>('/api-order/mission/image/listMissionImage', {
|
||||
method: 'POST',
|
||||
data: { missionCode },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询任务图片列表
|
||||
*/
|
||||
export async function pageMissionImage(params: {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
missionCode?: string;
|
||||
deviceSn?: string;
|
||||
}) {
|
||||
return request<API.PageResult<MissionImage>>('/api-order/mission/image/pageMissionImage', {
|
||||
method: 'POST',
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图片详情
|
||||
*/
|
||||
export async function getMissionImage(id: number) {
|
||||
return request<API.Result<MissionImage>>('/api-order/mission/image/getMissionImage', {
|
||||
method: 'POST',
|
||||
data: { id },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除图片记录
|
||||
*/
|
||||
export async function deleteMissionImage(id: number) {
|
||||
return request<API.Result<string>>('/api-order/mission/image/deleteMissionImage', {
|
||||
method: 'POST',
|
||||
data: { id },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计任务图片数量
|
||||
*/
|
||||
export async function countMissionImage(missionCode: string) {
|
||||
return request<API.Result<number>>('/api-order/mission/image/countMissionImage', {
|
||||
method: 'POST',
|
||||
data: { missionCode },
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { request } from 'umi';
|
||||
|
||||
/**
|
||||
* 订单服务(精简版)
|
||||
* 仅保留3D地图需要的景区相关接口
|
||||
*/
|
||||
export const ordersApi = {
|
||||
// 景区管理
|
||||
tourism: async (params: { current?: number; pageSize?: number; [k: string]: any }) => {
|
||||
const { current, pageSize, ...rest } = params || {};
|
||||
const res = await request('/api-order/tourism', { method: 'GET', params: { page: current, limit: pageSize, ...rest } });
|
||||
return { data: (res as any).data, total: (res as any).count };
|
||||
},
|
||||
|
||||
// 根据景区ID获取设备SN列表
|
||||
getDeviceSnsByTourismId: async (tourismId: number) => {
|
||||
const res = await request(`/api-order/tourism/${tourismId}/device-sns`, { method: 'GET' });
|
||||
return (res as any).data || [];
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,274 @@
|
||||
/**
|
||||
* SRS 流媒体服务
|
||||
* 处理 SRS 服务器认证和 WebRTC WHEP 视频流播放
|
||||
*/
|
||||
|
||||
// SRS 服务器配置
|
||||
const SRS_CONFIG = {
|
||||
// 所有环境都通过代理访问,避免跨域问题
|
||||
// 开发环境: webpack devServer 代理
|
||||
// 测试/生产环境: nginx 代理
|
||||
baseUrl: '',
|
||||
// 登录密码
|
||||
password: 'a6949674ed817fa3',
|
||||
};
|
||||
|
||||
// WebRTC ICE 服务器配置(用于 NAT 穿透)
|
||||
// 必须与 SRS 服务器配置的 STUN/TURN 一致
|
||||
const ICE_SERVERS: RTCConfiguration = {
|
||||
iceServers: [
|
||||
// 自建 STUN 服务器
|
||||
{ urls: 'stun:220.205.16.27:3478' },
|
||||
// 自建 TURN 服务器(用于复杂 NAT 环境)
|
||||
{
|
||||
urls: 'turn:220.205.16.27:3478?transport=udp',
|
||||
username: 'webrtc',
|
||||
credential: 'GoFly@2024',
|
||||
},
|
||||
// 备用 Google STUN(可选)
|
||||
{ urls: 'stun:stun.l.google.com:19302' },
|
||||
],
|
||||
iceCandidatePoolSize: 10,
|
||||
};
|
||||
|
||||
// 存储 token
|
||||
let srsToken: string | null = null;
|
||||
let tokenExpireTime: number = 0;
|
||||
|
||||
export interface SrsLoginResponse {
|
||||
code: number;
|
||||
data?: {
|
||||
token: string;
|
||||
[key: string]: any;
|
||||
};
|
||||
}
|
||||
|
||||
export const srsApi = {
|
||||
/**
|
||||
* 登录 SRS 服务器获取 token
|
||||
* @param password 登录密码
|
||||
*/
|
||||
login: async (password?: string): Promise<{ success: boolean; token?: string; error?: string }> => {
|
||||
try {
|
||||
const response = await fetch(`${SRS_CONFIG.baseUrl}/terraform/v1/mgmt/login`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ password: password || SRS_CONFIG.password }),
|
||||
credentials: 'include', // 重要:携带 cookie
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
return { success: false, error: `HTTP ${response.status}` };
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.code === 0 && data.data?.token) {
|
||||
srsToken = data.data.token;
|
||||
// token 有效期设为 1 小时
|
||||
tokenExpireTime = Date.now() + 3600 * 1000;
|
||||
return { success: true, token: data.data.token };
|
||||
}
|
||||
|
||||
return { success: false, error: data.msg || '登录失败' };
|
||||
} catch (error: any) {
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取当前 token(如果过期则重新登录)
|
||||
*/
|
||||
getToken: async (): Promise<string | null> => {
|
||||
// 检查 token 是否有效
|
||||
if (srsToken && Date.now() < tokenExpireTime) {
|
||||
return srsToken;
|
||||
}
|
||||
|
||||
// 重新登录获取 token
|
||||
const result = await srsApi.login();
|
||||
return result.success ? result.token || null : null;
|
||||
},
|
||||
|
||||
/**
|
||||
* 检查是否已登录
|
||||
*/
|
||||
isLoggedIn: (): boolean => {
|
||||
return !!srsToken && Date.now() < tokenExpireTime;
|
||||
},
|
||||
|
||||
/**
|
||||
* 构建 WHEP 播放 URL
|
||||
* @param streamId 流ID(如 49214ac552fa)
|
||||
* @param app 应用名称(默认 live)
|
||||
*/
|
||||
buildWhepUrl: (streamId: string, app: string = 'live'): string => {
|
||||
return `${SRS_CONFIG.baseUrl}/rtc/v1/whep/?app=${app}&stream=${streamId}`;
|
||||
},
|
||||
|
||||
/**
|
||||
* 使用 WHEP 协议播放 WebRTC 视频流
|
||||
* @param streamId 流ID
|
||||
* @param videoElement video 元素
|
||||
* @param options 选项
|
||||
*/
|
||||
playWhep: async (
|
||||
streamId: string,
|
||||
videoElement: HTMLVideoElement,
|
||||
options?: { app?: string; videoOnly?: boolean; audioOnly?: boolean }
|
||||
): Promise<{
|
||||
success: boolean;
|
||||
pc?: RTCPeerConnection;
|
||||
stream?: MediaStream;
|
||||
error?: string;
|
||||
}> => {
|
||||
try {
|
||||
// 确保已登录
|
||||
const token = await srsApi.getToken();
|
||||
if (!token) {
|
||||
return { success: false, error: 'SRS 认证失败,请检查密码' };
|
||||
}
|
||||
|
||||
const url = srsApi.buildWhepUrl(streamId, options?.app);
|
||||
|
||||
// 创建 RTCPeerConnection(配置 ICE 服务器用于 NAT 穿透)
|
||||
const pc = new RTCPeerConnection(ICE_SERVERS);
|
||||
const stream = new MediaStream();
|
||||
|
||||
// 设置接收音视频轨道
|
||||
if (!options?.videoOnly) {
|
||||
pc.addTransceiver('audio', { direction: 'recvonly' });
|
||||
}
|
||||
if (!options?.audioOnly) {
|
||||
pc.addTransceiver('video', { direction: 'recvonly' });
|
||||
}
|
||||
|
||||
// 监听远端轨道
|
||||
pc.ontrack = (event) => {
|
||||
stream.addTrack(event.track);
|
||||
videoElement.srcObject = stream;
|
||||
};
|
||||
|
||||
// 创建 offer
|
||||
const offer = await pc.createOffer();
|
||||
await pc.setLocalDescription(offer);
|
||||
|
||||
// 发送 offer 到 WHEP 端点
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/sdp',
|
||||
},
|
||||
body: offer.sdp,
|
||||
credentials: 'include', // 携带 cookie
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
pc.close();
|
||||
return { success: false, error: `WHEP 请求失败: HTTP ${response.status}` };
|
||||
}
|
||||
|
||||
const answerSdp = await response.text();
|
||||
|
||||
// 设置远端描述
|
||||
await pc.setRemoteDescription(new RTCSessionDescription({
|
||||
type: 'answer',
|
||||
sdp: answerSdp,
|
||||
}));
|
||||
|
||||
return { success: true, pc, stream };
|
||||
} catch (error: any) {
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 使用完整 URL 播放 WHEP 视频流
|
||||
* @param whepUrl 完整的 WHEP URL(如:http://220.205.16.27:8024/rtc/v1/whep/?app=live&stream=xxx)
|
||||
* @param videoElement video 元素
|
||||
* @param options 选项
|
||||
*/
|
||||
playWhepByUrl: async (
|
||||
whepUrl: string,
|
||||
videoElement: HTMLVideoElement,
|
||||
options?: { videoOnly?: boolean; audioOnly?: boolean }
|
||||
): Promise<{
|
||||
success: boolean;
|
||||
pc?: RTCPeerConnection;
|
||||
stream?: MediaStream;
|
||||
error?: string;
|
||||
}> => {
|
||||
try {
|
||||
// 解析 URL,提取路径部分通过代理访问(避免跨域)
|
||||
const urlObj = new URL(whepUrl);
|
||||
// 所有环境都使用代理路径,避免跨域问题
|
||||
const actualUrl = `${urlObj.pathname}${urlObj.search}`;
|
||||
|
||||
// 确保已登录
|
||||
const token = await srsApi.getToken();
|
||||
|
||||
// 创建 RTCPeerConnection(配置 ICE 服务器用于 NAT 穿透)
|
||||
const pc = new RTCPeerConnection(ICE_SERVERS);
|
||||
const stream = new MediaStream();
|
||||
|
||||
// 设置接收音视频轨道
|
||||
if (!options?.videoOnly) {
|
||||
pc.addTransceiver('audio', { direction: 'recvonly' });
|
||||
}
|
||||
if (!options?.audioOnly) {
|
||||
pc.addTransceiver('video', { direction: 'recvonly' });
|
||||
}
|
||||
|
||||
// 监听远端轨道
|
||||
pc.ontrack = (event) => {
|
||||
stream.addTrack(event.track);
|
||||
videoElement.srcObject = stream;
|
||||
};
|
||||
|
||||
// 创建 offer
|
||||
const offer = await pc.createOffer();
|
||||
await pc.setLocalDescription(offer);
|
||||
|
||||
// 发送 offer 到 WHEP 端点
|
||||
const response = await fetch(actualUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/sdp',
|
||||
},
|
||||
body: offer.sdp,
|
||||
credentials: 'include', // 携带 cookie
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
pc.close();
|
||||
return { success: false, error: `WHEP 请求失败: HTTP ${response.status}` };
|
||||
}
|
||||
|
||||
const answerSdp = await response.text();
|
||||
|
||||
// 设置远端描述
|
||||
await pc.setRemoteDescription(new RTCSessionDescription({
|
||||
type: 'answer',
|
||||
sdp: answerSdp,
|
||||
}));
|
||||
|
||||
return { success: true, pc, stream };
|
||||
} catch (error: any) {
|
||||
return { success: false, error: error.message };
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 停止播放并清理资源
|
||||
*/
|
||||
stopPlay: (pc: RTCPeerConnection | null, stream: MediaStream | null) => {
|
||||
if (stream) {
|
||||
stream.getTracks().forEach(track => track.stop());
|
||||
}
|
||||
if (pc) {
|
||||
pc.close();
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,60 @@
|
||||
import { request } from 'umi';
|
||||
|
||||
export interface TenantTreeNode {
|
||||
tenantId: string;
|
||||
tenantName: string;
|
||||
parentTenantId?: string;
|
||||
tenantType: string;
|
||||
tenantLevel: number;
|
||||
status: number;
|
||||
enabled: boolean;
|
||||
description?: string;
|
||||
children?: TenantTreeNode[];
|
||||
hasChildren?: boolean;
|
||||
childrenCount?: number;
|
||||
}
|
||||
|
||||
export interface TenantInfo {
|
||||
tenantId: string;
|
||||
tenantName: string;
|
||||
parentTenantId?: string;
|
||||
parentTenantName?: string;
|
||||
tenantLevel: number;
|
||||
tenantPath: string;
|
||||
tenantType: string;
|
||||
tenantCode?: string;
|
||||
contactPerson?: string;
|
||||
contactPhone?: string;
|
||||
address?: string;
|
||||
description?: string;
|
||||
status: number;
|
||||
statusText: string;
|
||||
hasChildren?: boolean;
|
||||
childrenCount?: number;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
export const tenantApi = {
|
||||
// 可访问租户树
|
||||
getAccessibleTenants: () => request('/api-user/tenant/accessible', { method: 'GET' }),
|
||||
// 切换当前查询租户
|
||||
switchTenant: (tenantId: string) => request('/api-user/tenant/switch-query', { method: 'POST', params: { tenantId } }),
|
||||
// 当前租户详情
|
||||
getCurrentTenant: () => request('/api-user/tenant/current/info', { method: 'GET' }),
|
||||
// 当前查询范围统计
|
||||
getScopeStats: () => request('/api-user/tenant/scope/stats', { method: 'GET' }),
|
||||
// 重置为默认租户
|
||||
resetToDefaultTenant: () => request('/api-user/tenant/reset', { method: 'POST' }),
|
||||
};
|
||||
|
||||
declare global {
|
||||
namespace API {
|
||||
interface ResponseStructure<T = any> {
|
||||
success: boolean;
|
||||
code?: number;
|
||||
msg?: string;
|
||||
data: T;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
import { request } from 'umi';
|
||||
|
||||
const API_BASE = '/api-device/3d-model';
|
||||
|
||||
export enum ModelType {
|
||||
OBLIQUE = 1,
|
||||
POINT_CLOUD = 2,
|
||||
BIM = 3,
|
||||
OTHER = 4,
|
||||
}
|
||||
|
||||
export const ModelTypeMap: Record<number, string> = {
|
||||
1: '倾斜摄影',
|
||||
2: '点云',
|
||||
3: 'BIM',
|
||||
4: '其他',
|
||||
};
|
||||
|
||||
export interface ThreeDModelVO {
|
||||
id: number;
|
||||
modelName: string;
|
||||
modelType: number;
|
||||
modelTypeName: string;
|
||||
modelFormat: string;
|
||||
description: string;
|
||||
tilesetUrl: string;
|
||||
fileCount: number;
|
||||
totalSize: number;
|
||||
totalSizeFormat: string;
|
||||
tourismId: number;
|
||||
tourismName: string;
|
||||
position: {
|
||||
longitude: number;
|
||||
latitude: number;
|
||||
height: number;
|
||||
cesiumHeight?: number;
|
||||
arcgisHeight?: number;
|
||||
terrainType?: string;
|
||||
};
|
||||
transform: {
|
||||
scale: number;
|
||||
rotationX: number;
|
||||
rotationY: number;
|
||||
rotationZ: number;
|
||||
};
|
||||
style: {
|
||||
maximumScreenSpaceError: number;
|
||||
maximumMemoryUsage: number;
|
||||
skipLevelOfDetail: boolean;
|
||||
preferLeaves: boolean;
|
||||
};
|
||||
status: number;
|
||||
statusName: string;
|
||||
uploadStatus: number;
|
||||
uploadStatusName: string;
|
||||
uploadProgress: number;
|
||||
thumbnailUrl: string;
|
||||
sourceType: string;
|
||||
createTime: string;
|
||||
updateTime: string;
|
||||
}
|
||||
|
||||
export interface ModelQueryParams {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
modelName?: string;
|
||||
modelType?: number;
|
||||
tourismId?: number;
|
||||
status?: number;
|
||||
uploadStatus?: number;
|
||||
}
|
||||
|
||||
export async function getModelList(params: ModelQueryParams) {
|
||||
return request<API.PageResult<ThreeDModelVO>>(API_BASE, {
|
||||
method: 'GET',
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
export async function getModelById(id: number) {
|
||||
return request<API.Result<ThreeDModelVO>>(`${API_BASE}/${id}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
export async function getModelsByTourismId(tourismId: number) {
|
||||
return request<API.Result<ThreeDModelVO[]>>(`${API_BASE}/tourism/${tourismId}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
export async function getAvailableModels() {
|
||||
return request<API.Result<ThreeDModelVO[]>>(`${API_BASE}/available`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
export function convertToTilesetConfig(model: ThreeDModelVO) {
|
||||
return {
|
||||
id: `model_${model.id}`,
|
||||
name: model.modelName,
|
||||
url: model.tilesetUrl,
|
||||
tourismId: model.tourismId,
|
||||
position: model.position ? {
|
||||
longitude: model.position.longitude || 0,
|
||||
latitude: model.position.latitude || 0,
|
||||
height: model.position.height || 0,
|
||||
cesiumHeight: model.position.cesiumHeight,
|
||||
arcgisHeight: model.position.arcgisHeight,
|
||||
terrainType: model.position.terrainType || 'cesium_ion',
|
||||
} : undefined,
|
||||
transform: model.transform ? {
|
||||
scale: model.transform.scale || 1,
|
||||
rotationX: model.transform.rotationX || 0,
|
||||
rotationY: model.transform.rotationY || 0,
|
||||
rotationZ: model.transform.rotationZ || 0,
|
||||
} : undefined,
|
||||
style: {
|
||||
maximumScreenSpaceError: model.style?.maximumScreenSpaceError || 1,
|
||||
maximumMemoryUsage: model.style?.maximumMemoryUsage || 2048,
|
||||
skipLevelOfDetail: model.style?.skipLevelOfDetail ?? false,
|
||||
preferLeaves: model.style?.preferLeaves ?? true,
|
||||
},
|
||||
visible: model.status === 1,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
import { request } from 'umi';
|
||||
|
||||
// 航线任务列表项
|
||||
export interface WaylineRouteListItemVO {
|
||||
routeId: string;
|
||||
routeName: string;
|
||||
fileWaylineId: string;
|
||||
deviceSn: string;
|
||||
deviceName: string;
|
||||
parseStatus: number;
|
||||
parseStatusDesc?: string;
|
||||
waypointCount: number;
|
||||
totalDistance: number;
|
||||
totalDuration: number;
|
||||
createTime: string;
|
||||
}
|
||||
|
||||
// 航点数据
|
||||
export interface WaypointVO {
|
||||
index: number;
|
||||
longitude: number;
|
||||
latitude: number;
|
||||
height: number; // 相对高度
|
||||
executeHeight?: number; // 执行高度
|
||||
ellipsoidHeight?: number; // 椭球高度(用于3D地图显示)
|
||||
speed?: number;
|
||||
headingAngle?: number;
|
||||
actions?: WaypointActionVO[];
|
||||
}
|
||||
|
||||
// 轨迹点数据
|
||||
export interface TrackPointVO {
|
||||
lng: number;
|
||||
lat: number;
|
||||
alt?: number;
|
||||
height?: number;
|
||||
speed?: number;
|
||||
heading?: number;
|
||||
batteryPercent?: number;
|
||||
time?: string;
|
||||
deviationDistance?: number;
|
||||
isDeviation?: boolean;
|
||||
}
|
||||
|
||||
// 航点动作数据
|
||||
export interface WaypointActionVO {
|
||||
actionGroupId?: number;
|
||||
actionIndex?: number;
|
||||
actionType?: string;
|
||||
actionTypeDesc?: string;
|
||||
actionParams?: Record<string, any>;
|
||||
triggerType?: string;
|
||||
triggerTypeDesc?: string;
|
||||
delayTime?: number;
|
||||
payloadPositionIndex?: number;
|
||||
hoverTime?: number;
|
||||
aircraftHeading?: number;
|
||||
gimbalPitchRotateAngle?: number;
|
||||
gimbalYawRotateAngle?: number;
|
||||
focalLength?: number;
|
||||
megaphoneFilePath?: string;
|
||||
}
|
||||
|
||||
// 创建航线任务参数
|
||||
export interface CreateRouteParams {
|
||||
routeName: string;
|
||||
fileWaylineId: string;
|
||||
deviceSn: string;
|
||||
deviceName?: string;
|
||||
remark?: string;
|
||||
}
|
||||
|
||||
// 航线任务详情
|
||||
export interface WaylineRouteDetailVO {
|
||||
routeId: string;
|
||||
routeName: string;
|
||||
fileWaylineId: string;
|
||||
deviceSn: string;
|
||||
deviceName: string;
|
||||
parseStatus: number;
|
||||
parseStatusDesc?: string;
|
||||
waypointCount: number;
|
||||
totalDistance: number;
|
||||
totalDuration: number;
|
||||
waypoints?: WaypointVO[];
|
||||
}
|
||||
|
||||
// 飞行轨迹数据
|
||||
export interface FlightTrackData {
|
||||
deviceSn: string;
|
||||
jobId?: string;
|
||||
routeId?: string;
|
||||
trackPoints: TrackPointVO[];
|
||||
totalPoints: number;
|
||||
duration: number;
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
}
|
||||
|
||||
// 航线任务详情(完整版)
|
||||
export interface RouteDetailVO {
|
||||
routeInfo: WaylineRouteListItemVO;
|
||||
waypoints: WaypointVO[];
|
||||
actions: WaypointActionVO[];
|
||||
totalWaypoints: number;
|
||||
totalActions: number;
|
||||
totalDistance: number;
|
||||
totalDuration: number;
|
||||
}
|
||||
|
||||
export const waylineRouteApi = {
|
||||
// 创建航线任务(关联航迹文件和设备)
|
||||
createRoute: (params: CreateRouteParams) =>
|
||||
request('/api-device/device/route/create', { method: 'POST', data: params }),
|
||||
|
||||
// 根据设备SN获取绑定的航线任务列表
|
||||
getRouteListByDevice: (deviceSn: string) =>
|
||||
request(`/api-device/device/route/listByDevice/${deviceSn}`) as Promise<{ resp_code: number; data: WaylineRouteListItemVO[] }>,
|
||||
|
||||
// 获取航线任务详情(含航点)
|
||||
getRouteDetails: (routeId: string) =>
|
||||
request(`/api-device/device/route/detail/${routeId}`) as Promise<{ resp_code: number; data: WaylineRouteDetailVO }>,
|
||||
|
||||
// 获取航点列表(3D地图绑制航线使用)
|
||||
getRouteWaypoints: (routeId: string) =>
|
||||
request(`/api-device/device/route/waypoints/${routeId}`) as Promise<{ resp_code: number; data: WaypointVO[] }>,
|
||||
|
||||
// 解析航线任务
|
||||
parseRoute: (routeId: string) =>
|
||||
request(`/api-device/device/route/parse/${routeId}`, { method: 'POST' }),
|
||||
|
||||
// 批量解析航线任务
|
||||
batchParseRoutes: (routeIds: string[]) =>
|
||||
request('/api-device/device/route/parse/batch', { method: 'POST', data: routeIds }),
|
||||
|
||||
// 获取飞行轨迹
|
||||
getFlightTrack: (
|
||||
deviceSn: string,
|
||||
params?: {
|
||||
jobId?: string;
|
||||
routeId?: string;
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
limit?: number;
|
||||
}
|
||||
) =>
|
||||
request(`/api-device/device/drone/track/${deviceSn}`, { params }) as Promise<{ resp_code: number; data: FlightTrackData }>,
|
||||
|
||||
// 获取最新轨迹点
|
||||
getLatestTrackPoint: (deviceSn: string) =>
|
||||
request(`/api-device/device/drone/track/latest/${deviceSn}`) as Promise<{ resp_code: number; data: TrackPointVO }>,
|
||||
|
||||
// 删除历史轨迹
|
||||
deleteHistoryTracks: (deviceSn: string, beforeTime: string) =>
|
||||
request(`/api-device/device/drone/track/history/${deviceSn}`, {
|
||||
method: 'DELETE',
|
||||
params: { beforeTime },
|
||||
}),
|
||||
|
||||
// 统计轨迹点数量
|
||||
countTrackPoints: (
|
||||
deviceSn: string,
|
||||
params?: {
|
||||
jobId?: string;
|
||||
routeId?: string;
|
||||
startTime?: string;
|
||||
endTime?: string;
|
||||
}
|
||||
) =>
|
||||
request(`/api-device/device/drone/track/count/${deviceSn}`, { params }) as Promise<{ resp_code: number; data: number }>,
|
||||
|
||||
// 获取无人机设备列表
|
||||
getDroneDeviceList: () =>
|
||||
request('/api-device/device/drone/list') as Promise<{ resp_code: number; data: Array<{ sn: string; deviceName: string }> }>,
|
||||
|
||||
// 获取航迹文件列表
|
||||
getWaylineFileList: (params?: any) =>
|
||||
request('/api-device/device/wayline', { params }) as Promise<{ resp_code: number; data: Array<{ waylineId: string; name: string }> }>,
|
||||
|
||||
// 根据航迹文件ID获取航线任务列表
|
||||
getRouteListByFileWaylineId: (fileWaylineId: string) =>
|
||||
request(`/api-device/device/route/listByFileWaylineId/${fileWaylineId}`) as Promise<{ resp_code: number; data: WaylineRouteListItemVO[] }>,
|
||||
|
||||
// 获取航线任务详情(含航点和动作)
|
||||
getRouteDetail: (routeId: string) =>
|
||||
request(`/api-device/device/route/detail/${routeId}`) as Promise<{ resp_code: number; data: RouteDetailVO }>,
|
||||
|
||||
// 绑定航迹文件到设备并解析航线
|
||||
bindWaylineToDevice: (params: {
|
||||
deviceSn: string;
|
||||
waylineId: string;
|
||||
waylineName: string;
|
||||
workspaceId?: string;
|
||||
}) =>
|
||||
request('/api-device/device/route/bindWaylineToDevice', { method: 'POST', data: params }),
|
||||
};
|
||||
Reference in New Issue
Block a user