From 55f68d2009a3ca43d5198e018fa4b31fc93f4224 Mon Sep 17 00:00:00 2001 From: liguoyang Date: Sat, 24 May 2025 15:15:20 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=B3=A8=E9=87=8A=E5=BD=92=E6=A1=A3?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Jobs/ArchiveDeviceUploadLogJob.cs | 122 +++++++++--------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/Src/Dlhis.ScheduledTask/Jobs/ArchiveDeviceUploadLogJob.cs b/Src/Dlhis.ScheduledTask/Jobs/ArchiveDeviceUploadLogJob.cs index 9a441628..f0dd8548 100644 --- a/Src/Dlhis.ScheduledTask/Jobs/ArchiveDeviceUploadLogJob.cs +++ b/Src/Dlhis.ScheduledTask/Jobs/ArchiveDeviceUploadLogJob.cs @@ -1,61 +1,61 @@ -using Dlhis.Entity.Device.Entities; -using Dlhis.ScheduledTask.Attributes; - -namespace Dlhis.ScheduledTask.Jobs; - -/// -/// 归档设备通行记录 -/// -[RecurringJob(nameof(ArchiveDeviceUploadLogJob), "0 0 3 * * ? ", Name = "归档设备通行记录")] -public class ArchiveDeviceUploadLogJob : BaseJob -{ - public ArchiveDeviceUploadLogJob(IServiceProvider serviceProvider) : base(serviceProvider) - { - } - - protected override async Task RunAsync(IServiceProvider serviceProvider) - { - //设置60天前的数据需要归档 - var before60Days = DateTime.Today.AddDays(-60).AddSeconds(1); - //每次查询500条数据 - const int limit = 500; - //归档表 - const string tableName = "deviceuploadlog_20250107"; - - //正序获取数据 - var data = await DbContext.Queryable() - .Where(x => x.RaiseDateTime < before60Days) - .OrderBy(x => x.Id) - .ToPageListAsync(1, limit); - - do - { - if (data.Any()) - { - await DbContext.Client.Ado.BeginTranAsync(); - try - { - //删除数据 - await DbContext.DeleteReallyAsync(data); - foreach (var item in data) - { - item.Id = 0; - } - - //插入到归档表 - await DbContext.Client.Insertable(data).AS(tableName).ExecuteCommandAsync(); - await DbContext.Client.Ado.CommitTranAsync(); - } - catch (Exception) - { - await DbContext.Client.Ado.RollbackTranAsync(); - } - - await Task.Delay(200); - - //再次获取数据 - data = await DbContext.Queryable().Where(x => x.RaiseDateTime < before60Days).OrderBy(x => x.Id).ToPageListAsync(1, limit); - } - } while (data.Count == limit); - } -} \ No newline at end of file +// using Dlhis.Entity.Device.Entities; +// using Dlhis.ScheduledTask.Attributes; +// +// namespace Dlhis.ScheduledTask.Jobs; +// +// /// +// /// 归档设备通行记录 +// /// +// [RecurringJob(nameof(ArchiveDeviceUploadLogJob), "0 0 3 * * ? ", Name = "归档设备通行记录")] +// public class ArchiveDeviceUploadLogJob : BaseJob +// { +// public ArchiveDeviceUploadLogJob(IServiceProvider serviceProvider) : base(serviceProvider) +// { +// } +// +// protected override async Task RunAsync(IServiceProvider serviceProvider) +// { +// //设置60天前的数据需要归档 +// var before60Days = DateTime.Today.AddDays(-60).AddSeconds(1); +// //每次查询500条数据 +// const int limit = 500; +// //归档表 +// const string tableName = "deviceuploadlog_20250107"; +// +// //正序获取数据 +// var data = await DbContext.Queryable() +// .Where(x => x.RaiseDateTime < before60Days) +// .OrderBy(x => x.Id) +// .ToPageListAsync(1, limit); +// +// do +// { +// if (data.Any()) +// { +// await DbContext.Client.Ado.BeginTranAsync(); +// try +// { +// //删除数据 +// await DbContext.DeleteReallyAsync(data); +// foreach (var item in data) +// { +// item.Id = 0; +// } +// +// //插入到归档表 +// await DbContext.Client.Insertable(data).AS(tableName).ExecuteCommandAsync(); +// await DbContext.Client.Ado.CommitTranAsync(); +// } +// catch (Exception) +// { +// await DbContext.Client.Ado.RollbackTranAsync(); +// } +// +// await Task.Delay(200); +// +// //再次获取数据 +// data = await DbContext.Queryable().Where(x => x.RaiseDateTime < before60Days).OrderBy(x => x.Id).ToPageListAsync(1, limit); +// } +// } while (data.Count == limit); +// } +// } \ No newline at end of file