| | |
| | | using HStation.WinFrmUI.PhartRelation; |
| | | using HStation.Vmo; |
| | | using HStation.WinFrmUI.PhartRelation; |
| | | |
| | | namespace HStation.WinFrmUI |
| | | { |
| | |
| | | bool IsMaching = false; |
| | | var pumpMain = new BLL.PumpMain(); |
| | | var adaptingManage = new BLL.AdaptingManage(); |
| | | var pipeLineManage = new BLL.PipeLineMain(); |
| | | var pipeLineManage = new BLL.PipeMain(); |
| | | var valveMain = new BLL.ValveMain(); |
| | | var elbowMain = new BLL.ElbowMain(); |
| | | var threeLinkMain = new BLL.ThreeLinkMain(); |
| | |
| | | //泵匹配 |
| | | public static async Task<bool> MatchingPumps(PumpMatchingViewModel InputModel, List<Vmo.PumpMainVmo> pumpMainVmos) |
| | | { |
| | | if (pumpMainVmos == null) |
| | | { |
| | | return true; |
| | | } |
| | | Vmo.PumpMainVmo vmo = null; |
| | | int startCount = 0; |
| | | // 尝试绝对匹配 |
| | |
| | | //阀门匹配 |
| | | public static bool MatchingValve(ValveMatchingViewModel input, List<Vmo.ValveMainVmo> adaptingManageVmos) |
| | | { |
| | | if (adaptingManageVmos == null) |
| | | { |
| | | return true; |
| | | } |
| | | HStation.Vmo.ValveMainVmo vmo = null; |
| | | int firstCount = 0; |
| | | //口径最小差值 |
| | | // 绝对匹配 |
| | | var absoluteMatch = adaptingManageVmos.Where(i => |
| | | ((i.Caliber == null) || i.Caliber == input.Diameter) && |
| | | ((input.Material == null) || i.Material == input.Material)).ToList(); |
| | | ((input.Material == null) || i.MaterialName == input.Material)).ToList(); |
| | | if (absoluteMatch.Any()) |
| | | { |
| | | foreach (var range in absoluteMatch) |
| | |
| | | foreach (var range in rangeMatch) |
| | | { |
| | | //以材料为条件开始匹配 |
| | | if (range.Material == null) |
| | | if (range.MaterialName == null) |
| | | { |
| | | materialList.Add(range); |
| | | } |
| | | else |
| | | { |
| | | int commonCount = GetIntersect(input.Material, range.Material); |
| | | int commonCount = GetIntersect(input.Material, range.MaterialName); |
| | | if (commonCount > firstCount) |
| | | { |
| | | materialList.Add(range); |
| | |
| | | input.MatchingMinorLoss = vmo.Coefficient; |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | input.MatchingDiameter = vmo.Caliber; |
| | | input.MatchingMaterial = vmo.Material; |
| | | input.MatchingMaterial = vmo.MaterialName; |
| | | input.MatchingModelType = vmo.Name; |
| | | // input.MatchingValveSetting = |
| | | input.MatchingValveType = vmo.SeriesType.ToString(); |
| | |
| | | } |
| | | |
| | | //管道匹配 |
| | | public static bool MatchingPipe(PipeMatchingViewModel input, List<Vmo.PipeLineMainVmo> pipeLineManageVmos) |
| | | public static bool MatchingPipe(PipeMatchingViewModel input, List<Vmo.PipeMainVmo> pipeLineManageVmos) |
| | | { |
| | | Vmo.PipeLineMainVmo vmo = null; |
| | | if (pipeLineManageVmos == null) |
| | | { |
| | | return true; |
| | | } |
| | | Vmo.PipeMainVmo vmo = null; |
| | | int StartCount = 0; |
| | | //口径最小差值 |
| | | // 绝对匹配 |
| | |
| | | //弯头匹配 |
| | | public static bool MatchingElbow(ElbowMatchingViewModel input, List<Vmo.ElbowMainVmo> adaptingManageVmos) |
| | | { |
| | | if (adaptingManageVmos == null) |
| | | { |
| | | return true; |
| | | } |
| | | Vmo.ElbowMainVmo vmo = null; |
| | | int firstCount = 0; |
| | | //口径最小差值 |
| | | // 绝对匹配 |
| | | var absoluteMatch = adaptingManageVmos.Where(i => |
| | | ((input.Caliber == null && i.Caliber == null) || i.Caliber == input.Caliber) && |
| | | ((input.Material == null) || i.Material == input.Material)).ToList(); |
| | | ((input.Material == null) || i.MaterialName == input.Material)).ToList(); |
| | | if (absoluteMatch.Any()) |
| | | { |
| | | foreach (var range in absoluteMatch) |
| | |
| | | foreach (var range in rangeMatch) |
| | | { |
| | | //以材料为条件开始匹配 |
| | | if (range.Material == null) |
| | | if (range.MaterialName == null) |
| | | { |
| | | materialList.Add(range); |
| | | } |
| | | else |
| | | { |
| | | int commonCount = GetIntersect(input.Material, range.Material); |
| | | int commonCount = GetIntersect(input.Material, range.MaterialName); |
| | | if (commonCount > firstCount) |
| | | { |
| | | materialList.Add(range); |
| | |
| | | { |
| | | input.MatchingMinorLoss = vmo.Coefficient; |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | input.MatchingMaterial = vmo.Material; |
| | | input.MatchingMaterial = vmo.MaterialName; |
| | | input.MatchingModelType = vmo.Name; |
| | | return true; |
| | | } |
| | |
| | | //三通匹配 |
| | | public static bool MatchingThreelink(ThreelinkMatchingViewModel input, List<Vmo.ThreeLinkMainVmo> adaptingManageVmos) |
| | | { |
| | | if (adaptingManageVmos == null) |
| | | { |
| | | return true; |
| | | } |
| | | Vmo.ThreeLinkMainVmo vmo = null; |
| | | int firstCount = 0; |
| | | //口径最小差值 |
| | | // 绝对匹配 |
| | | var absoluteMatch = adaptingManageVmos.Where(i => |
| | | ((input.Caliber == null && i.Caliber == null) || i.Caliber == input.Caliber) && |
| | | ((input.Material == null) || i.Material == input.Material)).ToList(); |
| | | ((input.Material == null) || i.MaterialName == input.Material)).ToList(); |
| | | if (absoluteMatch.Any()) |
| | | { |
| | | foreach (var range in absoluteMatch) |
| | |
| | | foreach (var range in rangeMatch) |
| | | { |
| | | //以材料为条件开始匹配 |
| | | if (range.Material == null) |
| | | if (range.MaterialName == null) |
| | | { |
| | | materialList.Add(range); |
| | | } |
| | | else |
| | | { |
| | | int commonCount = GetIntersect(input.Material, range.Material); |
| | | int commonCount = GetIntersect(input.Material, range.MaterialName); |
| | | if (commonCount > firstCount) |
| | | { |
| | | materialList.Add(range); |
| | |
| | | { |
| | | input.MatchingMinorLoss = vmo.Coefficient; |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | input.MatchingMaterial = vmo.Material; |
| | | input.MatchingMaterial = vmo.MaterialName; |
| | | input.MatchingModelType = vmo.Name; |
| | | return true; |
| | | } |
| | |
| | | //四通匹配 |
| | | public static bool MatchingFourlink(FourlinkMatchingViewModel input, List<Vmo.FourLinkMainVmo> adaptingManageVmos) |
| | | { |
| | | if (adaptingManageVmos == null) |
| | | { |
| | | return true; |
| | | } |
| | | Vmo.FourLinkMainVmo vmo = null; |
| | | int firstCount = 0; |
| | | //口径最小差值 |
| | | // 绝对匹配 |
| | | var absoluteMatch = adaptingManageVmos.Where(i => |
| | | ((input.Caliber == null && i.Caliber == null) || i.Caliber == input.Caliber) && |
| | | ((input.Material == null) || i.Material == input.Material)).ToList(); |
| | | ((input.Material == null) || i.MaterialName == input.Material)).ToList(); |
| | | if (absoluteMatch.Any()) |
| | | { |
| | | foreach (var range in absoluteMatch) |
| | |
| | | foreach (var range in rangeMatch) |
| | | { |
| | | //以材料为条件开始匹配 |
| | | if (range.Material == null) |
| | | if (range.MaterialName == null) |
| | | { |
| | | materialList.Add(range); |
| | | } |
| | | else |
| | | { |
| | | int commonCount = GetIntersect(input.Material, range.Material); |
| | | int commonCount = GetIntersect(input.Material, range.MaterialName); |
| | | if (commonCount > firstCount) |
| | | { |
| | | materialList.Add(range); |
| | |
| | | { |
| | | input.MatchingMinorLoss = vmo.Coefficient; |
| | | input.MatchingDbId = vmo.ID.ToString(); |
| | | input.MatchingMaterial = vmo.Material; |
| | | input.MatchingMaterial = vmo.MaterialName; |
| | | input.MatchingModelType = vmo.Name; |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /* |
| | | //返回两个字符串之间相同的字符个数 |
| | | private static int GetIntersect(string baseString, string compareString) |
| | | { |
| | | // 将字符串转换为字符集合 |
| | | if (baseString == string.Empty || baseString == null || compareString == string.Empty || compareString == null) |
| | | { |
| | | return 0; |
| | | } |
| | | HashSet<char> baseChars = new HashSet<char>(baseString); |
| | | HashSet<char> comparisonChars = new HashSet<char>(compareString); |
| | | // 计算两个集合的交集 |
| | | int commonCount = baseChars.Intersect(comparisonChars).Count(); |
| | | return commonCount; |
| | | }*/ |
| | | |
| | | /// <summary> |
| | | /// 获取两个字符串的所有交集 |