| | |
| | | using HStation.WinFrmUI.PhartRelation; |
| | | using HStation.CAL; |
| | | using HStation.WinFrmUI.PhartRelation; |
| | | using Swashbuckle.AspNetCore.SwaggerGen; |
| | | using System.Linq; |
| | | using System.Windows.Input; |
| | |
| | | private const double _flowTolerance = 10; |
| | | private const double _headTolerance = 5; |
| | | private const double _powerTolerance = 0.05; |
| | | |
| | | private const double _valveLift = 10;//阀门开度范围 |
| | | private const int _angle = 1;//角度范围 |
| | | |
| | |
| | | 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; |
| | |
| | | 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) |
| | | { |
| | |
| | | //三通匹配 |
| | | foreach (var item in assetsAutoMatchingView.Threelinks) |
| | | { |
| | | if (MatchingThreelink(item, allThreeLink)) |
| | | if (Matching(item, allThreeLink)) |
| | | { |
| | | IsMaching = true; |
| | | } |
| | |
| | | //四通匹配 |
| | | foreach (var item in assetsAutoMatchingView.Fourlinks) |
| | | { |
| | | if (MatchingFourlink(item, allFourLink)) |
| | | if (Matching(item, allFourLink)) |
| | | { |
| | | IsMaching = true; |
| | | } |
| | |
| | | //管道匹配 |
| | | foreach (var item in assetsAutoMatchingView.Pipes) |
| | | { |
| | | if (MatchingPipe(item, allPipeLine)) |
| | | if (Matching(item, allPipeLine)) |
| | | { |
| | | IsMaching = true; |
| | | } |
| | |
| | | //阀门匹配 |
| | | foreach (var item in assetsAutoMatchingView.Valves) |
| | | { |
| | | if (MatchingValve(item, allValve)) |
| | | if (Matching(item, allValve)) |
| | | { |
| | | IsMaching = true; |
| | | } |
| | |
| | | //弯头匹配 |
| | | foreach (var item in assetsAutoMatchingView.Elbows) |
| | | { |
| | | if (MatchingElbow(item, allElbow)) |
| | | if (Matching(item, allElbow)) |
| | | { |
| | | IsMaching = true; |
| | | } |
| | |
| | | //喷头匹配 |
| | | foreach (var item in assetsAutoMatchingView.Nozzles) |
| | | { |
| | | if (MatchingSprinkler(item, allSprinkler)) |
| | | if (Matching(item, allSprinkler)) |
| | | { |
| | | IsMaching = true; |
| | | } |
| | | } |
| | | |
| | | //喷头匹配 |
| | | foreach (var item in assetsAutoMatchingView.Coolings) |
| | | { |
| | | if (Matching(item, allCoolingMain)) |
| | | { |
| | | IsMaching = true; |
| | | } |
| | |
| | | //闷头匹配 |
| | | foreach (var item in assetsAutoMatchingView.Bluntheads) |
| | | { |
| | | if (MatchingBlunthead(item, allBluntheadMain)) |
| | | if (Matching(item, allBluntheadMain)) |
| | | { |
| | | IsMaching = true; |
| | | } |
| | |
| | | //水池匹配 |
| | | foreach (var item in assetsAutoMatchingView.Tanks) |
| | | { |
| | | if (MatchingTank(item, allTankMain)) |
| | | if (Matching(item, allTankMain)) |
| | | { |
| | | IsMaching = true; |
| | | } |
| | |
| | | //消火栓匹配 |
| | | foreach (var item in assetsAutoMatchingView.Hydrants) |
| | | { |
| | | if (MatchingHydrant(item, allHydrantMain)) |
| | | if (Matching(item, allHydrantMain)) |
| | | { |
| | | IsMaching = true; |
| | | } |
| | |
| | | //压力表匹配 |
| | | foreach (var item in assetsAutoMatchingView.Pressmeters) |
| | | { |
| | | if (MatchingPressmeter(item, allPressmeterMain)) |
| | | if (Matching(item, allPressmeterMain)) |
| | | { |
| | | IsMaching = true; |
| | | } |
| | |
| | | //过渡件匹配 |
| | | foreach (var item in assetsAutoMatchingView.Translations) |
| | | { |
| | | if (MatchingTranslation(item, allTranslationMain)) |
| | | if (Matching(item, allTranslationMain)) |
| | | { |
| | | IsMaching = true; |
| | | } |
| | |
| | | { |
| | | // 尝试区间匹配 |
| | | var rangeMatch = AssetsPumpMainVmos.Where(item => |
| | | (InputModel.RatedN.HasValue ? Math.Abs(InputModel.RatedN.Value - item.RatedSpeed) <= _speedTolerance : true) && |
| | | (InputModel.RatedQ.HasValue ? Math.Abs(InputModel.RatedQ.Value - item.RatedFlow) <= _flowTolerance : true) && |
| | | (InputModel.RatedH.HasValue ? Math.Abs(InputModel.RatedH.Value - item.RatedHead) <= _headTolerance : true) && |
| | | (InputModel.RatedN > 0 ? Math.Abs(InputModel.RatedN - item.RatedSpeed) <= _speedTolerance : true) && |
| | | (InputModel.RatedQ > 0 ? Math.Abs(InputModel.RatedQ - item.RatedFlow) <= _flowTolerance : true) && |
| | | (InputModel.RatedH > 0 ? Math.Abs(InputModel.RatedH - item.RatedHead) <= _headTolerance : true) && |
| | | (Math.Abs(InputModel.RatedP - item.RatedPower) <= _powerTolerance)).ToList(); |
| | | if (rangeMatch != null && rangeMatch.Count != 0) |
| | | { |
| | |
| | | InputModel.MatchingCurveQE.Add(new HydroCurvePointViewModel(item.X, item.Y)); |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | //阀门匹配 |
| | | public static bool MatchingValve(HydroValveMatchingViewModel input, List<Vmo.AssetsValveMainVmo> valveMainVmos) |
| | | public static bool Matching(HydroValveMatchingViewModel input, List<AssetsValveMainVmo> valveMainVmos) |
| | | { |
| | | bool isNotarize = false; //是否确定 |
| | | if (valveMainVmos == null) |
| | | //输入参数验证 |
| | | if (input == null) |
| | | { |
| | | return true; |
| | | return false; |
| | | } |
| | | HStation.Vmo.AssetsValveMainVmo vmo = null; |
| | | //口径最小差值 |
| | | // 绝对匹配 |
| | | valveMainVmos = valveMainVmos.Where(x => (int)x.ValveType == (int)input.ValveType).ToList(); |
| | | |
| | | var nameMatching = valveMainVmos.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();//使用型号名或者关键字找出相同字符在1以上并且进行排序 |
| | | |
| | | if (nameMatching.Count > 0) |
| | | //数据源没有数据则没有匹配成功 |
| | | if (valveMainVmos == null || valveMainVmos.Count < 1) |
| | | { |
| | | var absoluteMatching = nameMatching.Where(i => |
| | | ((i.Caliber == null) || Math.Abs(Convert.ToInt64(i.Caliber) - input.Diameter) <= _caliberTolerance) && //直径约束 |
| | | i.Material == input.Material //材料约束 |
| | | ).ToList(); |
| | | if (absoluteMatching.Count > 1) |
| | | return false; |
| | | } |
| | | |
| | | //权重字典 |
| | | var dict = new Dictionary<AssetsValveMainVmo, double>(); |
| | | foreach (var item in valveMainVmos) |
| | | { |
| | | dict.Add(item, 0); |
| | | } |
| | | |
| | | //型号 |
| | | int modelTypeWeight = 10; |
| | | if (!string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | foreach (var item in valveMainVmos) |
| | | { |
| | | var defaultList = absoluteMatching.Where(x => x.Flags.Contains("默认值")).ToList(); |
| | | //取默认 |
| | | if (defaultList.Count > 0) |
| | | if (!string.IsNullOrEmpty(item.Name)) |
| | | { |
| | | vmo = defaultList.First(); |
| | | } |
| | | else if (defaultList.Count <= 0) |
| | | { |
| | | vmo = valveMainVmos.First(); |
| | | var count = item.Name.ToLower().Intersect(input.ModelType.ToLower()).Count(); |
| | | dict[item] += count * modelTypeWeight; |
| | | } |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | vmo = valveMainVmos.First(); |
| | | } |
| | | else if (nameMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = nameMatching.First(); |
| | | } |
| | | else |
| | | //材质 |
| | | int materialWeight = 5; |
| | | if (!string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | var absoluteMatching = valveMainVmos.Where(i => |
| | | ((i.Caliber == null) || Math.Abs(Convert.ToInt64(i.Caliber) - input.Diameter) <= _caliberTolerance) && //直径约束 |
| | | i.Material == input.Material //材料约束 |
| | | ).ToList(); |
| | | if (absoluteMatching.Count > 1) |
| | | foreach (var item in valveMainVmos) |
| | | { |
| | | var defaultList = absoluteMatching.Where(x => x.Flags.Contains("默认值")).ToList(); |
| | | //取默认 |
| | | if (defaultList.Count > 0) |
| | | if (!string.IsNullOrEmpty(item.Material)) |
| | | { |
| | | vmo = defaultList.First(); |
| | | } |
| | | else if (defaultList.Count <= 0) |
| | | { |
| | | vmo = valveMainVmos.First(); |
| | | var count = item.Material.ToLower().Intersect(input.Material.ToLower()).Count(); |
| | | dict[item] += count * materialWeight; |
| | | } |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | vmo = valveMainVmos.First(); |
| | | } |
| | | if (vmo != null) |
| | | |
| | | //口径 |
| | | int caliberWeight = 1; |
| | | if (input.Diameter > 0) |
| | | { |
| | | if (!isNotarize) |
| | | foreach (var item in valveMainVmos) |
| | | { |
| | | if (input.CurveDbId == null) |
| | | if (item.Caliber.HasValue) |
| | | { |
| | | var list = Task.Run(async () => await new BLL.PhartDiagramRelation().GetExByObjectTypeAndObjectID(HStation.Assets.DataType.ValveMain, vmo.ID)).Result; |
| | | if (list != null && list.Count > 0) |
| | | var diff = Math.Abs(item.Caliber.Value - input.Diameter); |
| | | dict[item] += diff / input.Diameter * 100 * caliberWeight; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 关键字 |
| | | int keywordWeight = 1; |
| | | foreach (var item in valveMainVmos) |
| | | { |
| | | 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 valveMainVmos) |
| | | { |
| | | if (item.Flags != null && item.Flags.Count > 0) |
| | | { |
| | | if (item.Flags.Contains(HStation.Assets.Flags.默认)) |
| | | { |
| | | dict[item] += flagWeight; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var valve = dict.OrderBy(x => x.Value).LastOrDefault().Key; |
| | | input.MatchingDbId = valve.ID.ToString(); |
| | | if (string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | input.MatchingModelType = valve.Name; |
| | | } |
| | | if (string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | input.MatchingMaterial = valve.Material; |
| | | } |
| | | if (input.Diameter <= 0 && valve.Caliber.HasValue) |
| | | { |
| | | input.Diameter = valve.Caliber.Value; |
| | | } |
| | | if (input.MinorLoss < 0) |
| | | { |
| | | input.MatchingMinorLoss = valve.MinorLoss; |
| | | } |
| | | if (input.ValveSetting == null) |
| | | { |
| | | input.MatchingValveSetting = valve.ValveSetting; |
| | | } |
| | | if (input.CurveDbId == null) |
| | | { |
| | | var list = Task.Run(async () => |
| | | await new BLL.PhartDiagramRelation().GetExByObjectTypeAndObjectID(HStation.Assets.DataType.ValveMain, valve.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(); |
| | | if (valve.ValveType == HStation.Assets.eValveType.GPV) |
| | | { |
| | | input.MatchingCurveQL = new List<HydroCurvePointViewModel>(); |
| | | foreach (var item in curve) |
| | | { |
| | | 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)); |
| | | } |
| | | } |
| | | input.MatchingCurveQL.Add(new HydroCurvePointViewModel(item.X, item.Y)); |
| | | } |
| | | } |
| | | if (input.MinorLoss < 0) |
| | | else if (valve.ValveType == HStation.Assets.eValveType.TCV) |
| | | { |
| | | input.MatchingMinorLoss = vmo.MinorLoss; |
| | | } |
| | | if (!input.MatchingDiameter.HasValue) |
| | | input.MatchingDiameter = vmo.Caliber; |
| | | if (input.ValveSetting == null) |
| | | input.MatchingValveSetting = vmo.ValveSetting; |
| | | if (input.DbId == null) |
| | | { |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | input.MatchingMinorLoss = vmo.MinorLoss; |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | input.MatchingDiameter = vmo.Caliber; |
| | | input.MatchingMaterial = vmo.Material; |
| | | input.MatchingModelType = vmo.Name; |
| | | input.MatchingValveSetting = vmo.ValveSetting; |
| | | input.MatchingValveType = (eValveType?)(int)vmo.ValveType; |
| | | 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(); |
| | | if (vmo.ValveType == HStation.Assets.eValveType.GPV) |
| | | input.MatchingCurveOL = new List<HydroCurvePointViewModel>(); |
| | | foreach (var item in curve) |
| | | { |
| | | 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)); |
| | | } |
| | | input.MatchingCurveOL.Add(new HydroCurvePointViewModel(item.X, item.Y)); |
| | | } |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | |
| | | return true; |
| | | } |
| | | |
| | | //管道匹配 |
| | | public static bool MatchingPipe(HydroPipeMatchingViewModel input, List<Vmo.AssetsPipeMainVmo> pipeLineMainVmos) |
| | | public static bool Matching(HydroPipeMatchingViewModel input, List<AssetsPipeMainVmo> pipeLineMainVmos) |
| | | { |
| | | bool isNotarize = false; //是否确定 |
| | | if (pipeLineMainVmos == null) |
| | | //输入参数验证 |
| | | if (input == null) |
| | | { |
| | | return true; |
| | | return false; |
| | | } |
| | | Vmo.AssetsPipeMainVmo vmo = null; |
| | | |
| | | var nameMatching = pipeLineMainVmos.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(); |
| | | |
| | | if (nameMatching.Count > 1) |
| | | //数据源没有数据则没有匹配成功 |
| | | if (pipeLineMainVmos == null || pipeLineMainVmos.Count < 1) |
| | | { |
| | | var absoluteMatching = nameMatching.Where(i => |
| | | ((i.Caliber == null) || Math.Abs(Convert.ToInt64(i.Caliber) - input.Diameter) <= _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 = pipeLineMainVmos.First(); |
| | | } |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | vmo = pipeLineMainVmos.First(); |
| | | return false; |
| | | } |
| | | else if (nameMatching.Count == 1) |
| | | |
| | | //权重字典 |
| | | var dict = new Dictionary<AssetsPipeMainVmo, double>(); |
| | | foreach (var item in pipeLineMainVmos) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = nameMatching.First(); |
| | | dict.Add(item, 0); |
| | | } |
| | | else |
| | | |
| | | //型号 |
| | | int modelTypeWeight = 10; |
| | | if (!string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | var absoluteMatching = pipeLineMainVmos.Where(i => |
| | | ((i.Caliber == null) || Math.Abs(Convert.ToInt64(i.Caliber) - input.Diameter) <= _caliberTolerance) && //直径约束 |
| | | i.Material == input.Material //材料约束 |
| | | ).ToList(); |
| | | if (absoluteMatching.Count > 1) |
| | | foreach (var item in pipeLineMainVmos) |
| | | { |
| | | var defaultList = absoluteMatching.Where(x => x.Flags.Contains("默认值")).ToList(); |
| | | //取默认 |
| | | if (defaultList.Count > 0) |
| | | if (!string.IsNullOrEmpty(item.Name)) |
| | | { |
| | | vmo = defaultList.First(); |
| | | } |
| | | else if (defaultList.Count <= 0) |
| | | { |
| | | vmo = pipeLineMainVmos.First(); |
| | | var count = item.Name.ToLower().Intersect(input.ModelType.ToLower()).Count(); |
| | | dict[item] += count * modelTypeWeight; |
| | | } |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | vmo = pipeLineMainVmos.First(); |
| | | } |
| | | if (vmo != null) |
| | | |
| | | //材质 |
| | | int materialWeight = 5; |
| | | if (!string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | if (!isNotarize) |
| | | foreach (var item in pipeLineMainVmos) |
| | | { |
| | | if (input.DbId == null) |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | if (input.Material == null) |
| | | input.MatchingMaterial = vmo.Material; |
| | | if (input.MinorLoss < 0) |
| | | input.MatchingMinorLoss = vmo.MinorLoss; |
| | | switch (input.eAlgorithmType) |
| | | if (!string.IsNullOrEmpty(item.Material)) |
| | | { |
| | | case eAlgorithmType.Hazen: |
| | | input.MatchingRoughness = vmo.Hazen; |
| | | break; |
| | | |
| | | case eAlgorithmType.Manning: |
| | | input.MatchingRoughness = vmo.Manning; |
| | | break; |
| | | |
| | | case eAlgorithmType.Darcy: |
| | | input.MatchingRoughness = vmo.Darcy; |
| | | break; |
| | | |
| | | default: |
| | | input.MatchingRoughness = vmo.Hazen; |
| | | break; |
| | | var count = item.Material.ToLower().Intersect(input.Material.ToLower()).Count(); |
| | | dict[item] += count * materialWeight; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | switch (input.eAlgorithmType) |
| | | { |
| | | case eAlgorithmType.Hazen: |
| | | input.MatchingRoughness = vmo.Hazen; |
| | | break; |
| | | |
| | | case eAlgorithmType.Manning: |
| | | input.MatchingRoughness = vmo.Manning; |
| | | break; |
| | | |
| | | case eAlgorithmType.Darcy: |
| | | input.MatchingRoughness = vmo.Darcy; |
| | | break; |
| | | |
| | | default: |
| | | input.MatchingRoughness = vmo.Hazen; |
| | | break; |
| | | } |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | input.MatchingMaterial = vmo.Material; |
| | | input.MatchingModelType = vmo.Name; |
| | | input.MatchingMinorLoss = vmo.MinorLoss; |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | //弯头匹配 |
| | | public static bool MatchingElbow(HydroElbowMatchingViewModel input, List<Vmo.AssetsElbowMainVmo> elbowMainVmos) |
| | | { |
| | | bool isNotarize = false; //是否确定 |
| | | if (elbowMainVmos == null || input == null || elbowMainVmos.Count == 0) |
| | | //口径 |
| | | int caliberWeight = 1; |
| | | if (input.Diameter > 0) |
| | | { |
| | | return true; |
| | | foreach (var item in pipeLineMainVmos) |
| | | { |
| | | if (item.Caliber.HasValue) |
| | | { |
| | | var diff = Math.Abs(item.Caliber.Value - input.Diameter); |
| | | dict[item] += diff / input.Diameter * 100 * caliberWeight; |
| | | } |
| | | } |
| | | } |
| | | 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(); |
| | | |
| | | if (nameMatching.Count > 1) |
| | | // 关键字 |
| | | int keywordWeight = 1; |
| | | foreach (var item in pipeLineMainVmos) |
| | | { |
| | | 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) |
| | | if (item.KeyWords != null && item.KeyWords.Count > 0) |
| | | { |
| | | var defaultList = absoluteMatching.Where(x => x.Flags.Contains("默认值")).ToList(); |
| | | //取默认 |
| | | if (defaultList.Count > 0) |
| | | if (!string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | vmo = defaultList.First(); |
| | | var count = item.KeyWords.Count(x => input.ModelType.ToLower().Contains(x.ToLower())); |
| | | dict[item] += count * keywordWeight; |
| | | } |
| | | else if (defaultList.Count <= 0) |
| | | if (!string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | vmo = elbowMainVmos.First(); |
| | | var count = item.KeyWords.Count(x => input.Material.ToLower().Contains(x.ToLower())); |
| | | dict[item] += count * keywordWeight; |
| | | } |
| | | } |
| | | 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) |
| | | //标签 |
| | | int flagWeight = 1; |
| | | foreach (var item in pipeLineMainVmos) |
| | | { |
| | | if (!isNotarize) |
| | | if (item.Flags != null && item.Flags.Count > 0) |
| | | { |
| | | if (!input.MinorLoss.HasValue) |
| | | if (item.Flags.Contains(HStation.Assets.Flags.默认)) |
| | | { |
| | | 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; |
| | | dict[item] += flagWeight; |
| | | } |
| | | } |
| | | 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; |
| | | |
| | | var pipe = dict.OrderBy(x => x.Value).LastOrDefault().Key; |
| | | input.MatchingDbId = pipe.ID.ToString(); |
| | | if (string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | input.MatchingModelType = pipe.Name; |
| | | } |
| | | if (input.Roughness == 0) |
| | | { |
| | | input.MatchingRoughness = pipe.Hazen; |
| | | } |
| | | if (string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | input.MatchingMaterial = pipe.Material; |
| | | } |
| | | if (input.MinorLoss < 0) |
| | | { |
| | | input.MatchingMinorLoss = pipe.MinorLoss; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | //三通匹配 |
| | | public static bool MatchingThreelink(HydroThreelinkMatchingViewModel input, List<Vmo.AssetsThreelinkMainVmo> threelinkVmos) |
| | | public static bool Matching(HydroThreelinkMatchingViewModel input, List<AssetsThreelinkMainVmo> threelinkVmos) |
| | | { |
| | | bool isNotarize = false; //是否确定 |
| | | Vmo.AssetsThreelinkMainVmo vmo = null; |
| | | if (threelinkVmos == null || input == null || threelinkVmos.Count == 0) |
| | | //输入参数验证 |
| | | if (input == null) |
| | | { |
| | | return true; |
| | | return false; |
| | | } |
| | | var nameMatching = threelinkVmos.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(); |
| | | |
| | | if (nameMatching.Count > 1) |
| | | //数据源没有数据则没有匹配成功 |
| | | if (threelinkVmos == null || threelinkVmos.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) |
| | | return false; |
| | | } |
| | | |
| | | //权重字典 |
| | | var dict = new Dictionary<AssetsThreelinkMainVmo, double>(); |
| | | foreach (var item in threelinkVmos) |
| | | { |
| | | dict.Add(item, 0); |
| | | } |
| | | |
| | | //型号 |
| | | int modelTypeWeight = 10; |
| | | if (!string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | foreach (var item in threelinkVmos) |
| | | { |
| | | var defaultList = absoluteMatching.Where(x => x.Flags.Contains("默认值")).ToList(); |
| | | //取默认 |
| | | if (defaultList.Count > 0) |
| | | if (!string.IsNullOrEmpty(item.Name)) |
| | | { |
| | | vmo = defaultList.First(); |
| | | } |
| | | else if (defaultList.Count <= 0) |
| | | { |
| | | vmo = threelinkVmos.First(); |
| | | var count = item.Name.ToLower().Intersect(input.ModelType.ToLower()).Count(); |
| | | dict[item] += count * modelTypeWeight; |
| | | } |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | vmo = threelinkVmos.First(); |
| | | } |
| | | else if (nameMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = nameMatching.First(); |
| | | } |
| | | else |
| | | //材质 |
| | | int materialWeight = 5; |
| | | if (!string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | var absoluteMatching = threelinkVmos.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) |
| | | foreach (var item in threelinkVmos) |
| | | { |
| | | var defaultList = absoluteMatching.Where(x => x.Flags.Contains("默认值")).ToList(); |
| | | //取默认 |
| | | if (defaultList.Count > 0) |
| | | if (!string.IsNullOrEmpty(item.Material)) |
| | | { |
| | | vmo = defaultList.First(); |
| | | } |
| | | else if (defaultList.Count <= 0) |
| | | { |
| | | vmo = threelinkVmos.First(); |
| | | var count = item.Material.ToLower().Intersect(input.Material.ToLower()).Count(); |
| | | dict[item] += count * materialWeight; |
| | | } |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | } |
| | | |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | vmo = threelinkVmos.First(); |
| | | } |
| | | if (vmo != null) |
| | | //口径 |
| | | int caliberWeight = 1; |
| | | if (input.Caliber > 0) |
| | | { |
| | | if (!isNotarize) |
| | | foreach (var item in threelinkVmos) |
| | | { |
| | | if (!input.MinorLoss.HasValue) |
| | | input.MatchingMinorLoss = vmo.MinorLoss; |
| | | if (input.DbId == null) |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | if (!input.RunningThroughLoss.HasValue) |
| | | input.MatchingRunningThroughLoss = vmo.RunThroughMinorLoss; |
| | | if (!input.MatchingBranchThroughLoss.HasValue) |
| | | input.MatchingRunningThroughLoss = vmo.BranchThroughMinorLoss; |
| | | if (item.Caliber.HasValue) |
| | | { |
| | | var diff = Math.Abs(item.Caliber.Value - input.Caliber); |
| | | dict[item] += diff / input.Caliber * 100 * caliberWeight; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | input.MatchingMinorLoss = vmo.MinorLoss; |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | input.MatchingMaterial = vmo.Material; |
| | | input.MatchingModelType = vmo.Name; |
| | | input.MatchingRunningThroughLoss = vmo.RunThroughMinorLoss; |
| | | input.MatchingBranchThroughLoss = vmo.BranchThroughMinorLoss; |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | |
| | | // 关键字 |
| | | int keywordWeight = 1; |
| | | foreach (var item in threelinkVmos) |
| | | { |
| | | 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 threelinkVmos) |
| | | { |
| | | if (item.Flags != null && item.Flags.Count > 0) |
| | | { |
| | | if (item.Flags.Contains(HStation.Assets.Flags.默认)) |
| | | { |
| | | dict[item] += flagWeight; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var threelink = dict.OrderBy(x => x.Value).LastOrDefault().Key; |
| | | input.MatchingDbId = threelink.ID.ToString(); |
| | | if (string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | input.MatchingModelType = threelink.Name; |
| | | } |
| | | if (string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | input.MatchingMaterial = threelink.Material; |
| | | } |
| | | if (input.Caliber <= 0) |
| | | { |
| | | input.Caliber = threelink.Caliber ?? 0; |
| | | } |
| | | if (input.MinorLoss <= 0) |
| | | { |
| | | input.MatchingMinorLoss = threelink.MinorLoss; |
| | | } |
| | | if (input.RunningThroughLoss <= 0) |
| | | { |
| | | input.MatchingRunningThroughLoss = threelink.RunThroughMinorLoss; |
| | | } |
| | | if (input.MatchingBranchThroughLoss <= 0) |
| | | { |
| | | input.MatchingBranchThroughLoss = threelink.BranchThroughMinorLoss; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | //四通匹配 |
| | | public static bool MatchingFourlink(HydroFourlinkMatchingViewModel input, List<Vmo.AssetsFourlinkMainVmo> fourLinkVmos) |
| | | public static bool Matching(HydroFourlinkMatchingViewModel input, List<AssetsFourlinkMainVmo> fourLinkVmos) |
| | | { |
| | | bool isNotarize = false; //是否确定 |
| | | if (fourLinkVmos == null || input == null || fourLinkVmos.Count == 0) |
| | | //输入参数验证 |
| | | if (input == null) |
| | | { |
| | | return true; |
| | | return false; |
| | | } |
| | | 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 |
| | | ) //先进行筛选,后进行从大到小排序 |
| | | .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(); |
| | | |
| | | if (nameMatching.Count > 1) |
| | | //数据源没有数据则没有匹配成功 |
| | | if (fourLinkVmos == null || fourLinkVmos.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) |
| | | return false; |
| | | } |
| | | |
| | | //权重字典 |
| | | var dict = new Dictionary<AssetsFourlinkMainVmo, double>(); |
| | | foreach (var item in fourLinkVmos) |
| | | { |
| | | dict.Add(item, 0); |
| | | } |
| | | |
| | | //型号 |
| | | int modelTypeWeight = 10; |
| | | if (!string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | foreach (var item in fourLinkVmos) |
| | | { |
| | | var defaultList = absoluteMatching.Where(x => x.Flags.Contains("默认值")).ToList(); |
| | | //取默认 |
| | | if (defaultList.Count > 0) |
| | | if (!string.IsNullOrEmpty(item.Name)) |
| | | { |
| | | vmo = defaultList.First(); |
| | | } |
| | | else if (defaultList.Count <= 0) |
| | | { |
| | | vmo = fourLinkVmos.First(); |
| | | var count = item.Name.ToLower().Intersect(input.ModelType.ToLower()).Count(); |
| | | dict[item] += count * modelTypeWeight; |
| | | } |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | vmo = fourLinkVmos.First(); |
| | | } |
| | | else if (nameMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = nameMatching.First(); |
| | | } |
| | | else |
| | | //材质 |
| | | int materialWeight = 5; |
| | | if (!string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | var absoluteMatching = fourLinkVmos.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) |
| | | foreach (var item in fourLinkVmos) |
| | | { |
| | | var defaultList = absoluteMatching.Where(x => x.Flags.Contains("默认值")).ToList(); |
| | | //取默认 |
| | | if (defaultList.Count > 0) |
| | | if (!string.IsNullOrEmpty(item.Material)) |
| | | { |
| | | vmo = defaultList.First(); |
| | | } |
| | | else if (defaultList.Count <= 0) |
| | | { |
| | | vmo = fourLinkVmos.First(); |
| | | var count = item.Material.ToLower().Intersect(input.Material.ToLower()).Count(); |
| | | dict[item] += count * materialWeight; |
| | | } |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | } |
| | | |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | vmo = fourLinkVmos.First(); |
| | | } |
| | | if (vmo != null) |
| | | //口径 |
| | | int caliberWeight = 1; |
| | | if (input.Caliber > 0) |
| | | { |
| | | if (!isNotarize) |
| | | foreach (var item in fourLinkVmos) |
| | | { |
| | | 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.Name; |
| | | if (item.Caliber.HasValue) |
| | | { |
| | | var diff = Math.Abs(item.Caliber.Value - input.Caliber); |
| | | dict[item] += diff / input.Caliber * 100 * caliberWeight; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | input.MatchingMinorLoss = vmo.MinorLoss; |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | input.MatchingMaterial = vmo.Material; |
| | | input.MatchingModelType = vmo.Name; |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | |
| | | // 关键字 |
| | | int keywordWeight = 1; |
| | | foreach (var item in fourLinkVmos) |
| | | { |
| | | 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 fourLinkVmos) |
| | | { |
| | | if (item.Flags != null && item.Flags.Count > 0) |
| | | { |
| | | if (item.Flags.Contains(HStation.Assets.Flags.默认)) |
| | | { |
| | | dict[item] += flagWeight; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var fourlink = dict.OrderBy(x => x.Value).LastOrDefault().Key; |
| | | input.MatchingDbId = fourlink.ID.ToString(); |
| | | if (string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | input.MatchingModelType = fourlink.Name; |
| | | } |
| | | if (string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | input.MatchingMaterial = fourlink.Material; |
| | | } |
| | | if (input.Caliber <= 0) |
| | | { |
| | | input.Caliber = fourlink.Caliber ?? 0; |
| | | } |
| | | if (input.MinorLoss <= 0) |
| | | { |
| | | input.MatchingMinorLoss = fourlink.MinorLoss; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | //喷头匹配 |
| | | public static bool MatchingSprinkler(HydroNozzleMatchingViewModel input, List<Vmo.AssetsSprinklerMainVmo> sprinklerVmos) |
| | | public static bool Matching(HydroNozzleMatchingViewModel input, List<AssetsSprinklerMainVmo> sprinklerVmos) |
| | | { |
| | | bool isNotarize = false; //是否确定 |
| | | if (sprinklerVmos == null || input == null || sprinklerVmos.Count == 0) |
| | | //输入参数验证 |
| | | if (input == null) |
| | | { |
| | | return true; |
| | | return false; |
| | | } |
| | | Vmo.AssetsSprinklerMainVmo vmo = null; |
| | | var nameMatching = sprinklerVmos.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(); |
| | | |
| | | if (nameMatching.Count > 1) |
| | | //数据源没有数据则没有匹配成功 |
| | | if (sprinklerVmos == null || sprinklerVmos.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) |
| | | return false; |
| | | } |
| | | |
| | | //权重字典 |
| | | var dict = new Dictionary<AssetsSprinklerMainVmo, double>(); |
| | | foreach (var item in sprinklerVmos) |
| | | { |
| | | dict.Add(item, 0); |
| | | } |
| | | |
| | | //型号 |
| | | int modelTypeWeight = 10; |
| | | if (!string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | foreach (var item in sprinklerVmos) |
| | | { |
| | | var defaultList = absoluteMatching.Where(x => x.Flags.Contains("默认值")).ToList(); |
| | | //取默认 |
| | | if (defaultList.Count > 0) |
| | | if (!string.IsNullOrEmpty(item.Name)) |
| | | { |
| | | vmo = defaultList.First(); |
| | | } |
| | | else if (defaultList.Count <= 0) |
| | | { |
| | | vmo = sprinklerVmos.First(); |
| | | var count = item.Name.ToLower().Intersect(input.ModelType.ToLower()).Count(); |
| | | dict[item] += count * modelTypeWeight; |
| | | } |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | vmo = sprinklerVmos.First(); |
| | | } |
| | | else if (nameMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = nameMatching.First(); |
| | | } |
| | | else |
| | | //材质 |
| | | int materialWeight = 5; |
| | | if (!string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | var absoluteMatching = sprinklerVmos.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) |
| | | foreach (var item in sprinklerVmos) |
| | | { |
| | | var defaultList = absoluteMatching.Where(x => x.Flags.Contains("默认值")).ToList(); |
| | | //取默认 |
| | | if (defaultList.Count > 0) |
| | | if (!string.IsNullOrEmpty(item.Material)) |
| | | { |
| | | vmo = defaultList.First(); |
| | | } |
| | | else if (defaultList.Count <= 0) |
| | | { |
| | | vmo = sprinklerVmos.First(); |
| | | var count = item.Material.ToLower().Intersect(input.Material.ToLower()).Count(); |
| | | dict[item] += count * materialWeight; |
| | | } |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | } |
| | | |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | vmo = sprinklerVmos.First(); |
| | | } |
| | | if (vmo != null) |
| | | //口径 |
| | | int caliberWeight = 1; |
| | | if (input.Caliber > 0) |
| | | { |
| | | if (!isNotarize) |
| | | foreach (var item in sprinklerVmos) |
| | | { |
| | | 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.Name; |
| | | if (item.Caliber.HasValue) |
| | | { |
| | | var diff = Math.Abs(item.Caliber.Value - input.Caliber); |
| | | dict[item] += diff / input.Caliber * 100 * caliberWeight; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | input.MatchingMinorLoss = vmo.MinorLoss; |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | input.MatchingMaterial = vmo.Material; |
| | | input.MatchingModelType = vmo.Name; |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | |
| | | // 关键字 |
| | | int keywordWeight = 1; |
| | | foreach (var item in sprinklerVmos) |
| | | { |
| | | 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 sprinklerVmos) |
| | | { |
| | | if (item.Flags != null && item.Flags.Count > 0) |
| | | { |
| | | if (item.Flags.Contains(HStation.Assets.Flags.默认)) |
| | | { |
| | | dict[item] += flagWeight; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var sprinkler = dict.OrderBy(x => x.Value).LastOrDefault().Key; |
| | | input.MatchingDbId = sprinkler.ID.ToString(); |
| | | if (string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | input.MatchingModelType = sprinkler.Name; |
| | | } |
| | | if (string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | input.MatchingMaterial = sprinkler.Material; |
| | | } |
| | | if (input.Caliber <= 0) |
| | | { |
| | | input.Caliber = sprinkler.Caliber ?? 0; |
| | | } |
| | | if (input.MinorLoss <= 0) |
| | | { |
| | | input.MatchingMinorLoss = sprinkler.MinorLoss; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | //换热器匹配 |
| | |
| | | } |
| | | |
| | | //闷头匹配 |
| | | public static bool MatchingBlunthead(HydroBluntheadMatchingViewModel input, List<Vmo.AssetsBluntheadMainVmo> bluntheadVmos) |
| | | public static bool Matching(HydroBluntheadMatchingViewModel input, List<AssetsBluntheadMainVmo> bluntheadVmos) |
| | | { |
| | | bool isNotarize = false; //是否确定 |
| | | if (bluntheadVmos == null || input == null || bluntheadVmos.Count == 0) |
| | | //输入参数验证 |
| | | if (input == null) |
| | | { |
| | | return true; |
| | | return false; |
| | | } |
| | | Vmo.AssetsBluntheadMainVmo vmo = null; |
| | | var nameMatching = bluntheadVmos.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(); |
| | | |
| | | if (nameMatching.Count > 1) |
| | | //数据源没有数据则没有匹配成功 |
| | | if (bluntheadVmos == null || bluntheadVmos.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) |
| | | return false; |
| | | } |
| | | |
| | | //权重字典 |
| | | var dict = new Dictionary<AssetsBluntheadMainVmo, double>(); |
| | | foreach (var item in bluntheadVmos) |
| | | { |
| | | dict.Add(item, 0); |
| | | } |
| | | |
| | | //型号 |
| | | int modelTypeWeight = 10; |
| | | if (!string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | foreach (var item in bluntheadVmos) |
| | | { |
| | | var defaultList = absoluteMatching.Where(x => x.Flags.Contains("默认值")).ToList(); |
| | | //取默认 |
| | | if (defaultList.Count > 0) |
| | | if (!string.IsNullOrEmpty(item.Name)) |
| | | { |
| | | vmo = defaultList.First(); |
| | | } |
| | | else if (defaultList.Count <= 0) |
| | | { |
| | | vmo = bluntheadVmos.First(); |
| | | var count = item.Name.ToLower().Intersect(input.ModelType.ToLower()).Count(); |
| | | dict[item] += count * modelTypeWeight; |
| | | } |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | vmo = bluntheadVmos.First(); |
| | | } |
| | | else if (nameMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = nameMatching.First(); |
| | | } |
| | | else |
| | | //材质 |
| | | int materialWeight = 5; |
| | | if (!string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | var absoluteMatching = bluntheadVmos.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) |
| | | foreach (var item in bluntheadVmos) |
| | | { |
| | | var defaultList = absoluteMatching.Where(x => x.Flags.Contains("默认值")).ToList(); |
| | | //取默认 |
| | | if (defaultList.Count > 0) |
| | | if (!string.IsNullOrEmpty(item.Material)) |
| | | { |
| | | vmo = defaultList.First(); |
| | | } |
| | | else if (defaultList.Count <= 0) |
| | | { |
| | | vmo = bluntheadVmos.First(); |
| | | var count = item.Material.ToLower().Intersect(input.Material.ToLower()).Count(); |
| | | dict[item] += count * materialWeight; |
| | | } |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | } |
| | | |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | vmo = bluntheadVmos.First(); |
| | | } |
| | | if (vmo != null) |
| | | //口径 |
| | | int caliberWeight = 1; |
| | | if (input.Caliber > 0) |
| | | { |
| | | if (!isNotarize) |
| | | foreach (var item in bluntheadVmos) |
| | | { |
| | | if (input.MinorLoss < 0) |
| | | 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.Name; |
| | | if (item.Caliber.HasValue) |
| | | { |
| | | var diff = Math.Abs(item.Caliber.Value - input.Caliber); |
| | | dict[item] += diff / input.Caliber * 100 * caliberWeight; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | input.MatchingMinorLoss = vmo.MinorLoss; |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | input.MatchingMaterial = vmo.Material; |
| | | input.MatchingModelType = vmo.Name; |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | |
| | | // 关键字 |
| | | int keywordWeight = 1; |
| | | foreach (var item in bluntheadVmos) |
| | | { |
| | | 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 bluntheadVmos) |
| | | { |
| | | if (item.Flags != null && item.Flags.Count > 0) |
| | | { |
| | | if (item.Flags.Contains(HStation.Assets.Flags.默认)) |
| | | { |
| | | dict[item] += flagWeight; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var blunthead = dict.OrderBy(x => x.Value).LastOrDefault().Key; |
| | | input.MatchingDbId = blunthead.ID.ToString(); |
| | | if (string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | input.MatchingModelType = blunthead.Name; |
| | | } |
| | | if (string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | input.MatchingMaterial = blunthead.Material; |
| | | } |
| | | if (input.Caliber <= 0) |
| | | { |
| | | input.Caliber = blunthead.Caliber ?? 0; |
| | | } |
| | | if (input.MinorLoss < 0) |
| | | { |
| | | input.MatchingMinorLoss = blunthead.MinorLoss; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | //水池匹配 |
| | | public static bool MatchingTank(HydroTankMatchingViewModel input, List<Vmo.AssetsTankMainVmo> tankVmos) |
| | | public static bool Matching(HydroTankMatchingViewModel input, List<AssetsTankMainVmo> tankVmos) |
| | | { |
| | | bool isNotarize = false; //是否确定 |
| | | if (tankVmos == null || input == null || tankVmos.Count == 0) |
| | | //输入参数验证 |
| | | if (input == null) |
| | | { |
| | | return true; |
| | | return false; |
| | | } |
| | | 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 |
| | | ) //先进行筛选,后进行从大到小排序 |
| | | .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(); |
| | | |
| | | if (nameMatching.Count > 1) |
| | | //数据源没有数据则没有匹配成功 |
| | | if (tankVmos == null || tankVmos.Count < 1) |
| | | { |
| | | var defaultList = nameMatching.Where(x => x.Flags.Contains("默认值")).ToList(); |
| | | //取默认 |
| | | if (defaultList.Count > 0) |
| | | { |
| | | vmo = tankVmos.First(); |
| | | } |
| | | else if (defaultList.Count <= 0) |
| | | { |
| | | vmo = tankVmos.First(); |
| | | } |
| | | return false; |
| | | } |
| | | else if (nameMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = nameMatching.First(); |
| | | } |
| | | else |
| | | vmo = tankVmos.First(); |
| | | if (vmo != null) |
| | | //权重字典 |
| | | var dict = new Dictionary<AssetsTankMainVmo, double>(); |
| | | foreach (var item in tankVmos) |
| | | { |
| | | if (!isNotarize) |
| | | dict.Add(item, 0); |
| | | } |
| | | |
| | | //型号 |
| | | int modelTypeWeight = 10; |
| | | if (!string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | foreach (var item in tankVmos) |
| | | { |
| | | if (input.DbId == null) |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | if (input.ModelType == null) |
| | | input.MatchingModelType = vmo.Name; |
| | | if (input.DN < 0) |
| | | input.MatchingDN = vmo.DN; |
| | | if (input.MinLevel < 0) |
| | | input.MatchingMinLevel = vmo.MinLevel; |
| | | if (input.CurveDbId == null) |
| | | if (!string.IsNullOrEmpty(item.Name)) |
| | | { |
| | | 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)); |
| | | } |
| | | } |
| | | var count = item.Name.ToLower().Intersect(input.ModelType.ToLower()).Count(); |
| | | dict[item] += count * modelTypeWeight; |
| | | } |
| | | } |
| | | else |
| | | } |
| | | |
| | | // 关键字 |
| | | int keywordWeight = 1; |
| | | foreach (var item in tankVmos) |
| | | { |
| | | if (item.KeyWords != null && item.KeyWords.Count > 0) |
| | | { |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | input.MatchingModelType = vmo.Name; |
| | | input.MatchingDN = vmo.DN; |
| | | input.MatchingMinLevel = vmo.MinLevel; |
| | | input.MatchingOverFlow = vmo.OverFlow; |
| | | var list = Task.Run(async () => await new BLL.PhartDiagramRelation().GetExByObjectTypeAndObjectID(HStation.Assets.DataType.ValveMain, vmo.ID)).Result; |
| | | if (list != null && list.Count > 0) |
| | | if (!string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | 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)); |
| | | } |
| | | var count = item.KeyWords.Count(x => input.ModelType.ToLower().Contains(x.ToLower())); |
| | | dict[item] += count * keywordWeight; |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | |
| | | //标签 |
| | | int flagWeight = 1; |
| | | foreach (var item in tankVmos) |
| | | { |
| | | if (item.Flags != null && item.Flags.Count > 0) |
| | | { |
| | | if (item.Flags.Contains(HStation.Assets.Flags.默认)) |
| | | { |
| | | dict[item] += flagWeight; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var tank = dict.OrderBy(x => x.Value).LastOrDefault().Key; |
| | | input.MatchingDbId = tank.ID.ToString(); |
| | | if (string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | input.MatchingModelType = tank.Name; |
| | | } |
| | | |
| | | if (input.DN <= 0) |
| | | { |
| | | input.MatchingDN = tank.DN; |
| | | } |
| | | if (input.MinLevel <= 0) |
| | | { |
| | | input.MatchingMinLevel = tank.MinLevel; |
| | | } |
| | | input.MatchingOverFlow = tank.OverFlow; |
| | | if (input.MinVol <= 0) |
| | | { |
| | | input.MatchingMinVol = tank.MinVol; |
| | | } |
| | | if (input.MaxLevel <= 0) |
| | | { |
| | | input.MatchingMaxLevel = tank.MaxLevel; |
| | | } |
| | | if (input.CurveDbId == null) |
| | | { |
| | | var list = Task.Run(async () => |
| | | await new BLL.PhartDiagramRelation().GetExByObjectTypeAndObjectID(HStation.Assets.DataType.TankMain, tank.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; |
| | | } |
| | | |
| | | //水表匹配 |
| | |
| | | } |
| | | |
| | | //消火栓匹配 |
| | | public static bool MatchingHydrant(HydroHydrantMatchingViewModel input, List<Vmo.AssetsHydrantMainVmo> hydrantVmos) |
| | | public static bool Matching(HydroHydrantMatchingViewModel input, List<AssetsHydrantMainVmo> hydrantVmos) |
| | | { |
| | | bool isNotarize = false; //是否确定 |
| | | if (hydrantVmos == null || input == null || hydrantVmos.Count == 0) |
| | | //输入参数验证 |
| | | if (input == null) |
| | | { |
| | | return true; |
| | | return false; |
| | | } |
| | | Vmo.AssetsHydrantMainVmo vmo = null; |
| | | var nameMatching = hydrantVmos.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(); |
| | | |
| | | if (nameMatching.Count > 1) |
| | | //数据源没有数据则没有匹配成功 |
| | | if (hydrantVmos == null || hydrantVmos.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 = hydrantVmos.First(); |
| | | } |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | return false; |
| | | } |
| | | |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | vmo = hydrantVmos.First(); |
| | | } |
| | | else if (nameMatching.Count == 1) |
| | | //权重字典 |
| | | var dict = new Dictionary<AssetsHydrantMainVmo, double>(); |
| | | foreach (var item in hydrantVmos) |
| | | { |
| | | vmo = nameMatching.First(); |
| | | dict.Add(item, 0); |
| | | } |
| | | else |
| | | { |
| | | var absoluteMatching = hydrantVmos.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 = hydrantVmos.First(); |
| | | } |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | vmo = hydrantVmos.First(); |
| | | } |
| | | if (vmo != null) |
| | | //型号 |
| | | int modelTypeWeight = 10; |
| | | if (!string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | if (!isNotarize) |
| | | foreach (var item in hydrantVmos) |
| | | { |
| | | if (input.MinorLoss < 0) |
| | | input.MatchingMinorLoss = vmo.MinorLoss; |
| | | if (input.DbId == null) |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | if (input.ModelType == null) |
| | | input.MatchingModelType = vmo.Name; |
| | | if (!string.IsNullOrEmpty(item.Name)) |
| | | { |
| | | var count = item.Name.ToLower().Intersect(input.ModelType.ToLower()).Count(); |
| | | dict[item] += count * modelTypeWeight; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | input.MatchingMinorLoss = vmo.MinorLoss; |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | input.MatchingMaterial = vmo.Material; |
| | | input.MatchingModelType = vmo.Name; |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | |
| | | //材质 |
| | | int materialWeight = 5; |
| | | if (!string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | foreach (var item in hydrantVmos) |
| | | { |
| | | 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 > 0) |
| | | { |
| | | foreach (var item in hydrantVmos) |
| | | { |
| | | if (item.Caliber.HasValue) |
| | | { |
| | | var diff = Math.Abs(item.Caliber.Value - input.Caliber); |
| | | dict[item] += diff / input.Caliber * 100 * caliberWeight; |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 关键字 |
| | | int keywordWeight = 1; |
| | | foreach (var item in hydrantVmos) |
| | | { |
| | | 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 hydrantVmos) |
| | | { |
| | | if (item.Flags != null && item.Flags.Count > 0) |
| | | { |
| | | if (item.Flags.Contains(HStation.Assets.Flags.默认)) |
| | | { |
| | | dict[item] += flagWeight; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var hydrant = dict.OrderBy(x => x.Value).LastOrDefault().Key; |
| | | input.MatchingDbId = hydrant.ID.ToString(); |
| | | if (string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | input.MatchingModelType = hydrant.Name; |
| | | } |
| | | if (string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | input.MatchingMaterial = hydrant.Material; |
| | | } |
| | | if (input.Caliber <= 0) |
| | | { |
| | | input.Caliber = hydrant.Caliber ?? 0; |
| | | } |
| | | if (input.MinorLoss < 0) |
| | | { |
| | | input.MatchingMinorLoss = hydrant.MinorLoss; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | //弯头匹配 |
| | | 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 elbow = dict.OrderBy(x => x.Value).LastOrDefault().Key; |
| | | input.MatchingDbId = elbow.ID.ToString(); |
| | | if (string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | input.MatchingModelType = elbow.Name; |
| | | } |
| | | if (input.MinorLoss <= 0 || input.MinorLoss == null) |
| | | { |
| | | input.MatchingMinorLoss = elbow.MinorLoss; |
| | | } |
| | | if (input.BendingAngle <= 0 || input.BendingAngle == null) |
| | | { |
| | | input.MatchingBendingAngle = elbow.Angle; |
| | | } |
| | | input.MatchingElbowType = (Yw.WinFrmUI.eElbowType)(int)elbow.ElbowType; |
| | | if (input.Material == null || input.Material == string.Empty) |
| | | { |
| | | input.MatchingMaterial = elbow.Material; |
| | | } |
| | | if (input.Caliber <= 0) |
| | | { |
| | | input.MatchingCaliber = elbow.Caliber; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | //压力表匹配 |
| | | public static bool MatchingPressmeter(HydroPressmeterMatchingViewModel input, List<Vmo.AssetsPressmeterMainVmo> pressmeterVmos) |
| | | public static bool Matching(HydroPressmeterMatchingViewModel input, List<AssetsPressmeterMainVmo> pressmeterVmos) |
| | | { |
| | | bool isNotarize = false; //是否确定 |
| | | if (pressmeterVmos == null || input == null || pressmeterVmos.Count == 0) |
| | | //输入参数验证 |
| | | if (input == null) |
| | | { |
| | | return true; |
| | | return false; |
| | | } |
| | | Vmo.AssetsPressmeterMainVmo vmo = null; |
| | | var nameMatching = pressmeterVmos.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) |
| | | //数据源没有数据则没有匹配成功 |
| | | if (pressmeterVmos == null || pressmeterVmos.Count < 1) |
| | | { |
| | | var defaultList = nameMatching.Where(x => x.Flags.Contains("默认值")).ToList(); |
| | | //取默认 |
| | | if (defaultList.Count > 0) |
| | | { |
| | | vmo = pressmeterVmos.First(); |
| | | } |
| | | else if (defaultList.Count <= 0) |
| | | { |
| | | vmo = pressmeterVmos.First(); |
| | | } |
| | | return false; |
| | | } |
| | | else if (nameMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = nameMatching.First(); |
| | | } |
| | | else |
| | | //权重字典 |
| | | var dict = new Dictionary<AssetsPressmeterMainVmo, double>(); |
| | | foreach (var item in pressmeterVmos) |
| | | { |
| | | vmo = pressmeterVmos.First(); |
| | | dict.Add(item, 0); |
| | | } |
| | | if (vmo != null) |
| | | |
| | | //型号 |
| | | int modelTypeWeight = 10; |
| | | if (!string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | if (!isNotarize) |
| | | foreach (var item in pressmeterVmos) |
| | | { |
| | | if (input.MinorLoss < 0) |
| | | input.MatchingMinorLoss = vmo.MinorLoss; |
| | | if (input.DbId == null) |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | if (input.ModelType == null) |
| | | input.MatchingModelType = vmo.Name; |
| | | if (!string.IsNullOrEmpty(item.Name)) |
| | | { |
| | | var count = item.Name.ToLower().Intersect(input.ModelType.ToLower()).Count(); |
| | | dict[item] += count * modelTypeWeight; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | input.MatchingMinorLoss = vmo.MinorLoss; |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | input.MatchingModelType = vmo.Name; |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | |
| | | // 关键字 |
| | | int keywordWeight = 1; |
| | | foreach (var item in pressmeterVmos) |
| | | { |
| | | 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 = 1; |
| | | foreach (var item in pressmeterVmos) |
| | | { |
| | | if (item.Flags != null && item.Flags.Count > 0) |
| | | { |
| | | if (item.Flags.Contains(HStation.Assets.Flags.默认)) |
| | | { |
| | | dict[item] += flagWeight; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var pressmeter = dict.OrderBy(x => x.Value).LastOrDefault().Key; |
| | | input.MatchingDbId = pressmeter.ID.ToString(); |
| | | if (string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | input.MatchingModelType = pressmeter.Name; |
| | | } |
| | | if (input.MinorLoss < 0) |
| | | { |
| | | input.MatchingMinorLoss = pressmeter.MinorLoss; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | //过渡件匹配 |
| | | public static bool MatchingTranslation(HydroTranslationMatchingViewModel input, List<Vmo.AssetsTranslationMainVmo> translationVmos) |
| | | public static bool Matching(HydroTranslationMatchingViewModel input, List<AssetsTranslationMainVmo> translationVmos) |
| | | { |
| | | bool isNotarize = false; //是否确定 |
| | | |
| | | if (translationVmos == null || input == null || translationVmos.Count == 0) |
| | | //输入参数验证 |
| | | if (input == null) |
| | | { |
| | | return true; |
| | | return false; |
| | | } |
| | | Vmo.AssetsTranslationMainVmo vmo = null; |
| | | var nameMatching = translationVmos.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(); |
| | | |
| | | if (nameMatching.Count > 1) |
| | | //数据源没有数据则没有匹配成功 |
| | | if (translationVmos == null || translationVmos.Count < 1) |
| | | { |
| | | var absoluteMatching = nameMatching.Where(i => |
| | | i.Material == input.Material //材料约束 |
| | | ).ToList(); |
| | | if (absoluteMatching.Count > 1) |
| | | return false; |
| | | } |
| | | |
| | | //权重字典 |
| | | var dict = new Dictionary<AssetsTranslationMainVmo, double>(); |
| | | foreach (var item in translationVmos) |
| | | { |
| | | dict.Add(item, 0); |
| | | } |
| | | |
| | | //型号 |
| | | int modelTypeWeight = 10; |
| | | if (!string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | foreach (var item in translationVmos) |
| | | { |
| | | var defaultList = absoluteMatching.Where(x => x.Flags.Contains("默认值")).ToList(); |
| | | //取默认 |
| | | if (defaultList.Count > 0) |
| | | if (!string.IsNullOrEmpty(item.Name)) |
| | | { |
| | | vmo = defaultList.First(); |
| | | } |
| | | else if (defaultList.Count <= 0) |
| | | { |
| | | vmo = translationVmos.First(); |
| | | var count = item.Name.ToLower().Intersect(input.ModelType.ToLower()).Count(); |
| | | dict[item] += count * modelTypeWeight; |
| | | } |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | vmo = translationVmos.First(); |
| | | } |
| | | else if (nameMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | |
| | | vmo = nameMatching.First(); |
| | | } |
| | | else |
| | | //材质 |
| | | int materialWeight = 5; |
| | | if (!string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | var absoluteMatching = translationVmos.Where(i => |
| | | i.Material == input.Material //材料约束 |
| | | ).ToList(); |
| | | if (absoluteMatching.Count > 1) |
| | | foreach (var item in translationVmos) |
| | | { |
| | | var defaultList = absoluteMatching.Where(x => x.Flags.Contains("默认值")).ToList(); |
| | | //取默认 |
| | | if (defaultList.Count > 0) |
| | | if (!string.IsNullOrEmpty(item.Material)) |
| | | { |
| | | vmo = defaultList.First(); |
| | | } |
| | | else if (defaultList.Count <= 0) |
| | | { |
| | | vmo = translationVmos.First(); |
| | | var count = item.Material.ToLower().Intersect(input.Material.ToLower()).Count(); |
| | | dict[item] += count * materialWeight; |
| | | } |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | isNotarize = true; |
| | | } |
| | | |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | vmo = translationVmos.First(); |
| | | } |
| | | if (vmo != null) |
| | | // 关键字 |
| | | int keywordWeight = 1; |
| | | foreach (var item in translationVmos) |
| | | { |
| | | if (!isNotarize) |
| | | if (item.KeyWords != null && item.KeyWords.Count > 0) |
| | | { |
| | | if (input.MinorLoss < 0) |
| | | input.MatchingMinorLoss = vmo.MinorLoss; |
| | | if (input.DbId == null) |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | if (input.ModelType == null) |
| | | input.MatchingModelType = vmo.Name; |
| | | if (input.Roughness < 0) |
| | | input.MatchingRoughness = vmo.Roughness; |
| | | if (input.EndDiameter < 0) |
| | | input.MatchingEndDiameter = vmo.EndDiameter; |
| | | if (input.StartDiameter < 0) |
| | | input.MatchingStartDiameter = vmo.StartDiameter; |
| | | if (input.Diameter < 0) |
| | | input.MatchingDiameter = vmo.Diameter; |
| | | 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; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | input.MatchingMinorLoss = vmo.MinorLoss; |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | input.MatchingMaterial = vmo.Material; |
| | | input.MatchingModelType = vmo.Name; |
| | | input.MatchingDiameter = vmo.Diameter; |
| | | input.MatchingEndDiameter = vmo.EndDiameter; |
| | | input.MatchingStartDiameter = vmo.StartDiameter; |
| | | input.MatchingRoughness = vmo.Roughness; |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | | |
| | | //标签 |
| | | int flagWeight = 1; |
| | | foreach (var item in translationVmos) |
| | | { |
| | | if (item.Flags != null && item.Flags.Count > 0) |
| | | { |
| | | if (item.Flags.Contains(HStation.Assets.Flags.默认)) |
| | | { |
| | | dict[item] += flagWeight; |
| | | } |
| | | } |
| | | } |
| | | |
| | | var translation = dict.OrderBy(x => x.Value).LastOrDefault().Key; |
| | | input.MatchingDbId = translation.ID.ToString(); |
| | | if (string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | input.MatchingModelType = translation.Name; |
| | | } |
| | | if (string.IsNullOrEmpty(input.Material)) |
| | | { |
| | | input.MatchingMaterial = translation.Material; |
| | | } |
| | | if (input.MinorLoss < 0) |
| | | { |
| | | input.MatchingMinorLoss = translation.MinorLoss; |
| | | } |
| | | if (input.Roughness < 0) |
| | | { |
| | | input.MatchingRoughness = translation.Roughness; |
| | | } |
| | | if (input.EndDiameter < 0) |
| | | { |
| | | input.MatchingEndDiameter = translation.EndDiameter; |
| | | } |
| | | if (input.StartDiameter < 0) |
| | | { |
| | | input.MatchingStartDiameter = translation.StartDiameter; |
| | | } |
| | | if (input.Diameter < 0) |
| | | { |
| | | input.MatchingDiameter = translation.Diameter; |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | //冷却器匹配 |
| | |
| | | |
| | | //口径 |
| | | int caliberWeight = 1; |
| | | if (input.Caliber.HasValue) |
| | | if (input.Caliber > 0) |
| | | { |
| | | 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; |
| | | var diff = Math.Abs(item.Caliber.Value - input.Caliber); |
| | | dict[item] += diff / input.Caliber * 100 * caliberWeight; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | // 关键字 |
| | | int keywordWeight = 1; |
| | |
| | | { |
| | | input.MatchingMaterial = cooling.Material; |
| | | } |
| | | if (!input.Caliber.HasValue || input.Caliber.Value <= 0) |
| | | if (input.Caliber <= 0) |
| | | { |
| | | input.Caliber = cooling.Caliber; |
| | | input.Caliber = cooling.Caliber ?? 0; |
| | | } |
| | | if (input.Coefficient <= 1) |
| | | { |