From 4a8249a715bc94e4dee6b08057f1fc1d139d010a Mon Sep 17 00:00:00 2001 From: xiaochanghai Date: Tue, 27 Aug 2024 10:17:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E8=B0=83=E5=BA=A6-=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=BF=85=E9=80=89=E4=BF=AE=E8=A7=84=E5=88=99=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=8C=B9=E9=85=8D=E4=BA=BA=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Ghre/IGhre_StudyRuleServices.cs | 1 + .../Ghre/Ghre_StudyRuleServices.cs | 15 +++++++++- .../QuartzNet/Jobs/Job_StaffIn_Quartz.cs | 30 +++++++++++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 Tiobon.Core.Tasks/QuartzNet/Jobs/Job_StaffIn_Quartz.cs diff --git a/Tiobon.Core.IServices/Ghre/IGhre_StudyRuleServices.cs b/Tiobon.Core.IServices/Ghre/IGhre_StudyRuleServices.cs index 55c2de63..3dbee79e 100644 --- a/Tiobon.Core.IServices/Ghre/IGhre_StudyRuleServices.cs +++ b/Tiobon.Core.IServices/Ghre/IGhre_StudyRuleServices.cs @@ -8,5 +8,6 @@ namespace Tiobon.Core.IServices /// public interface IGhre_StudyRuleServices :IBaseServices { + Task StaffIn(); } } \ No newline at end of file diff --git a/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs b/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs index 2c9651a7..eb83b8a2 100644 --- a/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs +++ b/Tiobon.Core.Services/Ghre/Ghre_StudyRuleServices.cs @@ -37,7 +37,6 @@ public class Ghre_StudyRuleServices : BaseServices> QueryFilterPage(QueryBody filter, string condition, bool? IsEnable = true) { if (string.IsNullOrWhiteSpace(filter.orderBy)) @@ -466,4 +465,18 @@ public class Ghre_StudyRuleServices : BaseServices() + .Where(x => x.Indate != null && x.Indate.Value.Date == dt.Date) + .Select(x => new + { + x.StaffID, + x.StaffEname, + x.Indate, + x.OutDate + }).ToListAsync(); + } } \ No newline at end of file diff --git a/Tiobon.Core.Tasks/QuartzNet/Jobs/Job_StaffIn_Quartz.cs b/Tiobon.Core.Tasks/QuartzNet/Jobs/Job_StaffIn_Quartz.cs new file mode 100644 index 00000000..6c203fa6 --- /dev/null +++ b/Tiobon.Core.Tasks/QuartzNet/Jobs/Job_StaffIn_Quartz.cs @@ -0,0 +1,30 @@ +using Tiobon.Core.IServices; +using Quartz; + +/// +/// 这里要注意下,命名空间和程序集是一样的,不然反射不到 +/// +namespace Tiobon.Core.Tasks; + +public class Job_StaffIn_Quartz : JobBase, IJob +{ + private readonly IGhre_StudyRuleServices _ghre_StudyRuleServices; + + public Job_StaffIn_Quartz(IGhre_StudyRuleServices ghre_StudyRuleServices, ITasksQzServices tasksQzServices, ITasksLogServices tasksLogServices) + : base(tasksQzServices, tasksLogServices) + { + _ghre_StudyRuleServices = ghre_StudyRuleServices; + } + public async Task Execute(IJobExecutionContext context) + { + var executeLog = await ExecuteJob(context, async () => await Run(context)); + } + public async Task Run(IJobExecutionContext context) + { + Console.WriteLine($"Job_StaffIn_Quartz 执行 {DateTime.Now.ToShortTimeString()}"); + await _ghre_StudyRuleServices.StaffIn(); + // 也可以通过数据库配置,获取传递过来的参数 + JobDataMap data = context.JobDetail.JobDataMap; + //int jobId = data.GetInt("JobParam"); + } +}