fix:地图仪表盘设备状态显示逻辑,以及说明有啊

This commit is contained in:
2025-06-19 23:20:11 +08:00
parent 230560e321
commit 4f35fc4158
@@ -105,6 +105,8 @@ interface RealDevice {
subDeviceSn: string;
deviceOnlineStatus: number;
firstPowerOn: number;
powerSupplyType: number;
drcState: number;
};
airportStatus?: {
flightTaskStep: number;
@@ -458,6 +460,8 @@ const DeviceMapDashboard: React.FC = () => {
subDeviceSn: '',
deviceOnlineStatus: 0,
firstPowerOn: 0,
powerSupplyType: 0,
drcState: 0,
}
})));
} else {
@@ -542,6 +546,11 @@ const DeviceMapDashboard: React.FC = () => {
if (device.metrics.rainfall > 0) {
return DeviceStatus.MAINTENANCE;
}
// 检查DRC状态
if (device.metrics.drcState === 1) {
return DeviceStatus.TASK;
}
// 检查无人机是否在机库中
if (device.metrics.droneInDock === 1) {
@@ -549,7 +558,7 @@ const DeviceMapDashboard: React.FC = () => {
}
// 检查工作模式代码(飞行任务)
if (device.metrics.modeCode > 0) {
if (device.metrics.modeCode > 0 || device.metrics.flightTaskStep > 0) {
return DeviceStatus.TASK;
}
@@ -711,6 +720,8 @@ const DeviceMapDashboard: React.FC = () => {
subDeviceSn: '',
deviceOnlineStatus: 0,
firstPowerOn: 0,
powerSupplyType: 0,
drcState: 0,
}
}));
};
@@ -1328,7 +1339,8 @@ const DeviceMapDashboard: React.FC = () => {
// 数据速率(基于网络速率)
dataRate: networkRate,
// 更新时间
uptime: firstPowerOn > 0 ? Date.now() - firstPowerOn : 0
uptime: firstPowerOn > 0 ? Date.now() - firstPowerOn : 0,
drcState: 0,
},
lastUpdateTime: new Date().toISOString()
}
@@ -2175,6 +2187,74 @@ const DeviceMapDashboard: React.FC = () => {
<Divider style={{ margin: '12px 0' }} />
{/* 状态说明区域 */}
<div style={{ marginBottom: '16px' }}>
<div style={{ marginBottom: '8px', fontWeight: 'bold', fontSize: '14px' }}>
状态说明
</div>
<div style={{ fontSize: '12px' }}>
{Object.entries(DEVICE_STATUS_CONFIG).map(([status, config]) => (
<div
key={status}
style={{
padding: '8px',
marginBottom: '4px',
background: config.bgColor,
borderRadius: '4px',
border: `1px solid ${config.color}20`
}}
>
<div style={{
display: 'flex',
alignItems: 'center',
marginBottom: '4px',
color: config.color,
fontWeight: 'bold'
}}>
<span style={{ marginRight: '4px' }}>{config.icon}</span>
{config.text}
</div>
<div style={{ color: '#666' }}>
{status === 'offline' && '最后数据上报时间超过5分钟'}
{status === 'error' && '紧急停止、报警状态或电量低于20%'}
{status === 'maintenance' && '网络质量低于30%、定位质量差、风速过大或有降雨'}
{status === 'task' && 'DRC遥控中、执行任务中或飞行任务进行中'}
{status === 'standby' && '设备在线且无异常状态'}
</div>
{status === 'error' && (
<div style={{ marginTop: '4px', fontSize: '11px', color: '#ff4d4f' }}>
· 紧急停止:emergencyStopState = 1
<br />
· 报警状态:alarmState = 1
<br />
· 低电量:batteryCapacity &lt; 20%
</div>
)}
{status === 'maintenance' && (
<div style={{ marginTop: '4px', fontSize: '11px', color: '#fa8c16' }}>
· 网络质量:networkQuality &lt; 30%
<br />
· 定位质量:positionQuality &lt; 3
<br />
· 风速:windSpeed &gt; 10
<br />
· 降雨:rainfall &gt; 0
</div>
)}
{status === 'task' && (
<div style={{ marginTop: '4px', fontSize: '11px', color: '#52c41a' }}>
· DRC状态:drcState = 1
<br />
· 工作模式:modeCode &gt; 0
<br />
· 飞行任务:flightTaskStep &gt; 0
</div>
)}
</div>
))}
</div>
</div>
{/* 统计数据 */}
<Row gutter={[8, 8]} style={{ marginBottom: '16px' }}>
<Col span={12}>
@@ -2810,45 +2890,37 @@ const DeviceMapDashboard: React.FC = () => {
</div>
{/* 设备状态信息 */}
<div style={{ marginBottom: '16px' }}>
<Title level={5}>设备状态</Title>
<div style={{ marginBottom: '24px' }}>
<Title level={5}>基础状态</Title>
<Row gutter={[8, 8]}>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>紧急停止</div>
<div style={{ fontSize: '18px', fontWeight: 'bold', color: selectedDevice.metrics.emergencyStopState === 1 ? '#ff4d4f' : '#52c41a' }}>
{selectedDevice.metrics.emergencyStopState === 1 ? '已触发' : '正常'}
<div style={{ fontSize: '12px', color: '#666' }}>供电方式</div>
<div style={{ fontSize: '14px', fontWeight: 'bold' }}>
{selectedDevice.metrics.powerSupplyType === 0 ? '交流电' : '电池供电'}
</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>报警状态</div>
<div style={{ fontSize: '18px', fontWeight: 'bold', color: selectedDevice.metrics.alarmState === 1 ? '#ff4d4f' : '#52c41a' }}>
{selectedDevice.metrics.alarmState === 1 ? '有报警' : '正常'}
</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>机盖状态</div>
<div style={{ fontSize: '18px', fontWeight: 'bold', color: selectedDevice.metrics.coverState === 1 ? '#52c41a' : '#ff4d4f' }}>
<div style={{ fontSize: '12px', color: '#666' }}>舱盖状态</div>
<div style={{ fontSize: '14px', fontWeight: 'bold', color: selectedDevice.metrics.coverState === 1 ? '#52c41a' : '#ff4d4f' }}>
{selectedDevice.metrics.coverState === 1 ? '开启' : '关闭'}
</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>静音模式</div>
<div style={{ fontSize: '18px', fontWeight: 'bold', color: selectedDevice.metrics.silentMode === 1 ? '#52c41a' : '#8c8c8c' }}>
{selectedDevice.metrics.silentMode === 1 ? '开启' : '关闭'}
<div style={{ fontSize: '12px', color: '#666' }}>降落保护罩</div>
<div style={{ fontSize: '14px', fontWeight: 'bold', color: selectedDevice.metrics.putterState === 1 ? '#52c41a' : '#ff4d4f' }}>
{selectedDevice.metrics.putterState === 1 ? '开启' : '关闭'}
</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>补光灯</div>
<div style={{ fontSize: '18px', fontWeight: 'bold', color: selectedDevice.metrics.supplementLightState === 1 ? '#52c41a' : '#8c8c8c' }}>
<div style={{ fontSize: '14px', fontWeight: 'bold', color: selectedDevice.metrics.supplementLightState === 1 ? '#52c41a' : '#ff4d4f' }}>
{selectedDevice.metrics.supplementLightState === 1 ? '开启' : '关闭'}
</div>
</div>
@@ -2856,8 +2928,62 @@ const DeviceMapDashboard: React.FC = () => {
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>空调状态</div>
<div style={{ fontSize: '18px', fontWeight: 'bold', color: selectedDevice.metrics.airConditionerState === 1 ? '#52c41a' : '#8c8c8c' }}>
{selectedDevice.metrics.airConditionerState === 1 ? '开启' : '关闭'}
<div style={{ fontSize: '14px', fontWeight: 'bold' }}>
{selectedDevice.metrics.airConditionerState === 0 ? '关闭' :
selectedDevice.metrics.airConditionerState === 1 ? '制冷' : '制热'}
</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>静音模式</div>
<div style={{ fontSize: '14px', fontWeight: 'bold' }}>
{selectedDevice.metrics.silentMode === 1 ? '开启' : '关闭'}
</div>
</div>
</Col>
</Row>
</div>
{/* 环境数据 */}
<div style={{ marginBottom: '24px' }}>
<Title level={5}>环境数据</Title>
<Row gutter={[8, 8]}>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>环境温度</div>
<div style={{ fontSize: '14px', fontWeight: 'bold',
color: selectedDevice.metrics.environmentTemperature > 35 ? '#ff4d4f' :
selectedDevice.metrics.environmentTemperature < 0 ? '#ff4d4f' : '#52c41a' }}>
{selectedDevice.metrics.environmentTemperature}°C
</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>机场温度</div>
<div style={{ fontSize: '14px', fontWeight: 'bold',
color: selectedDevice.metrics.temperature > 40 ? '#ff4d4f' :
selectedDevice.metrics.temperature < 0 ? '#ff4d4f' : '#52c41a' }}>
{selectedDevice.metrics.temperature}°C
</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>相对湿度</div>
<div style={{ fontSize: '14px', fontWeight: 'bold',
color: selectedDevice.metrics.humidity > 95 ? '#ff4d4f' : '#52c41a' }}>
{selectedDevice.metrics.humidity}%
</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>风速</div>
<div style={{ fontSize: '14px', fontWeight: 'bold',
color: selectedDevice.metrics.windSpeed > 8 ? '#ff4d4f' : '#52c41a' }}>
{selectedDevice.metrics.windSpeed}m/s
</div>
</div>
</Col>
@@ -2949,6 +3075,165 @@ const DeviceMapDashboard: React.FC = () => {
</div>
)}
</div>
{/* 电源系统 */}
<div style={{ marginBottom: '24px' }}>
<Title level={5}>电源系统</Title>
<Row gutter={[8, 8]}>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666', marginBottom: '4px' }}>电池容量</div>
<Progress
type="circle"
percent={selectedDevice.metrics.batteryCapacity}
width={60}
strokeColor={{
'0%': '#ff4d4f',
'40%': '#faad14',
'60%': '#52c41a',
}}
/>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>电池状态</div>
<div style={{ fontSize: '14px', fontWeight: 'bold', color: selectedDevice.metrics.batteryState === 0 ? '#52c41a' : '#ff4d4f' }}>
{selectedDevice.metrics.batteryState === 0 ? '正常' : '异常'}
</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>工作电压</div>
<div style={{ fontSize: '14px', fontWeight: 'bold' }}>
{selectedDevice.metrics.workingVoltage}V
</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>工作电流</div>
<div style={{ fontSize: '14px', fontWeight: 'bold' }}>
{selectedDevice.metrics.workingCurrent}A
</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>备用电池电压</div>
<div style={{ fontSize: '14px', fontWeight: 'bold' }}>
{selectedDevice.metrics.backupBatteryVoltage}V
</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>交流输入</div>
<div style={{ fontSize: '14px', fontWeight: 'bold', color: selectedDevice.metrics.acdcPowerInput === 1 ? '#52c41a' : '#ff4d4f' }}>
{selectedDevice.metrics.acdcPowerInput === 1 ? '正常' : '异常'}
</div>
</div>
</Col>
</Row>
</div>
{/* 告警状态 */}
<div style={{ marginBottom: '24px' }}>
<Title level={5}>告警状态</Title>
<Row gutter={[8, 8]}>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>紧急停止</div>
<div style={{ fontSize: '14px', fontWeight: 'bold', color: selectedDevice.metrics.emergencyStopState === 1 ? '#ff4d4f' : '#52c41a' }}>
{selectedDevice.metrics.emergencyStopState === 1 ? '已触发' : '正常'}
</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>告警状态</div>
<div style={{ fontSize: '14px', fontWeight: 'bold', color: selectedDevice.metrics.alarmState === 1 ? '#ff4d4f' : '#52c41a' }}>
{selectedDevice.metrics.alarmState === 1 ? '有告警' : '正常'}
</div>
</div>
</Col>
<Col span={24}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666', marginBottom: '4px' }}>告警统计</div>
<Row gutter={8} justify="center">
<Col>
<Statistic
title="错误"
value={selectedDevice.metrics.errorCount}
valueStyle={{ color: selectedDevice.metrics.errorCount > 0 ? '#ff4d4f' : '#52c41a' }}
style={{ marginRight: '16px' }}
/>
</Col>
<Col>
<Statistic
title="警告"
value={selectedDevice.metrics.warningCount}
valueStyle={{ color: selectedDevice.metrics.warningCount > 0 ? '#faad14' : '#52c41a' }}
/>
</Col>
</Row>
</div>
</Col>
</Row>
</div>
{/* 设备运行状态 */}
<div style={{ marginBottom: '24px' }}>
<Title level={5}>运行状态</Title>
<Row gutter={[8, 8]}>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>DRC状态</div>
<div style={{
fontSize: '14px',
fontWeight: 'bold',
color: selectedDevice.metrics.drcState === 1 ? '#52c41a' : '#8c8c8c'
}}>
{selectedDevice.metrics.drcState === 1 ? '遥控中' : '待机中'}
</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>任务状态</div>
<div style={{
fontSize: '14px',
fontWeight: 'bold',
color: selectedDevice.metrics.flightTaskStep > 0 ? '#1890ff' : '#8c8c8c'
}}>
{selectedDevice.metrics.flightTaskStep > 0 ? `任务中(${selectedDevice.metrics.flightTaskStep})` : '空闲'}
</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>无人机状态</div>
<div style={{
fontSize: '14px',
fontWeight: 'bold',
color: selectedDevice.metrics.droneInDock === 1 ? '#52c41a' : '#1890ff'
}}>
{selectedDevice.metrics.droneInDock === 1 ? '在库' : '离库'}
</div>
</div>
</Col>
<Col span={12}>
<div style={{ textAlign: 'center', padding: '8px', background: '#f5f5f5', borderRadius: '4px' }}>
<div style={{ fontSize: '12px', color: '#666' }}>运行时间</div>
<div style={{ fontSize: '14px', fontWeight: 'bold' }}>
{Math.floor(selectedDevice.metrics.uptime / 3600)}小时
{Math.floor((selectedDevice.metrics.uptime % 3600) / 60)}分
</div>
</div>
</Col>
</Row>
</div>
</>
)}
</Card>