From 8f2d7a722b274344f58550374f4b09921f84eb83 Mon Sep 17 00:00:00 2001
From: duheng <2784771470@qq.com>
Date: 星期五, 07 二月 2025 11:02:32 +0800
Subject: [PATCH] 修复过渡件匹配问题

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/07-matching/00-core/AssetsMatchingHelper.cs |  187 +++++++++++++++++++++++++++++++---------------
 1 files changed, 126 insertions(+), 61 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 4275055..3147988 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,9 +1,6 @@
-锘縰sing HStation.CAL;
-using HStation.WinFrmUI.PhartRelation;
-using Swashbuckle.AspNetCore.SwaggerGen;
-using System.Linq;
-using System.Windows.Input;
-using Yw.WinFrmUI.Q3d;
+锘縰sing DevExpress.CodeParser;
+using System.Text.Json;
+using Yw.Ahart;
 
 namespace HStation.WinFrmUI
 {
@@ -118,7 +115,7 @@
                     }
                 }
 
-                //鍠峰ご鍖归厤
+                //鍐峰嵈濉斿尮閰�
                 foreach (var item in assetsAutoMatchingView.Coolings)
                 {
                     if (Matching(item, allCoolingMain))
@@ -391,7 +388,7 @@
             }
 
             //鏍囩
-            int flagWeight = 1;
+            int flagWeight = 1000;//涓存椂淇敼,涔嬪墠涓�1
             foreach (var item in valveMainVmos)
             {
                 if (item.Flags != null && item.Flags.Count > 0)
@@ -402,7 +399,6 @@
                     }
                 }
             }
-
             var valve = dict.OrderBy(x => x.Value).LastOrDefault().Key;
             input.MatchingDbId = valve.ID.ToString();
             if (string.IsNullOrEmpty(input.ModelType))
@@ -421,10 +417,6 @@
             {
                 input.MatchingMinorLoss = valve.MinorLoss;
             }
-            if (input.ValveSetting == null)
-            {
-                input.MatchingValveSetting = valve.ValveSetting;
-            }
             if (input.CurveDbId == null)
             {
                 var list = Task.Run(async () =>
@@ -433,27 +425,43 @@
                 {
                     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)
+                    //var curve = def.Diagram.GraphList[0].GetFeatPointList();
+                    //var curve1 = def.Diagram.GraphList[1].GetFeatPointList();
+                    //input.MatchingCurveQL = new List<HydroCurvePointViewModel>();
+                    /*   foreach (var item in curve)
+                       {
+                           input.MatchingCurveQL.Add(new HydroCurvePointViewModel(item.X, item.Y));
+                       }*/
+
+                    input.MatchingCurveOL = new List<HydroCurvePointViewModel>();
+                    input.MatchingCurvesQL = new List<HydroFactorCurveViewModel>();
+                    for (int i = 0; i < def.Diagram.GraphList.Count; i++)
                     {
-                        input.MatchingCurveQL = new List<HydroCurvePointViewModel>();
-                        foreach (var item in curve)
+                        var curve = def.Diagram.GraphList[i].GetFeatPointList();
+                        if (def.Diagram.GraphList[i].GraphType == 11)
                         {
-                            input.MatchingCurveQL.Add(new HydroCurvePointViewModel(item.X, item.Y));
+                            var opening = Yw.WinFrmUI.PhartGraphHelper.GetGraphParas<Yw.WinFrmUI.Phart.QLGraphParasViewModel>((Yw.Ahart.eCurveType)def.Diagram.GraphList[i].GraphType, def.Diagram.GraphList[i].GraphParas);
+                            var model = new HydroFactorCurveViewModel();
+                            model.CurveFactor = opening.Opening ?? 0;
+                            model.CurveData = new List<HydroCurvePointViewModel>();
+                            foreach (var item in curve)
+                            {
+                                model.CurveData.Add(new HydroCurvePointViewModel(item.X, item.Y));
+                            }
+                            input.MatchingCurvesQL.Add(model);
                         }
-                    }
-                    else if (valve.ValveType == HStation.Assets.eValveType.TCV)
-                    {
-                        input.MatchingCurveOL = new List<HydroCurvePointViewModel>();
-                        foreach (var item in curve)
+                        else if (def.Diagram.GraphList[i].GraphType == 12)
                         {
-                            input.MatchingCurveOL.Add(new HydroCurvePointViewModel(item.X, item.Y));
+                            foreach (var item in curve)
+                            {
+                                input.MatchingCurveOL.Add(new HydroCurvePointViewModel(item.X, item.Y));
+                            }
                         }
                     }
                 }
+                return true;
             }
-
-            return true;
+            return false;
         }
 
         //绠¢亾鍖归厤
@@ -540,7 +548,7 @@
             }
 
             //鏍囩
-            int flagWeight = 1;
+            int flagWeight = 1000;
             foreach (var item in pipeLineMainVmos)
             {
                 if (item.Flags != null && item.Flags.Count > 0)
@@ -558,17 +566,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;
@@ -658,7 +663,7 @@
             }
 
             //鏍囩
-            int flagWeight = 1;
+            int flagWeight = 1000;
             foreach (var item in threelinkVmos)
             {
                 if (item.Flags != null && item.Flags.Count > 0)
@@ -684,10 +689,7 @@
             {
                 input.Caliber = threelink.Caliber ?? 0;
             }
-            if (input.MinorLoss <= 0)
-            {
-                input.MatchingMinorLoss = threelink.MinorLoss;
-            }
+
             if (input.RunningThroughLoss <= 0)
             {
                 input.MatchingRunningThroughLoss = threelink.RunThroughMinorLoss;
@@ -784,7 +786,7 @@
             }
 
             //鏍囩
-            int flagWeight = 1;
+            int flagWeight = 1000;
             foreach (var item in fourLinkVmos)
             {
                 if (item.Flags != null && item.Flags.Count > 0)
@@ -902,7 +904,7 @@
             }
 
             //鏍囩
-            int flagWeight = 1;
+            int flagWeight = 1000;
             foreach (var item in sprinklerVmos)
             {
                 if (item.Flags != null && item.Flags.Count > 0)
@@ -930,7 +932,7 @@
             }
             if (input.MinorLoss <= 0)
             {
-                input.MatchingMinorLoss = sprinkler.MinorLoss;
+                input.MatchingMinorLoss = sprinkler.FlowMinorLoss;
             }
 
             return true;
@@ -1020,7 +1022,7 @@
             }
 
             //鏍囩
-            int flagWeight = 1;
+            int flagWeight = 1000;
             foreach (var item in allExchangerList)
             {
                 if (item.Flags != null && item.Flags.Count > 0)
@@ -1159,7 +1161,7 @@
             }
 
             //鏍囩
-            int flagWeight = 1;
+            int flagWeight = 1000;
             foreach (var item in allCompressorList)
             {
                 if (item.Flags != null && item.Flags.Count > 0)
@@ -1298,7 +1300,7 @@
             }
 
             //鏍囩
-            int flagWeight = 1;
+            int flagWeight = 1000;
             foreach (var item in bluntheadVmos)
             {
                 if (item.Flags != null && item.Flags.Count > 0)
@@ -1383,7 +1385,7 @@
             }
 
             //鏍囩
-            int flagWeight = 1;
+            int flagWeight = 1000;
             foreach (var item in tankVmos)
             {
                 if (item.Flags != null && item.Flags.Count > 0)
@@ -1489,7 +1491,7 @@
             }
 
             //鏍囩
-            int flagWeight = 10;
+            int flagWeight = 1000;
             foreach (var item in allMeterList)
             {
                 if (item.Flags != null && item.Flags.Count > 0)
@@ -1566,7 +1568,7 @@
             }
 
             //鏍囩
-            int flagWeight = 10;
+            int flagWeight = 1000;
             foreach (var item in allFlowmeterList)
             {
                 if (item.Flags != null && item.Flags.Count > 0)
@@ -1676,7 +1678,7 @@
             }
 
             //鏍囩
-            int flagWeight = 1;
+            int flagWeight = 1000;
             foreach (var item in hydrantVmos)
             {
                 if (item.Flags != null && item.Flags.Count > 0)
@@ -1724,7 +1726,7 @@
             {
                 return false;
             }
-
+            allElbowList = allElbowList.Where(x => x.Angle == 90).ToList();
             //鏉冮噸瀛楀吀
             var dict = new Dictionary<AssetsElbowMainVmo, double>();
             foreach (var item in allElbowList)
@@ -1745,7 +1747,40 @@
                     }
                 }
             }
-
+            //鍙e緞
+            int caliberWeight = 1;
+            if (input.Caliber > 0)
+            {
+                foreach (var item in allElbowList)
+                {
+                    if (item.Caliber.HasValue)
+                    {
+                        var diff = Math.Abs(item.Caliber.Value - input.Caliber);
+                        dict[item] += diff / input.Caliber * 100 * caliberWeight;
+                    }
+                }
+            }
+            // 瑙掑害
+            int angleWeight = 1000;
+            if (input.BendingAngle > 0)
+            {
+                foreach (var item in allElbowList)
+                {
+                    if (item.Angle > 0)
+                    {
+                        var count = Math.Abs(item.Angle.Value - input.BendingAngle);
+                        if (count != 0)
+                        {
+                            dict[item] += (1.0 / count) * angleWeight;
+                        }
+                        else
+                        {
+                            // 濡傛灉 count 涓� 0锛岃〃绀哄畬鍏ㄥ尮閰嶏紝缁欎簣鏈�澶ф潈閲�
+                            dict[item] += angleWeight * 100;
+                        }
+                    }
+                }
+            }
             // 鍏抽敭瀛�
             int keywordWeight = 1;
             foreach (var item in allElbowList)
@@ -1761,7 +1796,7 @@
             }
 
             //鏍囩
-            int flagWeight = 10;
+            int flagWeight = 1000;
             foreach (var item in allElbowList)
             {
                 if (item.Flags != null && item.Flags.Count > 0)
@@ -1787,7 +1822,10 @@
             {
                 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;
@@ -1850,7 +1888,7 @@
             }
 
             //鏍囩
-            int flagWeight = 1;
+            int flagWeight = 1000;
             foreach (var item in pressmeterVmos)
             {
                 if (item.Flags != null && item.Flags.Count > 0)
@@ -1912,6 +1950,37 @@
                 }
             }
 
+            // 涓婃父鍜屼笅娓哥洿寰�
+            int diameterWeight = 100;
+            if (input.StartDiameter > 0 && input.EndDiameter > 0)
+            {
+                foreach (var item in translationVmos)
+                {
+                    if (item.StartDiameter > 0 && item.EndDiameter > 0)
+                    {
+                        var startCount = Math.Abs(item.StartDiameter - input.StartDiameter);
+                        var endCount = Math.Abs(item.EndDiameter - input.EndDiameter);
+
+                        if (startCount == 0 && endCount == 0)
+                        {
+                            // 濡傛灉 startCount 鍜� endCount 閮戒负 0锛岃〃绀哄畬鍏ㄥ尮閰嶏紝缁欎簣鏈�澶ф潈閲�
+                            dict[item] += diameterWeight * 100;
+                        }
+                        else
+                        {
+                            // 鍚﹀垯锛屽垎鍒绠楁潈閲�
+                            if (startCount != 0)
+                            {
+                                dict[item] += (1.0 / startCount) * diameterWeight;
+                            }
+                            if (endCount != 0)
+                            {
+                                dict[item] += (1.0 / endCount) * diameterWeight;
+                            }
+                        }
+                    }
+                }
+            }
             //鏉愯川
             int materialWeight = 5;
             if (!string.IsNullOrEmpty(input.Material))
@@ -1946,7 +2015,7 @@
             }
 
             //鏍囩
-            int flagWeight = 1;
+            int flagWeight = 1000;
             foreach (var item in translationVmos)
             {
                 if (item.Flags != null && item.Flags.Count > 0)
@@ -1968,11 +2037,11 @@
             {
                 input.MatchingMaterial = translation.Material;
             }
-            if (input.MinorLoss < 0)
+            if (input.MinorLoss <= 0)
             {
                 input.MatchingMinorLoss = translation.MinorLoss;
             }
-            if (input.Roughness < 0)
+            if (input.Roughness <= 0)
             {
                 input.MatchingRoughness = translation.Roughness;
             }
@@ -1984,10 +2053,7 @@
             {
                 input.MatchingStartDiameter = translation.StartDiameter;
             }
-            if (input.Diameter < 0)
-            {
-                input.MatchingDiameter = translation.Diameter;
-            }
+            input.MatchingTranslationType = (Yw.WinFrmUI.eTranslationType)(int)translation.TranslationType;
 
             return true;
         }
@@ -2056,7 +2122,6 @@
                 }
             }
 
-
             // 鍏抽敭瀛�
             int keywordWeight = 1;
             foreach (var item in allCoolingList)
@@ -2077,7 +2142,7 @@
             }
 
             //鏍囩
-            int flagWeight = 1;
+            int flagWeight = 1000;
             foreach (var item in allCoolingList)
             {
                 if (item.Flags != null && item.Flags.Count > 0)

--
Gitblit v1.9.3