无人机 任务详情

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>
<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 }}> <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(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> <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> </Card>
{(selectedDevice?.productName?.includes('无人机') || selectedDevice?.device_sn) && ( {(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", justifyContent: "space-between", gap: 12, alignItems: "center" }}>
<div style={{ display: "flex", border: "1px solid #e8e8e8", borderRadius: 12, overflow: "hidden", flex: 1 }}> <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> <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) && ( {(!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' }}> <Row gutter={16} style={{ alignItems: 'center' }}>
<Col span={8}> <Col span={8}>
<div style={{ padding: '8px 12px', borderRadius: 8, background: '#f8fafc', textAlign: 'center' }}> <div style={{ padding: '8px 12px', borderRadius: 8, background: '#f8fafc', textAlign: 'center' }}>

View File

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