From d6f0e111f50f78057ff386f7c6fef7e463d12ba5 Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期五, 20 九月 2024 15:32:22 +0800
Subject: [PATCH] Merge branch 'master' of http://47.103.154.90:83/r/HStation/XHS.V1.0

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-AutoMatching/02-AsstesFormCtrl/PumpMatchingCtrl.cs |   63 ++-----------------------------
 1 files changed, 5 insertions(+), 58 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-AutoMatching/02-AsstesFormCtrl/PumpMatchingCtrl.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-AutoMatching/02-AsstesFormCtrl/PumpMatchingCtrl.cs
index 9e00f0e..ced9648 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-AutoMatching/02-AsstesFormCtrl/PumpMatchingCtrl.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-AutoMatching/02-AsstesFormCtrl/PumpMatchingCtrl.cs
@@ -11,72 +11,19 @@
         }
 
         private List<PumpMatchingViewModel> _allBindingList = null;
-        private BLL.PumpMain _pumpMainBll = null;
 
-        public List<PumpMatchingViewModel> SetBindingData(List<PumpMatchingViewModel> pumpMatchingViewModel, out List<PumpMatchingViewModel> errorList)
+        public List<PumpMatchingViewModel> SetBindingData(List<PumpMatchingViewModel> pumpMatchingViewModel, List<PumpMainVmo> pumpMainVmos, out List<PumpMatchingViewModel> errorList)
         {
-            _pumpMainBll = new BLL.PumpMain();
             errorList = null;
-            _allBindingList = new List<PumpMatchingViewModel>();
+            List<PumpMatchingViewModel> _allBindingList = new List<PumpMatchingViewModel>();
             if (pumpMatchingViewModel == null)
                 return null;
-            var alllist = _pumpMainBll.GetAll().Result;
-            const double speedTolerance = 100;
-            const double flowTolerance = 10;
-            const double headTolerance = 5;
-            const double efficiencyTolerance = 0.05;
-            foreach (var viewModel in pumpMatchingViewModel)
+            foreach (var item in pumpMatchingViewModel)
             {
-                foreach (var pumpMain in alllist)
-                {
-                    // 灏濊瘯缁濆鍖归厤
-                    var absoluteMatch = alllist.Where(item =>
-                        viewModel.RatedN == item.RatedSpeed &&
-                        viewModel.RatedQ == item.RatedFlow &&
-                        viewModel.RatedH == item.RatedHead &&
-                        viewModel.RatedP == item.RatedPower).ToList();
-                    if (absoluteMatch != null)
-                    {
-                    }
-                    else
-                    {
-                        // 灏濊瘯鍖洪棿鍖归厤
-                        var rangeMatch = alllist.Where(item =>
-                           (viewModel.RatedN.HasValue ? Math.Abs(viewModel.RatedN.Value - item.RatedSpeed) <= speedTolerance : true) &&
-                           (viewModel.RatedQ.HasValue ? Math.Abs(viewModel.RatedQ.Value - item.RatedFlow) <= flowTolerance : true) &&
-                           (viewModel.RatedH.HasValue ? Math.Abs(viewModel.RatedH.Value - item.RatedHead) <= headTolerance : true) &&
-                           (Math.Abs(viewModel.RatedP - item.RatedPower) <= efficiencyTolerance)).ToList();
-                        if (rangeMatch != null)
-                        {
-                            var vmo = new Vmo.PumpMainVmo();
-                            int firstCount = 0;
-                            foreach (var item in rangeMatch)
-                            {
-                                int commonCount = CountCommonCharacters(viewModel.ModelType, item.Name);
-                                if (commonCount > firstCount)
-                                {
-                                    vmo = item;
-                                    firstCount = commonCount;
-                                }
-                            }
-                        }
-                    }
-                }
+                var result = AsstesAutoMatchingHelper.PumpMatching(item, pumpMainVmos);
             }
             this.pumpMatchingViewModelBindingSource.DataSource = _allBindingList;
-            return new List<PumpMatchingViewModel>();
-        }
-
-        private static int CountCommonCharacters(string baseString, string comparisonString)
-        {
-            // 灏嗗瓧绗︿覆杞崲涓哄瓧绗﹂泦鍚�
-            HashSet<char> baseChars = new HashSet<char>(baseString);
-            HashSet<char> comparisonChars = new HashSet<char>(comparisonString);
-
-            // 璁$畻涓や釜闆嗗悎鐨勪氦闆�
-            int commonCount = baseChars.Intersect(comparisonChars).Count();
-
-            return commonCount;
+            return _allBindingList;
         }
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3