| | |
| | | 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) |
| | |
| | | { |
| | | // 尝试区间匹配 |
| | | 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) |
| | |
| | | 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)); |
| | | } |
| | | |
| | | } |
| | | } |