"use client"; import React, { useMemo } from "react"; import { Box, Typography, Chip, Table, TableBody, TableCell, TableHead, TableRow, } from "@mui/material"; import { FormatListBulleted } from "@mui/icons-material"; import dayjs from "dayjs"; import { getAreaColor } from "./utils"; import { FLOW_DISPLAY_UNIT, toM3h } from "@utils/units"; import { LeakageResultDetail } from "./types"; interface Props { result: LeakageResultDetail | null; } const RecognitionResults: React.FC = ({ result }) => { const sortedRows = useMemo(() => { if (!result?.rows) return []; return [...result.rows].sort( (a, b) => b.LeakageFlow_m3_per_s - a.LeakageFlow_m3_per_s, ); }, [result]); if (!result || !sortedRows.length) { return ( 暂无识别结果 请先加载方案或执行识别分析 ); } return ( {/* 方案详情卡片 */} {result.scheme_name || "漏损识别结果"} {result.username && ( )} {/* 方案时间 */} 方案时间 {dayjs(result.scheme_start_time || result.create_time).format( "MM-DD HH:mm", )} {/* 总漏损流量 */} 总漏损流量 {(() => { const val = (result.scheme_detail as any)?.algorithm_params ?.q_sum; const unit = String( (result.scheme_detail as any)?.algorithm_params?.q_sum_unit || "m3/s", ); const qSumM3h = toM3h(Number(val), unit); return Number.isFinite(qSumM3h) ? `${qSumM3h.toFixed(3)} ${FLOW_DISPLAY_UNIT}` : "-"; })()} {/* 分区数量 */} 分区数量 {(result.scheme_detail as any)?.result_summary?.area_count ?? result.areas?.length ?? 0}{" "} 个 {/* 最大漏损 */} 最大漏损 {(() => { const maxL = (result.scheme_detail as any)?.result_summary ?.max_leakage; const maxLeakageM3h = toM3h(Number(maxL), "m3/s"); return Number.isFinite(maxLeakageM3h) ? `${maxLeakageM3h.toFixed(3)} ${FLOW_DISPLAY_UNIT}` : "-"; })()} {/* 漏损列表 */} 区域漏损列表 区域 漏损量占比 (%) 漏损量 ({FLOW_DISPLAY_UNIT}) {sortedRows.map((row) => ( {row.Area} {(row.LeakageRatio * 100).toFixed(3)} {toM3h(Number(row.LeakageFlow_m3_per_s), "m3/s").toFixed(3)} ))}
); }; export default RecognitionResults;