在线面板数据优化 创建并执行成功
This commit is contained in:
@@ -70,9 +70,10 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
|
||||
if (!stationId) return;
|
||||
|
||||
try {
|
||||
console.log('开始请求设备数据,stationId:', userInfo);
|
||||
// 1. 同时发请求
|
||||
const [deviceRes, planeRes] = await Promise.all([
|
||||
getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1 }),
|
||||
getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1, orgId: userInfo.orgId }),
|
||||
getSiteUAVList(stationId),
|
||||
]);
|
||||
|
||||
@@ -343,14 +344,19 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
|
||||
);
|
||||
|
||||
// 顶部统计卡片
|
||||
|
||||
//feStatus; 1任务中 / 2空闲
|
||||
const dynamicTopCards = useMemo(() => {
|
||||
const totalDrones = planedevices?.length || 0;
|
||||
const onlineDrones = planedevices?.filter(d => d.onlineStatus === 1).length || 0;
|
||||
const totalRobots = devicesAll?.filter(d => d.productName?.includes('巡检')).length || 0;
|
||||
const activeRobots = devicesAll?.filter(d => d.productName?.includes('巡检') && d.onlineStatus === 1).length || 0;
|
||||
|
||||
//key 0 有任务 1 无任务
|
||||
const activeRobots = 0;
|
||||
const totalMowers = devicesAll?.filter(d => d.productName?.includes('割草机')).length || 0;
|
||||
const activeMowers = devicesAll?.filter(d => d.productName?.includes('割草机') && d.onlineStatus === 1).length || 0;
|
||||
const washDroneStandby = planedevices?.filter(d => d.productName?.includes('清洗') && d.onlineStatus === 1).length || 0;
|
||||
const activeMowers = devices?.filter(d => d.feStatus == 1).length || 0; // 作业中状态数量
|
||||
const washDroneStandby = planedevices?.[0]?.modeStatistics?.["0"] || 0;
|
||||
//key 设备状态:{"0":"空闲中","1":"现场调试","2":"远程调试","3":"固件升级中","4":"作业中"}
|
||||
|
||||
|
||||
|
||||
@@ -380,7 +386,7 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
|
||||
title: '除草机器人',
|
||||
icon: <CarOutlined style={{ color: '#722ED1', fontSize: 24 }} />,
|
||||
value: `${totalMowers} 台`,
|
||||
sub: `作业中 ${activeMowers}`,
|
||||
sub: `任务中 ${activeMowers}`,
|
||||
color: '#722ED1',
|
||||
iconBg: '#F9F0FF'
|
||||
},
|
||||
@@ -414,6 +420,7 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
|
||||
// 设备调度列表
|
||||
const dynamicScheduleList = useMemo(() => {
|
||||
return devicesAll?.map((d, index) => ({
|
||||
...d,
|
||||
id: d.deviceId || index,
|
||||
name: d.deviceAlias || d.deviceName || d.callsign || '未知设备',
|
||||
type: d.productName || '未知类型',
|
||||
@@ -422,7 +429,8 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
|
||||
capacity_percent: d.capacity_percent || 100,
|
||||
position: d.position || '站内',
|
||||
task: d.status === 4 ? '待命' : '作业中',
|
||||
comm: d.rssi ? `${d.rssi}dBm` : '良好'
|
||||
comm: d.rssi ? `${d.rssi}dBm` : '良好',
|
||||
|
||||
})) || [];
|
||||
}, [devicesAll]);
|
||||
|
||||
@@ -533,10 +541,36 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
|
||||
columns={[
|
||||
{ title: '装备名称', dataIndex: 'name', width: 140 },
|
||||
{ title: '类型', dataIndex: 'type', width: 90 },
|
||||
{ title: '当前状态', dataIndex: 'status', width: 70, render: s => <Tag color={s === '作业中' || s === '在线' ? 'success' : 'default'} style={{ margin: 0 }}>{s}</Tag> },
|
||||
{ title: '模式', dataIndex: 'mode', width: 70 },
|
||||
{ title: '电量', dataIndex: 'capacity_percent', width: 70, render: v => <Progress percent={v} size="small" status={v < 40 ? 'exception' : 'active'} /> },
|
||||
{ title: '位置', dataIndex: 'position', width: 90 },
|
||||
{
|
||||
title: '当前状态',
|
||||
dataIndex: 'onlineStatus',
|
||||
width: 70,
|
||||
render: (s) => {
|
||||
const text = s === 1 ? '在线' : '离线';
|
||||
const color = s === 1 ? 'success' : 'default';
|
||||
return <Tag color={color} style={{ margin: 0 }}>{text}</Tag>;
|
||||
}
|
||||
}, {
|
||||
title: '模式', dataIndex: 'feStatus', width: 70, render: (feStatus) => {
|
||||
console.log('feStatus:', feStatus);
|
||||
const text = feStatus == 1 ? '任务中' : feStatus == 2 ? '空闲' : '离线';
|
||||
const color = feStatus === 1 ? 'processing' : feStatus === 2 ? 'success' : 'default';
|
||||
return <Tag color={color} style={{ margin: 0 }}>{text}</Tag>;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '电量',
|
||||
dataIndex: 'lastrunning',
|
||||
width: 70,
|
||||
render: (lastrunning) => {
|
||||
const v = lastrunning?.battery || 0;
|
||||
return <Progress
|
||||
percent={v}
|
||||
size="small"
|
||||
status={v < 40 ? 'exception' : 'active'}
|
||||
/>;
|
||||
}
|
||||
}, { title: '位置', dataIndex: 'position', width: 90 },
|
||||
{ title: '当前任务', dataIndex: 'task', width: 100 },
|
||||
{ title: '通讯状态', dataIndex: 'comm', width: 70, render: v => <Badge status={v.includes('-') ? 'warning' : 'success'} text={v} /> },
|
||||
{ title: '操作', key: 'action', width: 80, render: () => <Space size={4}><Button size="small" type="text" icon={<EditOutlined />} /><Button size="small" type="text" icon={<SettingOutlined />} /></Space> },
|
||||
|
||||
Reference in New Issue
Block a user