using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace IStation.Calculation
|
{
|
/// <summary>
|
/// 能效标准多时辅助类
|
/// </summary>
|
public class EtaStandardMultiHourHelper
|
{
|
|
/// <summary>
|
/// 依赖
|
/// </summary>
|
public static List<Model.EtaStandardMultiHourRecord> Standard
|
(
|
long CorpID,
|
string ObjectType,
|
long ObjectID,
|
DateTime Day,
|
IEnumerable<Model.EtaStandardConfigure> configures,
|
IEnumerable<Model.EtaMultiRealRecord> list
|
)
|
{
|
if (configures == null || configures.Count() < 1)
|
return default;
|
if (list == null || list.Count() < 1)
|
return default;
|
var run_list = list.Where(x => x.RunningCount>0).ToList();
|
if (run_list.Count < 1)
|
return default;
|
var run_normal_list = run_list.Where(x => x.AnalyStatus == Model.Eta.eAnalyStatus.Normal).ToList();
|
if (run_normal_list.Count < 1)
|
return default;
|
|
var dt_now = DateTime.Now;
|
var record_list = new List<Model.EtaStandardMultiHourRecord>();
|
foreach (var configure in configures)
|
{
|
//存在此区间范围内的数据
|
var run_normal_limit_list = run_normal_list.Where(t => t.Ea >= configure.LowerLimit && t.Ea <= configure.UpperLimit).ToList();
|
if (run_normal_limit_list != null && run_normal_limit_list.Count > 0)
|
{
|
for (int i = 0; i < 24; i++)
|
{
|
//此小时的此范围的所有运行点数据
|
var run_normal_limit_hour_list = run_normal_limit_list.Where(t => t.DataTime >= Day.Date.AddHours(i) && t.DataTime < Day.Date.AddHours(i + 1)).ToList();
|
if (run_normal_limit_hour_list.Count > 0)
|
{
|
//此小时的所有运行点数据
|
var run_normal_hour_list = run_normal_list.Where(t => t.DataTime >= Day.Date.AddHours(i) && t.DataTime < Day.Date.AddHours(i + 1)).ToList();
|
var record = new Model.EtaStandardMultiHourRecord();
|
record.CorpID = CorpID;
|
record.ConfigureID = configure.ID;
|
record.ObjectType = ObjectType;
|
record.ObjectID = ObjectID;
|
record.DataDay = Day.Date;
|
record.DataHour = i + 1;
|
record.DataTime = dt_now;
|
record.LowerLimit = configure.LowerLimit;
|
record.UpperLimit = configure.UpperLimit;
|
|
record.Qmin = run_normal_limit_hour_list.Min(t => t.Qa.Value);
|
record.Qmax = run_normal_limit_hour_list.Max(t => t.Qa.Value);
|
record.Qavg = run_normal_limit_hour_list.Average(t => t.Qa.Value);
|
|
record.Emin = run_normal_limit_hour_list.Min(t => t.Ea.Value);
|
record.Emax = run_normal_limit_hour_list.Max(t => t.Ea.Value);
|
record.Eavg = run_normal_limit_hour_list.Average(t => t.Ea.Value);
|
|
record.Hmin = run_normal_limit_hour_list.Min(t => t.Ha.Value);
|
record.Hmax = run_normal_limit_hour_list.Max(t => t.Ha.Value);
|
record.Havg = run_normal_limit_hour_list.Average(t => t.Ha.Value);
|
|
record.Pmin = run_normal_limit_hour_list.Min(t => t.Pa.Value);
|
record.Pmax = run_normal_limit_hour_list.Max(t => t.Pa.Value);
|
record.Pavg = run_normal_limit_hour_list.Average(t => t.Pa.Value);
|
|
record.WPmin = run_normal_limit_hour_list.Min(t => t.WPa.Value);
|
record.WPmax = run_normal_limit_hour_list.Max(t => t.WPa.Value);
|
record.WPavg = run_normal_limit_hour_list.Average(t => t.WPa.Value);
|
|
record.UWPmin = run_normal_limit_hour_list.Min(t => t.UWPa.Value);
|
record.UWPmax = run_normal_limit_hour_list.Max(t => t.UWPa.Value);
|
record.UWPavg = run_normal_limit_hour_list.Average(t => t.UWPa.Value);
|
|
record.Qt = run_normal_limit_hour_list.Sum(x => x.Qa.Value * x.Duration) / 3600f;
|
record.Qtt = run_normal_hour_list.Sum(x => x.Qa.Value * x.Duration) / 3600f;
|
record.Dt = run_normal_limit_hour_list.Sum(x => x.Pa.Value * x.Duration) / 3600f;
|
record.Dtt = run_normal_hour_list.Sum(x => x.Pa.Value * x.Duration) / 3600f;
|
|
record.RunTime = run_normal_limit_hour_list.Sum(t => t.Duration);
|
record.TotalRunTime = run_normal_hour_list.Sum(t => t.Duration);
|
|
record.PointCount = run_normal_limit_hour_list.Count;
|
record.TotalPointCount = run_normal_hour_list.Count;
|
|
record_list.Add(record);
|
}
|
}
|
}
|
}
|
return record_list;
|
}
|
|
}
|
}
|