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 + +}