"use client" import {useState} from "react" import { App, Badge, Button, Card, Col, Form, Input, Modal, Row, Select, Space, Statistic, Table, Tag, Upload, } from "antd" import { ArrowDownOutlined, ArrowUpOutlined, CheckCircleOutlined, CloseCircleOutlined, EditOutlined, ExclamationCircleOutlined, ExportOutlined, EyeOutlined, PlusOutlined, SyncOutlined, UploadOutlined, } from "@ant-design/icons" import EChart from "@/components/echarts" import WaterMap from "./components/water-map" import AdminLayout from "./components/admin-layout" import type {EChartsCoreOption} from "echarts/core" import globalMessage from "@/app/_modules/globalMessage"; const { Search } = Input const { Option } = Select export default function WaterSupplyMonitoring() { const [activeTab, setActiveTab] = useState("dashboard") const [modalVisible, setModalVisible] = useState(false) const [facilityDetailModal, setFacilityDetailModal] = useState(false) const [deviceDetailModal, setDeviceDetailModal] = useState(false) const [thresholdModal, setThresholdModal] = useState(false) const [exportModal, setExportModal] = useState(false) const [selectedRecord, setSelectedRecord] = useState(null) const [loading, setLoading] = useState(false) const [form] = Form.useForm() const [thresholdForm] = Form.useForm() // 模拟数据 const facilitiesData = [ { key: "1", name: "湘江水源地", type: "水源地", location: "长沙市岳麓区", status: "正常", capacity: "10000m³/d" }, { key: "2", name: "长沙第一水厂", type: "水厂", location: "长沙市芙蓉区", status: "正常", capacity: "50000m³/d" }, { key: "3", name: "岳麓区增压泵站", type: "泵站", location: "长沙市岳麓区", status: "预警", capacity: "20000m³/d" }, { key: "4", name: "五一大道主管网", type: "管网", location: "长沙市芙蓉区", status: "正常", length: "15km" }, { key: "5", name: "中南大学", type: "大用户", location: "长沙市岳麓区", status: "报警", usage: "500m³/d" }, ] const devicesData = [ { key: "1", name: "流量计001", type: "流量计", location: "泵站A", status: "正常", lastMaintenance: "2024-01-15" }, { key: "2", name: "压力计002", type: "压力计", location: "管网节点1", status: "故障", lastMaintenance: "2024-01-10", }, { key: "3", name: "声波监测003", type: "漏失监测", location: "主管线", status: "正常", lastMaintenance: "2024-01-20", }, { key: "4", name: "流量计004", type: "流量计", location: "水厂出口", status: "维修中", lastMaintenance: "2024-01-12", }, ] const monitoringData = [ { key: "1", point: "监测点001", type: "流量", value: "125.6 m³/h", status: "正常", time: "2024-01-25 14:30" }, { key: "2", point: "监测点002", type: "压力", value: "0.45 MPa", status: "正常", time: "2024-01-25 14:30" }, { key: "3", point: "监测点003", type: "漏失", value: "检测到异常", status: "报警", time: "2024-01-25 14:25" }, { key: "4", point: "监测点004", type: "流量", value: "89.2 m³/h", status: "预警", time: "2024-01-25 14:30" }, ] const alarmsData = [ { key: "1", location: "增压泵站A", type: "压力异常", level: "中级", status: "待处理", time: "2024-01-25 14:25" }, { key: "2", location: "大用户A", type: "流量超限", level: "高级", status: "处理中", time: "2024-01-25 14:20" }, { key: "3", location: "主管网节点", type: "设备故障", level: "低级", status: "已处理", time: "2024-01-25 14:15" }, ] // 图表配置 const flowChartOption: EChartsCoreOption = { title: { text: "长沙市供水流量趋势", left: "center", textStyle: { fontSize: 16, fontWeight: "bold" }, }, tooltip: { trigger: "axis", backgroundColor: "rgba(0,0,0,0.8)", borderColor: "#1890ff", textStyle: { color: "#fff" }, }, legend: { data: ["湘江取水量", "供水总量", "用水需求"], bottom: 0 }, xAxis: { type: "category", data: ["00:00", "04:00", "08:00", "12:00", "16:00", "20:00", "24:00"], axisLine: { lineStyle: { color: "#d9d9d9" } }, }, yAxis: { type: "value", name: "流量(万m³/h)", axisLine: { lineStyle: { color: "#d9d9d9" } }, }, series: [ { name: "湘江取水量", type: "line", data: [120, 132, 101, 134, 90, 230, 210], smooth: true, itemStyle: { color: "#1890ff" }, areaStyle: { opacity: 0.3 }, animationDelay: 0, }, { name: "供水总量", type: "line", data: [110, 125, 95, 128, 85, 220, 200], smooth: true, itemStyle: { color: "#52c41a" }, areaStyle: { opacity: 0.3 }, animationDelay: 300, }, { name: "用水需求", type: "line", data: [100, 120, 90, 125, 80, 215, 195], smooth: true, itemStyle: { color: "#faad14" }, areaStyle: { opacity: 0.3 }, animationDelay: 600, }, ], animationDuration: 2000, animationEasing: "cubicOut", } const pressureChartOption: EChartsCoreOption = { title: { text: "长沙市管网压力分布", left: "center", textStyle: { fontSize: 16, fontWeight: "bold" }, }, tooltip: { trigger: "item", formatter: "{a}
{b}: {c} ({d}%)", }, series: [ { name: "压力分布", type: "pie", radius: ["40%", "70%"], center: ["50%", "60%"], data: [ { value: 45, name: "正常压力", itemStyle: { color: "#52c41a" } }, { value: 25, name: "低压预警", itemStyle: { color: "#faad14" } }, { value: 15, name: "高压预警", itemStyle: { color: "#ff7a45" } }, { value: 15, name: "压力异常", itemStyle: { color: "#ff4d4f" } }, ], emphasis: { itemStyle: { shadowBlur: 10, shadowOffsetX: 0, shadowColor: "rgba(0, 0, 0, 0.5)", }, }, animationType: "scale", animationEasing: "elasticOut", animationDelay: (idx: number) => Math.random() * 200, }, ], } const alarmTrendOption: EChartsCoreOption = { title: { text: "长沙市供水报警趋势统计", left: "center", textStyle: { fontSize: 16, fontWeight: "bold" }, }, tooltip: { trigger: "axis", backgroundColor: "rgba(0,0,0,0.8)", borderColor: "#1890ff", }, legend: { data: ["高级报警", "中级报警", "低级报警"], bottom: 0 }, xAxis: { type: "category", data: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"], }, yAxis: { type: "value", name: "报警次数" }, series: [ { name: "高级报警", type: "bar", data: [2, 1, 3, 2, 1, 0, 1], itemStyle: { color: "#ff4d4f" }, animationDelay: (idx: number) => idx * 100, }, { name: "中级报警", type: "bar", data: [5, 3, 4, 6, 3, 2, 4], itemStyle: { color: "#faad14" }, animationDelay: (idx: number) => idx * 100 + 300, }, { name: "低级报警", type: "bar", data: [8, 6, 7, 9, 5, 4, 6], itemStyle: { color: "#1890ff" }, animationDelay: (idx: number) => idx * 100 + 600, }, ], animationDuration: 1500, } // 实时监控仪表盘配置 const gaugeOption: EChartsCoreOption = { series: [ { name: "供水压力", type: "gauge", progress: { show: true, width: 18, }, axisLine: { lineStyle: { width: 18, }, }, axisTick: { show: false, }, splitLine: { length: 15, lineStyle: { width: 2, color: "#999", }, }, axisLabel: { distance: 25, color: "#999", fontSize: 12, }, anchor: { show: true, showAbove: true, size: 25, itemStyle: { borderWidth: 10, }, }, title: { show: false, }, detail: { valueAnimation: true, fontSize: 20, offsetCenter: [0, "70%"], }, data: [ { value: 0.65, name: "MPa", }, ], }, ], } // 仪表盘数据 const dashboardStats = { totalFacilities: 156, normalFacilities: 142, warningFacilities: 8, alarmFacilities: 6, totalDevices: 324, onlineDevices: 298, offlineDevices: 26, todayAlarms: 12, processedAlarms: 9, pendingAlarms: 3, } const handleExport = (type: string) => { setLoading(true) setTimeout(() => { globalMessage.success(`${type}数据导出成功!`) setLoading(false) setExportModal(false) }, 2000) } const handleRefresh = () => { setLoading(true) setTimeout(() => { globalMessage.success("数据刷新成功!") setLoading(false) }, 1500) } const handleViewDetail = (record: any, type: string) => { setSelectedRecord(record) if (type === "facility") { setFacilityDetailModal(true) } else if (type === "device") { setDeviceDetailModal(true) } } const handleProcessAlarm = (record: any) => { setSelectedRecord(record) setModalVisible(true) } const handleThresholdSetting = () => { setThresholdModal(true) } const renderDashboard = () => (
{/* 系统概览仪表盘 */} } suffix="个" valueStyle={{ color: "#1890ff", fontSize: "24px", fontWeight: "bold" }} /> } suffix="个" valueStyle={{ color: "#52c41a", fontSize: "24px", fontWeight: "bold" }} /> } suffix="个" valueStyle={{ color: "#faad14", fontSize: "24px", fontWeight: "bold" }} /> } suffix="个" valueStyle={{ color: "#ff4d4f", fontSize: "24px", fontWeight: "bold" }} /> {/* 实时监控数据 */}
{/* 图表展示 */}
) const renderContent = () => { switch (activeTab) { case "dashboard": return renderDashboard() case "facilities": return (
{/* 统计卡片 */} } valueStyle={{ color: "#1890ff" }} /> } valueStyle={{ color: "#52c41a" }} /> } valueStyle={{ color: "#faad14" }} /> } valueStyle={{ color: "#ff4d4f" }} /> {/* 图表展示 */} {/* 供水设施管理表格 */} } > ( ), }, { title: "容量/长度", dataIndex: "capacity", key: "capacity" }, { title: "操作", key: "action", render: (_, record) => ( ), }, ]} dataSource={facilitiesData} pagination={{ pageSize: 10 }} loading={loading} /> {/* GIS一图展示 */}
) case "devices": return (
{/* 设备统计 */}
} valueStyle={{ color: "#1890ff" }} /> } valueStyle={{ color: "#52c41a" }} /> } valueStyle={{ color: "#ff4d4f" }} /> } valueStyle={{ color: "#faad14" }} /> {/* 监测设备管理表格 */} } >
( ), }, { title: "最后维护", dataIndex: "lastMaintenance", key: "lastMaintenance" }, { title: "操作", key: "action", render: (_, record) => ( {record.status === "故障" && ( )} ), }, ]} dataSource={devicesData} pagination={{ pageSize: 10 }} loading={loading} /> ) case "monitoring": return (
{/* 运行监测表格 */} } >
( ), }, { title: "更新时间", dataIndex: "time", key: "time" }, { title: "操作", key: "action", render: (_, record) => ( ), }, ]} dataSource={monitoringData} pagination={{ pageSize: 10 }} loading={loading} /> ) case "alarms": return (
{/* 报警统计 */}
} valueStyle={{ color: "#ff4d4f" }} /> } valueStyle={{ color: "#ff4d4f" }} /> } valueStyle={{ color: "#faad14" }} /> } valueStyle={{ color: "#1890ff" }} /> {/* 报警趋势图 */} {/* 报警管理表格 */} } >
( {level} ), }, { title: "处理状态", dataIndex: "status", key: "status", render: (status: string) => ( ), }, { title: "报警时间", dataIndex: "time", key: "time" }, { title: "操作", key: "action", render: (_, record) => ( ), }, ]} dataSource={alarmsData} pagination={{ pageSize: 10 }} loading={loading} /> {/* 报警一张图 */}
) default: return
功能开发中...
} } return ( {renderContent()} setFacilityDetailModal(false)} footer={[ , ]} width={600} > {selectedRecord && (
设施名称: {selectedRecord.name}
设施类型: {selectedRecord.type}
位置: {selectedRecord.location}
运行状态:
容量/规模: {selectedRecord.capacity || selectedRecord.length || selectedRecord.usage}
)} setDeviceDetailModal(false)} footer={[ , ]} width={600} > {selectedRecord && (
设备名称: {selectedRecord.name}
设备类型: {selectedRecord.type}
安装位置: {selectedRecord.location}
运行状态:
最后维护时间: {selectedRecord.lastMaintenance}
)} { thresholdForm.validateFields().then(() => { globalMessage.success("阈值设置成功") setThresholdModal(false) thresholdForm.resetFields() }) }} onCancel={() => { setThresholdModal(false) thresholdForm.resetFields() }} width={600} >
setExportModal(false)} footer={[ , , ]} >
导出格式:
导出范围:
{/* 处理报警模态框 */} { form.validateFields().then(() => { globalMessage.success("报警处理成功") setModalVisible(false) form.resetFields() }) }} onCancel={() => { setModalVisible(false) form.resetFields() }} className="hover:shadow-2xl transition-shadow duration-300" >
) }