duheng
2024-12-04 7079cbb505471a8d3251cac4e27c7a3841f8e656
WinFrmUI/HStation.WinFrmUI.Xhs.Core/00-core/AssetsMatchingHelper.cs
@@ -103,6 +103,86 @@
                        IsMaching = true;
                    }
                }
                //喷头匹配
                foreach (var item in assetsAutoMatchingView.Nozzles)
                {
                    if (MatchingSprinkler(item, allSprinkler))
                    {
                        IsMaching = true;
                    }
                }
                //闷头匹配
                foreach (var item in assetsAutoMatchingView.Bluntheads)
                {
                    if (MatchingBlunthead(item, allBluntheadMain))
                    {
                        IsMaching = true;
                    }
                }
                //换热器匹配
                foreach (var item in assetsAutoMatchingView.Exchangers)
                {
                    if (MatchingExchanger(item, allExchanger))
                    {
                        IsMaching = true;
                    }
                }
                //压缩机匹配
                foreach (var item in assetsAutoMatchingView.Compressors)
                {
                    if (MatchingCompressor(item, allCompressorMain))
                    {
                        IsMaching = true;
                    }
                }
                //水池匹配
                foreach (var item in assetsAutoMatchingView.Tanks)
                {
                    if (MatchingTank(item, allTankMain))
                    {
                        IsMaching = true;
                    }
                }
                //水表匹配
                foreach (var item in assetsAutoMatchingView.Meters)
                {
                    if (MatchingMeter(item, allMeterMain))
                    {
                        IsMaching = true;
                    }
                }
                //流量计匹配
                foreach (var item in assetsAutoMatchingView.Flowmeters)
                {
                    if (MatchingFlowmeter(item, allFlowmeterMain))
                    {
                        IsMaching = true;
                    }
                }
                //消火栓匹配
                foreach (var item in assetsAutoMatchingView.Hydrants)
                {
                    if (MatchingHydrant(item, allHydrantMain))
                    {
                        IsMaching = true;
                    }
                }
                //压力表匹配
                foreach (var item in assetsAutoMatchingView.Pressmeters)
                {
                    if (MatchingPressmeter(item, allPressmeterMain))
                    {
                        IsMaching = true;
                    }
                }
                //过渡件匹配
                foreach (var item in assetsAutoMatchingView.Translations)
                {
                    if (MatchingTranslation(item, allTranslationMain))
                    {
                        IsMaching = true;
                    }
                }
            }
            catch (Exception ex)
            {
@@ -708,6 +788,682 @@
            return false;
        }
        //喷头匹配
        public static bool MatchingSprinkler(HydroNozzleMatchingViewModel input, List<Vmo.AssetsSprinklerMainVmo> sprinklerVmos)
        {
            if (sprinklerVmos == null)
            {
                return true;
            }
            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)
            {
                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 = sprinklerVmos.First();
                    }
                }
                else if (absoluteMatching.Count == 1)
                {
                    vmo = absoluteMatching.First();
                }
                else
                    vmo = sprinklerVmos.First();
            }
            else if (nameMatching.Count == 1)
            {
                vmo = nameMatching.First();
            }
            else
            {
                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)
                {
                    var defaultList = absoluteMatching.Where(x => x.Flags.Contains("默认值")).ToList();
                    //取默认
                    if (defaultList.Count > 0)
                    {
                        vmo = defaultList.First();
                    }
                    else if (defaultList.Count < 0)
                    {
                        vmo = sprinklerVmos.First();
                    }
                }
                else if (absoluteMatching.Count == 1)
                {
                    vmo = absoluteMatching.First();
                }
                else
                    vmo = sprinklerVmos.First();
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingMaterial = vmo.Material;
                input.MatchingModelType = vmo.Name;
                return true;
            }
            return false;
        }
        //换热器匹配
        public static bool MatchingExchanger(HydroExchangerMatchingViewModel input, List<Vmo.AssetsExchangerMainVmo> exchangerVmos)
        {
            if (exchangerVmos == null)
            {
                return true;
            }
            Vmo.AssetsExchangerMainVmo vmo = null;
            var nameMatching = exchangerVmos.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)
            {
                var absoluteMatching = nameMatching.Where(i =>
                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 = exchangerVmos.First();
                    }
                }
                else if (absoluteMatching.Count == 1)
                {
                    vmo = absoluteMatching.First();
                }
                else
                    vmo = exchangerVmos.First();
            }
            else if (nameMatching.Count == 1)
            {
                vmo = nameMatching.First();
            }
            else
            {
                var absoluteMatching = exchangerVmos.Where(i =>
            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 = exchangerVmos.First();
                    }
                }
                else if (absoluteMatching.Count == 1)
                {
                    vmo = absoluteMatching.First();
                }
                else
                    vmo = exchangerVmos.First();
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingMaterial = vmo.Material;
                input.MatchingModelType = vmo.Name;
                return true;
            }
            return false;
        }
        //空压机匹配
        public static bool MatchingCompressor(HydroCompressorMatchingViewModel input, List<Vmo.AssetsCompressorMainVmo> compressorVmos)
        {
            if (compressorVmos == null)
            {
                return true;
            }
            Vmo.AssetsCompressorMainVmo vmo = null;
            var nameMatching = compressorVmos.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)
            {
                var absoluteMatching = nameMatching.Where(i =>
                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 = compressorVmos.First();
                    }
                }
                else if (absoluteMatching.Count == 1)
                {
                    vmo = absoluteMatching.First();
                }
                else
                    vmo = compressorVmos.First();
            }
            else if (nameMatching.Count == 1)
            {
                vmo = nameMatching.First();
            }
            else
            {
                var absoluteMatching = compressorVmos.Where(i =>
            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 = compressorVmos.First();
                    }
                }
                else if (absoluteMatching.Count == 1)
                {
                    vmo = absoluteMatching.First();
                }
                else
                    vmo = compressorVmos.First();
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingMaterial = vmo.Material;
                input.MatchingModelType = vmo.Name;
                return true;
            }
            return false;
        }
        //闷头匹配
        public static bool MatchingBlunthead(HydroBluntheadMatchingViewModel input, List<Vmo.AssetsBluntheadMainVmo> bluntheadVmos)
        {
            if (bluntheadVmos == null)
            {
                return true;
            }
            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)
            {
                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 = bluntheadVmos.First();
                    }
                }
                else if (absoluteMatching.Count == 1)
                {
                    vmo = absoluteMatching.First();
                }
                else
                    vmo = bluntheadVmos.First();
            }
            else if (nameMatching.Count == 1)
            {
                vmo = nameMatching.First();
            }
            else
            {
                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)
                {
                    var defaultList = absoluteMatching.Where(x => x.Flags.Contains("默认值")).ToList();
                    //取默认
                    if (defaultList.Count > 0)
                    {
                        vmo = defaultList.First();
                    }
                    else if (defaultList.Count < 0)
                    {
                        vmo = bluntheadVmos.First();
                    }
                }
                else if (absoluteMatching.Count == 1)
                {
                    vmo = absoluteMatching.First();
                }
                else
                    vmo = bluntheadVmos.First();
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingMaterial = vmo.Material;
                input.MatchingModelType = vmo.Name;
                return true;
            }
            return false;
        }
        //水池匹配
        public static bool MatchingTank(HydroTankMatchingViewModel input, List<Vmo.AssetsTankMainVmo> tankVmos)
        {
            if (tankVmos == null)
            {
                return true;
            }
            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)
            {
                var defaultList = nameMatching.Where(x => x.Flags.Contains("默认值")).ToList();
                //取默认
                if (defaultList.Count > 0)
                {
                    vmo = tankVmos.First();
                }
                else if (defaultList.Count < 0)
                {
                    vmo = tankVmos.First();
                }
            }
            else if (nameMatching.Count == 1)
            {
                vmo = nameMatching.First();
            }
            else
                vmo = tankVmos.First();
            if (vmo != null)
            {
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingModelType = vmo.Name;
                //    input.mat
                return true;
            }
            return false;
        }
        //水表匹配
        public static bool MatchingMeter(HydroMeterMatchingViewModel input, List<Vmo.AssetsMeterMainVmo> MeterMainVmos)
        {
            Vmo.AssetsMeterMainVmo vmo = null;
            if (MeterMainVmos == null)
            {
                return true;
            }
            var nameMatching = MeterMainVmos.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)
            {
                var defaultList = nameMatching.Where(x => x.Flags.Contains("默认值")).ToList();
                //取默认
                if (defaultList.Count > 0)
                {
                    vmo = defaultList.First();
                }
                else if (defaultList.Count < 0)
                {
                    vmo = MeterMainVmos.First();
                }
            }
            else if (nameMatching.Count == 1)
            {
                vmo = nameMatching.First();
            }
            else
                vmo = MeterMainVmos.First();
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingModelType = vmo.Name;
                return true;
            }
            return false;
        }
        //流量计匹配
        public static bool MatchingFlowmeter(HydroFlowmeterMatchingViewModel input, List<Vmo.AssetsFlowmeterMainVmo> FlowmeterMainVmos)
        {
            if (FlowmeterMainVmos == null)
            {
                return true;
            }
            Vmo.AssetsFlowmeterMainVmo vmo = null;
            var nameMatching = FlowmeterMainVmos.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)
            {
                var defaultList = nameMatching.Where(x => x.Flags.Contains("默认值")).ToList();
                //取默认
                if (defaultList.Count > 0)
                {
                    vmo = defaultList.First();
                }
                else if (defaultList.Count < 0)
                {
                    vmo = FlowmeterMainVmos.First();
                }
            }
            else if (nameMatching.Count == 1)
            {
                vmo = nameMatching.First();
            }
            else
            {
                vmo = FlowmeterMainVmos.First();
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingModelType = vmo.Name;
                return true;
            }
            return false;
        }
        //消火栓匹配
        public static bool MatchingHydrant(HydroHydrantMatchingViewModel input, List<Vmo.AssetsHydrantMainVmo> hydrantVmos)
        {
            if (hydrantVmos == null)
            {
                return true;
            }
            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)
            {
                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)
                {
                    vmo = absoluteMatching.First();
                }
                else
                    vmo = hydrantVmos.First();
            }
            else if (nameMatching.Count == 1)
            {
                vmo = nameMatching.First();
            }
            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)
                {
                    vmo = absoluteMatching.First();
                }
                else
                    vmo = hydrantVmos.First();
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingMaterial = vmo.Material;
                input.MatchingModelType = vmo.Name;
                return true;
            }
            return false;
        }
        //压力表匹配
        public static bool MatchingPressmeter(HydroPressmeterMatchingViewModel input, List<Vmo.AssetsPressmeterMainVmo> pressmeterVmos)
        {
            if (pressmeterVmos == null)
            {
                return true;
            }
            Vmo.AssetsPressmeterMainVmo vmo = null;
            var nameMatching = pressmeterVmos.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)
            {
                var defaultList = nameMatching.Where(x => x.Flags.Contains("默认值")).ToList();
                //取默认
                if (defaultList.Count > 0)
                {
                    vmo = pressmeterVmos.First();
                }
                else if (defaultList.Count < 0)
                {
                    vmo = pressmeterVmos.First();
                }
            }
            else if (nameMatching.Count == 1)
            {
                vmo = nameMatching.First();
            }
            else
            {
                vmo = pressmeterVmos.First();
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingModelType = vmo.Name;
                return true;
            }
            return false;
        }
        //过渡件匹配
        public static bool MatchingTranslation(HydroTranslationMatchingViewModel input, List<Vmo.AssetsTranslationMainVmo> translationVmos)
        {
            if (translationVmos == null)
            {
                return true;
            }
            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)
            {
                var absoluteMatching = nameMatching.Where(i =>
                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 = translationVmos.First();
                    }
                }
                else if (absoluteMatching.Count == 1)
                {
                    vmo = absoluteMatching.First();
                }
                else
                    vmo = translationVmos.First();
            }
            else if (nameMatching.Count == 1)
            {
                vmo = nameMatching.First();
            }
            else
            {
                var absoluteMatching = translationVmos.Where(i =>
            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 = translationVmos.First();
                    }
                }
                else if (absoluteMatching.Count == 1)
                {
                    vmo = absoluteMatching.First();
                }
                else
                    vmo = translationVmos.First();
            }
            if (vmo != null)
            {
                input.MatchingMinorLoss = vmo.MinorLoss;
                input.MatchingDbId = vmo.ID.ToString();
                input.MatchingMaterial = vmo.Material;
                input.MatchingModelType = vmo.Name;
                return true;
            }
            return false;
        }
        /// <summary>
        /// 获取两个字符串的所有交集
        /// </summary>