master
杨威 7 months ago
parent 935f2794d7
commit dfda193165

@ -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<IDbContextLocal>();
using IDbContextHttp? dbContextHttp = services.GetService<IDbContextHttp>();
var reportId=await dbContextHttp!.Query<Report_Gel>()
.OrderByDesc(x => x.objId).Select(x => x.reportId).FirstOrDefaultAsync();
var objId=await dbContextLocal!.Query<Report_Gel>().Where(x => x.reportId == reportId)
.Select(x => x.objId).FirstOrDefaultAsync();
if (objId > 0)
{
List<Report_Gel> lsMain = new List<Report_Gel>();
List<Report_GelDoser_Detail> lsMainDetail = new List<Report_GelDoser_Detail>();
List<Report_GelMixing_Detail> lsMixerDetails = new();
var list= await dbContextLocal.Query<Report_Gel>().Where(x => x.objId > objId).ToListAsync();
foreach (var dry in list)
{
lsMain.Add(dry);
lsMainDetail.AddRange(await dbContextLocal.Query<Report_GelDoser_Detail>().Where(x=>x.reportId==dry.reportId).ToListAsync());
lsMixerDetails.AddRange(await dbContextLocal.Query<Report_GelMixing_Detail>().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<IDbContextLocal>();
using IDbContextHttp? dbContextHttp = services.GetService<IDbContextHttp>();
var reportId=await dbContextHttp!.Query<Report_Dry>()
.OrderByDesc(x => x.objId).Select(x => x.reportId).FirstOrDefaultAsync();
var objId=await dbContextLocal.Query<Report_Dry>().Where(x => x.reportId == reportId)
.Select(x => x.objId).FirstOrDefaultAsync();
if (objId > 0)
{
List<Report_Dry> lsMain = new List<Report_Dry>();
List<Report_DryDos_Detail> lsMainDetail = new List<Report_DryDos_Detail>();
List<Report_DryMixer_Detail> lsMixerDetails = new();
var list= await dbContextLocal.Query<Report_Dry>().Where(x => x.objId > objId).ToListAsync();
foreach (var dry in list)
{
lsMain.Add(dry);
lsMainDetail.AddRange(await dbContextLocal.Query<Report_DryDos_Detail>().Where(x=>x.reportId==dry.reportId).ToListAsync());
lsMixerDetails.AddRange(await dbContextLocal.Query<Report_DryMixer_Detail>().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);
}
}
}

Loading…
Cancel
Save