using DevExpress.XtraReports.Native.Templates;
|
using IStation.Model;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace IStation.WinFrmUI.Monitor
|
{
|
public class OutWaterHelper
|
{
|
public List<SSAData> GetMeanValue(List<OutTotalOneDayList> realHistoryData)
|
{
|
List<SSAData> listoutwater = new List<SSAData>();
|
List<OutTotalOneDayList> currentlist = new List<OutTotalOneDayList>(realHistoryData); // 创建一个新的列表,并将 realHistoryData 的内容复制过来
|
|
for (int i = 0; i < 15; i++)
|
{
|
var totalSumByTimePoint = currentlist
|
.SelectMany(otdl => otdl.pumpOutWater)
|
.GroupBy(totalDay => totalDay.DateTime.TimeOfDay) // 按照小时和分钟进行分组
|
.Select(group =>
|
{
|
var time = group.First().DateTime.TimeOfDay; // 从组中获取时间
|
var totalSumForTimePoint = group.Sum(totalDay => totalDay.Total); // 在时间点分组中计算总和
|
return new { Time = time, Total = totalSumForTimePoint };
|
});
|
|
List<SSAData> demo = new List<SSAData>();
|
foreach (var item in totalSumByTimePoint)
|
{
|
listoutwater.Add(new SSAData() { DateTime = currentlist.Last().DateTime.AddDays(1) + item.Time, Total = Math.Round(item.Total / currentlist.Count, 2) });
|
demo.Add(new SSAData() { DateTime = currentlist.Last().DateTime.AddDays(1) + item.Time, Total = Math.Round(item.Total / currentlist.Count, 2) });
|
}
|
|
currentlist.Add(new OutTotalOneDayList() { DateTime = currentlist.Last().DateTime.AddDays(1), pumpOutWater = demo });
|
currentlist.RemoveAt(0);
|
demo = new List<SSAData>();
|
}
|
return listoutwater;
|
}
|
}
|
}
|