diff --git a/Entity/Dto/Resp/ExchangeStationDayRunResultResp.cs b/Entity/Dto/Resp/ExchangeStationDayRunResultResp.cs
new file mode 100644
index 0000000..4796876
--- /dev/null
+++ b/Entity/Dto/Resp/ExchangeStationDayRunResultResp.cs
@@ -0,0 +1,101 @@
+using SqlSugar;
+
+namespace Entity.Dto.Resp
+{
+ public class ExchangeStationDayRunResultResp
+ {
+ ///
+ /// 主键ID
+ ///
+ public int Id { get; set; }
+
+ ///
+ /// 平均充电时长
+ ///
+ public string AvgChgTime { get; set; }
+
+ ///
+ /// 平均换电时长
+ ///
+ public string AvgRepTime { get; set; }
+
+ ///
+ /// 换电日期
+ ///
+ public string SwapDate { get; set; }
+
+ ///
+ /// 首次换电时间
+ ///
+ public string FristSwapTime { get; set; }
+
+ ///
+ /// 结束换电时间
+ ///
+ public string StopTime { get; set; }
+
+ ///
+ /// 运行开始时间
+ ///
+ public string RunStartTime { get; set; }
+
+ ///
+ /// 运行结束时间
+ ///
+ public string RunEndTime { get; set; }
+
+ ///
+ /// 充电总次数
+ ///
+ public int ChgCount { get; set; }
+
+ ///
+ /// 运营状态
+ ///
+ public int State { get; set; }
+
+ ///
+ /// 换电总次数
+ ///
+ public int ToltalSwapCount { get; set; }
+
+ ///
+ /// 换电总时长
+ ///
+ public double ToltalSwapAllTime { get; set; }
+
+ ///
+ /// 站运行总时长
+ ///
+ public double ToltalTimeCount { get; set; }
+
+ ///
+ /// Desc:创建人
+ /// Default:
+ /// Nullable:True
+ ///
+ public string? CreatedBy { get; set; }
+
+ ///
+ /// Desc:创建时间
+ /// Default:CURRENT_TIMESTAMP
+ /// Nullable:True
+ ///
+ public string? CreatedTime { get; set; }
+
+
+ ///
+ /// Desc:更新人
+ /// Default:
+ /// Nullable:True
+ ///
+ public string? UpdatedBy { get; set; }
+
+ ///
+ /// Desc:更新时间
+ /// Default:CURRENT_TIMESTAMP
+ /// Nullable:True
+ ///
public async Task> 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
/// 获取一年内每月的数据和
///
///
- public async Task> GetYearRunResult()
+ public async Task> 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 monthlyTotals = new Dictionary();
+ Dictionary monthlyTotals = new Dictionary();
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 resultList = monthlyTotals
+ List resultList = monthlyTotals
.ToDictionary(kvp => kvp.Key, kvp => kvp.Value)
.Select(pair => pair.Value)
.ToList();
diff --git a/WebStarter/Controllers/StatisticsController.cs b/WebStarter/Controllers/StatisticsController.cs
index f810a3c..e90a314 100644
--- a/WebStarter/Controllers/StatisticsController.cs
+++ b/WebStarter/Controllers/StatisticsController.cs
@@ -1,6 +1,7 @@
using System.ComponentModel.DataAnnotations;
using Entity.DbModel.Station;
using Entity.Dto.Req;
+using Entity.Dto.Resp;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Service.Init;
@@ -23,7 +24,7 @@ public class StatisticsController
///
- /// 获取一个月的每日数据(30天)
+ /// 获取上个月的每日数据
///
///
[HttpPost("GetMonthResult")]
@@ -36,13 +37,13 @@ public class StatisticsController
///
- /// 获取一年内每月的数据和(12月)
+ /// 获取今年到上月的每月的数据和
///
///
[HttpPost("GetYearResult")]
- public async Task>> GetYearResult()
+ public async Task>> GetYearResult()
{
- return Result>.Success(await _exStationDayRunResultService.GetYearRunResult());
+ return Result>.Success(await _exStationDayRunResultService.GetYearRunResult());
}
}
\ No newline at end of file
diff --git a/WebStarter/appsettings.dev.json b/WebStarter/appsettings.dev.json
index 0617f4a..032ac25 100644
--- a/WebStarter/appsettings.dev.json
+++ b/WebStarter/appsettings.dev.json
@@ -2,7 +2,7 @@
"ConnectionStrings": {
"ConfigId": "master",
"DbType": "MySql",
- "SqlConnection": "server=192.168.2.2;Port=3306;Database=nhet_dev;Uid=root;Pwd=Rszn123;Charset=utf8;"
+ "SqlConnection": "server=180.76.133.253;Port=16306;Database=nhet_dev;Uid=root;Pwd=Rszn123;Charset=utf8;"
},
"Update": {
"AutoUpdate": "false",
@@ -10,7 +10,7 @@
"Url": "http://121.4.95.243:8090/Updates/AutoUpdaterStarter.xml"
},
"Redis": {
- "Connection": "192.168.2.2:6379,password=123456",
+ "Connection": "127.0.0.1:6379,password=123456",
"InstanceName": "local",
"DefaultDB": "8"
},