namespace Yw.WinFrmUI
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public class HydroLossStatisticsCategoryHelper
|
{
|
/// <summary>
|
/// 创建
|
/// </summary>
|
public static HydroLossStatisticsCategoryViewModel 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 HydroLossStatisticsCategoryViewModel();
|
vm.Items = new List<HydroLossStatisticsCategoryItemViewModel>();
|
|
var groupList = allItemList.GroupBy(x => x.EnergyType).OrderBy(x => x.Key).ToList();
|
foreach (var group in groupList)
|
{
|
var item = new HydroLossStatisticsCategoryItemViewModel();
|
item.EnergyType = group.Key;
|
item.EnergyName = group.Key.GetDisplayText();
|
item.EnergyValue = group.Sum(x => x.EnergyValue);
|
vm.Items.Add(item);
|
}
|
|
double pumpLoss = 0;
|
if (hydroInfo.Pumps != null && hydroInfo.Pumps.Count > 0)
|
{
|
var allCalcuVisualDict = calcuResult.GetVisualDict();
|
foreach (var pump in hydroInfo.Pumps)
|
{
|
var calcuPumpResult = allCalcuVisualDict?.GetValue(pump.Code) as HydroCalcuPumpResult;
|
if (calcuPumpResult != null)
|
{
|
if (calcuPumpResult.CalcuP.HasValue && calcuPumpResult.CalcuE.HasValue)
|
{
|
pumpLoss += calcuPumpResult.CalcuP.Value * 1000 * (1 - calcuPumpResult.CalcuE.Value / 100);
|
}
|
}
|
}
|
}
|
|
var promoteItem = vm.Items.Find(x => x.EnergyType == eEnergyType.Promote);
|
if (promoteItem != null)
|
{
|
promoteItem.EnergyValue += pumpLoss;
|
}
|
|
var minorLossItem = vm.Items.Find(x => x.EnergyType == Yw.WinFrmUI.eEnergyType.MinorLoss);
|
if (minorLossItem != null)
|
{
|
minorLossItem.EnergyValue += pumpLoss;
|
}
|
|
//w=>kW
|
vm.Items.ForEach(x => x.EnergyValue = Math.Round(x.EnergyValue / 1000d, 1));
|
|
return vm;
|
|
}
|
|
}
|
}
|