From bee0b4fc0f1126dd10fb9d7be931121266f97f6e Mon Sep 17 00:00:00 2001 From: duheng <2784771470@qq.com> Date: 星期二, 14 一月 2025 19:03:27 +0800 Subject: [PATCH] 修复报错 --- WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/07-matching/00-core/AssetsMatchingHelper.cs | 139 ++++++++++++++++++++-------------------------- 1 files changed, 61 insertions(+), 78 deletions(-) diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/07-matching/00-core/AssetsMatchingHelper.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/07-matching/00-core/AssetsMatchingHelper.cs index 3041280..0baaaf4 100644 --- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/07-matching/00-core/AssetsMatchingHelper.cs +++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/07-matching/00-core/AssetsMatchingHelper.cs @@ -1,10 +1,4 @@ -锘縰sing HStation.WinFrmUI.PhartRelation; -using Swashbuckle.AspNetCore.SwaggerGen; -using System.Linq; -using System.Windows.Input; -using Yw.WinFrmUI.Q3d; - -namespace HStation.WinFrmUI +锘縩amespace HStation.WinFrmUI { public class AssetsMatchingHelper { @@ -117,7 +111,7 @@ } } - //鍠峰ご鍖归厤 + //鍐峰嵈濉斿尮閰� foreach (var item in assetsAutoMatchingView.Coolings) { if (Matching(item, allCoolingMain)) @@ -237,9 +231,9 @@ { // 灏濊瘯鍖洪棿鍖归厤 var rangeMatch = AssetsPumpMainVmos.Where(item => - (InputModel.RatedN.HasValue ? Math.Abs(InputModel.RatedN.Value - item.RatedSpeed) <= _speedTolerance : true) && - (InputModel.RatedQ.HasValue ? Math.Abs(InputModel.RatedQ.Value - item.RatedFlow) <= _flowTolerance : true) && - (InputModel.RatedH.HasValue ? Math.Abs(InputModel.RatedH.Value - item.RatedHead) <= _headTolerance : true) && + (InputModel.RatedN > 0 ? Math.Abs(InputModel.RatedN - item.RatedSpeed) <= _speedTolerance : true) && + (InputModel.RatedQ > 0 ? Math.Abs(InputModel.RatedQ - item.RatedFlow) <= _flowTolerance : true) && + (InputModel.RatedH > 0 ? Math.Abs(InputModel.RatedH - item.RatedHead) <= _headTolerance : true) && (Math.Abs(InputModel.RatedP - item.RatedPower) <= _powerTolerance)).ToList(); if (rangeMatch != null && rangeMatch.Count != 0) { @@ -401,7 +395,6 @@ } } } - var valve = dict.OrderBy(x => x.Value).LastOrDefault().Key; input.MatchingDbId = valve.ID.ToString(); if (string.IsNullOrEmpty(input.ModelType)) @@ -433,26 +426,21 @@ var def = list.OrderByDescending(x => x.Importance).First(); input.MatchingCurveDbId = def.ID.ToString(); var curve = def.Diagram.GraphList[0].GetFeatPointList(); - if (valve.ValveType == HStation.Assets.eValveType.GPV) + input.MatchingCurveQL = new List<HydroCurvePointViewModel>(); + /* foreach (var item in curve) + { + input.MatchingCurveQL.Add(new HydroCurvePointViewModel(item.X, item.Y)); + }*/ + + input.MatchingCurveOL = new List<HydroCurvePointViewModel>(); + foreach (var item in curve) { - input.MatchingCurveQL = new List<HydroCurvePointViewModel>(); - foreach (var item in curve) - { - input.MatchingCurveQL.Add(new HydroCurvePointViewModel(item.X, item.Y)); - } - } - else if (valve.ValveType == HStation.Assets.eValveType.TCV) - { - input.MatchingCurveOL = new List<HydroCurvePointViewModel>(); - foreach (var item in curve) - { - input.MatchingCurveOL.Add(new HydroCurvePointViewModel(item.X, item.Y)); - } + input.MatchingCurveOL.Add(new HydroCurvePointViewModel(item.X, item.Y)); } } + return true; } - - return true; + return false; } //绠¢亾鍖归厤 @@ -557,17 +545,14 @@ { input.MatchingModelType = pipe.Name; } - if (input.Roughness == 0) - { - input.MatchingRoughness = pipe.Hazen; - } + if (string.IsNullOrEmpty(input.Material)) { input.MatchingMaterial = pipe.Material; } if (input.MinorLoss < 0) { - input.MatchingMinorLoss = pipe.MinorLoss; + input.MatchingMinorLoss = pipe.Hazen; } return true; @@ -625,14 +610,14 @@ //鍙e緞 int caliberWeight = 1; - if (input.Caliber.HasValue) + if (input.Caliber > 0) { foreach (var item in threelinkVmos) { if (item.Caliber.HasValue) { - var diff = Math.Abs(item.Caliber.Value - input.Caliber.Value); - dict[item] += diff / input.Caliber.Value * 100 * caliberWeight; + var diff = Math.Abs(item.Caliber.Value - input.Caliber); + dict[item] += diff / input.Caliber * 100 * caliberWeight; } } } @@ -679,19 +664,16 @@ { input.MatchingMaterial = threelink.Material; } - if (!input.Caliber.HasValue || input.Caliber.Value <= 0) + if (input.Caliber <= 0) { - input.Caliber = threelink.Caliber; + input.Caliber = threelink.Caliber ?? 0; } - if (!input.MinorLoss.HasValue) - { - input.MatchingMinorLoss = threelink.MinorLoss; - } - if (!input.RunningThroughLoss.HasValue) + + if (input.RunningThroughLoss <= 0) { input.MatchingRunningThroughLoss = threelink.RunThroughMinorLoss; } - if (!input.MatchingBranchThroughLoss.HasValue) + if (input.MatchingBranchThroughLoss <= 0) { input.MatchingBranchThroughLoss = threelink.BranchThroughMinorLoss; } @@ -751,14 +733,14 @@ //鍙e緞 int caliberWeight = 1; - if (input.Caliber.HasValue) + if (input.Caliber > 0) { foreach (var item in fourLinkVmos) { if (item.Caliber.HasValue) { - var diff = Math.Abs(item.Caliber.Value - input.Caliber.Value); - dict[item] += diff / input.Caliber.Value * 100 * caliberWeight; + var diff = Math.Abs(item.Caliber.Value - input.Caliber); + dict[item] += diff / input.Caliber * 100 * caliberWeight; } } } @@ -805,11 +787,11 @@ { input.MatchingMaterial = fourlink.Material; } - if (!input.Caliber.HasValue || input.Caliber.Value <= 0) + if (input.Caliber <= 0) { - input.Caliber = fourlink.Caliber; + input.Caliber = fourlink.Caliber ?? 0; } - if (!input.MinorLoss.HasValue) + if (input.MinorLoss <= 0) { input.MatchingMinorLoss = fourlink.MinorLoss; } @@ -869,14 +851,14 @@ //鍙e緞 int caliberWeight = 1; - if (input.Caliber.HasValue) + if (input.Caliber > 0) { foreach (var item in sprinklerVmos) { if (item.Caliber.HasValue) { - var diff = Math.Abs(item.Caliber.Value - input.Caliber.Value); - dict[item] += diff / input.Caliber.Value * 100 * caliberWeight; + var diff = Math.Abs(item.Caliber.Value - input.Caliber); + dict[item] += diff / input.Caliber * 100 * caliberWeight; } } } @@ -923,13 +905,13 @@ { input.MatchingMaterial = sprinkler.Material; } - if (!input.Caliber.HasValue || input.Caliber.Value <= 0) + if (input.Caliber <= 0) { - input.Caliber = sprinkler.Caliber; + input.Caliber = sprinkler.Caliber ?? 0; } - if (!input.MinorLoss.HasValue) + if (input.MinorLoss <= 0) { - input.MatchingMinorLoss = sprinkler.MinorLoss; + input.MatchingMinorLoss = sprinkler.FlowMinorLoss; } return true; @@ -1265,14 +1247,14 @@ //鍙e緞 int caliberWeight = 1; - if (input.Caliber.HasValue) + if (input.Caliber > 0) { foreach (var item in bluntheadVmos) { if (item.Caliber.HasValue) { - var diff = Math.Abs(item.Caliber.Value - input.Caliber.Value); - dict[item] += diff / input.Caliber.Value * 100 * caliberWeight; + var diff = Math.Abs(item.Caliber.Value - input.Caliber); + dict[item] += diff / input.Caliber * 100 * caliberWeight; } } } @@ -1319,9 +1301,9 @@ { input.MatchingMaterial = blunthead.Material; } - if (!input.Caliber.HasValue || input.Caliber.Value <= 0) + if (input.Caliber <= 0) { - input.Caliber = blunthead.Caliber; + input.Caliber = blunthead.Caliber ?? 0; } if (input.MinorLoss < 0) { @@ -1643,14 +1625,14 @@ //鍙e緞 int caliberWeight = 1; - if (input.Caliber.HasValue) + if (input.Caliber > 0) { foreach (var item in hydrantVmos) { if (item.Caliber.HasValue) { - var diff = Math.Abs(item.Caliber.Value - input.Caliber.Value); - dict[item] += diff / input.Caliber.Value * 100 * caliberWeight; + var diff = Math.Abs(item.Caliber.Value - input.Caliber); + dict[item] += diff / input.Caliber * 100 * caliberWeight; } } } @@ -1697,9 +1679,9 @@ { input.MatchingMaterial = hydrant.Material; } - if (!input.Caliber.HasValue || input.Caliber.Value <= 0) + if (input.Caliber <= 0) { - input.Caliber = hydrant.Caliber; + input.Caliber = hydrant.Caliber ?? 0; } if (input.MinorLoss < 0) { @@ -1786,13 +1768,18 @@ { input.MatchingBendingAngle = elbow.Angle; } - input.MatchingElbowType = (Yw.WinFrmUI.eElbowType)(int)elbow.ElbowType; + if (elbow.ElbowType != null) + { + input.MatchingElbowType = (Yw.WinFrmUI.eElbowType)(int)elbow.ElbowType; + } if (input.Material == null || input.Material == string.Empty) { input.MatchingMaterial = elbow.Material; } - if (!input.Caliber.HasValue) + if (input.Caliber <= 0) + { input.MatchingCaliber = elbow.Caliber; + } return true; } @@ -1981,10 +1968,6 @@ { input.MatchingStartDiameter = translation.StartDiameter; } - if (input.Diameter < 0) - { - input.MatchingDiameter = translation.Diameter; - } return true; } @@ -2041,14 +2024,14 @@ //鍙e緞 int caliberWeight = 1; - if (input.Caliber.HasValue) + if (input.Caliber > 0) { foreach (var item in allCoolingList) { if (item.Caliber.HasValue) { - var diff = Math.Abs(item.Caliber.Value - input.Caliber.Value); - dict[item] += diff / input.Caliber.Value * 100 * caliberWeight; + var diff = Math.Abs(item.Caliber.Value - input.Caliber); + dict[item] += diff / input.Caliber * 100 * caliberWeight; } } } @@ -2095,9 +2078,9 @@ { input.MatchingMaterial = cooling.Material; } - if (!input.Caliber.HasValue || input.Caliber.Value <= 0) + if (input.Caliber <= 0) { - input.Caliber = cooling.Caliber; + input.Caliber = cooling.Caliber ?? 0; } if (input.Coefficient <= 1) { -- Gitblit v1.9.3