From 63834af1872ab37f22a5e67b5df20a082f7a052a Mon Sep 17 00:00:00 2001
From: duheng <2784771470@qq.com>
Date: 星期二, 24 十二月 2024 16:40:00 +0800
Subject: [PATCH] 修改资产--四通

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/07-matching/00-core/AssetsMatchingHelper.cs |  348 +++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 222 insertions(+), 126 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 7f5bb50..ffc7651 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
@@ -104,7 +104,7 @@
                 //寮ご鍖归厤
                 foreach (var item in assetsAutoMatchingView.Elbows)
                 {
-                    if (MatchingElbow(item, allElbow))
+                    if (Matching(item, allElbow))
                     {
                         IsMaching = true;
                     }
@@ -301,6 +301,7 @@
                         InputModel.MatchingCurveQE.Add(new HydroCurvePointViewModel(item.X, item.Y));
                     }
                 }
+
                 return true;
             }
             return false;
@@ -609,125 +610,125 @@
             return false;
         }
 
-        //寮ご鍖归厤
-        public static bool MatchingElbow(HydroElbowMatchingViewModel input, List<Vmo.AssetsElbowMainVmo> elbowMainVmos)
-        {
-            bool isNotarize = false; //鏄惁纭畾
-            if (elbowMainVmos == null || input == null || elbowMainVmos.Count == 0)
-            {
-                return true;
-            }
-            Vmo.AssetsElbowMainVmo vmo = null;
-            var nameMatching = elbowMainVmos.Where(x =>
-        (x.KeyWord != null && x.KeyWord.Any(keyword => GetIntersect(keyword, input.ModelType) >= 1)) ||
-        (x.KeyWord == null || !x.KeyWord.Any()) && GetIntersect(x.Name, input.ModelType) >= 1
-        ) //鍏堣繘琛岀瓫閫�,鍚庤繘琛屼粠澶у埌灏忔帓搴�
-       .OrderByDescending(x =>
-        (x.KeyWord != null && x.KeyWord.Any(keyword => GetIntersect(keyword, input.ModelType) >= 1)) ||
-        (x.KeyWord == null || !x.KeyWord.Any()) && GetIntersect(x.Name, input.ModelType) >= 1).ToList();
+        /*   //寮ご鍖归厤
+           public static bool MatchingElbow(HydroElbowMatchingViewModel input, List<Vmo.AssetsElbowMainVmo> elbowMainVmos)
+           {
+               bool isNotarize = false; //鏄惁纭畾
+               if (elbowMainVmos == null || input == null || elbowMainVmos.Count == 0)
+               {
+                   return true;
+               }
+               Vmo.AssetsElbowMainVmo vmo = null;
+               var nameMatching = elbowMainVmos.Where(x =>
+           (x.KeyWords != null && x.KeyWords.Any(keyword => GetIntersect(keyword, input.ModelType) >= 1)) ||
+           (x.KeyWords == null || !x.KeyWords.Any()) && GetIntersect(x.Name, input.ModelType) >= 1
+           ) //鍏堣繘琛岀瓫閫�,鍚庤繘琛屼粠澶у埌灏忔帓搴�
+          .OrderByDescending(x =>
+           (x.KeyWords != null && x.KeyWords.Any(keyword => GetIntersect(keyword, input.ModelType) >= 1)) ||
+           (x.KeyWords == null || !x.KeyWords.Any()) && GetIntersect(x.Name, input.ModelType) >= 1).ToList();
 
-            if (nameMatching.Count > 1)
-            {
-                var absoluteMatching = nameMatching.Where(i =>
-              ((i.Caliber == null || input.Caliber == null) || Math.Abs(Convert.ToInt64(i.Caliber) - Convert.ToInt64(input.Caliber)) <= _caliberTolerance) &&  //鐩村緞绾︽潫
-               i.Material == input.Material  //鏉愭枡绾︽潫
-                 ).ToList();
-                if (absoluteMatching.Count > 1)
-                {
-                    var defaultList = absoluteMatching.Where(x => x.Flags.Contains("榛樿鍊�")).ToList();
-                    //鍙栭粯璁�
-                    if (defaultList.Count > 0)
-                    {
-                        vmo = defaultList.First();
-                    }
-                    else if (defaultList.Count <= 0)
-                    {
-                        vmo = elbowMainVmos.First();
-                    }
-                }
-                else if (absoluteMatching.Count == 1)
-                {
-                    isNotarize = true;
-                    vmo = absoluteMatching.First();
-                }
-                else
-                    vmo = elbowMainVmos.First();
-            }
-            else if (nameMatching.Count == 1)
-            {
-                isNotarize = true;
-                vmo = nameMatching.First();
-            }
-            else
-            {
-                var absoluteMatching = elbowMainVmos.Where(i =>
-          ((i.Caliber == null || input.Caliber == null) || Math.Abs(Convert.ToInt64(i.Caliber) - Convert.ToInt64(input.Caliber)) <= _caliberTolerance) &&  //鐩村緞绾︽潫
-           i.Material == input.Material   //鏉愭枡绾︽潫
-             ).ToList();
-                if (absoluteMatching.Count > 1)
-                {
-                    var defaultList = absoluteMatching.Where(x => x.Flags.Contains("榛樿鍊�")).ToList();
-                    //鍙栭粯璁�
-                    if (defaultList.Count > 0)
-                    {
-                        vmo = defaultList.First();
-                    }
-                    else if (defaultList.Count <= 0)
-                    {
-                        vmo = elbowMainVmos.First();
-                    }
-                }
-                else if (absoluteMatching.Count == 1)
-                {
-                    isNotarize = true;
+               if (nameMatching.Count > 1)
+               {
+                   var absoluteMatching = nameMatching.Where(i =>
+                 ((i.Caliber == null || input.Caliber == null) || Math.Abs(Convert.ToInt64(i.Caliber) - Convert.ToInt64(input.Caliber)) <= _caliberTolerance) &&  //鐩村緞绾︽潫
+                  i.Material == input.Material  //鏉愭枡绾︽潫
+                    ).ToList();
+                   if (absoluteMatching.Count > 1)
+                   {
+                       var defaultList = absoluteMatching.Where(x => x.Flags.Contains("榛樿鍊�")).ToList();
+                       //鍙栭粯璁�
+                       if (defaultList.Count > 0)
+                       {
+                           vmo = defaultList.First();
+                       }
+                       else if (defaultList.Count <= 0)
+                       {
+                           vmo = elbowMainVmos.First();
+                       }
+                   }
+                   else if (absoluteMatching.Count == 1)
+                   {
+                       isNotarize = true;
+                       vmo = absoluteMatching.First();
+                   }
+                   else
+                       vmo = elbowMainVmos.First();
+               }
+               else if (nameMatching.Count == 1)
+               {
+                   isNotarize = true;
+                   vmo = nameMatching.First();
+               }
+               else
+               {
+                   var absoluteMatching = elbowMainVmos.Where(i =>
+             ((i.Caliber == null || input.Caliber == null) || Math.Abs(Convert.ToInt64(i.Caliber) - Convert.ToInt64(input.Caliber)) <= _caliberTolerance) &&  //鐩村緞绾︽潫
+              i.Material == input.Material   //鏉愭枡绾︽潫
+                ).ToList();
+                   if (absoluteMatching.Count > 1)
+                   {
+                       var defaultList = absoluteMatching.Where(x => x.Flags.Contains("榛樿鍊�")).ToList();
+                       //鍙栭粯璁�
+                       if (defaultList.Count > 0)
+                       {
+                           vmo = defaultList.First();
+                       }
+                       else if (defaultList.Count <= 0)
+                       {
+                           vmo = elbowMainVmos.First();
+                       }
+                   }
+                   else if (absoluteMatching.Count == 1)
+                   {
+                       isNotarize = true;
 
-                    vmo = absoluteMatching.First();
-                }
-                else
-                    vmo = elbowMainVmos.First();
-            }
-            if (vmo != null)
-            {
-                if (!isNotarize)
-                {
-                    if (!input.MinorLoss.HasValue)
-                    {
-                        input.MatchingMinorLoss = vmo.MinorLoss;
-                    }
-                    if (input.DbId == null)
-                    {
-                        input.MatchingDbId = vmo.ID.ToString();
-                    }
-                    if (input.Material == null)
-                    {
-                        input.MatchingMaterial = vmo.Material;
-                    }
-                    if (input.ModelType == null)
-                    {
-                        input.MatchingModelType = vmo.Material;
-                    }
-                    if (!input.ElbowType.HasValue)
-                    {
-                        input.MatchingElbowType = (eElbowType?)(int)vmo.ElbowType;
-                    }
-                    if (!input.BendingAngle.HasValue)
-                    {
-                        input.MatchingBendingAngle = vmo.Angle;
-                    }
-                }
-                else
-                {
-                    input.MatchingMinorLoss = vmo.MinorLoss;
-                    input.MatchingDbId = vmo.ID.ToString();
-                    input.MatchingMaterial = vmo.Material;
-                    input.MatchingModelType = vmo.Name;
-                    input.MatchingElbowType = (eElbowType?)(int)vmo.ElbowType;
-                    input.MatchingBendingAngle = vmo.Angle;
-                }
-                return true;
-            }
-            return false;
-        }
+                       vmo = absoluteMatching.First();
+                   }
+                   else
+                       vmo = elbowMainVmos.First();
+               }
+               if (vmo != null)
+               {
+                   if (!isNotarize)
+                   {
+                       if (!input.MinorLoss.HasValue)
+                       {
+                           input.MatchingMinorLoss = vmo.MinorLoss;
+                       }
+                       if (input.DbId == null)
+                       {
+                           input.MatchingDbId = vmo.ID.ToString();
+                       }
+                       if (input.Material == null)
+                       {
+                           input.MatchingMaterial = vmo.Material;
+                       }
+                       if (input.ModelType == null)
+                       {
+                           input.MatchingModelType = vmo.Material;
+                       }
+                       if (!input.ElbowType.HasValue)
+                       {
+                           input.MatchingElbowType = (eElbowType?)(int)vmo.ElbowType;
+                       }
+                       if (!input.BendingAngle.HasValue)
+                       {
+                           input.MatchingBendingAngle = vmo.Angle;
+                       }
+                   }
+                   else
+                   {
+                       input.MatchingMinorLoss = vmo.MinorLoss;
+                       input.MatchingDbId = vmo.ID.ToString();
+                       input.MatchingMaterial = vmo.Material;
+                       input.MatchingModelType = vmo.Name;
+                       input.MatchingElbowType = (eElbowType?)(int)vmo.ElbowType;
+                       input.MatchingBendingAngle = vmo.Angle;
+                   }
+                   return true;
+               }
+               return false;
+           }*/
 
         //涓夐�氬尮閰�
         public static bool MatchingThreelink(HydroThreelinkMatchingViewModel input, List<Vmo.AssetsThreelinkMainVmo> threelinkVmos)
@@ -845,12 +846,12 @@
             }
             Vmo.AssetsFourlinkMainVmo vmo = null;
             var nameMatching = fourLinkVmos.Where(x =>
-    (x.KeyWord != null && x.KeyWord.Any(keyword => GetIntersect(keyword, input.ModelType) >= 1)) ||
-    (x.KeyWord == null || !x.KeyWord.Any()) && GetIntersect(x.Name, input.ModelType) >= 1
+    (x.KeyWords != null && x.KeyWords.Any(keyword => GetIntersect(keyword, input.ModelType) >= 1)) ||
+    (x.KeyWords == null || !x.KeyWords.Any()) && GetIntersect(x.Name, input.ModelType) >= 1
     ) //鍏堣繘琛岀瓫閫�,鍚庤繘琛屼粠澶у埌灏忔帓搴�
     .OrderByDescending(x =>
-     (x.KeyWord != null && x.KeyWord.Any(keyword => GetIntersect(keyword, input.ModelType) >= 1)) ||
-     (x.KeyWord == null || !x.KeyWord.Any()) && GetIntersect(x.Name, input.ModelType) >= 1).ToList();
+     (x.KeyWords != null && x.KeyWords.Any(keyword => GetIntersect(keyword, input.ModelType) >= 1)) ||
+     (x.KeyWords == null || !x.KeyWords.Any()) && GetIntersect(x.Name, input.ModelType) >= 1).ToList();
 
             if (nameMatching.Count > 1)
             {
@@ -1469,15 +1470,20 @@
                 {
                     if (input.DbId == null)
                         input.MatchingDbId = vmo.ID.ToString();
-                    if (input.ModelType == null)
+                    if (input.ModelType == null && input.ModelType == string.Empty)
                         input.MatchingModelType = vmo.Name;
-                    if (input.DN < 0)
+                    if (input.DN <= 0)
                         input.MatchingDN = vmo.DN;
-                    if (input.MinLevel < 0)
+                    if (input.MinLevel <= 0)
                         input.MatchingMinLevel = vmo.MinLevel;
+                    input.MatchingOverFlow = vmo.OverFlow;
+                    if (input.MinVol <= 0)
+                        input.MatchingMinVol = vmo.MinVol;
+                    if (input.MaxLevel <= 0)
+                        input.MatchingMaxLevel = vmo.MaxLevel;
                     if (input.CurveDbId == null)
                     {
-                        var list = Task.Run(async () => await new BLL.PhartDiagramRelation().GetExByObjectTypeAndObjectID(HStation.Assets.DataType.ValveMain, vmo.ID)).Result;
+                        var list = Task.Run(async () => await new BLL.PhartDiagramRelation().GetExByObjectTypeAndObjectID(HStation.Assets.DataType.TankMain, vmo.ID)).Result;
                         if (list != null && list.Count > 0)
                         {
                             var def = list.OrderByDescending(x => x.Importance).First();
@@ -1498,6 +1504,9 @@
                     input.MatchingDN = vmo.DN;
                     input.MatchingMinLevel = vmo.MinLevel;
                     input.MatchingOverFlow = vmo.OverFlow;
+                    input.MatchingMinVol = vmo.MinVol;
+                    input.MatchingMaxLevel = vmo.MaxLevel;
+
                     var list = Task.Run(async () => await new BLL.PhartDiagramRelation().GetExByObjectTypeAndObjectID(HStation.Assets.DataType.ValveMain, vmo.ID)).Result;
                     if (list != null && list.Count > 0)
                     {
@@ -1770,6 +1779,93 @@
             return false;
         }
 
+        //寮ご鍖归厤
+        public static bool Matching(HydroElbowMatchingViewModel input, List<Vmo.AssetsElbowMainVmo> allElbowList)
+        {
+            //杈撳叆鍙傛暟楠岃瘉
+            if (input == null)
+            {
+                return false;
+            }
+
+            //鏁版嵁婧愭病鏈夋暟鎹垯娌℃湁鍖归厤鎴愬姛
+            if (allElbowList == null || allElbowList.Count < 1)
+            {
+                return false;
+            }
+
+            //鏉冮噸瀛楀吀
+            var dict = new Dictionary<AssetsElbowMainVmo, double>();
+            foreach (var item in allElbowList)
+            {
+                dict.Add(item, 0);
+            }
+
+            //鍨嬪彿
+            int modelTypeWeight = 100;
+            if (!string.IsNullOrEmpty(input.ModelType))
+            {
+                foreach (var item in allElbowList)
+                {
+                    if (!string.IsNullOrEmpty(item.Name))
+                    {
+                        var count = item.Name.ToLower().Intersect(input.ModelType.ToLower()).Count();
+                        dict[item] += count * modelTypeWeight;
+                    }
+                }
+            }
+
+            // 鍏抽敭瀛�
+            int keywordWeight = 1;
+            foreach (var item in allElbowList)
+            {
+                if (item.KeyWords != null && item.KeyWords.Count > 0)
+                {
+                    if (!string.IsNullOrEmpty(input.ModelType))
+                    {
+                        var count = item.KeyWords.Count(x => input.ModelType.ToLower().Contains(x.ToLower()));
+                        dict[item] += count * keywordWeight;
+                    }
+                }
+            }
+
+            //鏍囩
+            int flagWeight = 10;
+            foreach (var item in allElbowList)
+            {
+                if (item.Flags != null && item.Flags.Count > 0)
+                {
+                    if (item.Flags.Contains(HStation.Assets.Flags.榛樿))
+                    {
+                        dict[item] += flagWeight;
+                    }
+                }
+            }
+
+            var flowmeter = dict.OrderBy(x => x.Value).LastOrDefault().Key;
+            input.MatchingDbId = flowmeter.ID.ToString();
+            if (string.IsNullOrEmpty(input.ModelType))
+            {
+                input.MatchingModelType = flowmeter.Name;
+            }
+            if (input.MinorLoss <= 0)
+            {
+                input.MatchingMinorLoss = flowmeter.MinorLoss;
+            }
+            if (input.BendingAngle <= 0)
+            {
+                input.MatchingBendingAngle = flowmeter.Angle;
+            }
+            input.MatchingElbowType = (Yw.WinFrmUI.eElbowType)(int)flowmeter.ElbowType;
+            if (input.Material == null || input.Material == string.Empty)
+            {
+                input.MatchingMaterial = flowmeter.Material;
+            }
+            if (!input.Caliber.HasValue)
+                input.MatchingCaliber = flowmeter.Caliber;
+            return true;
+        }
+
         //鍘嬪姏琛ㄥ尮閰�
         public static bool MatchingPressmeter(HydroPressmeterMatchingViewModel input, List<Vmo.AssetsPressmeterMainVmo> pressmeterVmos)
         {

--
Gitblit v1.9.3