|
|
|
@ -17,6 +17,7 @@ using Entity.Dto;
|
|
|
|
|
using Magicodes.ExporterAndImporter.Excel;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using Entity.Dto.Resp;
|
|
|
|
|
|
|
|
|
|
namespace Service.Station
|
|
|
|
|
{
|
|
|
|
@ -94,8 +95,10 @@ namespace Service.Station
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<List<ExchangeStationDayRunResult>> GetMonthRunResult()
|
|
|
|
|
{
|
|
|
|
|
var monthTime1 = DateTimeOffset.UtcNow.AddMonths(-1).ToString("yyyy/MM/01 00:00:00");//上月1号
|
|
|
|
|
var monthTime2 = DateTimeOffset.UtcNow.AddMonths(0).ToString("yyyy/MM/01 00:00:00");//本月1号
|
|
|
|
|
|
|
|
|
|
var runresult = await _exStationDayRunResultRepository.QueryListByClauseAsync(u => u.CreatedTime >= DateTimeOffset.UtcNow.AddDays(-30));
|
|
|
|
|
var runresult = await _exStationDayRunResultRepository.QueryListByClauseAsync(u => u.CreatedTime >= Convert.ToDateTime(monthTime1) && u.CreatedTime < Convert.ToDateTime(monthTime2));
|
|
|
|
|
|
|
|
|
|
return runresult;
|
|
|
|
|
}
|
|
|
|
@ -105,19 +108,27 @@ namespace Service.Station
|
|
|
|
|
/// 获取一年内每月的数据和
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<List<ExchangeStationDayRunResult>> GetYearRunResult()
|
|
|
|
|
public async Task<List<ExchangeStationDayRunResultResp>> GetYearRunResult()
|
|
|
|
|
{
|
|
|
|
|
var runresult = _exStationDayRunResultRepository.QueryListByClause(u => u.CreatedTime >= DateTimeOffset.UtcNow.AddMonths(-12))
|
|
|
|
|
var monthTime1 = DateTimeOffset.UtcNow.AddYears(0).ToString("yyyy/01/01 00:00:00");//今年1月1号
|
|
|
|
|
var monthTime2 = DateTimeOffset.UtcNow.AddMonths(0).ToString("yyyy/MM/01 00:00:00");//本月1号
|
|
|
|
|
var runresult = _exStationDayRunResultRepository.QueryListByClause(u => u.CreatedTime >= Convert.ToDateTime(monthTime1) && u.CreatedTime < Convert.ToDateTime(monthTime2))
|
|
|
|
|
.GroupBy(d => d.CreatedTime.Value.Month);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 对每个月的数据求和
|
|
|
|
|
Dictionary<int, ExchangeStationDayRunResult> monthlyTotals = new Dictionary<int, ExchangeStationDayRunResult>();
|
|
|
|
|
Dictionary<int, ExchangeStationDayRunResultResp> monthlyTotals = new Dictionary<int, ExchangeStationDayRunResultResp>();
|
|
|
|
|
foreach (var group in runresult)
|
|
|
|
|
{
|
|
|
|
|
var month = group.Key;
|
|
|
|
|
ExchangeStationDayRunResult runResult = new ExchangeStationDayRunResult
|
|
|
|
|
|
|
|
|
|
DateTime CreatedTime = (DateTime)group.First().CreatedTime;
|
|
|
|
|
//CreatedTime=Convert.ToDateTime(CreatedTime.ToString("yyyy/MM"));
|
|
|
|
|
|
|
|
|
|
DateTime UpdatedTime = (DateTime)group.First().UpdatedTime;
|
|
|
|
|
//UpdatedTime = Convert.ToDateTime(CreatedTime.ToString("yyyy/MM"));
|
|
|
|
|
ExchangeStationDayRunResultResp runResult = new ExchangeStationDayRunResultResp
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
AvgChgTime = group.Sum(d => Convert.ToDouble(d.AvgChgTime)).ToString("F2"),
|
|
|
|
@ -126,15 +137,16 @@ namespace Service.Station
|
|
|
|
|
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,
|
|
|
|
|
CreatedTime= CreatedTime.ToString("yyyy/MM"),
|
|
|
|
|
UpdatedTime = UpdatedTime.ToString("yyyy/MM"),
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
monthlyTotals[month] = runResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<ExchangeStationDayRunResult> resultList = monthlyTotals
|
|
|
|
|
List<ExchangeStationDayRunResultResp> resultList = monthlyTotals
|
|
|
|
|
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value)
|
|
|
|
|
.Select(pair => pair.Value)
|
|
|
|
|
.ToList();
|
|
|
|
|