From 1e387f457092df846ec04e2c6792b83244aae04e Mon Sep 17 00:00:00 2001 From: duheng <2784771470@qq.com> Date: 星期六, 07 十二月 2024 12:09:23 +0800 Subject: [PATCH] Merge branch 'master' of http://47.103.154.90:83/r/HStation/XHS.V1.0 --- WinFrmUI/Yw.WinFrmUI.Hydro.Core/00-core/05-extensions/HydroModelInfoExtensions.cs | 188 +++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 173 insertions(+), 15 deletions(-) diff --git a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/00-core/05-extensions/HydroModelInfoExtensions.cs b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/00-core/05-extensions/HydroModelInfoExtensions.cs index 307d841..d672de1 100644 --- a/WinFrmUI/Yw.WinFrmUI.Hydro.Core/00-core/05-extensions/HydroModelInfoExtensions.cs +++ b/WinFrmUI/Yw.WinFrmUI.Hydro.Core/00-core/05-extensions/HydroModelInfoExtensions.cs @@ -5,27 +5,17 @@ namespace Yw.WinFrmUI { /// <summary> - /// + /// 姘村姏淇℃伅鎷撳睍 /// </summary> public static class HydroModelInfoExtensions { - /// <summary> - /// 鑾峰彇鍙瀛楀吀 - /// </summary> - public static Dictionary<string, HydroVisualInfo> GetVisualDict(this Yw.Model.HydroModelInfo hydroInfo) - { - if (hydroInfo == null) - { - return default; - } - var allVisualList = hydroInfo.GetAllVisuals(); - return allVisualList?.ToDictionary(x => x.Code); - } + + #region 淇绠$綉鏂瑰悜 /// <summary> - /// 淇 + /// 淇绠$綉鏂瑰悜 /// </summary> - public static bool Repair(this Yw.Model.HydroModelInfo hydroInfo, out string msg) + public static bool RepairLinksDirection(this Yw.Model.HydroModelInfo hydroInfo, out string msg) { msg = string.Empty; if (hydroInfo == null) @@ -79,6 +69,174 @@ return true; } + #endregion + + #region 淇鍙傛暟 + + private const double _pipe_diameter_default = 500;//绠¢亾榛樿鐩村緞 + private const double _pipe_roughness_default = 110;//绠¢亾榛樿绮楃硻绯绘暟 + private const double _pipe_minorloss_default = 0.1;//绠¢亾榛樿绮楃硻绯绘暟 + //闃�闂ㄩ粯璁ゅ眬闃荤郴鏁� + private const double _valve_minorloss_default = 0.3d; + + + /// <summary> + /// 淇鍙傛暟 + /// </summary> + public static void RepairParas(this Yw.Model.HydroModelInfo hydroInfo, out string msg) + { + msg = string.Empty; + if (hydroInfo == null) + { + return; + } + + var allNodes = hydroInfo.GetAllNodes(); + var allLinks = hydroInfo.GetAllLinks(); + + //绠¢亾 + if (hydroInfo.Pipes != null && hydroInfo.Pumps.Count > 0) + { + foreach (var pipe in hydroInfo.Pipes) + { + if (pipe.Diameter <= 0) + { + pipe.Diameter = _pipe_diameter_default; + pipe.UpdatePropStatus(nameof(pipe.Diameter), ePropStatus.Lack, $"鐩村緞缂虹渷锛屼娇鐢ㄩ粯璁ゅ�笺�恵_pipe_diameter_default}mm銆戜慨澶�"); + } + if (pipe.Roughness <= 0) + { + pipe.Roughness = _pipe_roughness_default; + pipe.UpdatePropStatus(nameof(pipe.Roughness), ePropStatus.Lack, $"绮楃硻绯绘暟缂虹渷锛屼娇鐢ㄩ粯璁ゅ�笺�恵_pipe_roughness_default}銆戜慨澶�"); + } + if (pipe.MinorLoss <= 0) + { + pipe.MinorLoss = _pipe_minorloss_default; + pipe.UpdatePropStatus(nameof(pipe.MinorLoss), ePropStatus.Lack, $"绮楃硻绯绘暟缂虹渷锛屼娇鐢ㄩ粯璁ゅ�笺�恵_pipe_minorloss_default}銆戜慨澶�"); + } + } + } + + //杩囨浮浠� + if (hydroInfo.Translations != null && hydroInfo.Translations.Count > 0) + { + foreach (var translation in hydroInfo.Translations) + { + if (translation.Diameter <= 0) + { + translation.Diameter = _pipe_diameter_default; + translation.UpdatePropStatus(nameof(translation.Diameter), ePropStatus.Lack, $"鐩村緞缂虹渷锛屼娇鐢ㄩ粯璁ゅ�笺�恵_pipe_diameter_default}mm銆戜慨澶�"); + } + if (translation.Roughness <= 0) + { + translation.Roughness = _pipe_roughness_default; + translation.UpdatePropStatus(nameof(translation.Roughness), ePropStatus.Lack, $"绮楃硻绯绘暟缂虹渷锛屼娇鐢ㄩ粯璁ゅ�笺�恵_pipe_roughness_default}銆戜慨澶�"); + } + if (translation.MinorLoss <= 0) + { + translation.MinorLoss = _pipe_minorloss_default; + translation.UpdatePropStatus(nameof(translation.MinorLoss), ePropStatus.Lack, $"绮楃硻绯绘暟缂虹渷锛屼娇鐢ㄩ粯璁ゅ�笺�恵_pipe_minorloss_default}銆戜慨澶�"); + } + } + foreach (var translation in hydroInfo.Translations) + { + double? tempDiameter = null; + var startNode = allNodes.Find(x => x.Code == translation.StartCode); + if (startNode != null) + { + var startLink = allLinks.Find(x => x.EndCode == startNode.Code); + if (startLink != null) + { + var startPipe = startLink as Yw.Model.HydroPipeInfo; + if (startPipe != null) + { + tempDiameter = startPipe.Diameter; + if (translation.StartDiameter != startPipe.Diameter) + { + translation.StartDiameter = startPipe.Diameter; + translation.UpdatePropStatus(nameof(translation.StartDiameter), ePropStatus.Lack, $"涓婃父鐩村緞缂虹渷锛屼娇鐢ㄤ笂娓哥閬撱�恵startPipe.Code}銆戜慨澶�"); + } + } + } + } + var endNode = allNodes.Find(x => x.Code == translation.EndCode); + if (endNode != null) + { + var endLink = allLinks.Find(x => x.StartCode == endNode.Code); + if (endLink != null) + { + var endPipe = endLink as Yw.Model.HydroPipeInfo; + if (endPipe != null) + { + if (translation.EndDiameter != endPipe.Diameter) + { + tempDiameter = endPipe.Diameter; + translation.EndDiameter = endPipe.Diameter; + translation.UpdatePropStatus(nameof(translation.EndDiameter), ePropStatus.Lack, $"涓嬫父鐩村緞缂虹渷锛屼娇鐢ㄤ笅娓哥閬撱�恵endPipe.Code}銆戜慨澶�"); + } + } + } + } + if (translation.StartDiameter <= 0) + { + if (tempDiameter.HasValue) + { + translation.StartDiameter = tempDiameter.Value; + } + } + if (translation.EndDiameter <= 0) + { + if (tempDiameter.HasValue) + { + translation.EndDiameter = tempDiameter.Value; + } + } + } + } + + //闃�闂� + if (hydroInfo.Valves != null && hydroInfo.Valves.Count > 0) + { + foreach (var valve in hydroInfo.Valves) + { + if (valve.MinorLoss <= 0) + { + valve.MinorLoss = _valve_minorloss_default; + valve.UpdatePropStatus(nameof(valve.MinorLoss), ePropStatus.Lack, $"灞�闃荤郴鏁扮己鐪侊紝浣跨敤榛樿鍊笺�恵_valve_minorloss_default}銆戜慨澶�"); + } + if (valve.Diameter <= 0) + { + var startNode = allNodes.Find(x => x.Code == valve.StartCode); + if (startNode != null) + { + var startPipe = allLinks.Find(x => x.EndCode == startNode.Code) as Yw.Model.HydroPipeInfo; + if (startPipe != null) + { + valve.Diameter = startPipe.Diameter; + valve.UpdatePropStatus(nameof(valve.Diameter), ePropStatus.Lack, $"鐩村緞缂虹渷锛屼娇鐢ㄤ笂娓哥閬撱�恵startPipe.Code}銆戜慨澶�"); + } + else + { + var endNode = allNodes.Find(x => x.Code == valve.EndCode); + if (endNode != null) + { + var endPipe = allLinks.Find(x => x.StartCode == endNode.Code) as Yw.Model.HydroPipeInfo; + if (endPipe != null) + { + valve.Diameter = endPipe.Diameter; + valve.UpdatePropStatus(nameof(valve.Diameter), ePropStatus.Lack, $"鐩村緞缂虹渷锛屼娇鐢ㄤ笅娓哥閬撱�恵endPipe.Code}銆戜慨澶�"); + } + } + } + } + } + } + } + + } + + + #endregion } } -- Gitblit v1.9.3