From 743560d3062b452b39a41bc81319707467857055 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=81=20=E4=BB=BB?= Date: Thu, 14 Nov 2024 10:08:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=A4=A7=E5=8E=85--=E5=B7=B2?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BB=BB=E5=8A=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../InsTaskHallManager/InsTaskHallApp.cs | 22 +++++++++++++------ .../InsTaskHallManager/Response/InsTaskRes.cs | 14 ++++++++++++ .../InsTaskHallController.cs | 5 +++-- 3 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 OpenAuth.App/ServiceApp/InsTaskHallManager/Response/InsTaskRes.cs diff --git a/OpenAuth.App/ServiceApp/InsTaskHallManager/InsTaskHallApp.cs b/OpenAuth.App/ServiceApp/InsTaskHallManager/InsTaskHallApp.cs index a3ec6f6..e7d6ff9 100644 --- a/OpenAuth.App/ServiceApp/InsTaskHallManager/InsTaskHallApp.cs +++ b/OpenAuth.App/ServiceApp/InsTaskHallManager/InsTaskHallApp.cs @@ -14,6 +14,7 @@ using DocumentFormat.OpenXml.Office2010.CustomUI; using NPOI.OpenXmlFormats.Dml; using Infrastructure.Extensions; using Moq; +using OpenAuth.App.ServiceApp.InsTaskHallManager.Response; namespace OpenAuth.App.ServiceApp.InsTaskHallManager { @@ -54,16 +55,23 @@ namespace OpenAuth.App.ServiceApp.InsTaskHallManager /// 完成任务 /// /// - public async Task> GetCompleteTaskList() + public async Task> GetCompleteTaskList() { var query = await client.Queryable().Where(r => r.IsCompleted == true&&r.CompleteTime!=null) - .OrderByDescending(r => r.CompleteTime) - .GroupBy(r=>r.CompleteTime.ToString("yyyy-MM-dd")) - .Select(r => new + .Select(r => new { - count = SqlFunc.AggregateCount(r.Id), - time= r.CompleteTime.ToString("yyyy-MM-dd") - }).ToListAsync(); + id=r.Id, + datetime= r.CompleteTime.Value.Date + }) + .MergeTable() + .GroupBy(r=>r.datetime) + .Select(r => new InsTaskRes + { + count = SqlFunc.AggregateCount(r.id), + time= r.datetime + }) + .MergeTable().OrderBy(r => r.time) + .ToListAsync(); return query; } diff --git a/OpenAuth.App/ServiceApp/InsTaskHallManager/Response/InsTaskRes.cs b/OpenAuth.App/ServiceApp/InsTaskHallManager/Response/InsTaskRes.cs new file mode 100644 index 0000000..54c63bf --- /dev/null +++ b/OpenAuth.App/ServiceApp/InsTaskHallManager/Response/InsTaskRes.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace OpenAuth.App.ServiceApp.InsTaskHallManager.Response +{ + public class InsTaskRes + { + public int count { get; set; } + public DateTime time { get; set; } + } +} diff --git a/OpenAuth.WebApi/Controllers/ServiceControllers/InsTaskHallController.cs b/OpenAuth.WebApi/Controllers/ServiceControllers/InsTaskHallController.cs index a7418c2..fd3665f 100644 --- a/OpenAuth.WebApi/Controllers/ServiceControllers/InsTaskHallController.cs +++ b/OpenAuth.WebApi/Controllers/ServiceControllers/InsTaskHallController.cs @@ -1,6 +1,7 @@ using Infrastructure; using Microsoft.AspNetCore.Mvc; using OpenAuth.App.ServiceApp.InsTaskHallManager; +using OpenAuth.App.ServiceApp.InsTaskHallManager.Response; using OpenAuth.App.SysDatabaseLink; namespace OpenAuth.WebApi.Controllers.ServiceControllers @@ -43,9 +44,9 @@ namespace OpenAuth.WebApi.Controllers.ServiceControllers /// /// [HttpGet] - public async Task>> GetCompleteTaskList() + public async Task>> GetCompleteTaskList() { - var result = new Response>(); + var result = new Response>(); try { result.Result = await _app.GetCompleteTaskList();