| | |
| | | //弯头匹配 |
| | | foreach (var item in assetsAutoMatchingView.Elbows) |
| | | { |
| | | if (MatchingElbow(item, allElbow)) |
| | | if (Matching(item, allElbow)) |
| | | { |
| | | IsMaching = true; |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | //弯头匹配 |
| | | /* //弯头匹配 |
| | | public static bool MatchingElbow(HydroElbowMatchingViewModel input, List<Vmo.AssetsElbowMainVmo> elbowMainVmos) |
| | | { |
| | | bool isNotarize = false; //是否确定 |
| | |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | }*/ |
| | | |
| | | //三通匹配 |
| | | public static bool MatchingThreelink(HydroThreelinkMatchingViewModel input, List<Vmo.AssetsThreelinkMainVmo> threelinkVmos) |
| | |
| | | return false; |
| | | } |
| | | |
| | | //弯头匹配 |
| | | 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 flowmeter = dict.OrderBy(x => x.Value).LastOrDefault().Key; |
| | | input.MatchingDbId = flowmeter.ID.ToString(); |
| | | if (string.IsNullOrEmpty(input.ModelType)) |
| | | { |
| | | input.MatchingModelType = flowmeter.Name; |
| | | } |
| | | if (input.MinorLoss <= 0) |
| | | { |
| | | input.MatchingMinorLoss = flowmeter.MinorLoss; |
| | | } |
| | | if (input.BendingAngle <= 0) |
| | | { |
| | | input.MatchingBendingAngle = flowmeter.Angle; |
| | | } |
| | | input.MatchingElbowType = (Yw.WinFrmUI.eElbowType)(int)flowmeter.ElbowType; |
| | | if (input.Material == null || input.Material == string.Empty) |
| | | { |
| | | input.MatchingMaterial = flowmeter.Material; |
| | | } |
| | | if (!input.Caliber.HasValue) |
| | | input.MatchingCaliber = flowmeter.Caliber; |
| | | return true; |
| | | } |
| | | |
| | | //压力表匹配 |
| | | public static bool MatchingPressmeter(HydroPressmeterMatchingViewModel input, List<Vmo.AssetsPressmeterMainVmo> pressmeterVmos) |
| | | { |