using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace IStation.Calculation
|
{
|
/// <summary>
|
/// 能效标准业务日辅助类
|
/// </summary>
|
public class EtaStandardLogicDayHelper
|
{
|
|
/// <summary>
|
/// 标准
|
/// </summary>
|
public static List<Model.EtaStandardLogicDayRecord> Standard
|
(
|
long CorpID,
|
string ObjectType,
|
long ObjectID,
|
DateTime Day,
|
IEnumerable<Model.EtaStandardConfigure> configures,
|
IEnumerable<Model.EtaLogicRealRecord> list
|
)
|
{
|
if (configures == null || configures.Count() < 1)
|
return default;
|
if (list == null || list.Count() < 1)
|
return default;
|
var normal_list = list.Where(x => x.AnalyStatus == Model.Eta.eAnalyStatus.Normal).ToList();
|
if (normal_list.Count < 1)
|
return default;
|
|
var dt_now = DateTime.Now;
|
var record_list = new List<Model.EtaStandardLogicDayRecord>();
|
foreach (var configure in configures)
|
{
|
//存在此区间范围内的数据
|
var normal_limit_list = normal_list.Where(t => t.Ea >= configure.LowerLimit && t.Ea <= configure.UpperLimit).ToList();
|
if (normal_limit_list != null && normal_limit_list.Count > 0)
|
{
|
var record = new Model.EtaStandardLogicDayRecord();
|
record.CorpID =CorpID;
|
record.ConfigureID = configure.ID;
|
record.ObjectType = ObjectType;
|
record.ObjectID = ObjectID;
|
record.DataDay = Day.Date;
|
record.DataTime = dt_now;
|
record.LowerLimit = configure.LowerLimit;
|
record.UpperLimit = configure.UpperLimit;
|
|
record.Qmin = normal_limit_list.Where(x => x.Qa.HasValue).Min(t => t.Qa.Value);
|
record.Qmax = normal_limit_list.Where(x => x.Qa.HasValue).Max(t => t.Qa.Value);
|
record.Qavg = normal_limit_list.Where(x => x.Qa.HasValue).Average(t => t.Qa.Value);
|
|
record.Emin = normal_limit_list.Where(x => x.Ea.HasValue).Min(t => t.Ea.Value);
|
record.Emax = normal_limit_list.Where(x => x.Ea.HasValue).Max(t => t.Ea.Value);
|
record.Eavg = normal_limit_list.Where(x => x.Ea.HasValue).Average(t => t.Ea.Value);
|
|
record.Hmin = normal_limit_list.Where(x => x.Ha.HasValue).Min(t => t.Ha.Value);
|
record.Hmax = normal_limit_list.Where(x => x.Ha.HasValue).Max(t => t.Ha.Value);
|
record.Havg = normal_limit_list.Where(x => x.Ha.HasValue).Average(t => t.Ha.Value);
|
|
record.Pmin = normal_limit_list.Where(x=>x.Pa.HasValue).Min(t => t.Pa.Value);
|
record.Pmax = normal_limit_list.Where(x => x.Pa.HasValue).Max(t => t.Pa.Value);
|
record.Pavg = normal_limit_list.Where(x => x.Pa.HasValue).Average(t => t.Pa.Value);
|
|
record.WPmin = normal_limit_list.Where(x => x.WPa.HasValue).Min(t => t.WPa.Value);
|
record.WPmax = normal_limit_list.Where(x => x.WPa.HasValue).Max(t => t.WPa.Value);
|
record.WPavg = normal_limit_list.Where(x => x.WPa.HasValue).Average(t => t.WPa.Value);
|
|
record.UWPmin = normal_limit_list.Where(x => x.UWPa.HasValue).Min(t => t.UWPa.Value);
|
record.UWPmax = normal_limit_list.Where(x => x.UWPa.HasValue).Max(t => t.UWPa.Value);
|
record.UWPavg = normal_limit_list.Where(x => x.UWPa.HasValue).Average(t => t.UWPa.Value);
|
|
record.Qt = normal_limit_list.Where(x => x.Qa.HasValue).Sum(x => x.Qa.Value * x.Duration) / 3600f;
|
record.Qtt = normal_list.Where(x => x.Qa.HasValue).Sum(x => x.Qa.Value * x.Duration) / 3600f;
|
record.Dt = normal_limit_list.Where(x => x.Pa.HasValue).Sum(x => x.Pa.Value * x.Duration) / 3600f;
|
record.Dtt = normal_list.Where(x => x.Pa.HasValue).Sum(x => x.Pa.Value * x.Duration) / 3600f;
|
|
record.PointCount = normal_limit_list.Count;
|
record.TotalPointCount = normal_list.Count();
|
|
record_list.Add(record);
|
}
|
}
|
return record_list;
|
}
|
|
}
|
}
|