|
|
@ -16,6 +16,7 @@ using AutoMapper;
|
|
|
|
using Entity.Dto;
|
|
|
|
using Entity.Dto;
|
|
|
|
using Magicodes.ExporterAndImporter.Excel;
|
|
|
|
using Magicodes.ExporterAndImporter.Excel;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Service.Station
|
|
|
|
namespace Service.Station
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -84,5 +85,63 @@ namespace Service.Station
|
|
|
|
{ FileDownloadName = DateTime.Now.ToString("yyyyMMddHHmm") + "换电站日运行统计.xlsx" };
|
|
|
|
{ FileDownloadName = DateTime.Now.ToString("yyyyMMddHHmm") + "换电站日运行统计.xlsx" };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 获取一个月的每日数据
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="type"></param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public async Task<List<ExchangeStationDayRunResult>> GetMonthRunResult()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var runresult = await _exStationDayRunResultRepository.QueryListByClauseAsync(u => u.CreatedTime >= DateTimeOffset.UtcNow.AddDays(-30));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return runresult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 获取一年内每月的数据和
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
public async Task<List<ExchangeStationDayRunResult>> GetYearRunResult()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var runresult = _exStationDayRunResultRepository.QueryListByClause(u => u.CreatedTime >= DateTimeOffset.UtcNow.AddMonths(-12))
|
|
|
|
|
|
|
|
.GroupBy(d => d.CreatedTime.Value.Month);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 对每个月的数据求和
|
|
|
|
|
|
|
|
Dictionary<int, ExchangeStationDayRunResult> monthlyTotals = new Dictionary<int, ExchangeStationDayRunResult>();
|
|
|
|
|
|
|
|
foreach (var group in runresult)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var month = group.Key;
|
|
|
|
|
|
|
|
ExchangeStationDayRunResult runResult = new ExchangeStationDayRunResult
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AvgChgTime = group.Sum(d => Convert.ToDouble(d.AvgChgTime)).ToString("F2"),
|
|
|
|
|
|
|
|
AvgRepTime = group.Sum(d => Convert.ToDouble(d.AvgRepTime)).ToString("F2"),
|
|
|
|
|
|
|
|
ChgCount = group.Sum(d => d.ChgCount),
|
|
|
|
|
|
|
|
ToltalSwapCount = group.Sum(d => d.ToltalSwapCount),
|
|
|
|
|
|
|
|
ToltalSwapAllTime = group.Sum(d => d.ToltalSwapAllTime),
|
|
|
|
|
|
|
|
ToltalTimeCount = group.Sum(d => d.ToltalTimeCount),
|
|
|
|
|
|
|
|
CreatedTime= group.First().CreatedTime,
|
|
|
|
|
|
|
|
UpdatedTime = group.First().UpdatedTime,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
monthlyTotals[month] = runResult;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ExchangeStationDayRunResult> resultList = monthlyTotals
|
|
|
|
|
|
|
|
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value)
|
|
|
|
|
|
|
|
.Select(pair => pair.Value)
|
|
|
|
|
|
|
|
.ToList();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return resultList;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|