xx
This commit is contained in:
@@ -265,6 +265,29 @@ export default function AlarmCenterPage() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
// 按日期+告警级别分组统计趋势数据
|
||||||
|
const getAlarmTrendData = () => {
|
||||||
|
if (!alarmList.length) return [];
|
||||||
|
const groupMap = {};
|
||||||
|
|
||||||
|
alarmList.forEach(item => {
|
||||||
|
if (!item.alarmTime || !item.alarmLevel) return;
|
||||||
|
const day = dayjs(item.alarmTime).format('MM-DD');
|
||||||
|
const level = String(item.alarmLevel);
|
||||||
|
|
||||||
|
if (!groupMap[day]) groupMap[day] = {};
|
||||||
|
groupMap[day][level] = (groupMap[day][level] || 0) + 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 规整成图表一维数组
|
||||||
|
return Object.entries(groupMap).map(([date, obj]) => ({
|
||||||
|
date,
|
||||||
|
severe: obj['1'] || 0, // 严重
|
||||||
|
important: obj['2'] || 0, // 重要
|
||||||
|
normal: obj['3'] || 0, // 一般
|
||||||
|
tip: obj['4'] || 0 // 提示
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
const pieData = [
|
const pieData = [
|
||||||
{
|
{
|
||||||
@@ -347,83 +370,7 @@ export default function AlarmCenterPage() {
|
|||||||
{contextHolder}
|
{contextHolder}
|
||||||
|
|
||||||
{/* 查询栏 */}
|
{/* 查询栏 */}
|
||||||
<Row gutter={8} style={{ marginBottom: 8 }}>
|
|
||||||
<Col span={24}>
|
|
||||||
<Card bordered={false} bodyStyle={{ padding: '16px 24px' }} style={{ borderRadius: 8 }}>
|
|
||||||
<Row gutter={[24, 16]} align="middle">
|
|
||||||
<Col>
|
|
||||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>告警级别</div>
|
|
||||||
<Select
|
|
||||||
style={{ width: 120 }}
|
|
||||||
value={queryParams.alarmLevel}
|
|
||||||
onChange={v => setQueryParams({ ...queryParams, alarmLevel: v })}
|
|
||||||
options={[
|
|
||||||
{ value: '', label: '全部' },
|
|
||||||
{ value: 1, label: '严重' },
|
|
||||||
{ value: 2, label: '重要' },
|
|
||||||
{ value: 3, label: '一般' },
|
|
||||||
{ value: 4, label: '提示' },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
</Col>
|
|
||||||
<Col>
|
|
||||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>处理状态</div>
|
|
||||||
<Select
|
|
||||||
style={{ width: 120 }}
|
|
||||||
value={queryParams.handleStatus}
|
|
||||||
onChange={v => setQueryParams({ ...queryParams, handleStatus: v })}
|
|
||||||
options={[
|
|
||||||
{ value: '', label: '全部' },
|
|
||||||
{ value: 1, label: '待处理' },
|
|
||||||
{ value: 2, label: '处理中' },
|
|
||||||
{ value: 3, label: '已关闭' },
|
|
||||||
{ value: 4, label: '已忽略' },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
</Col>
|
|
||||||
<Col>
|
|
||||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>设备ID</div>
|
|
||||||
<Input
|
|
||||||
placeholder="设备ID"
|
|
||||||
value={queryParams.deviceId}
|
|
||||||
onChange={e => setQueryParams({ ...queryParams, deviceId: e.target.value })}
|
|
||||||
style={{ width: 160 }}
|
|
||||||
/>
|
|
||||||
</Col>
|
|
||||||
<Col>
|
|
||||||
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>时间范围</div>
|
|
||||||
<RangePicker
|
|
||||||
showTime
|
|
||||||
style={{ width: 320 }}
|
|
||||||
onChange={arr => {
|
|
||||||
if (arr) {
|
|
||||||
setQueryParams({
|
|
||||||
...queryParams,
|
|
||||||
startTime: arr[0].format('YYYY-MM-DD HH:mm:ss'),
|
|
||||||
endTime: arr[1].format('YYYY-MM-DD HH:mm:ss')
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Col>
|
|
||||||
<Col style={{ alignSelf: 'flex-end' }}>
|
|
||||||
<Space>
|
|
||||||
<Button style={{ borderRadius: 8 }} onClick={() => {
|
|
||||||
setQueryParams({ deviceId: '', alarmLevel: '', handleStatus: '', startTime: '', endTime: '' });
|
|
||||||
fetchList();
|
|
||||||
}}>重置</Button>
|
|
||||||
<Button type="primary" style={{ borderRadius: 8, background: '#165DFF' }} onClick={fetchList}>
|
|
||||||
<SearchOutlined />查询
|
|
||||||
</Button>
|
|
||||||
<Button style={{ borderRadius: 8 }} onClick={doExport}>
|
|
||||||
<FileTextOutlined />导出
|
|
||||||
</Button>
|
|
||||||
</Space>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
</Card>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
|
|
||||||
{/* 统计卡片 */}
|
{/* 统计卡片 */}
|
||||||
<Row gutter={[8, 8]} style={{ marginBottom: 8, flexWrap: 'wrap' }}>
|
<Row gutter={[8, 8]} style={{ marginBottom: 8, flexWrap: 'wrap' }}>
|
||||||
@@ -513,6 +460,83 @@ export default function AlarmCenterPage() {
|
|||||||
</Col>
|
</Col>
|
||||||
))}
|
))}
|
||||||
</Row>
|
</Row>
|
||||||
|
<Row gutter={8} style={{ marginBottom: 8 }}>
|
||||||
|
<Col span={24}>
|
||||||
|
<Card bordered={false} bodyStyle={{ padding: '16px 24px' }} style={{ borderRadius: 8 }}>
|
||||||
|
<Row gutter={[24, 16]} align="middle">
|
||||||
|
<Col>
|
||||||
|
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>告警级别</div>
|
||||||
|
<Select
|
||||||
|
style={{ width: 120 }}
|
||||||
|
value={queryParams.alarmLevel}
|
||||||
|
onChange={v => setQueryParams({ ...queryParams, alarmLevel: v })}
|
||||||
|
options={[
|
||||||
|
{ value: '', label: '全部' },
|
||||||
|
{ value: 1, label: '严重' },
|
||||||
|
{ value: 2, label: '重要' },
|
||||||
|
{ value: 3, label: '一般' },
|
||||||
|
{ value: 4, label: '提示' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
<Col>
|
||||||
|
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>处理状态</div>
|
||||||
|
<Select
|
||||||
|
style={{ width: 120 }}
|
||||||
|
value={queryParams.handleStatus}
|
||||||
|
onChange={v => setQueryParams({ ...queryParams, handleStatus: v })}
|
||||||
|
options={[
|
||||||
|
{ value: '', label: '全部' },
|
||||||
|
{ value: 1, label: '待处理' },
|
||||||
|
{ value: 2, label: '处理中' },
|
||||||
|
{ value: 3, label: '已关闭' },
|
||||||
|
{ value: 4, label: '已忽略' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
<Col>
|
||||||
|
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>设备ID</div>
|
||||||
|
<Input
|
||||||
|
placeholder="设备ID"
|
||||||
|
value={queryParams.deviceId}
|
||||||
|
onChange={e => setQueryParams({ ...queryParams, deviceId: e.target.value })}
|
||||||
|
style={{ width: 160 }}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
<Col>
|
||||||
|
<div style={{ fontSize: 12, color: '#4E5969', marginBottom: 4 }}>时间范围</div>
|
||||||
|
<RangePicker
|
||||||
|
showTime
|
||||||
|
style={{ width: 320 }}
|
||||||
|
onChange={arr => {
|
||||||
|
if (arr) {
|
||||||
|
setQueryParams({
|
||||||
|
...queryParams,
|
||||||
|
startTime: arr[0].format('YYYY-MM-DD HH:mm:ss'),
|
||||||
|
endTime: arr[1].format('YYYY-MM-DD HH:mm:ss')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
<Col style={{ alignSelf: 'flex-end' }}>
|
||||||
|
<Space>
|
||||||
|
<Button style={{ borderRadius: 8 }} onClick={() => {
|
||||||
|
setQueryParams({ deviceId: '', alarmLevel: '', handleStatus: '', startTime: '', endTime: '' });
|
||||||
|
fetchList();
|
||||||
|
}}>重置</Button>
|
||||||
|
<Button type="primary" style={{ borderRadius: 8, background: '#165DFF' }} onClick={fetchList}>
|
||||||
|
<SearchOutlined />查询
|
||||||
|
</Button>
|
||||||
|
<Button style={{ borderRadius: 8 }} onClick={doExport}>
|
||||||
|
<FileTextOutlined />导出
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</Card>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
{/* 表格 */}
|
{/* 表格 */}
|
||||||
<Row gutter={16} style={{ marginBottom: 8 }}>
|
<Row gutter={16} style={{ marginBottom: 8 }}>
|
||||||
@@ -546,38 +570,7 @@ export default function AlarmCenterPage() {
|
|||||||
<Col span={8}>
|
<Col span={8}>
|
||||||
<Card bordered={false} title="告警趋势" style={{ borderRadius: 8 }}>
|
<Card bordered={false} title="告警趋势" style={{ borderRadius: 8 }}>
|
||||||
<UniversalLineChart
|
<UniversalLineChart
|
||||||
data={[
|
data={getAlarmTrendData()}
|
||||||
{
|
|
||||||
date: '00:00',
|
|
||||||
severe: statData.levelStats?.[1] || 0,
|
|
||||||
important: statData.levelStats?.[2] || 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: '04:00',
|
|
||||||
severe: (statData.levelStats?.[1] || 0) + 1,
|
|
||||||
important: (statData.levelStats?.[2] || 0) + 2,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: '08:00',
|
|
||||||
severe: (statData.levelStats?.[1] || 0) + 2,
|
|
||||||
important: (statData.levelStats?.[2] || 0) + 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: '12:00',
|
|
||||||
severe: statData.levelStats?.[1] || 0,
|
|
||||||
important: statData.levelStats?.[2] || 0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: '16:00',
|
|
||||||
severe: (statData.levelStats?.[1] || 0) + 1,
|
|
||||||
important: (statData.levelStats?.[2] || 0) + 1,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: '20:00',
|
|
||||||
severe: statData.levelStats?.[1] || 0,
|
|
||||||
important: statData.levelStats?.[2] || 0,
|
|
||||||
},
|
|
||||||
]}
|
|
||||||
xKey="date"
|
xKey="date"
|
||||||
height={220}
|
height={220}
|
||||||
smooth
|
smooth
|
||||||
@@ -588,7 +581,7 @@ export default function AlarmCenterPage() {
|
|||||||
key: 'severe',
|
key: 'severe',
|
||||||
name: '严重',
|
name: '严重',
|
||||||
color: '#FF4D4F',
|
color: '#FF4D4F',
|
||||||
strokeWidth: 3,
|
strokeWidth: 2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: 'important',
|
key: 'important',
|
||||||
@@ -596,6 +589,18 @@ export default function AlarmCenterPage() {
|
|||||||
color: '#FA8C16',
|
color: '#FA8C16',
|
||||||
strokeWidth: 2,
|
strokeWidth: 2,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'normal',
|
||||||
|
name: '一般',
|
||||||
|
color: '#FADB14',
|
||||||
|
strokeWidth: 2,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'tip',
|
||||||
|
name: '提示',
|
||||||
|
color: '#1890FF',
|
||||||
|
strokeWidth: 2,
|
||||||
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
Reference in New Issue
Block a user