using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace IStation.Application { /// /// 能效汇总业务日辅助类 /// public class EtaSumLogicDayHelper { /// /// 汇总 /// public static Model.EtaSumLogicDayRecord Sum ( long CorpID, string ObjectType, long ObjectID, DateTime Day, IEnumerable list ) { if (list == null || list.Count() < 1) return default; var normal_list = list.Where(x => x.AnalyStatus == Model.Eta.eAnalyStatus.Normal).ToList(); var model = new Model.EtaSumLogicDayRecord(); model.CorpID = CorpID; model.ObjectType = ObjectType; model.ObjectID = ObjectID; model.DataDay = Day.Date; model.DataTime = Day; model.Qt = list.Sum(x => (x.Qa ?? 0) * x.Duration) / 3600f; model.Dt = list.Sum(x => (x.Pa ?? 0) * x.Duration) / 3600f; model.PointCount = list.Count(); if (normal_list.Count > 0) { if (normal_list.Exists(x => x.Qa.HasValue)) { model.Qmin = normal_list.Where(x => x.Qa.HasValue).Min(x => x.Qa.Value); model.Qmax = normal_list.Where(x => x.Qa.HasValue).Max(x => x.Qa.Value); model.Qavg = normal_list.Where(x => x.Qa.HasValue).Average(x => x.Qa.Value); } if (normal_list.Exists(x => x.Ha.HasValue)) { model.Hmin = normal_list.Where(x => x.Ha.HasValue).Min(x => x.Ha.Value); model.Hmax = normal_list.Where(x => x.Ha.HasValue).Max(x => x.Ha.Value); model.Havg = normal_list.Where(x => x.Ha.HasValue).Average(x => x.Ha.Value); } if (normal_list.Exists(x => x.Ea.HasValue)) { model.Emin = normal_list.Where(x => x.Ea.HasValue).Min(x => x.Ea.Value); model.Emax = normal_list.Where(x => x.Ea.HasValue).Max(x => x.Ea.Value); model.Eavg = normal_list.Where(x => x.Ea.HasValue).Average(x => x.Ea.Value); } if (normal_list.Exists(x => x.Pa.HasValue)) { model.Pmin = normal_list.Where(x => x.Pa.HasValue).Min(x => x.Pa.Value); model.Pmax = normal_list.Where(x => x.Pa.HasValue).Max(x => x.Pa.Value); model.Pavg = normal_list.Where(x => x.Pa.HasValue).Average(x => x.Pa.Value); } if (normal_list.Exists(x => x.WPa.HasValue)) { model.WPmin = normal_list.Where(x => x.WPa.HasValue).Min(x => x.WPa.Value); model.WPmax = normal_list.Where(x => x.WPa.HasValue).Max(x => x.WPa.Value); model.WPavg = normal_list.Where(x => x.WPa.HasValue).Average(x => x.WPa.Value); } if (normal_list.Exists(x => x.UWPa.HasValue)) { model.UWPmin = normal_list.Where(x => x.UWPa.HasValue).Min(x => x.UWPa.Value); model.UWPmax = normal_list.Where(x => x.UWPa.HasValue).Max(x => x.UWPa.Value); model.UWPavg = normal_list.Where(x => x.UWPa.HasValue).Average(x => x.UWPa.Value); } } return model; } } }