From ae24ba996474271c7e3607767860dbf2b43466c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=9F=B3=E5=A4=B4?= Date: Thu, 19 Sep 2024 14:34:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BD=9C=E4=B8=9A=E5=B7=B2?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=E7=9A=84=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "AntJob.Data/Entity/\344\275\234\344\270\232.Biz.cs" | 1 + ...275\234\344\270\232\344\273\273\345\212\241.Biz.cs" | 10 +++++++--- ...344\275\234\344\270\232\344\273\273\345\212\241.cs" | 3 ++- AntJob.Data/Model.xml | 3 ++- AntJob.Server/Worker.cs | 3 +++ 5 files changed, 15 insertions(+), 5 deletions(-) diff --git "a/AntJob.Data/Entity/\344\275\234\344\270\232.Biz.cs" "b/AntJob.Data/Entity/\344\275\234\344\270\232.Biz.cs" index 33294d3..8fb9d5b 100644 --- "a/AntJob.Data/Entity/\344\275\234\344\270\232.Biz.cs" +++ "b/AntJob.Data/Entity/\344\275\234\344\270\232.Biz.cs" @@ -4,6 +4,7 @@ using NewLife.Data; using NewLife.Threading; using XCode; +using XCode.DataAccessLayer; namespace AntJob.Data.Entity; diff --git "a/AntJob.Data/Entity/\344\275\234\344\270\232\344\273\273\345\212\241.Biz.cs" "b/AntJob.Data/Entity/\344\275\234\344\270\232\344\273\273\345\212\241.Biz.cs" index e401a25..e8f6c7e 100644 --- "a/AntJob.Data/Entity/\344\275\234\344\270\232\344\273\273\345\212\241.Biz.cs" +++ "b/AntJob.Data/Entity/\344\275\234\344\270\232\344\273\273\345\212\241.Biz.cs" @@ -150,14 +150,14 @@ public static IEnumerable Search(Int32 id, Int32 appid, Int32 jobid, Jo var exp = new WhereExpression(); if (id > 0) exp &= _.ID == id; - if (appid > 0) exp &= _.AppID == appid; - if (jobid > 0) exp &= _.JobID == jobid; + if (appid >= 0) exp &= _.AppID == appid; + if (jobid >= 0) exp &= _.JobID == jobid; if (status >= JobStatus.就绪) exp &= _.Status == status; if (!client.IsNullOrEmpty()) exp &= _.Client == client; if (!key.IsNullOrEmpty()) exp &= _.Data.Contains(key) | _.Message.Contains(key) | _.Key == key; exp &= _.DataTime.Between(dataStart, dataEnd); - exp &= _.DataTime.Between(start, end); + exp &= _.UpdateTime.Between(start, end); return FindAll(exp, p); } @@ -207,6 +207,10 @@ public void Reset() //public static Int32 DeleteByAppId(Int32 appid) => Delete(_.AppID == appid); + /// 删除作业已不存在的任务 + /// + public static Int32 DeleteNoJob() => Delete(_.JobID.NotIn(Entity.Job.FindSQLWithKey())); + /// 转模型类 /// public TaskModel ToModel() diff --git "a/AntJob.Data/Entity/\344\275\234\344\270\232\344\273\273\345\212\241.cs" "b/AntJob.Data/Entity/\344\275\234\344\270\232\344\273\273\345\212\241.cs" index faa5fef..d9ad2ff 100644 --- "a/AntJob.Data/Entity/\344\275\234\344\270\232\344\273\273\345\212\241.cs" +++ "b/AntJob.Data/Entity/\344\275\234\344\270\232\344\273\273\345\212\241.cs" @@ -18,8 +18,9 @@ namespace AntJob.Data.Entity; [DataObject] [Description("作业任务。计算作业在执行过程中生成的任务实例,具有该次执行所需参数")] [BindIndex("IX_JobTask_JobID_DataTime", false, "JobID,DataTime")] -[BindIndex("IX_JobTask_AppID_Client_Status", false, "AppID,Client,Status")] [BindIndex("IX_JobTask_JobID_CreateTime", false, "JobID,CreateTime")] +[BindIndex("IX_JobTask_JobID_UpdateTime", false, "JobID,UpdateTime")] +[BindIndex("IX_JobTask_AppID_Client_Status", false, "AppID,Client,Status")] [BindTable("JobTask", Description = "作业任务。计算作业在执行过程中生成的任务实例,具有该次执行所需参数", ConnName = "Ant", DbType = DatabaseType.None)] public partial class JobTask { diff --git a/AntJob.Data/Model.xml b/AntJob.Data/Model.xml index c6d2e12..fa1eb2b 100644 --- a/AntJob.Data/Model.xml +++ b/AntJob.Data/Model.xml @@ -195,8 +195,9 @@ - + + diff --git a/AntJob.Server/Worker.cs b/AntJob.Server/Worker.cs index 0cf49f0..8c07a56 100644 --- a/AntJob.Server/Worker.cs +++ b/AntJob.Server/Worker.cs @@ -145,6 +145,9 @@ private static void ClearItems(Object state) p += list.Count; } + // 删除作业已不存在的任务 + rs += JobTask.DeleteNoJob(); + if (rs > 0) { sw.Stop();