using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace IStation.Calculation
|
{
|
/// <summary>
|
/// 能效汇总单时辅助类
|
/// </summary>
|
public class EtaSumSingleHourHelper
|
{
|
/// <summary>
|
/// 汇总
|
/// </summary>
|
/// <returns></returns>
|
public static List<Model.EtaSumSingleHourRecord> Sum
|
(
|
long CorpID,
|
string ObjectType,
|
long ObjectID,
|
DateTime Day,
|
IEnumerable<Model.EtaSingleRealRecord> records
|
)
|
{
|
if (records == null || records.Count() < 1)
|
return default;
|
var run_record_list = records.Where(x => x.RSa == RunStatus.Run).ToList();
|
var result = new List<Model.EtaSumSingleHourRecord>();
|
for (int i = 0; i < 24; i++)
|
{
|
var run_hour_record_list = run_record_list.Where(x => x.DataTime >= Day.Date.AddHours(i) && x.DataTime < Day.Date.AddHours(i + 1)).ToList();
|
var run_normal_hour_record_list = run_hour_record_list.Where(x => x.AnalyStatus == Model.Eta.eAnalyStatus.Normal).ToList();
|
var model = new Model.EtaSumSingleHourRecord();
|
model.CorpID = CorpID;
|
model.ObjectType = ObjectType;
|
model.ObjectID = ObjectID;
|
model.DataDay = Day.Date;
|
model.DataHour = i + 1;
|
model.DataTime = DateTime.Now;
|
model.Qt=run_hour_record_list.Sum(x => (x.Qa ?? 0) * x.Duration) / 3600f;
|
model.Dt = run_hour_record_list.Sum(x => (x.Pa ?? 0) * x.Duration) / 3600f;
|
model.RunTime = run_hour_record_list.Sum(x => x.Duration);
|
model.PointCount = run_hour_record_list.Count;
|
|
if (run_normal_hour_record_list.Count > 0)
|
{
|
model.Qmin = run_normal_hour_record_list.Min(x=>x.Qa.Value);
|
model.Qmax = run_normal_hour_record_list.Max(x => x.Qa.Value);
|
model.Qavg = run_normal_hour_record_list.Average(x => x.Qa.Value);
|
|
model.Hmin = run_normal_hour_record_list.Min(x=>x.Ha.Value);
|
model.Hmax= run_normal_hour_record_list.Max(x=>x.Ha.Value);
|
model.Havg= run_normal_hour_record_list.Average(x=>x.Ha.Value);
|
|
model.Emin= run_normal_hour_record_list.Min(x=>x.Ea.Value);
|
model.Emax= run_normal_hour_record_list.Max(x=>x.Ea.Value);
|
model.Eavg= run_normal_hour_record_list.Average(x=>x.Ea.Value);
|
|
model.Pmin= run_normal_hour_record_list.Min(x=>x.Pa.Value);
|
model.Pmax= run_normal_hour_record_list.Max(x=>x.Pa.Value);
|
model.Pavg= run_normal_hour_record_list.Average(x=>x.Pa.Value);
|
|
model.WPmin= run_normal_hour_record_list.Min(x=>x.WPa.Value);
|
model.WPmax = run_normal_hour_record_list.Max(x=>x.WPa.Value);
|
model.WPavg = run_normal_hour_record_list.Average(x=>x.WPa.Value);
|
|
model.UWPmin = run_normal_hour_record_list.Min(x=>x.UWPa.Value);
|
model.UWPmax = run_normal_hour_record_list.Max(x=>x.UWPa.Value);
|
model.UWPavg = run_normal_hour_record_list.Average(x=>x.UWPa.Value);
|
}
|
|
if (run_hour_record_list.Count > 1)
|
{
|
var run_hour_boot_list = run_hour_record_list.OrderBy(x => x.DataTime).ToList();
|
for (int j = 1; j < run_hour_boot_list.Count; j++)
|
{
|
if ((run_hour_boot_list[j].DataTime - run_hour_boot_list[j - 1].DataTime).TotalSeconds > 5 * run_hour_boot_list[j].Duration)
|
{
|
model.BootTimes += 1;
|
}
|
}
|
}
|
|
result.Add(model);
|
}
|
|
return result;
|
}
|
|
|
|
}
|
}
|