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 |  516 ++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 325 insertions(+), 191 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 692c781..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
@@ -1,6 +1,7 @@
 锘縰sing HStation.WinFrmUI.PhartRelation;
 using Swashbuckle.AspNetCore.SwaggerGen;
 using System.Linq;
+using System.Windows.Input;
 using Yw.WinFrmUI.Q3d;
 
 namespace HStation.WinFrmUI
@@ -39,6 +40,7 @@
             var AssetsHydrantMain = new BLL.AssetsHydrantMain();
             var AssetsPressmeterMain = new BLL.AssetsPressmeterMain();
             var AssetsTranslationMain = new BLL.AssetsTranslationMain();
+            var AssetsCoolingMain = new BLL.AssetsCoolingMain();
             try
             {
                 var allPump = Task.Run(async () => await AssetsPumpMain.GetAll()).Result;
@@ -58,6 +60,7 @@
                 var allHydrantMain = Task.Run(async () => await AssetsHydrantMain.GetAll()).Result;
                 var allPressmeterMain = Task.Run(async () => await AssetsPressmeterMain.GetAll()).Result;
                 var allTranslationMain = Task.Run(async () => await AssetsTranslationMain.GetAll()).Result;
+                var allCoolingMain = Task.Run(async () => await AssetsCoolingMain.GetAll()).Result;
                 //娉靛尮閰�
                 foreach (var item in assetsAutoMatchingView.Pumps)
                 {
@@ -101,7 +104,7 @@
                 //寮ご鍖归厤
                 foreach (var item in assetsAutoMatchingView.Elbows)
                 {
-                    if (MatchingElbow(item, allElbow))
+                    if (Matching(item, allElbow))
                     {
                         IsMaching = true;
                     }
@@ -110,6 +113,15 @@
                 foreach (var item in assetsAutoMatchingView.Nozzles)
                 {
                     if (MatchingSprinkler(item, allSprinkler))
+                    {
+                        IsMaching = true;
+                    }
+                }
+
+                //鍠峰ご鍖归厤
+                foreach (var item in assetsAutoMatchingView.Coolings)
+                {
+                    if (Matching(item, allCoolingMain))
                     {
                         IsMaching = true;
                     }
@@ -265,62 +277,31 @@
                 InputModel.MatchingDbId = vmo.ID.ToString();
                 InputModel.MatchingModelType = vmo.Name;
                 var list = Task.Run(async () => await new BLL.PhartDiagramRelation().GetExByObjectTypeAndObjectID(HStation.Assets.DataType.PumpMain, vmo.ID)).Result;
-                var def = list.OrderByDescending(x => x.Importance).First();
-                InputModel.MatchingCurveDbId = def.ID.ToString();
-                var diagram = def.Diagram.GetDefaultVmo();
-                var qh = diagram.QH.GetFeatPointList();
-                var qp = diagram.QP.GetFeatPointList();
-                var qe = diagram.QE.GetFeatPointList();
-                InputModel.MatchingCurveQH = new List<HydroCurvePointViewModel>();
-                InputModel.MatchingCurveQP = new List<HydroCurvePointViewModel>();
-                InputModel.MatchingCurveQE = new List<HydroCurvePointViewModel>();
-                foreach (var item in qh)
+                if (list != null && list.Count > 0)
                 {
-                    InputModel.MatchingCurveQH.Add(new HydroCurvePointViewModel(item.X, item.Y));
+                    var def = list.OrderByDescending(x => x.Importance).First();
+                    InputModel.MatchingCurveDbId = def.ID.ToString();
+                    var diagram = def.Diagram.GetDefaultVmo();
+                    var qh = diagram.QH.GetFeatPointList();
+                    var qp = diagram.QP.GetFeatPointList();
+                    var qe = diagram.QE.GetFeatPointList();
+                    InputModel.MatchingCurveQH = new List<HydroCurvePointViewModel>();
+                    InputModel.MatchingCurveQP = new List<HydroCurvePointViewModel>();
+                    InputModel.MatchingCurveQE = new List<HydroCurvePointViewModel>();
+                    foreach (var item in qh)
+                    {
+                        InputModel.MatchingCurveQH.Add(new HydroCurvePointViewModel(item.X, item.Y));
+                    }
+                    foreach (var item in qp)
+                    {
+                        InputModel.MatchingCurveQP.Add(new HydroCurvePointViewModel(item.X, item.Y));
+                    }
+                    foreach (var item in qe)
+                    {
+                        InputModel.MatchingCurveQE.Add(new HydroCurvePointViewModel(item.X, item.Y));
+                    }
                 }
-                foreach (var item in qp)
-                {
-                    InputModel.MatchingCurveQP.Add(new HydroCurvePointViewModel(item.X, item.Y));
-                }
-                foreach (var item in qe)
-                {
-                    InputModel.MatchingCurveQE.Add(new HydroCurvePointViewModel(item.X, item.Y));
-                }
-                /*     if (list != null && list.Count > 0)
-                     {
-                         var maxImportanceItem = list.OrderByDescending(x => x.Importance).First();
-                         InputModel.MatchingCurveDbId = maxImportanceItem.ID.ToString();
-                         var graph_qh = maxImportanceItem.Diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.QH);
-                         var graph_qe = maxImportanceItem.Diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.QE);
-                         var graph_qp = maxImportanceItem.Diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.QP);
-                         if (graph_qh != null)
-                         {
-                             var points_qh = PhartPerformCurveHelper.GetFeatPointList(graph_qh.GraphType, graph_qh.GeometryInfo, 100, null);
-                             InputModel.MatchingCurveQH = new List<HydroCurvePointViewModel>();
-                             foreach (var item in points_qh)
-                             {
-                                 InputModel.MatchingCurveQH.Add(new HydroCurvePointViewModel(item.X, item.Y));
-                             }
-                         }
-                         if (graph_qe != null)
-                         {
-                             var points_qe = PhartPerformCurveHelper.GetFeatPointList(graph_qe.GraphType, graph_qe.GeometryInfo, 100, null);
-                             InputModel.MatchingCurveQE = new List<HydroCurvePointViewModel>();
-                             foreach (var item in points_qe)
-                             {
-                                 InputModel.MatchingCurveQE.Add(new HydroCurvePointViewModel(item.X, item.Y));
-                             }
-                         }
-                         if (graph_qp != null)
-                         {
-                             var points_qp = PhartPerformCurveHelper.GetFeatPointList(graph_qp.GraphType, graph_qp.GeometryInfo, 100, null);
-                             InputModel.MatchingCurveQP = new List<HydroCurvePointViewModel>();
-                             foreach (var item in points_qp)
-                             {
-                                 InputModel.MatchingCurveQP.Add(new HydroCurvePointViewModel(item.X, item.Y));
-                             }
-                         }
-                     }*/
+
                 return true;
             }
             return false;
@@ -416,11 +397,28 @@
                 {
                     if (input.CurveDbId == null)
                     {
-                        if ((int)input.ValveType == (int)HStation.Assets.eValveType.GPV)
+                        var list = Task.Run(async () => await new BLL.PhartDiagramRelation().GetExByObjectTypeAndObjectID(HStation.Assets.DataType.ValveMain, vmo.ID)).Result;
+                        if (list != null && list.Count > 0)
                         {
-                        }
-                        else if ((int)vmo.ValveType == (int)HStation.Assets.eValveType.TCV)
-                        {
+                            var def = list.OrderByDescending(x => x.Importance).First();
+                            input.MatchingCurveDbId = def.ID.ToString();
+                            var curve = def.Diagram.GraphList[0].GetFeatPointList();
+                            if (vmo.ValveType == HStation.Assets.eValveType.GPV)
+                            {
+                                input.MatchingCurveQL = new List<HydroCurvePointViewModel>();
+                                foreach (var item in curve)
+                                {
+                                    input.MatchingCurveQL.Add(new HydroCurvePointViewModel(item.X, item.Y));
+                                }
+                            }
+                            else if (vmo.ValveType == HStation.Assets.eValveType.TCV)
+                            {
+                                input.MatchingCurveOL = new List<HydroCurvePointViewModel>();
+                                foreach (var item in curve)
+                                {
+                                    input.MatchingCurveOL.Add(new HydroCurvePointViewModel(item.X, item.Y));
+                                }
+                            }
                         }
                     }
                     if (input.MinorLoss < 0)
@@ -445,11 +443,28 @@
                     input.MatchingModelType = vmo.Name;
                     input.MatchingValveSetting = vmo.ValveSetting;
                     input.MatchingValveType = (eValveType?)(int)vmo.ValveType;
-                    if (vmo.ValveType == HStation.Assets.eValveType.GPV)
+                    var list = Task.Run(async () => await new BLL.PhartDiagramRelation().GetExByObjectTypeAndObjectID(HStation.Assets.DataType.ValveMain, vmo.ID)).Result;
+                    if (list != null && list.Count > 0)
                     {
-                    }
-                    else if (vmo.ValveType == HStation.Assets.eValveType.TCV)
-                    {
+                        var def = list.OrderByDescending(x => x.Importance).First();
+                        input.MatchingCurveDbId = def.ID.ToString();
+                        var curve = def.Diagram.GraphList[0].GetFeatPointList();
+                        if (vmo.ValveType == HStation.Assets.eValveType.GPV)
+                        {
+                            input.MatchingCurveQL = new List<HydroCurvePointViewModel>();
+                            foreach (var item in curve)
+                            {
+                                input.MatchingCurveQL.Add(new HydroCurvePointViewModel(item.X, item.Y));
+                            }
+                        }
+                        else if (vmo.ValveType == HStation.Assets.eValveType.TCV)
+                        {
+                            input.MatchingCurveOL = new List<HydroCurvePointViewModel>();
+                            foreach (var item in curve)
+                            {
+                                input.MatchingCurveOL.Add(new HydroCurvePointViewModel(item.X, item.Y));
+                            }
+                        }
                     }
                 }
                 return true;
@@ -595,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)
@@ -831,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)
             {
@@ -1421,12 +1436,12 @@
             }
             Vmo.AssetsTankMainVmo vmo = null;
             var nameMatching = tankVmos.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)
             {
@@ -1455,14 +1470,31 @@
                 {
                     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.TankMain, vmo.ID)).Result;
+                        if (list != null && list.Count > 0)
+                        {
+                            var def = list.OrderByDescending(x => x.Importance).First();
+                            input.MatchingCurveDbId = def.ID.ToString();
+                            var curve = def.Diagram.GraphList[0].GetFeatPointList();
+                            input.MatchingVolCurve = new List<HydroCurvePointViewModel>();
+                            foreach (var item in curve)
+                            {
+                                input.MatchingVolCurve.Add(new HydroCurvePointViewModel(item.X, item.Y));
+                            }
+                        }
                     }
                 }
                 else
@@ -1472,6 +1504,21 @@
                     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)
+                    {
+                        var def = list.OrderByDescending(x => x.Importance).First();
+                        input.MatchingCurveDbId = def.ID.ToString();
+                        var curve = def.Diagram.GraphList[0].GetFeatPointList();
+                        input.MatchingVolCurve = new List<HydroCurvePointViewModel>();
+                        foreach (var item in curve)
+                        {
+                            input.MatchingVolCurve.Add(new HydroCurvePointViewModel(item.X, item.Y));
+                        }
+                    }
                 }
                 return true;
             }
@@ -1732,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