From c22cc4c60e9ff156fc25b39a5c024cc758df354b Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期一, 30 十二月 2024 09:40:51 +0800
Subject: [PATCH] 水力模块联动修改

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/07-matching/00-core/AssetsMatchingHelper.cs |   84 ++++++++++++++++++++++--------------------
 1 files changed, 44 insertions(+), 40 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..4275055 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,4 +1,5 @@
-锘縰sing HStation.WinFrmUI.PhartRelation;
+锘縰sing HStation.CAL;
+using HStation.WinFrmUI.PhartRelation;
 using Swashbuckle.AspNetCore.SwaggerGen;
 using System.Linq;
 using System.Windows.Input;
@@ -237,9 +238,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)
                 {
@@ -625,14 +626,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 +680,19 @@
             {
                 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)
+            if (input.MinorLoss <= 0)
             {
                 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 +752,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 +806,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 +870,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,11 +924,11 @@
             {
                 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;
             }
@@ -1265,14 +1266,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 +1320,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 +1644,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 +1698,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)
             {
@@ -1791,8 +1792,10 @@
             {
                 input.MatchingMaterial = elbow.Material;
             }
-            if (!input.Caliber.HasValue)
+            if (input.Caliber <= 0)
+            {
                 input.MatchingCaliber = elbow.Caliber;
+            }
             return true;
         }
 
@@ -2041,17 +2044,18 @@
 
             //鍙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;
                     }
                 }
             }
+
 
             // 鍏抽敭瀛�
             int keywordWeight = 1;
@@ -2095,9 +2099,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