From ea93b941e0ba6c5e3f0c4b9a11db0ce0918f5eee Mon Sep 17 00:00:00 2001 From: liguoyang Date: Thu, 29 Feb 2024 13:02:21 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E8=BF=87=E6=BB=A4=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Job/CreateGetUploadRecordJob.cs | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetUploadRecordJob.cs b/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetUploadRecordJob.cs index d17e7215..4b2b9062 100644 --- a/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetUploadRecordJob.cs +++ b/Src/Dlhis.ScheduledTask/TaskAssignment/Job/CreateGetUploadRecordJob.cs @@ -25,24 +25,20 @@ public class CreateGetUploadRecordJob { var devices = await _dbContext.Queryable() .Where(x => x.Enable) - .Where(x => x.Type == DeviceTypeEnumType.Attendance || (x.Type == DeviceTypeEnumType.Door && x.AsAttendance) + .Where(x => x.Type == DeviceTypeEnumType.Attendance || (x.Type == DeviceTypeEnumType.Door && x.AsAttendance) || x.Type == DeviceTypeEnumType.Door) .ToListAsync(); - var ds = devices.Select(x => x.UniqueNo).ToList(); + var uniqueNos = devices.Select(x => x.UniqueNo).ToList(); + //过滤处理中的任务 + uniqueNos = await _dbContext.Queryable() + .Where(x => !uniqueNos.Contains(x.DeviceUniqueNo)) + .Where(x => x.Type == DeviceTaskEnumType.UploadRecord) + .Where(x => x.Status == DeviceTaskStatusEnumType.Process || x.Status == DeviceTaskStatusEnumType.Wait) + .Select(x => x.DeviceUniqueNo) + .ToListAsync(); - var b = await _dbContext.Queryable() - .Where(x => ds.Contains(x.DeviceUniqueNo)) - .Where(x => x.Type == DeviceTaskEnumType.UploadRecord) - .Where(x => x.Status == DeviceTaskStatusEnumType.Process || x.Status == DeviceTaskStatusEnumType.Wait) - .AnyAsync(); - - if (b) - { - return; - } - - var tasks = devices.Select(x => new DeviceTaskEntity + var tasks = devices.Where(x => uniqueNos.Contains(x.UniqueNo)).Select(x => new DeviceTaskEntity { DeviceUniqueNo = x.UniqueNo, Status = DeviceTaskStatusEnumType.Wait,