fix 数据条件修改

This commit is contained in:
2024-07-09 13:38:02 +08:00
parent f79844281d
commit c5ca376fd3

View File

@@ -11,7 +11,6 @@ namespace Dlhis.ScheduledTask.Jobs;
[RecurringJob(nameof(CreateGetUploadRecordJob), "0 0/10 * * * ?", Name = "创建上传设备数据任务")]
public class CreateGetUploadRecordJob : BaseJob
{
public CreateGetUploadRecordJob(IServiceProvider serviceProvider) : base(serviceProvider)
{
}
@@ -20,15 +19,15 @@ public class CreateGetUploadRecordJob : BaseJob
{
var devices = await DbContext.Queryable<DeviceEntity>()
.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)
.ToListAsync();
//过滤处理中的任务
var currentUniqueNos = await DbContext.Queryable<DeviceTaskEntity>()
.Where(x => x.Type == DeviceTaskEnumType.UploadRecord)
.Where(x => x.Status == DeviceTaskStatusEnumType.Process || x.Status == DeviceTaskStatusEnumType.Wait)
.Select(x => x.DeviceUniqueNo)
.ToListAsync();
.Where(x => x.Type == DeviceTaskEnumType.UploadRecord)
.Where(x => x.Status == DeviceTaskStatusEnumType.Process || x.Status == DeviceTaskStatusEnumType.Wait)
.Select(x => x.DeviceUniqueNo)
.ToListAsync();
var tasks = devices.Where(x => !currentUniqueNos.Contains(x.UniqueNo)).Select(x => new DeviceTaskEntity
{
@@ -40,10 +39,8 @@ public class CreateGetUploadRecordJob : BaseJob
Type = DeviceTaskEnumType.UploadRecord,
CancellationId = 0,
Priority = 50,
})
.ToList();
}).ToList();
await DbContext.InsertAsync(tasks);
}
}
}