using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using IStation.Untity;
|
|
namespace IStation.Calculation
|
{
|
/// <summary>
|
/// 能效汇总多日辅助类
|
/// </summary>
|
public class EtaSumMultiDayHelper
|
{
|
|
/// <summary>
|
/// 汇总
|
/// </summary>
|
public static List<Model.EtaSumMultiDayRecord> Sum
|
(
|
long CorpID,
|
string ObjectType,
|
long ObjectID,
|
DateTime Day,
|
IEnumerable<Model.EtaMultiRealRecord> list
|
)
|
{
|
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 group_list = run_list.GroupBy(x => new {
|
CorpID=x.CorpID,
|
ObjectType=x.ObjectType,
|
ObjectID=x.ObjectID,
|
RunningCount = x.RunningCount,
|
RunningFlag =IntListHelper.ToString(x.RunningFlag)
|
}).ToList();
|
|
var result= group_list.Select(x => {
|
var model = new Model.EtaSumMultiDayRecord();
|
model.CorpID = CorpID;
|
model.ObjectType = ObjectType;
|
model.ObjectID = ObjectID;
|
model.DataDay = Day.Date;
|
model.DataTime = DateTime.Now;
|
model.RunningCount = x.Key.RunningCount;
|
model.RunningFlag = IntListHelper.ToList(x.Key.RunningFlag);
|
model.Qt = x.Sum(t => (t.Qa ?? 0) * t.Duration) / 3600f;
|
model.Dt = x.Sum(t => (t.Pa ?? 0) * t.Duration) / 3600f;
|
model.RunTime = x.Sum(t => t.Duration);
|
model.PointCount = x.Count();
|
|
var normal_list = x.Where(x => x.AnalyStatus == Model.Eta.eAnalyStatus.Normal).ToList();
|
if (normal_list.Count > 0)
|
{
|
model.Qmin = normal_list.Min(x => x.Qa.Value);
|
model.Qmax = normal_list.Max(x => x.Qa.Value);
|
model.Qavg = normal_list.Average(x => x.Qa.Value);
|
|
model.Hmin = normal_list.Min(x => x.Ha.Value);
|
model.Hmax = normal_list.Max(x => x.Ha.Value);
|
model.Havg = normal_list.Average(x => x.Ha.Value);
|
|
model.Emin = normal_list.Min(x => x.Ea.Value);
|
model.Emax = normal_list.Max(x => x.Ea.Value);
|
model.Eavg = normal_list.Average(x => x.Ea.Value);
|
|
model.Pmin = normal_list.Min(x => x.Pa.Value);
|
model.Pmax = normal_list.Max(x => x.Pa.Value);
|
model.Pavg = normal_list.Average(x => x.Pa.Value);
|
|
model.WPmin = normal_list.Min(x => x.WPa.Value);
|
model.WPmax = normal_list.Max(x => x.WPa.Value);
|
model.WPavg = normal_list.Average(x => x.WPa.Value);
|
|
model.UWPmin = normal_list.Min(x => x.UWPa.Value);
|
model.UWPmax = normal_list.Max(x => x.UWPa.Value);
|
model.UWPavg = normal_list.Average(x => x.UWPa.Value);
|
}
|
return model;
|
|
}).ToList();
|
|
return result;
|
|
|
}
|
}
|
}
|