using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Yw.WinFrmUI { /// /// /// public static class HydroCatalogLossScaleHelper { /// /// 获取分类损失比例列表 /// public static List GetAllCatalogLossScaleList(this Yw.Model.HydroModelInfo hydroInfo, List allEnergyList) { if (hydroInfo == null) { return default; } var allScaleList = new List(); if (allEnergyList != null && allEnergyList.Count > 0) { if (hydroInfo.Pipes != null && hydroInfo.Pipes.Count > 0) { var allVisualIds = hydroInfo.Pipes.Select(x => x.Code).Distinct().ToList(); var allVisualEnergyList = allEnergyList.Where(x => allVisualIds.Contains(x.Id)).ToList(); var visualLossScale = new HydroCatalogLossScaleViewModel(); visualLossScale.Catalog = Yw.Hydro.ParterCatalog.Pipe; visualLossScale.CatalogName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Pipe); visualLossScale.Loss = allVisualEnergyList.Count > 0 ? allVisualEnergyList.Sum(x => x.EnergyPower) : 0; allScaleList.Add(visualLossScale); } if (hydroInfo.Translations != null && hydroInfo.Translations.Count > 0) { var allVisualIds = hydroInfo.Translations.Select(x => x.Code).Distinct().ToList(); var allVisualEnergyList = allEnergyList.Where(x => allVisualIds.Contains(x.Id)).ToList(); var visualLossScale = new HydroCatalogLossScaleViewModel(); visualLossScale.Catalog = Yw.Hydro.ParterCatalog.Translation; visualLossScale.CatalogName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Translation); visualLossScale.Loss = allVisualEnergyList.Count > 0 ? allVisualEnergyList.Sum(x => x.EnergyPower) : 0; allScaleList.Add(visualLossScale); } if (hydroInfo.Valves != null && hydroInfo.Valves.Count > 0) { var allVisualIds = hydroInfo.Valves.Select(x => x.Code).Distinct().ToList(); var allVisualEnergyList = allEnergyList.Where(x => allVisualIds.Contains(x.Id)).ToList(); var visualLossScale = new HydroCatalogLossScaleViewModel(); visualLossScale.Catalog = Yw.Hydro.ParterCatalog.Valve; visualLossScale.CatalogName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Valve); visualLossScale.Loss = allVisualEnergyList.Count > 0 ? allVisualEnergyList.Sum(x => x.EnergyPower) : 0; allScaleList.Add(visualLossScale); } if (hydroInfo.Elbows != null && hydroInfo.Elbows.Count > 0) { var allVisualIds = hydroInfo.Elbows.Select(x => x.Code).Distinct().ToList(); var allVisualEnergyList = allEnergyList.Where(x => allVisualIds.Contains(x.Id)).ToList(); var visualLossScale = new HydroCatalogLossScaleViewModel(); visualLossScale.Catalog = Yw.Hydro.ParterCatalog.Elbow; visualLossScale.CatalogName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Elbow); visualLossScale.Loss = allVisualEnergyList.Count > 0 ? allVisualEnergyList.Sum(x => x.EnergyPower) : 0; allScaleList.Add(visualLossScale); } if (hydroInfo.Threelinks != null && hydroInfo.Threelinks.Count > 0) { var allVisualIds = hydroInfo.Threelinks.Select(x => x.Code).Distinct().ToList(); var allVisualEnergyList = allEnergyList.Where(x => allVisualIds.Contains(x.Id)).ToList(); var visualLossScale = new HydroCatalogLossScaleViewModel(); visualLossScale.Catalog = Yw.Hydro.ParterCatalog.Threelink; visualLossScale.CatalogName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Threelink); visualLossScale.Loss = allVisualEnergyList.Count > 0 ? allVisualEnergyList.Sum(x => x.EnergyPower) : 0; allScaleList.Add(visualLossScale); } } return allScaleList; } } }