| | |
| | | using HStation.WinFrmUI.PhartRelation; |
| | | using Swashbuckle.AspNetCore.SwaggerGen; |
| | | using System.Linq; |
| | | using Yw.WinFrmUI.Q3d; |
| | | |
| | | namespace HStation.WinFrmUI |
| | | { |
| | | public class AssetsMatchingHelper |
| | | { |
| | | private readonly Lazy<BLL.XhsPumpMainPhartMappingExtensions> _bll_ex = new(); |
| | | private readonly Lazy<BLL.PhartDiagramRelation> _bll_ex = new(); |
| | | private const double _caliberTolerance = 10.0; |
| | | private const double _speedTolerance = 100; |
| | | private const double _flowTolerance = 10; |
| | |
| | | InputModel.MatchingRatedP = vmo.RatedPower; |
| | | InputModel.MatchingDbId = vmo.ID.ToString(); |
| | | InputModel.MatchingModelType = vmo.Name; |
| | | var list = Task.Run(async () => await new BLL.XhsPumpMainPhartMappingExtensions().GetByPumpMainID(vmo.ID)).Result; |
| | | var list = Task.Run(async () => await new BLL.PhartDiagramRelation().GetExByObjectTypeAndObjectID(HStation.Assets.DataType.PumpMain, vmo.ID)).Result; |
| | | 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.PumpQH); |
| | | var graph_qe = maxImportanceItem.Diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQE); |
| | | var graph_qp = maxImportanceItem.Diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQP); |
| | | 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); |
| | |
| | | input.MatchingDiameter = vmo.Caliber; |
| | | if (input.ValveSetting == null) |
| | | input.MatchingValveSetting = vmo.ValveSetting; |
| | | if (input.DbId == null) |
| | | { |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | |
| | | return false; |
| | | } |
| | | |
| | | //冷却器匹配 |
| | | public static bool Matching(HydroCoolingMatchingViewModel input, List<AssetsCoolingMainVmo> allCoolingList) |
| | | { |
| | | //输入参数验证 |
| | | if (input == null) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | //数据源没有数据则没有匹配成功 |
| | | if (allCoolingList == null || allCoolingList.Count < 1) |
| | | { |
| | | return false; |
| | | } |
| | | |
| | | //权重字典 |
| | | var dict = new Dictionary<AssetsCoolingMainVmo, double>(); |
| | | foreach (var item in allCoolingList) |
| | | { |
| | | dict.Add(item, 0); |
| | | } |
| | | |
| | | //型号 |
| | | int modelTypeWeight = 10; |
| | | if (!string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | foreach (var item in allCoolingList) |
| | | { |
| | | if (!string.IsNullOrEmpty(item.Name)) |
| | | { |
| | | var count = item.Name.ToLower().Intersect(input.ModelType.ToLower()).Count(); |
| | | dict[item] += count * modelTypeWeight; |
| | | } |
| | | } |
| | | } |
| | | |
| | | //材质 |
| | | int materialWeight = 5; |
| | | if (!string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | foreach (var item in allCoolingList) |
| | | { |
| | | if (!string.IsNullOrEmpty(item.Material)) |
| | | { |
| | | var count = item.Material.ToLower().Intersect(input.Material.ToLower()).Count(); |
| | | dict[item] += count * materialWeight; |
| | | } |
| | | } |
| | | } |
| | | |
| | | //口径 |
| | | int caliberWeight = 1; |
| | | if (input.Caliber.HasValue) |
| | | { |
| | | foreach (var item in allCoolingList) |
| | | { |
| | | if (item.Caliber.HasValue) |
| | | { |
| | | var diff = Math.Abs(item.Caliber.Value - input.Caliber.Value); |
| | | dict[item] += diff / input.Caliber.Value * 100 * caliberWeight; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 关键字 |
| | | int keywordWeight = 1; |
| | | foreach (var item in allCoolingList) |
| | | { |
| | | 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; |
| | | } |
| | | if (!string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | var count = item.KeyWords.Count(x => input.Material.ToLower().Contains(x.ToLower())); |
| | | dict[item] += count * keywordWeight; |
| | | } |
| | | } |
| | | } |
| | | |
| | | //标签 |
| | | int flagWeight = 1; |
| | | foreach (var item in allCoolingList) |
| | | { |
| | | if (item.Flags != null && item.Flags.Count > 0) |
| | | { |
| | | if (item.Flags.Contains(HStation.Assets.Flags.默认)) |
| | | { |
| | | dict[item] += flagWeight; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var cooling = dict.OrderBy(x => x.Value).LastOrDefault().Key; |
| | | input.MatchingDbId = cooling.ID.ToString(); |
| | | if (string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | input.MatchingModelType = cooling.Name; |
| | | } |
| | | if (string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | input.MatchingMaterial = cooling.Material; |
| | | } |
| | | if (!input.Caliber.HasValue || input.Caliber.Value <= 0) |
| | | { |
| | | input.Caliber = cooling.Caliber; |
| | | } |
| | | if (input.Coefficient <= 1) |
| | | { |
| | | input.MatchingCoefficient = cooling.Coefficient; |
| | | } |
| | | if (input.LowerLimit <= 0) |
| | | { |
| | | input.MatchingLowerLimit = cooling.LowerLimit; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取两个字符串的所有交集 |
| | | /// </summary> |