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,
HydroCalcuResult calcuResult,
List allEnergyList
)
{
if (hydroInfo == null)
{
return default;
}
var allCalcuResultVisualDict = calcuResult?.GetVisualDict();
var allScaleList = new List();
#region 水泵
if (hydroInfo.Pumps != null && hydroInfo.Pumps.Count > 0)
{
var visualLossScale = new HydroCatalogLossScaleViewModel();
visualLossScale.Catalog = Yw.Hydro.ParterCatalog.Pump;
visualLossScale.CatalogName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Pump);
foreach (var pump in hydroInfo.Pumps)
{
var calcuPumpResult = allCalcuResultVisualDict?.GetValue(pump.Code) as HydroCalcuPumpResult;
if (calcuPumpResult != null)
{
if (calcuPumpResult.CalcuP.HasValue && calcuPumpResult.CalcuE.HasValue)
{
visualLossScale.Loss += calcuPumpResult.CalcuP.Value * 1000 * (1 - calcuPumpResult.CalcuE.Value / 100);
}
}
}
allScaleList.Add(visualLossScale);
}
#endregion
if (allEnergyList != null && allEnergyList.Count > 0)
{
#region 管道
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);
}
#endregion
#region 过渡件
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);
}
#endregion
#region 阀门
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);
}
#endregion
#region 弯头
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);
}
#endregion
#region 三通
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);
}
#endregion
#region 四通
if (hydroInfo.Fourlinks != null && hydroInfo.Fourlinks.Count > 0)
{
var allVisualIds = hydroInfo.Fourlinks.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.Fourlink;
visualLossScale.CatalogName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Fourlink);
visualLossScale.Loss = allVisualEnergyList.Count > 0 ? allVisualEnergyList.Sum(x => x.EnergyPower) : 0;
allScaleList.Add(visualLossScale);
}
#endregion
#region 换热器
if (hydroInfo.Exchangers != null && hydroInfo.Exchangers.Count > 0)
{
var allVisualIds = hydroInfo.Exchangers.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.Exchanger;
visualLossScale.CatalogName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Exchanger);
visualLossScale.Loss = allVisualEnergyList.Count > 0 ? allVisualEnergyList.Sum(x => x.EnergyPower) : 0;
allScaleList.Add(visualLossScale);
}
#endregion
#region 压缩机
if (hydroInfo.Compressors != null && hydroInfo.Compressors.Count > 0)
{
var allVisualIds = hydroInfo.Compressors.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.Compressor;
visualLossScale.CatalogName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Compressor);
visualLossScale.Loss = allVisualEnergyList.Count > 0 ? allVisualEnergyList.Sum(x => x.EnergyPower) : 0;
allScaleList.Add(visualLossScale);
}
#endregion
}
return allScaleList;
}
}
}