namespace Yw.WinFrmUI
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public class HydroLossStatisticsCatalogHelper
|
{
|
/// <summary>
|
/// 创建
|
/// </summary>
|
public static HydroLossStatisticsCatalogViewModel Create
|
(
|
Yw.Model.HydroModelInfo hydroInfo,
|
HydroCalcuResult calcuResult,
|
List<HydroLossStatisticsItemViewModel> allItemList
|
)
|
{
|
if (hydroInfo == null)
|
{
|
return default;
|
}
|
if (calcuResult == null || !calcuResult.Succeed)
|
{
|
return default;
|
}
|
if (allItemList == null || allItemList.Count < 1)
|
{
|
return default;
|
}
|
|
var vm = new HydroLossStatisticsCatalogViewModel();
|
vm.Items = new List<HydroLossStatisticsCatalogItemViewModel>();
|
|
#region 水泵
|
|
if (hydroInfo.Pumps != null && hydroInfo.Pumps.Count > 0)
|
{
|
var allCalcuVisualDict = calcuResult.GetVisualDict();
|
var itemForPump = new HydroLossStatisticsCatalogItemViewModel();
|
itemForPump.EnergyName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Pump);
|
foreach (var pump in hydroInfo.Pumps)
|
{
|
var calcuPumpResult = allCalcuVisualDict?.GetValue(pump.Code) as HydroCalcuPumpResult;
|
if (calcuPumpResult != null)
|
{
|
if (calcuPumpResult.CalcuP.HasValue && calcuPumpResult.CalcuE.HasValue)
|
{
|
itemForPump.EnergyValue += calcuPumpResult.CalcuP.Value * 1000 * (1 - calcuPumpResult.CalcuE.Value / 100);
|
}
|
}
|
}
|
vm.Items.Add(itemForPump);
|
}
|
|
#endregion
|
|
#region 管道
|
|
if (hydroInfo.Pipes != null && hydroInfo.Pipes.Count > 0)
|
{
|
var itemForPipe = new HydroLossStatisticsCatalogItemViewModel();
|
itemForPipe.EnergyName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Pipe);
|
var codes = hydroInfo.Pipes.Select(x => x.Code).Distinct().ToList();
|
var items = allItemList.Where(x => codes.Contains(x.EnergyCode)).ToList();
|
if (items != null && items.Count > 0)
|
{
|
itemForPipe.EnergyValue = items.Sum(x => x.EnergyValue);
|
}
|
vm.Items.Add(itemForPipe);
|
}
|
|
#endregion
|
|
#region 过渡件
|
|
if (hydroInfo.Translations != null && hydroInfo.Translations.Count > 0)
|
{
|
var itemForTranslation = new HydroLossStatisticsCatalogItemViewModel();
|
itemForTranslation.EnergyName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Translation);
|
var codes = hydroInfo.Translations.Select(x => x.Code).Distinct().ToList();
|
var items = allItemList.Where(x => codes.Contains(x.EnergyCode)).ToList();
|
if (items != null && items.Count > 0)
|
{
|
itemForTranslation.EnergyValue = items.Sum(x => x.EnergyValue);
|
}
|
vm.Items.Add(itemForTranslation);
|
}
|
|
#endregion
|
|
#region 阀门
|
|
if (hydroInfo.Valves != null && hydroInfo.Valves.Count > 0)
|
{
|
var itemForValve = new HydroLossStatisticsCatalogItemViewModel();
|
itemForValve.EnergyName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Valve);
|
var codes = hydroInfo.Valves.Select(x => x.Code).Distinct().ToList();
|
var items = allItemList.Where(x => codes.Contains(x.EnergyCode)).ToList();
|
if (items != null && items.Count > 0)
|
{
|
itemForValve.EnergyValue = items.Sum(x => x.EnergyValue);
|
}
|
vm.Items.Add(itemForValve);
|
}
|
|
#endregion
|
|
#region 弯头
|
|
if (hydroInfo.Elbows != null && hydroInfo.Elbows.Count > 0)
|
{
|
var itemForElbow = new HydroLossStatisticsCatalogItemViewModel();
|
itemForElbow.EnergyName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Elbow);
|
var codes = hydroInfo.Elbows.Select(x => x.Code).Distinct().ToList();
|
var items = allItemList.Where(x => codes.Contains(x.EnergyCode)).ToList();
|
if (items != null && items.Count > 0)
|
{
|
itemForElbow.EnergyValue = items.Sum(x => x.EnergyValue);
|
}
|
vm.Items.Add(itemForElbow);
|
}
|
|
#endregion
|
|
#region 三通
|
|
if (hydroInfo.Threelinks != null && hydroInfo.Threelinks.Count > 0)
|
{
|
var itemForThreelink = new HydroLossStatisticsCatalogItemViewModel();
|
itemForThreelink.EnergyName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Threelink);
|
var codes = hydroInfo.Threelinks.Select(x => x.Code).Distinct().ToList();
|
var items = allItemList.Where(x => codes.Contains(x.EnergyCode)).ToList();
|
if (items != null && items.Count > 0)
|
{
|
itemForThreelink.EnergyValue = items.Sum(x => x.EnergyValue);
|
}
|
vm.Items.Add(itemForThreelink);
|
}
|
|
#endregion
|
|
#region 四通
|
|
if (hydroInfo.Fourlinks != null && hydroInfo.Fourlinks.Count > 0)
|
{
|
var itemForFourlink = new HydroLossStatisticsCatalogItemViewModel();
|
itemForFourlink.EnergyName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Fourlink);
|
var codes = hydroInfo.Fourlinks.Select(x => x.Code).Distinct().ToList();
|
var items = allItemList.Where(x => codes.Contains(x.EnergyCode)).ToList();
|
if (items != null && items.Count > 0)
|
{
|
itemForFourlink.EnergyValue = items.Sum(x => x.EnergyValue);
|
}
|
vm.Items.Add(itemForFourlink);
|
}
|
|
#endregion
|
|
#region 换热器
|
|
if (hydroInfo.Exchangers != null && hydroInfo.Exchangers.Count > 0)
|
{
|
var itemForExchanger = new HydroLossStatisticsCatalogItemViewModel();
|
itemForExchanger.EnergyName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Exchanger);
|
var codes = hydroInfo.Exchangers.Select(x => x.Code).Distinct().ToList();
|
var items = allItemList.Where(x => codes.Contains(x.EnergyCode)).ToList();
|
if (items != null && items.Count > 0)
|
{
|
itemForExchanger.EnergyValue = items.Sum(x => x.EnergyValue);
|
}
|
vm.Items.Add(itemForExchanger);
|
}
|
|
#endregion
|
|
#region 压缩机
|
|
if (hydroInfo.Compressors != null && hydroInfo.Compressors.Count > 0)
|
{
|
var itemForCompressor = new HydroLossStatisticsCatalogItemViewModel();
|
itemForCompressor.EnergyName = HydroParterCatalogHelper.GetName(Yw.Hydro.ParterCatalog.Compressor);
|
var codes = hydroInfo.Compressors.Select(x => x.Code).Distinct().ToList();
|
var items = allItemList.Where(x => codes.Contains(x.EnergyCode)).ToList();
|
if (items != null && items.Count > 0)
|
{
|
itemForCompressor.EnergyValue = items.Sum(x => x.EnergyValue);
|
}
|
vm.Items.Add(itemForCompressor);
|
}
|
|
#endregion
|
|
if (vm.Items.Count > 0)
|
{
|
vm.TotalEnergyValue = vm.Items.Sum(x => x.EnergyValue);
|
}
|
|
//w=>kW
|
vm.TotalEnergyValue = Math.Round(vm.TotalEnergyValue / 1000d, 1);
|
vm.Items.ForEach(x => x.EnergyValue = Math.Round(x.EnergyValue / 1000d, 1));
|
|
return vm;
|
|
}
|
}
|
}
|