import { Activity, AlertTriangle, CheckCircle, TrendingUp, TrendingDown, RefreshCw, Bell, Settings, Zap, Thermometer, Gauge, Clock } from "lucide-react"; import { motion, AnimatePresence } from "motion/react"; import { LineChart, Line, BarChart, Bar, AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from "recharts"; import { useState, useEffect, useRef } from "react"; import { toast } from "sonner"; const steelProcessStages = [ { name: "炼铁", status: "normal", load: 85, temp: 1250 }, { name: "炼钢", status: "normal", load: 92, temp: 1650 }, { name: "连铸", status: "normal", load: 88, temp: 1520 }, { name: "热轧", status: "normal", load: 90, temp: 1180 }, { name: "冷轧", status: "normal", load: 78, temp: 850 }, ]; const aluminaProcessStages = [ { name: "铝土矿破碎", status: "normal", load: 82, temp: 25 }, { name: "拜耳法溶出", status: "normal", load: 88, temp: 260 }, { name: "沉降分离", status: "normal", load: 85, temp: 100 }, { name: "晶种分解", status: "warning", load: 78, temp: 80 }, { name: "焙烧", status: "normal", load: 90, temp: 1100 }, ]; const steelTemperatureTrend = [ { time: "08:00", t1: 1245, t2: 1648, t3: 1518 }, { time: "10:00", t1: 1248, t2: 1650, t3: 1520 }, { time: "12:00", t1: 1250, t2: 1652, t3: 1522 }, { time: "14:00", t1: 1252, t2: 1649, t3: 1519 }, { time: "16:00", t1: 1250, t2: 1650, t3: 1520 }, ]; const aluminaTemperatureTrend = [ { time: "08:00", t1: 24, t2: 258, t3: 98 }, { time: "10:00", t1: 25, t2: 260, t3: 100 }, { time: "12:00", t1: 26, t2: 262, t3: 102 }, { time: "14:00", t1: 25, t2: 259, t3: 99 }, { time: "16:00", t1: 25, t2: 260, t3: 100 }, ]; const steelProductionData = [ { hour: "00", value: 820 }, { hour: "04", value: 780 }, { hour: "08", value: 950 }, { hour: "12", value: 1020 }, { hour: "16", value: 980 }, { hour: "20", value: 890 }, ]; const aluminaProductionData = [ { hour: "00", value: 420 }, { hour: "04", value: 380 }, { hour: "08", value: 480 }, { hour: "12", value: 520 }, { hour: "16", value: 490 }, { hour: "20", value: 450 }, ]; const steelAlerts = [ { id: 1, type: "warning", message: "高炉1#冷却水温差偏高", time: "10:35", handled: false }, { id: 2, type: "info", message: "连铸2#定期维护提醒", time: "10:20", handled: false }, { id: 3, type: "success", message: "炼钢3#工艺优化已完成", time: "10:15", handled: true }, { id: 4, type: "warning", message: "热轧设备温度波动", time: "10:05", handled: true }, ]; const aluminaAlerts = [ { id: 1, type: "warning", message: "分解槽搅拌强度偏低", time: "10:35", handled: false }, { id: 2, type: "info", message: "蒸发器定期维护提醒", time: "10:20", handled: false }, { id: 3, type: "success", message: "铝酸钠溶液浓度优化完成", time: "10:15", handled: true }, { id: 4, type: "warning", message: "晶种分解效率波动", time: "10:05", handled: true }, ]; const steelEquipmentStatus = [ { name: "高炉 #1", status: "running", efficiency: 94, uptime: "99.2%" }, { name: "高炉 #2", status: "running", efficiency: 92, uptime: "98.8%" }, { name: "转炉 #1", status: "running", efficiency: 96, uptime: "99.5%" }, { name: "转炉 #2", status: "maintenance", efficiency: 0, uptime: "—" }, { name: "连铸 #1", status: "running", efficiency: 91, uptime: "98.3%" }, { name: "连铸 #2", status: "running", efficiency: 93, uptime: "99.1%" }, ]; const aluminaEquipmentStatus = [ { name: "磨机 #1", status: "running", efficiency: 94, uptime: "99.2%" }, { name: "磨机 #2", status: "running", efficiency: 92, uptime: "98.8%" }, { name: "溶出器 #1", status: "running", efficiency: 96, uptime: "99.5%" }, { name: "溶出器 #2", status: "running", efficiency: 91, uptime: "98.3%" }, { name: "沉降槽 #1", status: "running", efficiency: 93, uptime: "99.1%" }, { name: "分解槽 #1", status: "maintenance", efficiency: 0, uptime: "—" }, ]; export function MonitoringCenter() { const [currentTime, setCurrentTime] = useState(new Date()); const [alertsList, setAlertsList] = useState(steelAlerts); const [processData, setProcessData] = useState(steelProcessStages); const [tempTrendData, setTempTrendData] = useState(steelTemperatureTrend); const [industry, setIndustry] = useState<"steel" | "alumina">("steel"); const currentProductionData = industry === "steel" ? steelProductionData : aluminaProductionData; const currentEquipmentStatus = industry === "steel" ? steelEquipmentStatus : aluminaEquipmentStatus; const currentProcessStages = industry === "steel" ? steelProcessStages : aluminaProcessStages; const currentTempTrend = industry === "steel" ? steelTemperatureTrend : aluminaTemperatureTrend; const currentAlerts = industry === "steel" ? steelAlerts : aluminaAlerts; // Reset data when industry changes useEffect(() => { setProcessData(currentProcessStages); setTempTrendData(currentTempTrend); setAlertsList(currentAlerts); }, [industry, currentProcessStages, currentTempTrend, currentAlerts]); // Update current time useEffect(() => { const interval = setInterval(() => { setCurrentTime(new Date()); }, 1000); return () => clearInterval(interval); }, []); // Simulate real-time data updates useEffect(() => { const interval = setInterval(() => { setProcessData(prev => prev.map(stage => ({ ...stage, load: Math.max(70, Math.min(100, stage.load + (Math.random() - 0.5) * 5)), temp: stage.temp + (Math.random() - 0.5) * 10 }))); setTempTrendData(prev => { const newData = [...prev]; newData.shift(); const lastPoint = newData[newData.length - 1]; newData.push({ time: new Date().toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' }), t1: lastPoint.t1 + (Math.random() - 0.5) * 5, t2: lastPoint.t2 + (Math.random() - 0.5) * 5, t3: lastPoint.t3 + (Math.random() - 0.5) * 5, }); return newData; }); }, 3000); return () => clearInterval(interval); }, []); const handleAlertAction = (id: number) => { setAlertsList(prev => prev.map(alert => alert.id === id ? { ...alert, handled: !alert.handled } : alert )); toast.success("报警状态已更新", { duration: 2000 }); }; const handleRefresh = () => { toast.promise( new Promise((resolve) => setTimeout(resolve, 1000)), { loading: '刷新监控数据...', success: '数据已更新!', error: '刷新失败', } ); }; const handleNotification = () => { const unhandled = alertsList.filter(a => !a.handled).length; if (unhandled > 0) { toast.warning(`您有 ${unhandled} 条未处理报警`, { duration: 3000 }); } else { toast.success("暂无未处理报警", { duration: 2000 }); } }; return (
全厂实时状态监控与数据分析