diff --git a/src/api/device.ts b/src/api/device.ts index 1d5b7d2..9c314a7 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -8,6 +8,7 @@ export function getDeviceListApi(data) { }); } + export function getPlaneDeviceList(params) { return request({ url: '/iot/UAV/getUAVList', @@ -16,6 +17,9 @@ export function getPlaneDeviceList(params) { }) } +//modeStatistics{"0":"空闲中","1":"现场调试","2":"远程调试","3":"固件升级中","4":"作业中"} + + export function getSiteUAVList(siteId) { return request({ url: '/iot/UAV/getSiteUAVList', diff --git a/src/components/devices/DeviceOverviewPage.tsx b/src/components/devices/DeviceOverviewPage.tsx index ce9a7fc..2e71ffa 100644 --- a/src/components/devices/DeviceOverviewPage.tsx +++ b/src/components/devices/DeviceOverviewPage.tsx @@ -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: , 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 => {s} }, - { title: '模式', dataIndex: 'mode', width: 70 }, - { title: '电量', dataIndex: 'capacity_percent', width: 70, render: v => }, - { title: '位置', dataIndex: 'position', width: 90 }, + { + title: '当前状态', + dataIndex: 'onlineStatus', + width: 70, + render: (s) => { + const text = s === 1 ? '在线' : '离线'; + const color = s === 1 ? 'success' : 'default'; + return {text}; + } + }, { + 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 {text}; + } + }, + { + title: '电量', + dataIndex: 'lastrunning', + width: 70, + render: (lastrunning) => { + const v = lastrunning?.battery || 0; + return ; + } + }, { title: '位置', dataIndex: 'position', width: 90 }, { title: '当前任务', dataIndex: 'task', width: 100 }, { title: '通讯状态', dataIndex: 'comm', width: 70, render: v => }, { title: '操作', key: 'action', width: 80, render: () =>