page.tsx 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526
  1. "use client"
  2. import React, {useEffect, useMemo, useState, useRef} from "react"
  3. import type {MenuProps, TableColumnsType} from "antd"
  4. import {
  5. Badge,
  6. Button,
  7. Card,
  8. Col,
  9. ConfigProvider,
  10. DatePicker,
  11. Descriptions,
  12. Divider,
  13. Drawer,
  14. Empty,
  15. Layout,
  16. Menu,
  17. Progress,
  18. Row,
  19. Segmented,
  20. Select,
  21. Space,
  22. Statistic,
  23. Switch,
  24. Table,
  25. Tabs,
  26. Tag,
  27. Timeline,
  28. Tooltip as AntdTooltip,
  29. } from "antd"
  30. import {
  31. Activity,
  32. AlertTriangle,
  33. BellRing,
  34. ClipboardList,
  35. Database,
  36. Droplets,
  37. Factory,
  38. Flame,
  39. Gauge,
  40. Layers3,
  41. LineChartIcon,
  42. Moon,
  43. Settings2,
  44. ShieldCheck,
  45. Sun,
  46. Table2,
  47. TrendingUp,
  48. Users,
  49. Waves
  50. } from 'lucide-react'
  51. import EChart from "@/components/echarts"
  52. import dayjs from "dayjs"
  53. import "dayjs/locale/zh-cn"
  54. import zhCN from "antd/es/locale/zh_CN"
  55. import {MapContainer, Marker, Popup, TileLayer} from 'react-leaflet'
  56. import 'leaflet/dist/leaflet.css'
  57. import L from 'leaflet'
  58. //地图控件部分
  59. import './BaiduMapPage.css';
  60. import dataJson from './index.json';
  61. import markerData from './markerData.json';
  62. import fameng from './fameng.png';
  63. import shuifa from './shuifa.png';
  64. import deom1 from './deom1.png';
  65. import deom2 from './deom2.png';
  66. import Uptow from './up-two.png';
  67. import BaiduMapPage from "@/app/(business)/test/test2/page";
  68. // 修复Leaflet默认图标问题
  69. delete (L.Icon.Default.prototype as any)._getIconUrl;
  70. L.Icon.Default.mergeOptions({
  71. iconRetinaUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-icon-2x.png',
  72. iconUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-icon.png',
  73. shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-shadow.png',
  74. });
  75. dayjs.locale("zh-cn")
  76. const { Header, Sider, Content } = Layout
  77. const { RangePicker } = DatePicker
  78. // Helpers
  79. const primary = "#10b981" // teal, avoid blue
  80. const danger = "#ef4444"
  81. const warn = "#f59e0b"
  82. const ok = "#22c55e"
  83. const muted = "#6b7280"
  84. type Facility = {
  85. id: string
  86. industry: "燃气" | "供水" | "排水"
  87. type: string
  88. count: number
  89. age: number
  90. region: string
  91. }
  92. type Device = {
  93. id: string
  94. type: string
  95. status: "在线" | "离线"
  96. industry: Facility["industry"]
  97. risk: "高" | "中" | "低"
  98. lat: number
  99. lng: number
  100. }
  101. type Alert = {
  102. id: string
  103. level: "I级" | "II级" | "III级" | "IV级"
  104. industry: Facility["industry"]
  105. type: string
  106. time: string
  107. status: "待处置" | "处置中" | "已闭环"
  108. location: string
  109. desc: string
  110. }
  111. function useMockData() {
  112. const [facilities] = useState<Facility[]>(() => {
  113. const regions = ["中心城区", "东区", "西区", "南区", "北区"]
  114. const types = {
  115. 燃气: ["高压管道", "调压站", "门站", "阀门井"],
  116. 供水: ["原水管", "净水厂", "二次供水", "监测点"],
  117. 排水: ["主干管", "泵站", "检查井", "溢流口"],
  118. } as const
  119. let i = 0
  120. return (["燃气", "供水", "排水"] as Facility["industry"][]).flatMap((ind) =>
  121. types[ind].map((t) => ({
  122. id: `f-${i++}`,
  123. industry: ind,
  124. type: t,
  125. count: Math.floor(Math.random() * 900 + 100),
  126. age: Math.floor(Math.random() * 30 + 1),
  127. region: regions[Math.floor(Math.random() * regions.length)],
  128. }))
  129. )
  130. })
  131. const [devices, setDevices] = useState<Device[]>(() => {
  132. const types = ["压力", "流量", "液位", "阀位", "水质", "气体浓度"]
  133. let i = 0
  134. return Array.from({ length: 250 }).map(() => ({
  135. id: `d-${i++}`,
  136. type: types[Math.floor(Math.random() * types.length)],
  137. status: Math.random() > 0.12 ? "在线" : "离线",
  138. industry: (["燃气", "供水", "排水"] as const)[Math.floor(Math.random() * 3)],
  139. risk: Math.random() > 0.8 ? "高" : Math.random() > 0.5 ? "中" : "低",
  140. lat: Math.random(),
  141. lng: Math.random(),
  142. }))
  143. })
  144. // Simulate device status fluctuation
  145. useEffect(() => {
  146. const t = setInterval(() => {
  147. setDevices((prev) =>
  148. prev.map((d) =>
  149. Math.random() > 0.97 ? { ...d, status: d.status === "在线" ? "离线" : "在线" } : d
  150. )
  151. )
  152. }, 4000)
  153. return () => clearInterval(t)
  154. }, [])
  155. const [alerts, setAlerts] = useState<Alert[]>(() => {
  156. const levels: Alert["level"][] = ["I级", "II级", "III级", "IV级"]
  157. const types = ["泄漏", "压力异常", "流量突变", "停电", "液位过低", "浊度异常"]
  158. let i = 0
  159. return Array.from({ length: 30 }).map(() => ({
  160. id: `a-${i++}`,
  161. level: levels[Math.floor(Math.random() * levels.length)],
  162. industry: (["燃气", "供水", "排水"] as const)[Math.floor(Math.random() * 3)],
  163. type: types[Math.floor(Math.random() * types.length)],
  164. time: dayjs().subtract(Math.floor(Math.random() * 200), "minute").format("YYYY-MM-DD HH:mm"),
  165. status: Math.random() > 0.6 ? "已闭环" : Math.random() > 0.3 ? "处置中" : "待处置",
  166. location: ["中心城区", "东区", "西区", "南区", "北区"][Math.floor(Math.random() * 5)],
  167. desc: "自动监测发现异常,已推送至管理单位核实。",
  168. }))
  169. })
  170. // Simulate new alerts
  171. useEffect(() => {
  172. const t = setInterval(() => {
  173. setAlerts((prev) => {
  174. const n: Alert = {
  175. id: `a-${prev.length + 1}`,
  176. level: Math.random() > 0.85 ? "I级" : Math.random() > 0.6 ? "II级" : Math.random() > 0.3 ? "III级" : "IV级",
  177. industry: (["燃气", "供水", "排水"] as const)[Math.floor(Math.random() * 3)],
  178. type: ["泄漏", "压力异常", "流量突变", "停电", "液位过低", "浊度异常"][Math.floor(Math.random() * 6)],
  179. time: dayjs().format("YYYY-MM-DD HH:mm"),
  180. status: "待处置",
  181. location: ["中心城区", "东区", "西区", "南区", "北区"][Math.floor(Math.random() * 5)],
  182. desc: "前端设备上报新预警,请尽快核查。",
  183. }
  184. return [n, ...prev].slice(0, 60)
  185. })
  186. }, 20000)
  187. return () => clearInterval(t)
  188. }, [])
  189. return { facilities, devices, alerts }
  190. }
  191. function LevelTag({ level }: { level: Alert["level"] }) {
  192. const map = {
  193. "I级": { color: danger },
  194. "II级": { color: warn },
  195. "III级": { color: "#f97316" },
  196. "IV级": { color: ok },
  197. } as const
  198. return <Tag color={map[level].color}>{level}</Tag>
  199. }
  200. function StatusBadge({ s }: { s: Alert["status"] }) {
  201. const status = {
  202. 待处置: "error",
  203. 处置中: "processing",
  204. 已闭环: "success",
  205. } as const
  206. // @ts-expect-error antd types for Badge status
  207. return <Badge status={status[s]} text={s} />
  208. }
  209. export default function Page() {
  210. const [collapsed, setCollapsed] = useState(false)
  211. const { facilities, devices, alerts } = useMockData()
  212. const [selectedMenu, setSelectedMenu] = useState("overview")
  213. const [drawerOpen, setDrawerOpen] = useState(false)
  214. const [selectedAlert, setSelectedAlert] = useState<Alert | null>(null)
  215. const [isDark, setIsDark] = useState(false) // 默认白色主题
  216. const [assetTab, setAssetTab] = useState("archive")
  217. const [monitorTab, setMonitorTab] = useState("summary")
  218. const [alertTab, setAlertTab] = useState("current")
  219. const totals = useMemo(() => {
  220. const sum = { 燃气: 0, 供水: 0, 排水: 0 } as Record<Facility["industry"], number>
  221. facilities.forEach((f) => (sum[f.industry] += f.count))
  222. return sum
  223. }, [facilities])
  224. const onlineRate = useMemo(() => {
  225. const total = devices.length
  226. const online = devices.filter((d) => d.status === "在线").length
  227. return Math.round((online / Math.max(total, 1)) * 100)
  228. }, [devices])
  229. const riskDist = useMemo(() => {
  230. const dist = { 高: 0, 中: 0, 低: 0 } as Record<Device["risk"], number>
  231. devices.forEach((d) => (dist[d.risk] += 1))
  232. return dist
  233. }, [devices])
  234. // Menu
  235. const menuItems: MenuProps["items"] = [
  236. { key: "overview", icon: <Layers3 size={18} />, label: "总体概览" },
  237. { key: "asset", icon: <Database size={18} />, label: "基础设施管理" },
  238. { key: "monitor", icon: <Activity size={18} />, label: "运行监测管理" },
  239. { key: "alert", icon: <BellRing size={18} />, label: "预警处置管理" },
  240. { type: "divider" as const },
  241. { key: "devices", icon: <Gauge size={18} />, label: "设备管理" },
  242. { key: "reports", icon: <ClipboardList size={18} />, label: "数据报表" },
  243. { key: "incidents", icon: <Users size={18} />, label: "事件中心" },
  244. { key: "bigscreen", icon: <LineChartIcon size={18} />, label: "数据大屏(示意)" },
  245. { type: "divider" as const },
  246. { key: "settings", icon: <Settings2 size={18} />, label: "设置" },
  247. ]
  248. // Charts Options
  249. const infraPieOption = useMemo(
  250. () => ({
  251. title: { text: "设施类型占比", left: "center", textStyle: { fontSize: 14 } },
  252. tooltip: { trigger: "item" },
  253. legend: { bottom: 0 },
  254. color: [primary, "#f59e0b", "#6366f1", "#ef4444", "#14b8a6", "#a855f7"],
  255. series: [
  256. {
  257. type: "pie",
  258. radius: ["35%", "60%"],
  259. avoidLabelOverlap: false,
  260. itemStyle: { borderRadius: 6, borderColor: "#fff", borderWidth: 2 },
  261. data: ["燃气", "供水", "排水"].map((ind) => ({
  262. name: ind,
  263. value: facilities
  264. .filter((f) => f.industry === ind)
  265. .reduce((acc, f) => acc + f.count, 0),
  266. })),
  267. },
  268. ],
  269. }),
  270. [facilities]
  271. )
  272. const deviceBarOption = useMemo(() => {
  273. const types = Array.from(new Set(devices.map((d) => d.type)))
  274. const byType = types.map((t) => devices.filter((d) => d.type === t).length)
  275. return {
  276. title: { text: "监测设备类型规模", left: "center", textStyle: { fontSize: 14 } },
  277. tooltip: { trigger: "axis" },
  278. xAxis: { type: "category", data: types, axisLabel: { rotate: 20 } },
  279. yAxis: { type: "value" },
  280. grid: { left: 40, right: 10, bottom: 50, top: 40 },
  281. color: [primary],
  282. series: [{ type: "bar", data: byType, barWidth: "50%", itemStyle: { borderRadius: [4, 4, 0, 0] } }],
  283. } as const
  284. }, [devices])
  285. const alertTrendOption = useMemo(() => {
  286. const days = 14
  287. const labels = Array.from({ length: days }).map((_, i) => dayjs().subtract(days - i - 1, "day").format("MM-DD"))
  288. const series = (["燃气", "供水", "排水"] as const).map((ind, idx) => ({
  289. name: ind,
  290. type: "line",
  291. smooth: true,
  292. data: labels.map(() => Math.floor(Math.random() * (idx === 0 ? 12 : idx === 1 ? 9 : 7)) + (idx === 0 ? 3 : 1)),
  293. }))
  294. return {
  295. title: { text: "预警趋势(近14天)", left: "center", textStyle: { fontSize: 14 } },
  296. tooltip: { trigger: "axis" },
  297. legend: { bottom: 0 },
  298. grid: { left: 40, right: 10, bottom: 40, top: 40 },
  299. xAxis: { type: "category", data: labels },
  300. yAxis: { type: "value" },
  301. color: [primary, "#f59e0b", "#a855f7"],
  302. series,
  303. } as const
  304. }, [])
  305. const onlineGaugeOption = useMemo(
  306. () => ({
  307. title: { text: "设备在线率", left: "center", top: 10, textStyle: { fontSize: 14 } },
  308. series: [
  309. {
  310. type: "gauge",
  311. startAngle: 200,
  312. endAngle: -20,
  313. radius: "90%",
  314. pointer: { show: false },
  315. progress: { show: true, width: 16, itemStyle: { color: onlineRate > 95 ? ok : onlineRate > 85 ? "#84cc16" : warn } },
  316. axisLine: { lineStyle: { width: 16 } },
  317. axisTick: { show: false },
  318. splitLine: { show: false },
  319. axisLabel: { show: false },
  320. detail: { valueAnimation: true, formatter: "{value}%", fontSize: 22, offsetCenter: [0, "10%"] },
  321. data: [{ value: onlineRate }],
  322. },
  323. ],
  324. }),
  325. [onlineRate]
  326. )
  327. const riskBarOption = useMemo(
  328. () => ({
  329. title: { text: "风险等级分布", left: "center", textStyle: { fontSize: 14 } },
  330. tooltip: { trigger: "axis" },
  331. grid: { left: 40, right: 10, top: 40, bottom: 20 },
  332. xAxis: { type: "category", data: ["高", "中", "低"] },
  333. yAxis: { type: "value" },
  334. color: [danger, warn, ok],
  335. series: [{ type: "bar", data: [riskDist["高"], riskDist["中"], riskDist["低"]], barWidth: "50%" }],
  336. }),
  337. [riskDist]
  338. )
  339. const efficiencyPieOption = useMemo(() => {
  340. const closed = alerts.filter((a) => a.status === "已闭环").length
  341. const correct = Math.floor(closed * (0.85 + Math.random() * 0.1)) // 假定人工复核正确率
  342. const wrong = Math.max(closed - correct, 0)
  343. return {
  344. title: { text: "预警正确性(闭环内)", left: "center", textStyle: { fontSize: 14 } },
  345. tooltip: { trigger: "item", formatter: "{b}: {c} ({d}%)" },
  346. legend: { bottom: 0 },
  347. color: [ok, danger],
  348. series: [
  349. {
  350. type: "pie",
  351. radius: ["35%", "60%"],
  352. data: [
  353. { name: "正确预警", value: correct },
  354. { name: "误报", value: wrong },
  355. ],
  356. },
  357. ],
  358. } as const
  359. }, [alerts])
  360. const radarCapacityOption = useMemo(
  361. () => ({
  362. title: { text: "应急保障能力雷达", left: "center", textStyle: { fontSize: 14 } },
  363. tooltip: {},
  364. radar: {
  365. indicator: [
  366. { name: "抢修速度", max: 100 },
  367. { name: "物资充足", max: 100 },
  368. { name: "跨部门联动", max: 100 },
  369. { name: "覆盖广度", max: 100 },
  370. { name: "应急演练", max: 100 },
  371. ],
  372. },
  373. color: [primary],
  374. series: [
  375. {
  376. type: "radar",
  377. data: [{ value: [78, 85, 72, 88, 76], name: "当前" }],
  378. areaStyle: { color: primary + "33" },
  379. },
  380. ],
  381. }),
  382. []
  383. )
  384. // Tables
  385. const facilityColumns: TableColumnsType<Facility> = [
  386. { title: "行业", dataIndex: "industry", key: "industry", width: 90 },
  387. { title: "类型", dataIndex: "type", key: "type" },
  388. { title: "数量", dataIndex: "count", key: "count", width: 100 },
  389. { title: "平均年限", dataIndex: "age", key: "age", width: 120, render: (v) => `${v} 年` },
  390. { title: "分布区域", dataIndex: "region", key: "region", width: 120 },
  391. ]
  392. const alertColumns: TableColumnsType<Alert> = [
  393. { title: "等级", dataIndex: "level", key: "level", width: 90, render: (v) => <LevelTag level={v} /> },
  394. { title: "行业", dataIndex: "industry", key: "industry", width: 90 },
  395. { title: "类型", dataIndex: "type", key: "type", width: 140 },
  396. { title: "时间", dataIndex: "time", key: "time", width: 160 },
  397. { title: "状态", dataIndex: "status", key: "status", width: 120, render: (s) => <StatusBadge s={s} /> },
  398. { title: "位置", dataIndex: "location", key: "location", width: 120 },
  399. {
  400. title: "操作",
  401. key: "action",
  402. render: (_, record) => (
  403. <Space size="small">
  404. <a
  405. onClick={() => {
  406. setSelectedAlert(record)
  407. setDrawerOpen(true)
  408. }}
  409. >
  410. 查看
  411. </a>
  412. <a>派单</a>
  413. <a>联动</a>
  414. </Space>
  415. ),
  416. width: 160,
  417. fixed: "right",
  418. },
  419. ]
  420. const deviceColumns: TableColumnsType<Device> = [
  421. { title: "行业", dataIndex: "industry", key: "industry", width: 90 },
  422. { title: "类型", dataIndex: "type", key: "type", width: 100 },
  423. {
  424. title: "状态",
  425. dataIndex: "status",
  426. key: "status",
  427. width: 100,
  428. render: (s) => <Badge status={s === "在线" ? "success" : "default"} text={s} />,
  429. filters: [
  430. { text: "在线", value: "在线" },
  431. { text: "离线", value: "离线" },
  432. ],
  433. onFilter: (v, r) => r.status === v,
  434. },
  435. {
  436. title: "风险",
  437. dataIndex: "risk",
  438. key: "risk",
  439. width: 100,
  440. render: (r) => <Tag color={r === "高" ? danger : r === "中" ? warn : ok}>{r}</Tag>,
  441. filters: [
  442. { text: "高", value: "高" },
  443. { text: "中", value: "中" },
  444. { text: "低", value: "低" },
  445. ],
  446. onFilter: (v, r) => r.risk === v,
  447. },
  448. { title: "编号", dataIndex: "id", key: "id" },
  449. ]
  450. const alertLevelColor = (lvl: Alert["level"]) =>
  451. lvl === "I级" ? danger : lvl === "II级" ? warn : lvl === "III级" ? "#f97316" : ok
  452. // Derived numbers
  453. const stats = [
  454. {
  455. title: "燃气总规模",
  456. value: totals["燃气"],
  457. icon: <Flame className="text-white" size={18} />,
  458. bg: "bg-emerald-500",
  459. },
  460. {
  461. title: "供水总规模",
  462. value: totals["供水"],
  463. icon: <Droplets className="text-white" size={18} />,
  464. bg: "bg-teal-500",
  465. },
  466. {
  467. title: "排水总规模",
  468. value: totals["排水"],
  469. icon: <Waves className="text-white" size={18} />,
  470. bg: "bg-cyan-500",
  471. },
  472. {
  473. title: "在线设备",
  474. value: devices.filter((d) => d.status === "在线").length,
  475. icon: <Gauge className="text-white" size={18} />,
  476. bg: "bg-lime-500",
  477. },
  478. ]
  479. // Map markers for device distribution
  480. const markers = devices.slice(0, 120).map((d) => ({
  481. id: d.id,
  482. top: `${Math.floor(d.lat * 85) + 5}%`,
  483. left: `${Math.floor(d.lng * 90) + 5}%`,
  484. color: d.risk === "高" ? danger : d.risk === "中" ? warn : ok,
  485. title: `${d.industry}/${d.type}(${d.status})`,
  486. }))
  487. const themeTokens = useMemo(
  488. () => ({
  489. token: {
  490. colorPrimary: primary,
  491. colorInfo: primary,
  492. borderRadius: 8,
  493. fontSize: 13,
  494. },
  495. components: {
  496. Layout: {
  497. headerBg: isDark ? "#0f172a" : "#ffffff",
  498. siderBg: isDark ? "#0b1220" : "#ffffff",
  499. bodyBg: isDark ? "#0b1220" : "#f6f7f9",
  500. },
  501. Menu: {
  502. itemSelectedBg: isDark ? "#0ea5a8" : "#d1fae5",
  503. itemSelectedColor: isDark ? "#fff" : "#0f172a",
  504. itemActiveBg: "#0ea5a822",
  505. },
  506. },
  507. }),
  508. [isDark]
  509. )
  510. // const BaiduMapPage = () => {
  511. const mapRef = useRef(null);
  512. const [map, setMap] = useState(null);
  513. var lineLayer = null;
  514. var icon1 = deom1.src;
  515. var icon2 = deom2.src;
  516. var upTwo = Uptow.src;
  517. // 初始化地图
  518. useEffect(() => {
  519. // 检查是否已加载百度地图 GL JS API
  520. if (!window.BMapGL) {
  521. // 动态加载百度地图 GL JS API
  522. const script = document.createElement('script');
  523. script.src = `https://api.map.baidu.com/api?v=2.0&ak=jWDCUpsk33htQsF6IEwk4ctkERTOFFH0&type=webgl`;
  524. script.async = true;
  525. document.head.appendChild(script);
  526. window.initMap = () => {
  527. initializeMap();
  528. };
  529. } else {
  530. initializeMap();
  531. }
  532. return () => {
  533. // 清理工作
  534. if (map) {
  535. map.destroy();
  536. }
  537. };
  538. }, []);
  539. const initializeMap = () => {
  540. // 创建地图实例
  541. const mapInstance = new window.BMapGL.Map(mapRef.current);
  542. // 设置中心点坐标(北京)
  543. const point = new window.BMapGL.Point(110.39573035064166, 28.44628067667752);
  544. mapInstance.centerAndZoom(point, 16);
  545. // 启用滚轮放大缩小
  546. mapInstance.enableScrollWheelZoom(true);
  547. // 添加控件
  548. // mapInstance.addControl(new window.BMapGL.NavigationControl());
  549. // mapInstance.addControl(new window.BMapGL.ScaleControl());
  550. // mapInstance.addControl(new window.BMapGL.OverviewMapControl());
  551. // mapInstance.addControl(new window.BMapGL.MapTypeControl());
  552. mapInstance.setMinZoom(16);
  553. mapInstance.setMaxZoom(19);
  554. mapInstance.setMapStyleV2({
  555. styleId: '62ce43ad2a1362c23e612b783d7406e7'
  556. });
  557. markerData.list.dataOne.forEach(item => {
  558. const icon = new window.BMapGL.Icon(fameng.src, new window.BMapGL.Size(23, 25), {
  559. anchor: new window.BMapGL.Size(10, 25),
  560. });
  561. const markers = new window.BMapGL.Point(item.lng, item.lat);
  562. const marker = new window.BMapGL.Marker(markers,{
  563. icon:icon
  564. });
  565. mapInstance.addOverlay(marker);
  566. // 创建信息窗口
  567. let opts = {
  568. width: 300,
  569. title: item.name
  570. };
  571. let infoWindow = new window.BMapGL.InfoWindow("倾斜角度:" + '188deg' + "<br/>" +
  572. "状态:" + '正常运行' + "<br/>" +
  573. "信噪比:" + '16db' + "<br/>" +
  574. "负责人:" + '张三' + "<br/>" +
  575. "联系方式:" + '121234564', opts);
  576. // 点标记添加点击事件
  577. marker.addEventListener('click', function() {
  578. mapInstance.openInfoWindow(infoWindow, markers); // 开启信息窗口
  579. });
  580. })
  581. markerData.list.dataTwo.forEach(item => {
  582. const icon = new window.BMapGL.Icon(shuifa.src, new window.BMapGL.Size(23, 25), {
  583. anchor: new window.BMapGL.Size(20, 0),
  584. });
  585. const markers = new window.BMapGL.Point(item.lng, item.lat);
  586. const marker = new window.BMapGL.Marker(markers,{
  587. icon:icon
  588. });
  589. mapInstance.addOverlay(marker);
  590. // 创建信息窗口
  591. let opts = {
  592. width: 300,
  593. title: item.name
  594. };
  595. let infoWindow = new window.BMapGL.InfoWindow("倾斜角度:" + '188deg' + "<br/>" +
  596. "状态:" + '正常运行' + "<br/>" +
  597. "信噪比:" + '16db' + "<br/>" +
  598. "负责人:" + '张三' + "<br/>" +
  599. "联系方式:" + '121234564', opts);
  600. // 点标记添加点击事件
  601. marker.addEventListener('click', function() {
  602. mapInstance.openInfoWindow(infoWindow, markers); // 开启信息窗口
  603. });
  604. })
  605. if (!lineLayer) {
  606. lineLayer = new window.BMapGL.LineLayer({
  607. enablePicked: true,
  608. autoSelect: true,
  609. pickWidth: 30,
  610. pickHeight: 30,
  611. opacity: 1,
  612. selectedColor: 'blue', // 选中项颜色
  613. style: {
  614. sequence: false, // 是否采用间隔填充纹理,默认false
  615. marginLength: 18, // 间隔距离,默认16,单位像素
  616. // borderColor: '#999',
  617. borderMask: true, // 是否受内部填充区域掩膜,默认true,如果存在borderWeight小于0,则自动切换false
  618. // borderWeight: ['match', ['get', 'name'], 'demo1', 2, 0], // 描边宽度,可以设置负值
  619. strokeWeight: 10, // 描边线宽度,默认0
  620. strokeLineJoin: 'round',//描边线连接处类型, 可选'miter', 'round', 'bevel'
  621. strokeLineCap: 'round',// 描边线端头类型,可选'round', 'butt', 'square',默认round
  622. // 填充纹理图片地址,默认是空。图片需要是竖向表达,在填充时会自动横向处理。
  623. strokeTextureUrl: ['match', ['get', 'name'], 'demo1', icon1, 'demo2', icon2, upTwo],
  624. }
  625. });
  626. }
  627. lineLayer.setData(dataJson);
  628. mapInstance.addNormalLayer(lineLayer);
  629. setMap(mapInstance);
  630. // 添加点击地图事件
  631. mapInstance.addEventListener('click', (e) => {
  632. console.log('点击位置经纬度:', e.latlng.lng, e.latlng.lat);
  633. });
  634. // };
  635. };
  636. return (
  637. <ConfigProvider locale={zhCN} theme={themeTokens}>
  638. <Layout style={{ minHeight: "100vh" }}>
  639. <Sider collapsible collapsed={collapsed} onCollapse={setCollapsed} width={240} theme={isDark ? "dark" : "light"}>
  640. <div className="flex items-center gap-2 px-4 py-3">
  641. <ShieldCheck className="text-emerald-400" size={22} />
  642. {!collapsed && (
  643. <div className={isDark ? "text-emerald-100 font-medium" : "text-emerald-700 font-medium"}>
  644. 城市生命线驾驶舱
  645. </div>
  646. )}
  647. </div>
  648. <Menu
  649. theme={isDark ? "dark" : "light"}
  650. mode="inline"
  651. selectedKeys={[selectedMenu]}
  652. onClick={(e) => setSelectedMenu(e.key)}
  653. items={menuItems}
  654. />
  655. </Sider>
  656. <Layout>
  657. <Header className="flex items-center justify-between px-4">
  658. <div className={`flex items-center gap-3 ${isDark ? "text-white" : "text-slate-800"}`}>
  659. <Factory size={18} />
  660. <span className="font-medium">综合运行态势</span>
  661. <span className={`text-xs hidden md:inline ${isDark ? "text-slate-300" : "text-slate-500"}`}>
  662. 更新时间 {dayjs().format("YYYY-MM-DD HH:mm:ss")}
  663. </span>
  664. </div>
  665. <div className="flex items-center gap-3">
  666. <Select
  667. size="small"
  668. defaultValue="全市"
  669. options={[
  670. { value: "全市", label: "全市" },
  671. { value: "中心城区", label: "中心城区" },
  672. { value: "东区", label: "东区" },
  673. { value: "西区", label: "西区" },
  674. { value: "南区", label: "南区" },
  675. { value: "北区", label: "北区" },
  676. ]}
  677. style={{ width: 120 }}
  678. />
  679. <RangePicker size="small" />
  680. <Button size="small" onClick={() => setIsDark((v) => !v)} icon={isDark ? <Sun size={14} /> : <Moon size={14} />}>
  681. {isDark ? "暗色" : "白色"}
  682. </Button>
  683. </div>
  684. </Header>
  685. <Content className="p-4 md:p-6">
  686. {selectedMenu === "overview" && (
  687. <section className="space-y-4">
  688. <Row gutter={[16, 16]}>
  689. {stats.map((s) => (
  690. <Col xs={24} sm={12} md={12} lg={6} key={s.title}>
  691. <Card>
  692. <div className="flex items-center gap-3">
  693. <div className={`w-9 h-9 rounded-md flex items-center justify-center ${s.bg}`}>{s.icon}</div>
  694. <div className="flex-1">
  695. <div className="text-xs text-slate-500">{s.title}</div>
  696. <div className="text-xl font-semibold">{s.value.toLocaleString()}</div>
  697. </div>
  698. <AntdTooltip title="环比增长">
  699. <TrendingUp className="text-emerald-500" size={18} />
  700. </AntdTooltip>
  701. </div>
  702. </Card>
  703. </Col>
  704. ))}
  705. </Row>
  706. <Row gutter={[16, 16]}>
  707. <Col xs={24} md={12} lg={8}>
  708. <Card>
  709. <EChart option={infraPieOption} />
  710. </Card>
  711. </Col>
  712. <Col xs={24} md={12} lg={8}>
  713. <Card>
  714. <EChart option={deviceBarOption} />
  715. </Card>
  716. </Col>
  717. <Col xs={24} md={24} lg={8}>
  718. <Card>
  719. <EChart option={onlineGaugeOption} />
  720. </Card>
  721. </Col>
  722. </Row>
  723. <Row gutter={[16, 16]}>
  724. <Col xs={24} md={12}>
  725. <Card>
  726. <EChart option={alertTrendOption} />
  727. </Card>
  728. </Col>
  729. <Col xs={24} md={12}>
  730. <Card>
  731. <EChart option={riskBarOption} />
  732. </Card>
  733. </Col>
  734. </Row>
  735. <Card title="监测分布(示意)" extra={<span className="text-xs text-slate-500">标注颜色代表风险等级</span>}>
  736. <div className="baidu-map-page">
  737. <div className="map-container">
  738. <div ref={mapRef} className="map-content"></div>
  739. </div>
  740. </div>
  741. </Card>
  742. </section>
  743. )}
  744. {selectedMenu === "asset" && (
  745. <section className="space-y-4">
  746. <Tabs
  747. activeKey={assetTab}
  748. onChange={setAssetTab}
  749. items={[
  750. { key: "archive", label: "基础档案" },
  751. { key: "run", label: "运行信息" },
  752. { key: "mgmt", label: "管理信息" },
  753. { key: "emergency", label: "应急保障" },
  754. ]}
  755. />
  756. {assetTab === "archive" && (
  757. <>
  758. <Row gutter={[16, 16]}>
  759. <Col xs={24} lg={14}>
  760. <Card title="设施基础档案">
  761. <Table
  762. size="small"
  763. rowKey="id"
  764. columns={facilityColumns}
  765. dataSource={facilities}
  766. pagination={{ pageSize: 8 }}
  767. scroll={{ x: 700 }}
  768. />
  769. </Card>
  770. </Col>
  771. <Col xs={24} lg={10}>
  772. <Card title="行业重点指标">
  773. <div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
  774. <div>
  775. <div className="text-xs text-slate-500 mb-1">平均设施年限</div>
  776. <Statistic value={Math.round(facilities.reduce((a, b) => a + b.age, 0) / facilities.length)} suffix="年" />
  777. <Progress percent={Math.min(100, Math.round((facilities.filter((f) => f.age >= 20).length / facilities.length) * 100))} size="small" />
  778. <div className="text-xs text-slate-500 mt-1">20年以上占比</div>
  779. </div>
  780. <div>
  781. <div className="text-xs text-slate-500 mb-1">重点设施数量</div>
  782. <Statistic value={facilities.filter((f) => f.type.includes("主") || f.type.includes("厂")).reduce((a, b) => a + b.count, 0)} />
  783. <div className="text-xs text-slate-500 mt-1">主干/厂站等关键设施总量</div>
  784. </div>
  785. </div>
  786. </Card>
  787. <Card className="mt-4" title="分布热点(示意)">
  788. <EChart
  789. option={{
  790. title: { text: "区域设施数量", left: "center", textStyle: { fontSize: 14 } },
  791. xAxis: { type: "category", data: ["中心城区", "东区", "西区", "南区", "北区"] },
  792. yAxis: { type: "value" },
  793. grid: { left: 40, right: 10, bottom: 20, top: 40 },
  794. color: [primary],
  795. series: [
  796. {
  797. type: "bar",
  798. data: ["中心城区", "东区", "西区", "南区", "北区"].map(
  799. (r) => facilities.filter((f) => f.region === r).reduce((a, b) => a + b.count, 0)
  800. ),
  801. barWidth: "50%",
  802. },
  803. ],
  804. }}
  805. />
  806. </Card>
  807. </Col>
  808. </Row>
  809. </>
  810. )}
  811. {assetTab === "run" && (
  812. <>
  813. <Row gutter={[16, 16]}>
  814. <Col xs={24} md={12}>
  815. <Card title="日常供应能力(示意)">
  816. <EChart
  817. option={{
  818. tooltip: { trigger: "axis" },
  819. legend: { bottom: 0 },
  820. grid: { left: 40, right: 10, top: 20, bottom: 40 },
  821. xAxis: { type: "category", data: Array.from({ length: 24 }).map((_, i) => `${i}:00`) },
  822. yAxis: { type: "value" },
  823. color: [primary, "#f59e0b"],
  824. series: [
  825. { name: "供水(万m³/h)", type: "line", smooth: true, data: Array.from({ length: 24 }).map(() => 50 + Math.random() * 20) },
  826. { name: "燃气(万m³/h)", type: "line", smooth: true, data: Array.from({ length: 24 }).map(() => 30 + Math.random() * 15) },
  827. ],
  828. }}
  829. />
  830. </Card>
  831. </Col>
  832. <Col xs={24} md={12}>
  833. <Card title="承载能力(示意)">
  834. <EChart
  835. option={{
  836. tooltip: { trigger: "axis" },
  837. grid: { left: 40, right: 10, top: 20, bottom: 40 },
  838. xAxis: { type: "category", data: ["中心", "东", "西", "南", "北"] },
  839. yAxis: { type: "value" },
  840. color: [primary],
  841. series: [{ type: "bar", data: [92, 86, 74, 80, 77] }],
  842. }}
  843. />
  844. </Card>
  845. </Col>
  846. </Row>
  847. </>
  848. )}
  849. {assetTab === "mgmt" && (
  850. <>
  851. <Row gutter={[16, 16]}>
  852. <Col xs={24} md={12}>
  853. <Card title="管理单位信息">
  854. <Descriptions size="small" column={1} bordered>
  855. <Descriptions.Item label="燃气管理单位">市燃气集团、区属燃气公司等(共 6 家)</Descriptions.Item>
  856. <Descriptions.Item label="供水管理单位">市自来水公司、二供物业等(共 9 家)</Descriptions.Item>
  857. <Descriptions.Item label="排水管理单位">城排中心、各区运营公司(共 7 家)</Descriptions.Item>
  858. <Descriptions.Item label="产权分布">市属 60%,区属 30%,社会 10%</Descriptions.Item>
  859. </Descriptions>
  860. <Divider className="my-3" />
  861. <Timeline
  862. items={[
  863. { color: "green", children: "制度更新:设施巡检标准(本月)" },
  864. { color: "blue", children: "完成年度普查 80%" },
  865. { color: "orange", children: "外包维保单位进场(上周)" },
  866. ]}
  867. />
  868. </Card>
  869. </Col>
  870. <Col xs={24} md={12}>
  871. <Card title="产权分布">
  872. <EChart
  873. option={{
  874. tooltip: { trigger: "item" },
  875. legend: { bottom: 0 },
  876. color: [primary, "#34d399", "#a7f3d0"],
  877. series: [
  878. { type: "pie", radius: ["35%", "60%"], data: [{ value: 60, name: "市属" }, { value: 30, name: "区属" }, { value: 10, name: "社会" }] },
  879. ],
  880. }}
  881. />
  882. </Card>
  883. </Col>
  884. </Row>
  885. </>
  886. )}
  887. {assetTab === "emergency" && (
  888. <>
  889. <Row gutter={[16, 16]}>
  890. <Col xs={24} md={12}>
  891. <Card title="应急资源配置">
  892. <div className="grid grid-cols-2 gap-4">
  893. <Card size="small">
  894. <div className="text-xs text-slate-500">物资仓库</div>
  895. <div className="text-xl font-semibold mt-1">12 处</div>
  896. <Progress percent={78} status="active" size="small" />
  897. <div className="text-xs text-slate-500 mt-1">库存充足度</div>
  898. </Card>
  899. <Card size="small">
  900. <div className="text-xs text-slate-500">抢修队伍</div>
  901. <div className="text-xl font-semibold mt-1">26 支</div>
  902. <Progress percent={86} status="active" size="small" />
  903. <div className="text-xs text-slate-500 mt-1">到岗率</div>
  904. </Card>
  905. <Card size="small">
  906. <div className="text-xs text-slate-500">重点防护目标</div>
  907. <div className="text-xl font-semibold mt-1">143 处</div>
  908. <Progress percent={92} status="active" size="small" />
  909. <div className="text-xs text-slate-500 mt-1">纳入台账比例</div>
  910. </Card>
  911. <Card size="small">
  912. <div className="text-xs text-slate-500">联动单位</div>
  913. <div className="text-xl font-semibold mt-1">19 家</div>
  914. <Progress percent={74} status="active" size="small" />
  915. <div className="text-xs text-slate-500 mt-1">联动成熟度</div>
  916. </Card>
  917. </div>
  918. </Card>
  919. </Col>
  920. <Col xs={24} md={12}>
  921. <Card>
  922. <EChart option={radarCapacityOption} />
  923. </Card>
  924. </Col>
  925. </Row>
  926. </>
  927. )}
  928. </section>
  929. )}
  930. {selectedMenu === "monitor" && (
  931. <section className="space-y-4">
  932. <Tabs
  933. activeKey={monitorTab}
  934. onChange={setMonitorTab}
  935. items={[
  936. { key: "summary", label: "监测概览" },
  937. { key: "distribution", label: "监测分布" },
  938. { key: "running", label: "运行概况" },
  939. ]}
  940. />
  941. {monitorTab === "summary" && (
  942. <>
  943. <Row gutter={[16, 16]}>
  944. <Col xs={24} md={12} lg={8}>
  945. <Card>
  946. <EChart option={onlineGaugeOption} />
  947. </Card>
  948. </Col>
  949. <Col xs={24} md={12} lg={8}>
  950. <Card>
  951. <EChart option={deviceBarOption} />
  952. </Card>
  953. </Col>
  954. <Col xs={24} md={24} lg={8}>
  955. <Card>
  956. <EChart option={riskBarOption} />
  957. </Card>
  958. </Col>
  959. </Row>
  960. </>
  961. )}
  962. {monitorTab === "distribution" && (
  963. <>
  964. <Card title="监测分布(按行业与风险)">
  965. <Row gutter={[16, 16]}>
  966. {(["燃气", "供水", "排水"] as const).map((ind) => (
  967. <Col xs={24} md={8} key={ind}>
  968. <Card size="small" title={ind}>
  969. <div className="flex items-center gap-4">
  970. <div className="flex-1">
  971. <div className="text-xs text-slate-500">设备在线</div>
  972. <div className="text-lg font-semibold">
  973. {devices.filter((d) => d.industry === ind && d.status === "在线").length}
  974. </div>
  975. <div className="text-xs text-slate-500">总量 {devices.filter((d) => d.industry === ind).length}</div>
  976. </div>
  977. <div className="flex-1">
  978. <div className="text-xs text-slate-500">高风险</div>
  979. <div className="text-lg font-semibold">
  980. {devices.filter((d) => d.industry === ind && d.risk === "高").length}
  981. </div>
  982. <Progress
  983. percent={Math.round(
  984. (devices.filter((d) => d.industry === ind && d.risk === "高").length /
  985. Math.max(devices.filter((d) => d.industry === ind).length, 1)) *
  986. 100
  987. )}
  988. size="small"
  989. />
  990. </div>
  991. </div>
  992. </Card>
  993. </Col>
  994. ))}
  995. </Row>
  996. </Card>
  997. <Card title="一张图(示意)">
  998. <div className="relative w-full h-[380px] rounded-md overflow-hidden bg-slate-100">
  999. <img
  1000. src="/images/city-map.png"
  1001. alt="城市简化地图"
  1002. className="absolute inset-0 w-full h-full object-cover opacity-90"
  1003. />
  1004. {markers.map((m) => (
  1005. <AntdTooltip key={m.id} title={m.title}>
  1006. <div
  1007. className="absolute w-2.5 h-2.5 rounded-full ring-2 ring-white/70"
  1008. style={{ top: m.top, left: m.left, backgroundColor: m.color }}
  1009. />
  1010. </AntdTooltip>
  1011. ))}
  1012. </div>
  1013. </Card>
  1014. </>
  1015. )}
  1016. {monitorTab === "running" && (
  1017. <>
  1018. <Card title="运行概况(报警覆盖)">
  1019. <EChart
  1020. option={{
  1021. tooltip: { trigger: "axis" },
  1022. legend: { bottom: 0 },
  1023. grid: { left: 40, right: 10, top: 20, bottom: 40 },
  1024. xAxis: { type: "category", data: Array.from({ length: 12 }).map((_, i) => dayjs().subtract(11 - i, "month").format("YYYY-MM")) },
  1025. yAxis: { type: "value" },
  1026. color: [primary, "#f59e0b", "#a855f7"],
  1027. series: (["燃气", "供水", "排水"] as const).map((ind, idx) => ({
  1028. name: ind,
  1029. type: "bar",
  1030. stack: "sum",
  1031. emphasis: { focus: "series" },
  1032. data: Array.from({ length: 12 }).map(() => Math.floor(Math.random() * (idx === 0 ? 50 : idx === 1 ? 40 : 30))),
  1033. })),
  1034. }}
  1035. />
  1036. </Card>
  1037. <Row gutter={[16, 16]} className="mt-1">
  1038. <Col xs={24} md={12}>
  1039. <Card>
  1040. <EChart option={alertTrendOption} />
  1041. </Card>
  1042. </Col>
  1043. <Col xs={24} md={12}>
  1044. <Card>
  1045. <EChart option={deviceBarOption} />
  1046. </Card>
  1047. </Col>
  1048. </Row>
  1049. </>
  1050. )}
  1051. </section>
  1052. )}
  1053. {selectedMenu === "alert" && (
  1054. <section className="space-y-4">
  1055. <Tabs
  1056. activeKey={alertTab}
  1057. onChange={setAlertTab}
  1058. items={[
  1059. { key: "current", label: "当前预警" },
  1060. { key: "history", label: "历史分析" },
  1061. { key: "efficiency", label: "预警效率" },
  1062. { key: "analysis", label: "预警分析" },
  1063. ]}
  1064. />
  1065. {alertTab === "current" && (
  1066. <>
  1067. <Row gutter={[16, 16]}>
  1068. <Col xs={24} lg={16}>
  1069. <Card title="总体预警处置情况">
  1070. <Table
  1071. size="small"
  1072. rowKey="id"
  1073. columns={alertColumns}
  1074. dataSource={alerts}
  1075. pagination={{ pageSize: 8 }}
  1076. onRow={(record) => ({
  1077. onClick: () => {
  1078. setSelectedAlert(record)
  1079. setDrawerOpen(true)
  1080. },
  1081. })}
  1082. scroll={{ x: 900 }}
  1083. />
  1084. </Card>
  1085. </Col>
  1086. <Col xs={24} lg={8}>
  1087. <Card title="处置效率">
  1088. <div className="grid grid-cols-2 gap-4">
  1089. <div>
  1090. <div className="text-xs text-slate-500">平均处置时效</div>
  1091. <div className="text-xl font-semibold mt-1">{(45 + Math.random() * 30).toFixed(0)} 分钟</div>
  1092. <Progress percent={78} status="active" size="small" />
  1093. <div className="text-xs text-slate-500 mt-1">较上月 +6%</div>
  1094. </div>
  1095. <div>
  1096. <div className="text-xs text-slate-500">闭环率</div>
  1097. <div className="text-xl font-semibold mt-1">
  1098. {Math.round((alerts.filter((a) => a.status === "已闭环").length / Math.max(alerts.length, 1)) * 100)}%
  1099. </div>
  1100. <Progress percent={86} status="active" size="small" />
  1101. <div className="text-xs text-slate-500 mt-1">较上周 +2%</div>
  1102. </div>
  1103. </div>
  1104. </Card>
  1105. <Card className="mt-4">
  1106. <EChart option={efficiencyPieOption} />
  1107. </Card>
  1108. </Col>
  1109. </Row>
  1110. <Drawer
  1111. title={
  1112. <div className="flex items-center gap-2">
  1113. <AlertTriangle size={18} color={selectedAlert ? alertLevelColor(selectedAlert.level) : primary} />
  1114. <span>预警详情</span>
  1115. </div>
  1116. }
  1117. placement="right"
  1118. width={520}
  1119. open={drawerOpen}
  1120. onClose={() => setDrawerOpen(false)}
  1121. >
  1122. {selectedAlert ? (
  1123. <div className="space-y-4">
  1124. <Descriptions size="small" column={1} bordered>
  1125. <Descriptions.Item label="预警编号">{selectedAlert.id}</Descriptions.Item>
  1126. <Descriptions.Item label="等级">
  1127. <LevelTag level={selectedAlert.level} />
  1128. </Descriptions.Item>
  1129. <Descriptions.Item label="行业">{selectedAlert.industry}</Descriptions.Item>
  1130. <Descriptions.Item label="类型">{selectedAlert.type}</Descriptions.Item>
  1131. <Descriptions.Item label="时间">{selectedAlert.time}</Descriptions.Item>
  1132. <Descriptions.Item label="位置">{selectedAlert.location}</Descriptions.Item>
  1133. <Descriptions.Item label="状态">
  1134. <StatusBadge s={selectedAlert.status} />
  1135. </Descriptions.Item>
  1136. <Descriptions.Item label="描述">{selectedAlert.desc}</Descriptions.Item>
  1137. </Descriptions>
  1138. <Card size="small" title="事件时序">
  1139. <EChart
  1140. option={{
  1141. grid: { left: 30, right: 10, top: 20, bottom: 20 },
  1142. xAxis: { type: "category", data: ["发现", "确认", "处置", "复盘"] },
  1143. yAxis: { type: "value" },
  1144. color: [primary],
  1145. series: [{ type: "line", smooth: true, data: [0, 12, 38, 60] }],
  1146. }}
  1147. />
  1148. </Card>
  1149. <Card size="small" title="一张图联动(示意)">
  1150. <div className="relative w-full h-[200px] rounded-md overflow-hidden">
  1151. <img src="/images/city-map.png" alt="地图联动示意图" className="absolute inset-0 w-full h-full object-cover opacity-90" />
  1152. <div className="absolute inset-0">
  1153. <div
  1154. className="absolute w-3 h-3 rounded-full ring-2 ring-white animate-pulse"
  1155. style={{ top: "42%", left: "56%", background: alertLevelColor(selectedAlert.level) }}
  1156. title="预警位置"
  1157. />
  1158. </div>
  1159. </div>
  1160. </Card>
  1161. <Space>
  1162. <a className="text-emerald-600">查看工单</a>
  1163. <a className="text-emerald-600">下达指令</a>
  1164. <a className="text-emerald-600">通知联动</a>
  1165. </Space>
  1166. </div>
  1167. ) : (
  1168. <div className="text-slate-500 text-sm">请选择左侧预警查看详情。</div>
  1169. )}
  1170. </Drawer>
  1171. </>
  1172. )}
  1173. {alertTab === "history" && (
  1174. <>
  1175. <Row gutter={[16, 16]}>
  1176. <Col xs={24} md={12}>
  1177. <Card title="各行业预警数量(近6月)">
  1178. <EChart
  1179. option={{
  1180. tooltip: { trigger: "axis" },
  1181. legend: { bottom: 0 },
  1182. grid: { left: 40, right: 10, top: 20, bottom: 40 },
  1183. xAxis: { type: "category", data: Array.from({ length: 6 }).map((_, i) => dayjs().subtract(5 - i, "month").format("YYYY-MM")) },
  1184. yAxis: { type: "value" },
  1185. color: [primary, "#f59e0b", "#a855f7"],
  1186. series: (["燃气", "供水", "排水"] as const).map((ind, idx) => ({
  1187. name: ind,
  1188. type: "line",
  1189. smooth: true,
  1190. data: Array.from({ length: 6 }).map(() => Math.floor(Math.random() * (idx === 0 ? 60 : idx === 1 ? 45 : 35)) + 5),
  1191. })),
  1192. }}
  1193. />
  1194. </Card>
  1195. </Col>
  1196. <Col xs={24} md={12}>
  1197. <Card title="已闭环预警(示意)">
  1198. <Table
  1199. size="small"
  1200. rowKey="id"
  1201. columns={[
  1202. { title: "编号", dataIndex: "id" },
  1203. { title: "类型", dataIndex: "type" },
  1204. { title: "行业", dataIndex: "industry", width: 90 },
  1205. { title: "完成时间", dataIndex: "time", width: 160 },
  1206. ]}
  1207. dataSource={alerts.filter((a) => a.status === "已闭环")}
  1208. pagination={{ pageSize: 6 }}
  1209. />
  1210. </Card>
  1211. </Col>
  1212. </Row>
  1213. </>
  1214. )}
  1215. {alertTab === "efficiency" && (
  1216. <>
  1217. <Row gutter={[16, 16]}>
  1218. <Col xs={24} md={12}>
  1219. <Card title="整体效率">
  1220. <div className="grid grid-cols-2 gap-4">
  1221. <div>
  1222. <div className="text-xs text-slate-500">平均处置时效</div>
  1223. <div className="text-xl font-semibold mt-1">{(42 + Math.random() * 25).toFixed(0)} 分钟</div>
  1224. <Progress percent={82} status="active" size="small" />
  1225. <div className="text-xs text-slate-500 mt-1">较上月 +4%</div>
  1226. </div>
  1227. <div>
  1228. <div className="text-xs text-slate-500">正确预警率</div>
  1229. <div className="text-xl font-semibold mt-1">{(88 + Math.random() * 4).toFixed(1)}%</div>
  1230. <Progress percent={89} status="active" size="small" />
  1231. <div className="text-xs text-slate-500 mt-1">核实误报下降</div>
  1232. </div>
  1233. </div>
  1234. </Card>
  1235. </Col>
  1236. <Col xs={24} md={12}>
  1237. <Card>
  1238. <EChart option={efficiencyPieOption} />
  1239. </Card>
  1240. </Col>
  1241. </Row>
  1242. </>
  1243. )}
  1244. {alertTab === "analysis" && (
  1245. <>
  1246. <Row gutter={[16, 16]}>
  1247. <Col xs={24}>
  1248. <Card title="预警类型与成因分布">
  1249. <EChart
  1250. option={{
  1251. tooltip: { trigger: "axis" },
  1252. legend: { bottom: 0 },
  1253. grid: { left: 40, right: 10, top: 20, bottom: 40 },
  1254. xAxis: {
  1255. type: "category",
  1256. data: ["泄漏", "压力异常", "流量突变", "停电", "液位过低", "浊度异常"],
  1257. axisLabel: { rotate: 20 },
  1258. },
  1259. yAxis: { type: "value" },
  1260. color: [primary, "#f59e0b"],
  1261. series: [
  1262. { name: "设备原因", type: "bar", data: [30, 22, 18, 12, 9, 7] },
  1263. { name: "外部原因", type: "bar", data: [18, 15, 14, 28, 11, 10] },
  1264. ],
  1265. }}
  1266. />
  1267. </Card>
  1268. </Col>
  1269. </Row>
  1270. </>
  1271. )}
  1272. </section>
  1273. )}
  1274. {selectedMenu === "devices" && (
  1275. <section className="space-y-4">
  1276. <Row justify="space-between" align="middle">
  1277. <Col>
  1278. <div className="text-base font-medium">设备管理</div>
  1279. </Col>
  1280. <Col>
  1281. <Space>
  1282. <Segmented
  1283. options={["全部", "在线", "离线"]}
  1284. onChange={() => {}}
  1285. aria-label="设备状态筛选"
  1286. />
  1287. <Button size="small" icon={<Table2 size={14} />}>
  1288. 批量导出
  1289. </Button>
  1290. </Space>
  1291. </Col>
  1292. </Row>
  1293. <Card>
  1294. <Table
  1295. size="small"
  1296. rowKey="id"
  1297. columns={deviceColumns}
  1298. dataSource={devices}
  1299. pagination={{ pageSize: 10 }}
  1300. scroll={{ x: 700 }}
  1301. />
  1302. </Card>
  1303. </section>
  1304. )}
  1305. {selectedMenu === "reports" && (
  1306. <section className="space-y-4">
  1307. <Row gutter={[16, 16]}>
  1308. <Col xs={24} md={12}>
  1309. <Card title="月度运行报告(示意)" extra={<Button size="small">导出 PDF</Button>}>
  1310. <EChart
  1311. option={{
  1312. tooltip: { trigger: "axis" },
  1313. grid: { left: 40, right: 10, top: 20, bottom: 30 },
  1314. xAxis: { type: "category", data: ["一", "二", "三", "四", "五", "六"] },
  1315. yAxis: { type: "value" },
  1316. color: [primary],
  1317. series: [{ type: "line", smooth: true, data: [120, 132, 101, 134, 90, 230] }],
  1318. }}
  1319. />
  1320. </Card>
  1321. </Col>
  1322. <Col xs={24} md={12}>
  1323. <Card title="安全事件统计(示意)" extra={<Button size="small">导出 Excel</Button>}>
  1324. <EChart
  1325. option={{
  1326. tooltip: { trigger: "axis" },
  1327. grid: { left: 40, right: 10, top: 20, bottom: 30 },
  1328. xAxis: { type: "category", data: ["燃气", "供水", "排水"] },
  1329. yAxis: { type: "value" },
  1330. color: [primary, "#f59e0b", "#a855f7"],
  1331. series: [{ type: "bar", data: [32, 21, 17], barWidth: "50%" }],
  1332. }}
  1333. />
  1334. </Card>
  1335. </Col>
  1336. </Row>
  1337. </section>
  1338. )}
  1339. {selectedMenu === "incidents" && (
  1340. <section className="space-y-4">
  1341. <Row gutter={[16, 16]}>
  1342. <Col xs={24} md={16}>
  1343. <Card title="事件列表(示意)" extra={<Button size="small">新建事件</Button>}>
  1344. <Empty description="暂无数据(示意)" />
  1345. </Card>
  1346. </Col>
  1347. <Col xs={24} md={8}>
  1348. <Card title="事件趋势(示意)">
  1349. <EChart
  1350. option={{
  1351. tooltip: { trigger: "axis" },
  1352. grid: { left: 40, right: 10, top: 20, bottom: 30 },
  1353. xAxis: { type: "category", data: Array.from({ length: 12 }).map((_, i) => `${i + 1}月`) },
  1354. yAxis: { type: "value" },
  1355. color: [primary],
  1356. series: [{ type: "line", smooth: true, data: Array.from({ length: 12 }).map(() => Math.floor(Math.random() * 20) + 5) }],
  1357. }}
  1358. />
  1359. </Card>
  1360. </Col>
  1361. </Row>
  1362. </section>
  1363. )}
  1364. {selectedMenu === "bigscreen" && (
  1365. <section className="space-y-4">
  1366. <Card title="数据大屏(示意)">
  1367. <Row gutter={[16, 16]}>
  1368. {[
  1369. { title: "设备总数", val: devices.length },
  1370. { title: "在线率", val: `${onlineRate}%` },
  1371. { title: "本月预警", val: (alerts.length + Math.floor(Math.random() * 30)).toString() },
  1372. { title: "闭环率", val: `${Math.round((alerts.filter((a) => a.status === "已闭环").length / Math.max(alerts.length, 1)) * 100)}%` },
  1373. ].map((s) => (
  1374. <Col xs={12} md={6} key={s.title}>
  1375. <Card size="small">
  1376. <div className="text-xs text-slate-500">{s.title}</div>
  1377. <div className="text-2xl font-semibold mt-1">{s.val}</div>
  1378. </Card>
  1379. </Col>
  1380. ))}
  1381. </Row>
  1382. <Row gutter={[16, 16]} className="mt-1">
  1383. <Col xs={24} md={12}>
  1384. <Card>
  1385. <EChart option={deviceBarOption} />
  1386. </Card>
  1387. </Col>
  1388. <Col xs={24} md={12}>
  1389. <Card>
  1390. <EChart option={riskBarOption} />
  1391. </Card>
  1392. </Col>
  1393. </Row>
  1394. </Card>
  1395. </section>
  1396. )}
  1397. {selectedMenu === "settings" && (
  1398. <section className="space-y-4">
  1399. <Card title="预警设置">
  1400. <Row gutter={[16, 16]}>
  1401. <Col xs={24} md={12}>
  1402. <Card size="small" title="阈值设置">
  1403. <div className="grid grid-cols-2 gap-4">
  1404. <div>
  1405. <div className="text-xs text-slate-500 mb-1">压力异常阈值</div>
  1406. <Select defaultValue="P≤0.3MPa" options={[{ value: "P≤0.3MPa", label: "P≤0.3MPa" }, { value: "P≤0.2MPa", label: "P≤0.2MPa" }]} />
  1407. </div>
  1408. <div>
  1409. <div className="text-xs text-slate-500 mb-1">流量突变阈值</div>
  1410. <Select defaultValue="ΔQ≥20%" options={[{ value: "ΔQ≥20%", label: "ΔQ≥20%" }, { value: "ΔQ≥30%", label: "ΔQ≥30%" }]} />
  1411. </div>
  1412. <div>
  1413. <div className="text-xs text-slate-500 mb-1">水质指标(浊度)</div>
  1414. <Select defaultValue="≥5 NTU" options={[{ value: "≥5 NTU", label: "≥5 NTU" }, { value: "≥3 NTU", label: "≥3 NTU" }]} />
  1415. </div>
  1416. <div>
  1417. <div className="text-xs text-slate-500 mb-1">液位过低</div>
  1418. <Select defaultValue="≤20%" options={[{ value: "≤20%", label: "≤20%" }, { value: "≤15%", label: "≤15%" }]} />
  1419. </div>
  1420. </div>
  1421. </Card>
  1422. </Col>
  1423. <Col xs={24} md={12}>
  1424. <Card size="small" title="通知策略">
  1425. <div className="grid grid-cols-2 gap-4">
  1426. <div className="flex items-center justify-between">
  1427. <span>高等级预警短信</span>
  1428. <Switch defaultChecked />
  1429. </div>
  1430. <div className="flex items-center justify-between">
  1431. <span>邮件抄送管理层</span>
  1432. <Switch />
  1433. </div>
  1434. <div className="flex items-center justify-between">
  1435. <span>自动派单</span>
  1436. <Switch />
  1437. </div>
  1438. <div className="flex items-center justify-between">
  1439. <span>与值守大屏联动</span>
  1440. <Switch defaultChecked />
  1441. </div>
  1442. </div>
  1443. </Card>
  1444. </Col>
  1445. </Row>
  1446. </Card>
  1447. </section>
  1448. )}
  1449. </Content>
  1450. </Layout>
  1451. </Layout>
  1452. </ConfigProvider>
  1453. )
  1454. }