| | |
| | | private const double _headTolerance = 5; |
| | | private const double _powerTolerance = 0.05; |
| | | |
| | | private const double _valveLift = 10;//阀门开度范围 |
| | | private const int _angle = 1;//角度范围 |
| | | |
| | | //资产自动匹配 |
| | | public static bool Matching(AssetsMatchingViewModel assetsAutoMatchingView, out string Error) |
| | | { |
| | |
| | | return true; |
| | | } |
| | | HStation.Vmo.AssetsValveMainVmo vmo = null; |
| | | int firstCount = 0; |
| | | //口径最小差值 |
| | | // 绝对匹配 |
| | | var absoluteMatch = adaptingManageVmos.Where(i => |
| | | adaptingManageVmos = adaptingManageVmos.Where(x => x.Type.ToString() == input.ValveType).ToList(); |
| | | var nameMatching = adaptingManageVmos.Where(x => GetIntersect(x.KeyWord == string.Empty |
| | | ? x.Name : x.KeyWord, input.ModelType) >= 1) |
| | | .OrderByDescending(x => GetIntersect(x.KeyWord == string.Empty ? x.Name : x.KeyWord, input.ModelType)) |
| | | .ToList();//使用型号名或者关键字找出相同字符在2以上并且进行排序 |
| | | if (nameMatching.Count > 0) |
| | | { |
| | | var absoluteMatching = nameMatching.Where(i => |
| | | ((i.Caliber == null) || Math.Abs(Convert.ToInt64(i.Caliber) - input.Diameter) <= _caliberTolerance) && //直径约束 |
| | | i.MaterialName == input.Material && //材料约束 |
| | | (i.ValveLift == input.ValveLift || Math.Abs(Convert.ToInt64(i.ValveLift) - Convert.ToInt64(input.ValveLift)) <= _valveLift) //阀门开度约束 |
| | | ).ToList(); |
| | | if (absoluteMatching.Count > 1) |
| | | { |
| | | return false; |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | return false; |
| | | } |
| | | else if (nameMatching.Count == 1) |
| | | { |
| | | vmo = nameMatching.First(); |
| | | } |
| | | else |
| | | { |
| | | var absoluteMatching = adaptingManageVmos.Where(i => |
| | | ((i.Caliber == null) || Math.Abs(Convert.ToInt64(i.Caliber) - input.Diameter) <= _caliberTolerance) && //直径约束 |
| | | i.MaterialName == input.Material && //材料约束 |
| | | (i.ValveLift == input.ValveLift || Math.Abs(Convert.ToInt64(i.ValveLift) - Convert.ToInt64(input.ValveLift)) <= _valveLift) //阀门开度约束 |
| | | ).ToList(); |
| | | if (absoluteMatching.Count > 1) |
| | | { |
| | | return false; |
| | | } |
| | | else if (absoluteMatching.Count == 1) |
| | | { |
| | | vmo = absoluteMatching.First(); |
| | | } |
| | | else |
| | | return false; |
| | | } |
| | | |
| | | /*var absoluteMatch = adaptingManageVmos.Where(i => |
| | | ((i.Caliber == null) || i.Caliber == input.Diameter) && |
| | | ((input.Material == null) || i.MaterialName == input.Material)).ToList(); |
| | | ((input.Material == null && i.MaterialName == null) || i.MaterialName == input.Material)).ToList(); |
| | | if (absoluteMatch.Count > 1) |
| | | { |
| | | var allMatchingList = absoluteMatch |
| | | .Where(x => GetIntersect(x.KeyWord == string.Empty ? x.Name : x.KeyWord, input.ModelType) >= 2) |
| | | .Where(x => GetIntersect(x.KeyWord == string.Empty |
| | | ? x.Name : x.KeyWord, input.ModelType) >= 2) |
| | | .OrderByDescending(x => GetIntersect(x.KeyWord == string.Empty ? x.Name : x.KeyWord, input.ModelType)) |
| | | .ToList();//找出相同字符在2以上并且进行排序 |
| | | if (allMatchingList.Count < 1) |
| | |
| | | var rangeMatch = adaptingManageVmos |
| | | .Where(item => |
| | | item.Caliber == null || |
| | | Math.Abs(Convert.ToInt64(item.Caliber) - Convert.ToInt64(input.Diameter)) <= _caliberTolerance) |
| | | Math.Abs(Convert.ToInt64(item.Caliber) - Convert.ToInt64(input.Diameter)) <= _caliberTolerance |
| | | || Math.Abs(Convert.ToInt64(item.ValveLift) - Convert.ToInt64(input.ValveLift)) <= _valveLift) |
| | | .ToList(); |
| | | if (rangeMatch != null && rangeMatch.Count > 0) |
| | | { |
| | |
| | | } |
| | | } |
| | | //口径和材料都没有匹配上,就用型号名匹配 |
| | | firstCount = 0; |
| | | firstCount = 0;*/ |
| | | if (vmo != null) |
| | | { |
| | | input.MatchingMinorLoss = vmo.Coefficient; |
| | |
| | | input.MatchingDiameter = vmo.Caliber; |
| | | input.MatchingMaterial = vmo.MaterialName; |
| | | input.MatchingModelType = vmo.Name; |
| | | // input.MatchingValveSetting = |
| | | input.MatchingValveType = vmo.SeriesType.ToString(); |
| | | input.MatchingValveSetting = vmo.ValveSetting; |
| | | input.MatchingValveLift = vmo.ValveLift; |
| | | input.MatchingValveType = vmo.Type.ToString(); |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | //区间匹配 |
| | | var rangeMatch = adaptingManageVmos |
| | | .Where(item => |
| | | input.Caliber == null || |
| | | item.Caliber == null || |
| | | Math.Abs(Convert.ToInt64(item.Caliber) - Convert.ToInt64(input.Caliber)) <= _caliberTolerance) |
| | | .ToList(); |
| | | (input.Caliber == null && input.Caliber == null) |
| | | || (item.Caliber.HasValue && input.Caliber.HasValue) && //存在值,则进行下面差值判断 |
| | | Math.Abs(Convert.ToInt64(item.Caliber) - Convert.ToInt64(input.Caliber)) <= _caliberTolerance |
| | | || item.ConnectionLength == input.ConnectionLength |
| | | || (item.Angle.HasValue && input.Angle.HasValue) && //存在值,则进行下面差值判断 |
| | | Math.Abs(Convert.ToInt64(item.Angle) - Convert.ToInt64(input.Angle)) <= _angle) |
| | | .ToList(); |
| | | if (rangeMatch != null && rangeMatch.Count > 0) |
| | | { |
| | | var materialList = new List<Vmo.AssetsElbowMainVmo>(); |
| | |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | input.MatchingMaterial = vmo.MaterialName; |
| | | input.MatchingModelType = vmo.Name; |
| | | input.MatchingConnectionLength = vmo.ConnectionLength; |
| | | input.MatchingAngle = vmo.Angle; |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | input.MatchingMaterial = vmo.MaterialName; |
| | | input.MatchingModelType = vmo.Name; |
| | | input.MatchingRunThroughCoefficient = vmo.RunThroughCoefficient; |
| | | input.MatchingBranchThroughCoefficient = vmo.BranchThroughCoefficient; |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | public static int GetIntersect(string str1, string str2) |
| | | { |
| | | if (str1 == null || str2 == null) return 0; |
| | | |
| | | var a = string.Join("", str1.Intersect(str2)).Count(); |
| | | return string.Join("", str1.Intersect(str2)).Count(); |
| | | } |
| | | } |