"use client" import {useState} from "react" import {Button, Card, Col, Row, Select, Space, Statistic, Switch, Tag} from "antd" import {BellOutlined, FullscreenOutlined, ReloadOutlined} from "@ant-design/icons" import EChart from "@/components/echarts" import dynamic from "next/dynamic" const GasNetworkMap = dynamic(() => import("./gas-network-map"), { ssr: false, loading: () =>
加载地图中...
, }) const { Option } = Select // 模拟报警点位数据 const mockAlarmPoints = [ { id: "A001", name: "解放路压力报警", position: [39.9042, 116.4074], type: "pressure", level: "高", status: "未处理", createTime: "2024-01-15 14:30:25", value: 0.52, threshold: 0.45, unit: "MPa", }, { id: "A002", name: "人民路流量报警", position: [39.9052, 116.4084], type: "flow", level: "中", status: "处理中", createTime: "2024-01-15 13:45:10", value: 4200, threshold: 3500, unit: "m³/h", }, { id: "A003", name: "建设路泄漏报警", position: [39.9032, 116.4064], type: "leakage", level: "高", status: "已处理", createTime: "2024-01-15 12:20:15", value: 0.08, threshold: 0.05, unit: "ppm", }, ] // 模拟报警统计数据 const mockAlarmTypeStats = [ { type: "压力异常", count: 15, percentage: 42.9 }, { type: "流量异常", count: 12, percentage: 34.3 }, { type: "泄漏检测", count: 6, percentage: 17.1 }, { type: "温度异常", count: 2, percentage: 5.7 }, ] const mockAlarmLevelStats = [ { level: "高", count: 8, color: "#f5222d" }, { level: "中", count: 18, color: "#faad14" }, { level: "低", count: 9, color: "#52c41a" }, ] const mockHourlyStats = [ { hour: "00", count: 2 }, { hour: "01", count: 1 }, { hour: "02", count: 0 }, { hour: "03", count: 1 }, { hour: "04", count: 3 }, { hour: "05", count: 2 }, { hour: "06", count: 4 }, { hour: "07", count: 6 }, { hour: "08", count: 8 }, { hour: "09", count: 5 }, { hour: "10", count: 7 }, { hour: "11", count: 9 }, { hour: "12", count: 12 }, { hour: "13", count: 8 }, { hour: "14", count: 6 }, { hour: "15", count: 4 }, { hour: "16", count: 3 }, { hour: "17", count: 5 }, { hour: "18", count: 7 }, { hour: "19", count: 4 }, { hour: "20", count: 2 }, { hour: "21", count: 1 }, { hour: "22", count: 1 }, { hour: "23", count: 0 }, ] export default function AlarmVisualization() { const [layerVisibility, setLayerVisibility] = useState({ pipeline: true, pressureAlarm: true, flowAlarm: true, temperatureAlarm: true, leakageAlarm: true, highLevel: true, mediumLevel: true, lowLevel: true, }) const [selectedTimeRange, setSelectedTimeRange] = useState("24hours") const [isFullscreen, setIsFullscreen] = useState(false) const handleLayerToggle = (layer: string, visible: boolean) => { setLayerVisibility((prev) => ({ ...prev, [layer]: visible, })) } const handleRefresh = () => { console.log("刷新报警数据") } const getStatusColor = (status: string) => { switch (status) { case "未处理": return "#f5222d" case "处理中": return "#faad14" case "已处理": return "#52c41a" default: return "#1890ff" } } const getLevelColor = (level: string) => { switch (level) { case "高": return "#f5222d" case "中": return "#faad14" case "低": return "#52c41a" default: return "#1890ff" } } const getTypeLabel = (type: string) => { const typeMap = { pressure: "压力", flow: "流量", temperature: "温度", leakage: "泄漏", } return typeMap[type as keyof typeof typeMap] || type } const pieOption = { title: { text: "报警类型分布", left: "center" }, tooltip: { trigger: "item" }, legend: { orient: "vertical", left: "left" }, series: [ { type: "pie", radius: "50%", data: mockAlarmTypeStats.map((item) => ({ value: item.count, name: item.type, })), emphasis: { itemStyle: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: "rgba(0, 0, 0, 0.5)", }, }, }, ], } const columnOption = { title: { text: "24小时报警分布", left: "center" }, tooltip: { trigger: "axis" }, grid: { left: "3%", right: "4%", bottom: "3%", containLabel: true }, xAxis: { type: "category", data: mockHourlyStats.map((item) => item.hour + ":00"), }, yAxis: { type: "value", name: "报警数量" }, series: [ { type: "bar", data: mockHourlyStats.map((item) => item.count), itemStyle: { color: "#f5222d" }, }, ], } const unhandledCount = mockAlarmPoints.filter((point) => point.status === "未处理").length const processingCount = mockAlarmPoints.filter((point) => point.status === "处理中").length const handledCount = mockAlarmPoints.filter((point) => point.status === "已处理").length return (
{/* 报警概览统计 */} } /> {/* 图层控制 */}
handleLayerToggle("pipeline", checked)} size="small" /> 管网管线
handleLayerToggle("pressureAlarm", checked)} size="small" /> 压力报警
handleLayerToggle("flowAlarm", checked)} size="small" /> 流量报警
handleLayerToggle("leakageAlarm", checked)} size="small" /> 泄漏报警
handleLayerToggle("highLevel", checked)} size="small" /> 高级报警
handleLayerToggle("mediumLevel", checked)} size="small" /> 中级报警
handleLayerToggle("lowLevel", checked)} size="small" /> 低级报警
{/* 时间范围选择 */} 高级报警 中级报警 低级报警 压力异常 流量异常 泄漏检测 温度异常 {/* 地图和统计图表 */} {/* 报警点位详情 */}
{mockAlarmPoints .filter((point) => point.status !== "已处理") .map((point) => (
{point.name}
{point.level} {point.status}
类型: {getTypeLabel(point.type)}
异常值: {point.value} {point.unit} (阈值: {point.threshold} {point.unit})
报警时间: {point.createTime}
))}
) }