From dfda1931656247176c565f80332382c92158ab93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=94=84=E5=A4=B4?= Date: Mon, 6 May 2024 16:09:19 +0800 Subject: [PATCH] wordk --- Worker.cs | 88 ++----------------------------------------------------- 1 file changed, 2 insertions(+), 86 deletions(-) diff --git a/Worker.cs b/Worker.cs index 1c6b573..f3621b0 100644 --- a/Worker.cs +++ b/Worker.cs @@ -110,94 +110,10 @@ namespace WorkerSynReport - private async Task SynGel() - { - - XTrace.WriteLine("开始跑糊化机"); - using var scope = _scopeFactory.CreateScope(); - var services = scope.ServiceProvider; - using IDbContextLocal? dbContextLocal = services.GetService(); - using IDbContextHttp? dbContextHttp = services.GetService(); - - var reportId=await dbContextHttp!.Query() - .OrderByDesc(x => x.objId).Select(x => x.reportId).FirstOrDefaultAsync(); - - var objId=await dbContextLocal!.Query().Where(x => x.reportId == reportId) - .Select(x => x.objId).FirstOrDefaultAsync(); - - if (objId > 0) - { - List lsMain = new List(); - List lsMainDetail = new List(); - List lsMixerDetails = new(); - - var list= await dbContextLocal.Query().Where(x => x.objId > objId).ToListAsync(); - - foreach (var dry in list) - { - lsMain.Add(dry); - lsMainDetail.AddRange(await dbContextLocal.Query().Where(x=>x.reportId==dry.reportId).ToListAsync()); - - lsMixerDetails.AddRange(await dbContextLocal.Query().Where(x=>x.reportId==dry.reportId).ToListAsync()); - } - - if (lsMain.Any()) - { - XTrace.WriteLine("插入数据:{0}",lsMain.Count); - await dbContextHttp.InsertRangeAsync(lsMain); - await dbContextHttp.InsertRangeAsync(lsMainDetail); - await dbContextHttp.InsertRangeAsync(lsMixerDetails); - } - } - { - XTrace.WriteLine("插入数据:{0}",lsMain.Count); - await dbContextHttp.InsertRangeAsync(lsMain); - await dbContextHttp.InsertRangeAsync(lsMainDetail); - } - } - - } - - - private async Task SynDry() - { - XTrace.WriteLine("开始跑干混机"); - using var scope = _scopeFactory.CreateScope(); - var services = scope.ServiceProvider; - using IDbContextLocal? dbContextLocal = services.GetService(); - using IDbContextHttp? dbContextHttp = services.GetService(); - - var reportId=await dbContextHttp!.Query() - .OrderByDesc(x => x.objId).Select(x => x.reportId).FirstOrDefaultAsync(); - - var objId=await dbContextLocal.Query().Where(x => x.reportId == reportId) - .Select(x => x.objId).FirstOrDefaultAsync(); - - if (objId > 0) - { - List lsMain = new List(); - List lsMainDetail = new List(); - List lsMixerDetails = new(); - - var list= await dbContextLocal.Query().Where(x => x.objId > objId).ToListAsync(); + - foreach (var dry in list) - { - lsMain.Add(dry); - lsMainDetail.AddRange(await dbContextLocal.Query().Where(x=>x.reportId==dry.reportId).ToListAsync()); - - lsMixerDetails.AddRange(await dbContextLocal.Query().Where(x=>x.reportId==dry.reportId).ToListAsync()); - } - if (lsMain.Any()) - { - XTrace.WriteLine("插入数据:{0}",lsMain.Count); - await dbContextHttp.InsertRangeAsync(lsMain); - await dbContextHttp.InsertRangeAsync(lsMainDetail); - await dbContextHttp.InsertRangeAsync(lsMixerDetails); - } - } - } +