| | |
| | | var list = Task.Run(async () => await new BLL.XhsPumpMainPhartMappingExtensions().GetByPumpMainID(vmo.ID)).Result; |
| | | if (list != null && list.Count > 0) |
| | | { |
| | | InputModel.MatchingCurveDbId = list.First().ID.ToString(); |
| | | var graph_qh = list.First().Diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQH); |
| | | var graph_qe = list.First().Diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQE); |
| | | var graph_qp = list.First().Diagram.GraphList.Find(x => x.GraphType == HStation.PhartRelation.eGraphType.PumpQP); |
| | | 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); |
| | | if (graph_qh != null) |
| | | { |
| | | var points_qh = PhartPerformCurveHelper.GetFeatPointList(graph_qh.GraphType, graph_qh.GeometryInfo, 100, null); |
| | |
| | | { |
| | | return true; |
| | | } |
| | | HStation.Vmo.AssetsValveMainVmo vmo = null; |
| | | //口径最小差值 |
| | | // 绝对匹配 |
| | | 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; |
| | | } |
| | | /* HStation.Vmo.AssetsValveMainVmo vmo = null; |
| | | //口径最小差值 |
| | | // 绝对匹配 |
| | | adaptingManageVmos = adaptingManageVmos.Where(x => x.ValveType.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以上并且进行排序 |
| | | |
| | | /*var absoluteMatch = adaptingManageVmos.Where(i => |
| | | ((i.Caliber == null) || i.Caliber == input.Diameter) && |
| | | ((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) |
| | | .OrderByDescending(x => GetIntersect(x.KeyWord == string.Empty ? x.Name : x.KeyWord, input.ModelType)) |
| | | .ToList();//找出相同字符在2以上并且进行排序 |
| | | if (allMatchingList.Count < 1) |
| | | return false;//通过型号名没有找到,则视为没有匹配到 |
| | | foreach (var item in allMatchingList) |
| | | { |
| | | if (item.IsDefault) |
| | | { |
| | | vmo = item; |
| | | } |
| | | } |
| | | vmo = allMatchingList.First();//如果没有设置默认值,则默认返回匹配字符最多的一条数据 |
| | | } |
| | | else if (absoluteMatch.Count == 1) |
| | | { |
| | | vmo = absoluteMatch.First(); |
| | | } |
| | | else |
| | | { |
| | | //区间匹配 |
| | | var rangeMatch = adaptingManageVmos |
| | | .Where(item => |
| | | item.Caliber == null || |
| | | 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) |
| | | { |
| | | var materialList = new List<Vmo.AssetsValveMainVmo>(); |
| | | foreach (var range in rangeMatch) |
| | | { |
| | | //以材料为条件开始匹配 |
| | | if (range.MaterialName == null) |
| | | { |
| | | materialList.Add(range); |
| | | } |
| | | else |
| | | { |
| | | int commonCount = GetIntersect(input.Material, range.MaterialName); |
| | | if (commonCount > firstCount) |
| | | { |
| | | materialList.Add(range); |
| | | firstCount = commonCount; |
| | | } |
| | | } |
| | | } |
| | | //用已经筛选完成的列表中以名称筛选 |
| | | firstCount = 0; |
| | | if (materialList.Count < 1) |
| | | return false; |
| | | var allMatchingList = materialList |
| | | .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) |
| | | return false;//通过型号名没有找到,则视为没有匹配到 |
| | | foreach (var item in allMatchingList) |
| | | { |
| | | if (item.IsDefault) |
| | | { |
| | | vmo = item; |
| | | } |
| | | } |
| | | vmo = allMatchingList.First();//如果没有设置默认值,则默认返回匹配字符最多的一条数据 |
| | | } |
| | | } |
| | | //口径和材料都没有匹配上,就用型号名匹配 |
| | | firstCount = 0;*/ |
| | | if (vmo != null) |
| | | { |
| | | input.MatchingMinorLoss = vmo.Coefficient; |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | input.MatchingDiameter = vmo.Caliber; |
| | | input.MatchingMaterial = vmo.MaterialName; |
| | | input.MatchingModelType = vmo.Name; |
| | | input.MatchingValveSetting = vmo.ValveSetting; |
| | | input.MatchingValveLift = vmo.ValveLift; |
| | | input.MatchingValveType = vmo.Type.ToString(); |
| | | return true; |
| | | } |
| | | if (nameMatching.Count > 0) |
| | | { |
| | | 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; |
| | | } |
| | | 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.Material == input.Material //材料约束 |
| | | ).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.Materia == null) || i.Materia == input.Material)).ToList(); |
| | | if (absoluteMatch.Count > 1) |
| | | { |
| | | var allMatchingList = absoluteMatch |
| | | .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) |
| | | return false;//通过型号名没有找到,则视为没有匹配到 |
| | | foreach (var item in allMatchingList) |
| | | { |
| | | if (item.IsDefault) |
| | | { |
| | | vmo = item; |
| | | } |
| | | } |
| | | vmo = allMatchingList.First();//如果没有设置默认值,则默认返回匹配字符最多的一条数据 |
| | | } |
| | | else if (absoluteMatch.Count == 1) |
| | | { |
| | | vmo = absoluteMatch.First(); |
| | | } |
| | | else |
| | | { |
| | | //区间匹配 |
| | | var rangeMatch = adaptingManageVmos |
| | | .Where(item => |
| | | item.Caliber == null || |
| | | 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) |
| | | { |
| | | var materialList = new List<Vmo.AssetsValveMainVmo>(); |
| | | foreach (var range in rangeMatch) |
| | | { |
| | | //以材料为条件开始匹配 |
| | | if (range.Materia == null) |
| | | { |
| | | materialList.Add(range); |
| | | } |
| | | else |
| | | { |
| | | int commonCount = GetIntersect(input.Material, range.Materia); |
| | | if (commonCount > firstCount) |
| | | { |
| | | materialList.Add(range); |
| | | firstCount = commonCount; |
| | | } |
| | | } |
| | | } |
| | | //用已经筛选完成的列表中以名称筛选 |
| | | firstCount = 0; |
| | | if (materialList.Count < 1) |
| | | return false; |
| | | var allMatchingList = materialList |
| | | .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) |
| | | return false;//通过型号名没有找到,则视为没有匹配到 |
| | | foreach (var item in allMatchingList) |
| | | { |
| | | if (item.IsDefault) |
| | | { |
| | | vmo = item; |
| | | } |
| | | } |
| | | vmo = allMatchingList.First();//如果没有设置默认值,则默认返回匹配字符最多的一条数据 |
| | | } |
| | | } |
| | | //口径和材料都没有匹配上,就用型号名匹配 |
| | | firstCount = 0;*//* |
| | | if (vmo != null) |
| | | { |
| | | 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 = vmo.ValveType.ToString(); |
| | | return true; |
| | | }*/ |
| | | return false; |
| | | } |
| | | |