无人机 任务详情

This commit is contained in:
mmc
2026-05-27 13:14:34 +08:00
parent 8eef08f77a
commit 347472be4e
2 changed files with 108 additions and 111 deletions

View File

@@ -340,7 +340,7 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
)}
</Card>
<Card title={<><ApiOutlined /> AI分析与操作建议</>} bordered={false} style={{ borderRadius: 12, marginBottom: 16 }}>
<Card title={<><ApiOutlined /> AI分析与操作建议</>} bordered={false} style={{ borderRadius: 12, marginBottom: 8 }}>
<Row gutter={16} style={{ marginBottom: 20 }}>
<Col span={6}><div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '6px 12px 4px', borderRadius: 12, border: '1px solid #e8e8e8' }}><div style={{ width: 30, height: 30, borderRadius: '50%', background: 'rgba(255,77,79,0.15)', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#ff4d4f', fontSize: 20 }}><span role="img" aria-label="hotspot">🔥</span></div><div><div style={{ fontSize: 11, color: '#666' }}>热斑疑似</div><div style={{ fontSize: 22, fontWeight: 700, color: '#222' }}>2 <span style={{ fontSize: 12 }}>处</span></div></div></div></Col>
<Col span={6}><div style={{ display: 'flex', alignItems: 'center', gap: 10, padding: '6px 12px 4px', borderRadius: 12, border: '1px solid #e8e8e8' }}><div style={{ width: 30, height: 30, borderRadius: '50%', background: 'rgba(82,196,26,0.15)', display: 'flex', alignItems: 'center', justifyContent: 'center', color: '#52c41a', fontSize: 16 }}><BranchesOutlined /></div><div><div style={{ fontSize: 11, color: '#666' }}>杂草高发区</div><div style={{ fontSize: 22, fontWeight: 700, color: '#222' }}>3 <span style={{ fontSize: 12 }}>块</span></div></div></div></Col>
@@ -371,7 +371,7 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
</Card>
{(selectedDevice?.productName?.includes('无人机') || selectedDevice?.device_sn) && (
<Card title="环境与飞行条件" bordered={false} style={{ borderRadius: 12, marginBottom: 16 }}>
<Card title="环境与飞行条件" bordered={false} style={{ borderRadius: 12, marginBottom: 8 }}>
<div style={{ display: "flex", justifyContent: "space-between", gap: 12, alignItems: "center" }}>
<div style={{ display: "flex", border: "1px solid #e8e8e8", borderRadius: 12, overflow: "hidden", flex: 1 }}>
<div style={{ flex: 1, textAlign: 'center', whiteSpace: "nowrap", padding: "12px 4px", borderRight: "1px solid #e8e8e8" }}><div style={{ fontSize: 11, color: '#666', fontWeight: 600 }}>风速</div><div style={{ fontSize: 14, fontWeight: 700, color: '#222', marginTop: 2 }}>{fix2(selectedDevice?.wind_speed)} m/s</div></div>
@@ -391,7 +391,7 @@ export default function DeviceOverviewPage({ devices, planedevices, devicesAll,
)}
{(!selectedDevice?.productName?.includes('无人机') && !selectedDevice?.device_sn) && (
<Card title={<div style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 14, fontWeight: 600 }}><RobotOutlined style={{ color: '#165DFF' }} />机器人作业状态</div>} bordered={false} style={{ borderRadius: 12, marginBottom: 16, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', border: '1px solid #f0f0f0' }}>
<Card title={<div style={{ display: 'flex', alignItems: 'center', gap: 8, fontSize: 14, fontWeight: 600 }}><RobotOutlined style={{ color: '#165DFF' }} />机器人作业状态</div>} bordered={false} style={{ borderRadius: 12, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)', border: '1px solid #f0f0f0' }}>
<Row gutter={16} style={{ alignItems: 'center' }}>
<Col span={8}>
<div style={{ padding: '8px 12px', borderRadius: 8, background: '#f8fafc', textAlign: 'center' }}>

View File

@@ -17,7 +17,7 @@ import {
LayoutGrid, Clock, CheckCircle2, AlertCircle, Zap, Waves,
Calendar, User, TrendingUp, Maximize2, Play, Square, X, MapPin, RotateCw
} from 'lucide-react';
import { getsinglePlan, getsinglePlanTrack, updateFlightTaskStatus, postFlightCommmand, getWayLine, createWaylineTask } from '@/api/device';
import { getsinglePlan, getsinglePlanTrack, updateFlightTaskStatus, postFlightCommmand, getWayLine, createWaylineTask, getFlightTaskDetail } from '@/api/device';
import dayjs from 'dayjs';
import utils from '@/lib/utils';
import CesiumMap from '../Map';
@@ -57,6 +57,7 @@ export default function WayLinePage({ planedevices }) {
// ✅ 创建任务弹窗相关状态(已完整整合)
// ==============================================
const [createTaskModal, setCreateTaskModal] = useState(false);
const [taskDetail, setTaskDetail] = useState(null);
const [waylineUuid, setWaylineUuid] = useState('');
const [waylineList, setWaylineList] = useState([]); // 航线列表
const [taskForm, setTaskForm] = useState({
@@ -357,6 +358,8 @@ export default function WayLinePage({ planedevices }) {
const handleRowClick = async (record) => {
setSelectedTask(record); // 记录当前选中的任务
try {
getTaskDetail(record.uuid); // 获取任务详情
const res = await getsinglePlanTrack(record);
if (res.code === 0 && res.data.track?.points?.length) {
const points = res.data.track.points.map(item => ({
@@ -440,6 +443,28 @@ export default function WayLinePage({ planedevices }) {
setFlightCommandLoading(false);
}
};
const getTaskDetail = async (taskId) => {
console.log('获取任务详情,taskId=', taskId);
if (!taskId) return;
setTaskDetail(null);
setLoading(true);
try {
const res = await getFlightTaskDetail(taskId);
if (res.code === 0) {
setTaskDetail(res.data);
} else {
setTaskDetail(null);
utils.message.error('暂无详情');
}
} catch (err) {
setTaskDetail(null);
utils.message.error('获取详情接口异常');
} finally {
setLoading(false);
}
};
// 任务状态更新逻辑
const updateTaskStatus = async (taskId: string, status: string) => {
@@ -585,7 +610,7 @@ export default function WayLinePage({ planedevices }) {
}
bordered={false}
bodyStyle={{ padding: 0, display: 'flex', flexDirection: 'column', height: "calc(100% - 40px)", overflow: "auto" }}
style={{ ...cardStyle, height: "250px", flex: 1, marginBottom: 0 }}
style={{ ...cardStyle, height: "240px", flex: 1, marginBottom: 0 }}
>
<Table
size="small"
@@ -605,7 +630,7 @@ export default function WayLinePage({ planedevices }) {
</Card>
</Col>
<Col xs={24} xl={10}>
<Col xs={24} xl={10} style={{ display: "flex", flexDirection: "column" }} >
<Card
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>任务编排与 AI 建议</span>}
bordered={false}
@@ -657,14 +682,16 @@ export default function WayLinePage({ planedevices }) {
>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: '8px', marginBottom: 8 }}>
{[
{ label: '飞行高度', value: '35', unit: 'm' },
{ label: '飞行高度', value: taskDetail.rth_altitude, unit: 'm' },
{ label: '速度', value: '6', unit: 'm/s' },
{ label: '航向重叠', value: '75', unit: '%' },
{ label: '旁向重叠', value: '65', unit: '%' },
{ label: '安全返航电量', value: '25', unit: '%' },
{
label: '安全返航电量', value: taskDetail.min_battery_capacity, unit: '%'
},
{ label: '清洗喷洒量', value: '120', unit: 'ml/㎡' },
{ label: '除草宽幅', value: '1.2', unit: 'm' },
{ label: '巡检采样频率', value: '2', unit: 'Hz' },
{ label: '任务类型', value: taskDetail.task_type, unit: '' },
].map((item, idx) => (
<div
key={idx}
@@ -757,110 +784,80 @@ export default function WayLinePage({ planedevices }) {
title={<span style={{ fontSize: fontTitle, fontWeight: 700 }}>天气窗口与执行约束</span>}
bordered={false}
bodyStyle={{ padding: '16px' }}
style={cardStyle}
style={{ ...cardStyle, flex: 1 }}
>
<Row gutter={16} align="middle">
<Col span={6}>
<div style={{ textAlign: 'center', background: '#F6FFED', padding: '12px 8px', borderRadius: 10, border: '1px solid #B7EB8F' }}>
<div style={{ fontSize: 11, color: '#52C41A', fontWeight: 700, marginBottom: 8 }}>适宜执行</div>
<CheckCircle2 size={24} color="#52C41A" style={{ margin: '0 auto 8px' }} />
<div style={{ fontSize: 10, color: '#86909C' }}>适宜航行</div>
{/* 顶部参数卡片区域,改成和截图一致的横向布局 */}
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(5, 1fr)', gap: '8px', marginBottom: 16 }}>
{/* 适宜性 */}
<div style={{ background: '#F7F8FA', borderRadius: 10, padding: '12px', display: 'flex', alignItems: 'center', gap: 10 }}>
<div style={{ width: 40, height: 40, borderRadius: '50%', background: 'rgba(22, 93, 255, 0.1)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<CloudOutlined size={20} style={{ color: '#165DFF' }} />
</div>
</Col>
<Col span={18}>
<Row gutter={[16, 16]}>
{[
{
label: '风速',
value: `${listDrone?.wind_speed ?? '-'} m/s`,
icon: <Wind size={16} />,
color: '#165DFF',
judge: (val) => {
const speed = parseFloat(val);
if (isNaN(speed)) return { desc: '未知', color: '#86909C' };
if (speed <= 5) return { desc: '适宜', color: '#52C41A' };
if (speed <= 8) return { desc: '谨慎', color: '#FF7D00' };
return { desc: '不适宜', color: '#F53F3F' };
}
},
{
label: '温度',
value: `${listDrone?.environment_temperature ?? '-'}℃`,
icon: <Thermometer size={16} />,
color: '#FF7D00',
judge: (val) => {
const temp = parseFloat(val);
if (isNaN(temp)) return { desc: '未知', color: '#86909C' };
if (temp >= 0 && temp <= 40) return { desc: '适宜', color: '#52C41A' };
return { desc: '不适宜', color: '#F53F3F' };
}
},
{
label: '降雨',
value: `${listDrone?.rainfall ?? '-'} `,
icon: <ThunderboltOutlined size={16} />,
color: '#FF7D00',
judge: (val) => {
if (val?.trim() === "no_rain") {
return { desc: '适宜', color: '#52C41A' };
} else {
return { desc: '不适宜', color: '#F53F3F' };
}
}
},
{
label: '信号质量',
value: (() => {
const q = listDrone?.network_state?.quality;
if (q === 'good') return '优';
if (q === 'better') return '良';
if (q === 'moderate') return '中';
if (q === 'poor') return '差';
if (q === 'too_pool') return '极差';
return '正常';
})(),
icon: <Satellite size={16} />,
color: '#00B42A',
judge: (val) => {
if (val === '优' || val === '良' || val === '正常') return { desc: '适宜', color: '#52C41A' };
if (val === '中') return { desc: '谨慎', color: '#FF7D00' };
return { desc: '不适宜', color: '#F53F3F' };
}
},
].map((item, idx) => {
const status = item.judge(item.value);
return (
<Col span={12} key={idx}>
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
<div
style={{
width: 32, height: 32, borderRadius: 8,
background: '#F7F8FA', display: 'flex',
justifyContent: 'center', alignItems: 'center',
color: item.color
}}
>
{item.icon}
</div>
<div>
<div style={{ fontSize: 10, color: '#86909C' }}>{item.label}</div>
<div style={{ fontSize: fontNormal, fontWeight: 700, color: '#1D2129' }}>
{item.value}
</div>
<div style={{ fontSize: 10, color: status.color, fontWeight: 500 }}>
{status.desc}
</div>
</div>
</div>
</Col>
);
})}
</Row>
</Col>
</Row>
<div style={{ marginTop: 16, display: 'flex', flexDirection: 'column', gap: 6, fontSize: 11, color: '#86909C', borderTop: '1px solid #F1F2F5', paddingTop: 12 }}>
<Space size={6}><AlertCircle size={14} color="#FF7D00" /> <span>16:30 后风速升高,建议提前完成任务</span></Space>
<Space size={6}><Clock size={14} color="#165DFF" /> <span>预计 14:00-16:00 为最佳执行窗口</span></Space>
<div>
<div style={{ fontSize: 12, color: '#86909C' }}>适宜性</div>
<div style={{ fontSize: 14, fontWeight: 700, color: '#00B42A' }}>适宜执行</div>
</div>
</div>
{/* 风速 */}
<div style={{ background: '#F7F8FA', borderRadius: 10, padding: '12px', display: 'flex', alignItems: 'center', gap: 10 }}>
<div style={{ width: 40, height: 40, borderRadius: '50%', background: 'rgba(22, 93, 255, 0.1)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<Wind size={20} style={{ color: '#165DFF' }} />
</div>
<div>
<div style={{ fontSize: 12, color: '#86909C' }}>风速</div>
<div style={{ fontSize: 14, fontWeight: 700, color: '#1D2129' }}>{listDrone?.wind_speed ?? '-'} m/s</div>
<div style={{ fontSize: 12, color: '#00B42A' }}>适宜</div>
</div>
</div>
{/* 温度 */}
<div style={{ background: '#F7F8FA', borderRadius: 10, padding: '12px', display: 'flex', alignItems: 'center', gap: 10 }}>
<div style={{ width: 40, height: 40, borderRadius: '50%', background: 'rgba(255, 125, 0, 0.1)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<Thermometer size={20} style={{ color: '#FF7D00' }} />
</div>
<div>
<div style={{ fontSize: 12, color: '#86909C' }}>温度</div>
<div style={{ fontSize: 14, fontWeight: 700, color: '#1D2129' }}>{listDrone?.environment_temperature ?? '-'}℃</div>
<div style={{ fontSize: 12, color: '#00B42A' }}>适宜</div>
</div>
</div>
{/* 降水概率 */}
<div style={{ background: '#F7F8FA', borderRadius: 10, padding: '12px', display: 'flex', alignItems: 'center', gap: 10 }}>
<div style={{ width: 40, height: 40, borderRadius: '50%', background: 'rgba(255, 125, 0, 0.1)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<Droplets size={20} style={{ color: '#FF7D00' }} />
</div>
<div>
<div style={{ fontSize: 12, color: '#86909C' }}>降水概率</div>
<div style={{ fontSize: 14, fontWeight: 700, color: '#1D2129' }}>10%</div>
<div style={{ fontSize: 12, color: '#00B42A' }}>低</div>
</div>
</div>
{/* GNSS质量 */}
<div style={{ background: '#F7F8FA', borderRadius: 10, padding: '12px', display: 'flex', alignItems: 'center', gap: 10 }}>
<div style={{ width: 40, height: 40, borderRadius: '50%', background: 'rgba(0, 180, 42, 0.1)', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<Satellite size={20} style={{ color: '#00B42A' }} />
</div>
<div>
<div style={{ fontSize: 12, color: '#86909C' }}>GNSS质量</div>
<div style={{ fontSize: 14, fontWeight: 700, color: '#1D2129' }}>良好</div>
<div style={{ fontSize: 12, color: '#00B42A' }}>适宜</div>
</div>
</div>
</div>
{/* 底部提示区域 */}
<div style={{ display: 'flex', gap: '12px' }}>
<div style={{ flex: 1, background: 'rgba(255, 125, 0, 0.1)', borderRadius: 8, padding: '10px 12px', display: 'flex', alignItems: 'center', gap: 8 }}>
<AlertCircle size={16} style={{ color: '#FF7D00' }} />
<span style={{ fontSize: 13, color: '#FF7D00', fontWeight: 500 }}>16:30 后风速升高,建议提前完成任务</span>
</div>
<div style={{ flex: 1, background: 'rgba(22, 93, 255, 0.1)', borderRadius: 8, padding: '10px 12px', display: 'flex', alignItems: 'center', gap: 8 }}>
<InfoCircleOutlined size={16} style={{ color: '#165DFF' }} />
<span style={{ fontSize: 13, color: '#165DFF', fontWeight: 500 }}>预计 14:00-16:00 为最佳执行窗口</span>
</div>
</div>
</Card>
</Col>