fix 增加时间配置

This commit is contained in:
2025-05-12 17:10:25 +08:00
parent cce445b607
commit c2b97024dc

View File

@@ -6,7 +6,7 @@ namespace Dlhis.ScheduledTask.Jobs;
/// <summary>
/// 归档设备通行记录
/// </summary>
[RecurringJob(nameof(ArchiveDeviceUploadLogJob), "0 0/5 * * * ?", Name = "归档设备通行记录")]
[RecurringJob(nameof(ArchiveDeviceUploadLogJob), "0 0 20 * * ? ", Name = "归档设备通行记录")]
public class ArchiveDeviceUploadLogJob : BaseJob
{
public ArchiveDeviceUploadLogJob(IServiceProvider serviceProvider) : base(serviceProvider)
@@ -21,6 +21,7 @@ public class ArchiveDeviceUploadLogJob : BaseJob
var data = await DbContext.Queryable<DeviceUploadLogEntity>().Where(x => x.RaiseDateTime < before60Days).OrderBy(x => x.Id).ToPageListAsync(1, limit);
var now = DateTime.Now;
do
{
if (data.Any())
@@ -47,6 +48,18 @@ public class ArchiveDeviceUploadLogJob : BaseJob
data = await DbContext.Queryable<DeviceUploadLogEntity>().Where(x => x.RaiseDateTime < before60Days).OrderBy(x => x.Id).ToPageListAsync(1, limit);
}
} while (data.Count == limit);
now = DateTime.Now;
} while (data.Count == limit && TimeSetting(now));
}
private bool TimeSetting(DateTime d)
{
if (d.Hour is >= 20 or <= 7)
{
return true;
}
return false;
}
}