From 712cf53d7338f32a3441f6592019022672fb1ad5 Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Fri, 17 Jan 2025 15:07:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9F=B9=E8=AE=AD=E6=8A=A5=E8=A1=A8=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9F=A5=E8=AF=A2=E6=96=B0=E5=85=A5=E8=81=8C?= =?UTF-8?q?=E5=91=98=E5=B7=A5=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/ReportController.cs | 35 +++++++++++++ Tiobon.Core.Api/Tiobon.Core.xml | 20 +++++++ Tiobon.Core.Common/Helper/DateTimeHelper.cs | 6 ++- Tiobon.Core.IServices/IReportServices.cs | 14 +++++ Tiobon.Core.Services/ReportServices.cs | 52 +++++++++++++++++++ 5 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 Tiobon.Core.Api/Controllers/ReportController.cs create mode 100644 Tiobon.Core.IServices/IReportServices.cs create mode 100644 Tiobon.Core.Services/ReportServices.cs diff --git a/Tiobon.Core.Api/Controllers/ReportController.cs b/Tiobon.Core.Api/Controllers/ReportController.cs new file mode 100644 index 00000000..6748f073 --- /dev/null +++ b/Tiobon.Core.Api/Controllers/ReportController.cs @@ -0,0 +1,35 @@ +namespace Tiobon.Core.Controllers; + +/// +/// 公共服务 +/// +[Produces("application/json")] +[Route("api/Report")] +[Authorize(Permissions.Name), ApiExplorerSettings(GroupName = Grouping.GroupName_System)] +public class ReportController : BaseApiController +{ + private readonly ILogger _logger; + private readonly IReportServices _services; + + /// + /// 构造函数 + /// + /// + /// + public ReportController(ILogger logger, IReportServices services) + { + _services = services; + _logger = logger; + } + + #region 获取新入职人员列表 + /// + /// 获取新入职人员列表 + /// + /// + /// + /// + [HttpPost, Route("QueryNewStaff")] + public async Task> QueryNewStaffAsync([FromBody] QueryBody filter, string condition)=> await _services.QueryNewStaffAsync(filter, condition, true); + #endregion +} \ No newline at end of file diff --git a/Tiobon.Core.Api/Tiobon.Core.xml b/Tiobon.Core.Api/Tiobon.Core.xml index e7c55336..d645663f 100644 --- a/Tiobon.Core.Api/Tiobon.Core.xml +++ b/Tiobon.Core.Api/Tiobon.Core.xml @@ -571,6 +571,26 @@ + + + 公共服务 + + + + + 构造函数 + + + + + + + 获取新入职人员列表 + + + + + 分页获取 diff --git a/Tiobon.Core.Common/Helper/DateTimeHelper.cs b/Tiobon.Core.Common/Helper/DateTimeHelper.cs index 95d6d2d3..65e59b10 100644 --- a/Tiobon.Core.Common/Helper/DateTimeHelper.cs +++ b/Tiobon.Core.Common/Helper/DateTimeHelper.cs @@ -100,7 +100,11 @@ public class DateTimeHelper } return dateTime.ToString(@"yyyy\/MM\/dd"); } - + /// + /// 格式化DateTime类型为字符串类型,精确到天,如:2008/01/01 + /// + /// + /// public static DateTime ConvertToDay(DateTime dateTime) { string result = ConvertToDayString(dateTime); diff --git a/Tiobon.Core.IServices/IReportServices.cs b/Tiobon.Core.IServices/IReportServices.cs new file mode 100644 index 00000000..bc0d37e3 --- /dev/null +++ b/Tiobon.Core.IServices/IReportServices.cs @@ -0,0 +1,14 @@ +using Tiobon.Core.Common; +using Tiobon.Core.IServices.BASE; +using Tiobon.Core.Model; +using Tiobon.Core.Model.Models; + +namespace Tiobon.Core.IServices; + +/// +/// IReportServices +/// +public interface IReportServices : IBaseServices> +{ + Task> QueryNewStaffAsync(QueryBody filter, string condition, bool? IsEnable = true); +} diff --git a/Tiobon.Core.Services/ReportServices.cs b/Tiobon.Core.Services/ReportServices.cs new file mode 100644 index 00000000..46cc0f3e --- /dev/null +++ b/Tiobon.Core.Services/ReportServices.cs @@ -0,0 +1,52 @@ +using Microsoft.Extensions.Logging; + +namespace Tiobon.Core.Services; + +public partial class ReportServices : BaseServices>, IReportServices +{ + IHttpContextAccessor _httpContextAccessor; + ILogger _logger; + public ICaching _caching; + private readonly IGhra_StaffServices _staffServices; + public ReportServices(ILogger logger, IHttpContextAccessor httpContextAccessor, ICaching caching = null, IGhra_StaffServices staffServices = null) + { + _logger = logger; + _httpContextAccessor = httpContextAccessor; + _caching = caching; + _staffServices = staffServices; + } + + #region 获取新入职人员列表 + /// + /// 获取新入职人员列表 + /// + /// + /// + /// + /// + public async Task> QueryNewStaffAsync(QueryBody filter, string condition, bool? IsEnable = true) + { + int month = 3; + + var config = await Db.Queryable().Where(x => x.ConfigCode == "New_Staff_Month").FirstAsync(); + if (config != null) + { + try + { + month = Convert.ToInt32(config.ConfigValue); + } + catch (Exception) + { + + } + } + var dateTime = DateTime.Now.AddMonths(-month); + + condition = $"Indate >= '{DateTimeHelper.ConvertToDayString(dateTime)}'"; + var result = await _staffServices.QueryFilterPage(filter, condition, IsEnable); + + return result; + } + #endregion + +}