From 47e47fc6054578e067fff6d7b558fd4bb9616485 Mon Sep 17 00:00:00 2001 From: JIANG Date: Sat, 7 Mar 2026 17:49:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E5=AE=9E=E9=99=85=E9=9C=80?= =?UTF-8?q?=E6=B0=B4=E9=87=8F=E5=8D=95=E4=BD=8D=E4=B8=BA=20m=C2=B3/h?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE=E5=B1=95=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/OlMap/Controls/Toolbar.tsx | 16 ++++++++++--- src/app/OlMap/MapComponent.tsx | 36 ++++++++++++------------------ 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/src/app/OlMap/Controls/Toolbar.tsx b/src/app/OlMap/Controls/Toolbar.tsx index affaa34..14afb0f 100644 --- a/src/app/OlMap/Controls/Toolbar.tsx +++ b/src/app/OlMap/Controls/Toolbar.tsx @@ -21,7 +21,7 @@ import { useNotification } from "@refinedev/core"; import { config } from "@/config/config"; import { apiFetch } from "@/lib/apiFetch"; -import { FLOW_DISPLAY_UNIT } from "@utils/units"; +import { FLOW_DISPLAY_UNIT, toM3h } from "@utils/units"; // 添加接口定义隐藏按钮的props interface ToolbarProps { @@ -467,6 +467,11 @@ const Toolbar: React.FC = ({ if (computedProperties) { pipeComputedFields.forEach(({ key, label, unit }) => { let value = computedProperties[key]; + + if (key === "flow" && value !== undefined) { + value = toM3h(value, "lps"); + } + // 如果是单位水头损失且后端未返回,则通过水头损失/长度计算 (单位 m/km) if ( key === "unit_headloss" && @@ -505,10 +510,11 @@ const Toolbar: React.FC = ({ columns: ["demand", "pattern"], rows: Array.from({ length: 5 }, (_, i) => i + 1) .map((idx) => { - const d = properties?.[`demand${idx}`]?.toFixed?.(3); + let d = properties?.[`demand${idx}`]; const p = properties?.[`pattern${idx}`]; // 仅当 demand 有效时展示该行 if (d !== undefined && d !== null && d !== "") { + d = toM3h(Number(d), "lps"); return [typeof d === "number" ? d.toFixed(3) : d, p ?? "-"]; } }) @@ -520,10 +526,14 @@ const Toolbar: React.FC = ({ if (computedProperties) { nodeComputedFields.forEach(({ key, label, unit }) => { if (computedProperties[key] !== undefined) { + let value = computedProperties[key]; + if (key === "actual_demand") { + value = toM3h(value, "lps"); + } result.properties.push({ label, value: - computedProperties[key].toFixed?.(3) || computedProperties[key], + value?.toFixed?.(3) || value, unit, }); } diff --git a/src/app/OlMap/MapComponent.tsx b/src/app/OlMap/MapComponent.tsx index 99c053d..d319678 100644 --- a/src/app/OlMap/MapComponent.tsx +++ b/src/app/OlMap/MapComponent.tsx @@ -33,6 +33,7 @@ import { Icon, Style } from "ol/style.js"; import { FeatureLike } from "ol/Feature"; import { Point } from "ol/geom"; import { ContourLayer } from "deck.gl"; +import { toM3h } from "@utils/units"; interface MapComponentProps { children?: React.ReactNode; @@ -151,7 +152,12 @@ const MapComponent: React.FC = ({ children }) => { const nodeMap = new Map(currentJunctionCalData.map((r: any) => [r.ID, r])); return junctionData.map((j) => { const record = nodeMap.get(j.id); - return record ? { ...j, [junctionText]: record.value } : j; + let val = record ? record.value : undefined; + // 在这合并时将实际需水量从 LPS 转换为大写表示 + if (val !== undefined && junctionText === "actualdemand") { + val = toM3h(val, "lps"); + } + return record ? { ...j, [junctionText]: val } : j; }); }, [junctionData, currentJunctionCalData, junctionText]); @@ -161,9 +167,13 @@ const MapComponent: React.FC = ({ children }) => { const record = linkMap.get(p.id); if (!record) return p; const isFlow = pipeText === "flow"; + let val = record.value; + if (val !== undefined && isFlow) { + val = toM3h(val, "lps"); + } return { ...p, - [pipeText]: isFlow ? Math.abs(record.value) : record.value, + [pipeText]: isFlow ? Math.abs(val) : val, flowFlag: isFlow && record.value < 0 ? -1 : 1, path: isFlow && record.value < 0 ? [...p.path].reverse() : p.path, }; @@ -790,15 +800,7 @@ const MapComponent: React.FC = ({ children }) => { let propPart = ""; if (showJunctionTextLayer && d[junctionText] !== undefined) { const value = (d[junctionText] as number).toFixed(3); - // 根据属性类型添加符号前缀 - const prefix = - { - pressure: "P:", - head: "H:", - quality: "Q:", - actualdemand: "D:", - }[junctionText] || ""; - propPart = `${prefix}${value}`; + propPart = `${value}`; } if (idPart && propPart) return `${idPart} - ${propPart}`; return idPart || propPart; @@ -850,17 +852,7 @@ const MapComponent: React.FC = ({ children }) => { } else { value = Math.abs(d[pipeText] as number).toFixed(3); } - // 根据属性类型添加符号前缀 - const prefix = - { - flow: "F:", - velocity: "V:", - headloss: "HL:", - unit_headloss: "UHL:", - diameter: "D:", - friction: "FR:", - }[pipeText] || ""; - propPart = `${prefix}${value}`; + propPart = `${value}`; } if (idPart && propPart) return `${idPart} - ${propPart}`; return idPart || propPart;