lixiaojun
2024-09-26 158292021eb0b31e494b5fdc26a31c58af0bf01b
WinFrmUI/HStation.WinFrmUI.Xhs.Core/04-simulation/06-simulation/01-autoMatching/02-AsstesFormCtrl/AssetsMatchingHelper.cs
@@ -1,15 +1,13 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace HStation.WinFrmUI
namespace HStation.WinFrmUI
{
    public class AssetsMatchingHelper
    {
        private readonly Lazy<BLL.XhsPumpMainPhartMappingExtensions> _bll_ex = new();
        private const double _caliberTolerance = 10.0;
        private const double speedTolerance = 100;
        private const double flowTolerance = 10;
        private const double headTolerance = 5;
        private const double powerTolerance = 0.05;
        private const double _speedTolerance = 100;
        private const double _flowTolerance = 10;
        private const double _headTolerance = 5;
        private const double _powerTolerance = 0.05;
        //资产自动匹配
        public static async Task<AssetsAutoMatchingViewModel> AssetsMatching(AssetsAutoMatchingViewModel assetsAutoMatchingView)
@@ -479,10 +477,10 @@
            {
                // 尝试区间匹配
                var rangeMatch = pumpMainVmos.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) <= powerTolerance)).ToList();
                   (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) <= _powerTolerance)).ToList();
                if (rangeMatch != null && rangeMatch.Count != 0)
                {
                    foreach (var item in rangeMatch)
@@ -620,5 +618,19 @@
            int commonCount = baseChars.Intersect(comparisonChars).Count();
            return commonCount;
        }
        /// <summary>
        /// 获取两个字符串的所有交集
        /// </summary>
        /// <param name="str1"></param>
        /// <param name="str2"></param>
        /// <returns></returns>
        public static string GetIntersect(string str1, string str2)
        {
            if (str1 == null || str2 == null) return null;
            return string.Join("", str1.Intersect(str2));
        }
    }
}