|
|
@ -1,5 +1,4 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Linq.Dynamic.Core; |
|
|
|
using System.Threading.Tasks; |
|
|
@ -38,20 +37,20 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable |
|
|
|
|
|
|
|
await HandDelEdiDataAsync().ConfigureAwait(false); |
|
|
|
|
|
|
|
var seDetailGroup = db.Set<HBPO_SE_DETAIL>().Where(t => t.IsHaveEdiData == false).GroupBy(t => new { t.PN, t.CustomerPartCodeNoSpace }).Select(t => new { t.Key.PN, LU = t.Key.CustomerPartCodeNoSpace }); |
|
|
|
var ediDetailGroup = db.Set<HBPO_SE_EDI>().Where(t => t.IsDeleted == false && t.IsHaveSeData == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU }); |
|
|
|
var seDetailGroup = db.Set<HBPO_SE_DETAIL>().Where(t => t.IsHaveEdiData == false).GroupBy(t => new { t.PN, t.CustomerPartCodeNoSpace }).Select(t => new { t.Key.PN, t.Key.CustomerPartCodeNoSpace }); |
|
|
|
var ediDetailGroup = db.Set<HBPO_SE_EDI>().Where(t => t.IsDeleted == false && t.IsHaveSeData == false).GroupBy(t => new { t.PN, t.CustomerPartCodeNoSpace }).Select(t => new { t.Key.PN, t.Key.CustomerPartCodeNoSpace }); |
|
|
|
|
|
|
|
var keyCodes = from se in seDetailGroup |
|
|
|
from edi in ediDetailGroup |
|
|
|
where se.PN == edi.PN && se.LU == edi.LU |
|
|
|
select new { se.PN, se.LU }; |
|
|
|
where se.PN == edi.PN && se.CustomerPartCodeNoSpace == edi.CustomerPartCodeNoSpace |
|
|
|
select new { se.PN, se.CustomerPartCodeNoSpace }; |
|
|
|
var seDetailsQuery = from se in db.Set<HBPO_SE_DETAIL>() |
|
|
|
from keyCode in keyCodes |
|
|
|
where se.PN == keyCode.PN && se.CustomerPartCodeNoSpace == keyCode.LU && se.IsHaveEdiData == false |
|
|
|
where se.PN == keyCode.PN && se.CustomerPartCodeNoSpace == keyCode.CustomerPartCodeNoSpace && se.IsHaveEdiData == false |
|
|
|
select se; |
|
|
|
var ediDetailsQuery = from edi in db.Set<HBPO_SE_EDI>() |
|
|
|
from keyCode in keyCodes |
|
|
|
where edi.PN == keyCode.PN && edi.LU == keyCode.LU && edi.IsDeleted == false && edi.IsHaveSeData == false |
|
|
|
where edi.PN == keyCode.PN && edi.CustomerPartCodeNoSpace == keyCode.CustomerPartCodeNoSpace && edi.IsDeleted == false && edi.IsHaveSeData == false |
|
|
|
select edi; |
|
|
|
|
|
|
|
var seDetails = seDetailsQuery.Take(5000).ToList(); |
|
|
@ -85,24 +84,38 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable |
|
|
|
{ |
|
|
|
using var serviceScope = _serviceProvider.CreateScope(); |
|
|
|
var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>(); |
|
|
|
var seed = 0; |
|
|
|
while (seed < 10) |
|
|
|
{ |
|
|
|
seed++; |
|
|
|
//Edi 删除的数据(有发运数据)
|
|
|
|
var ediDelKeyCodes = db.Set<HBPO_SE_EDI>().Where(t => t.IsDeleted == true && t.IsHaveSeData == true).Select(t => new { t.PN, t.LU }).Distinct().ToList(); |
|
|
|
|
|
|
|
var ediDelKeyCodes = db.Set<HBPO_SE_EDI>().Where(t => t.IsDeleted == true && t.IsHaveSeData == true).GroupBy(t => t.PN).Select(t => t.Key).Take(1000).ToList(); |
|
|
|
if (ediDelKeyCodes.Any()) |
|
|
|
{ |
|
|
|
var seDetails = db.Set<HBPO_SE_DETAIL>().Join(ediDelKeyCodes, a => new { a.PN, LU = a.CustomerPartCodeNoSpace }, b => new { b.PN, b.LU }, (a, b) => a); |
|
|
|
var ediDetails = db.Set<HBPO_SE_EDI>().Join(ediDelKeyCodes, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (a, b) => a); |
|
|
|
var seDetails = db.Set<HBPO_SE_DETAIL>() |
|
|
|
.Where(t => t.IsHaveEdiData == true) |
|
|
|
.Where(t => ediDelKeyCodes.Contains(t.PN)) |
|
|
|
.ToList(); |
|
|
|
if (seDetails.Any()) |
|
|
|
{ |
|
|
|
seDetails.ForEach(t => t.IsHaveEdiData = false); |
|
|
|
db.Set<HBPO_SE_DETAIL>().UpdateRange(seDetails); |
|
|
|
await db.BulkUpdateAsync<HBPO_SE_DETAIL>(seDetails).ConfigureAwait(false); |
|
|
|
} |
|
|
|
|
|
|
|
var ediDetails = db.Set<HBPO_SE_EDI>() |
|
|
|
.Where(t => t.IsHaveSeData == true) |
|
|
|
.Where(t => ediDelKeyCodes.Contains(t.PN)) |
|
|
|
.ToList(); |
|
|
|
if (ediDetails.Any()) |
|
|
|
{ |
|
|
|
ediDetails.ForEach(t => t.IsHaveSeData = false); |
|
|
|
db.Set<HBPO_SE_EDI>().UpdateRange(ediDetails); |
|
|
|
await db.BulkUpdateAsync<HBPO_SE_EDI>(ediDetails).ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
break; |
|
|
|
} |
|
|
|
await db.SaveChangesAsync().ConfigureAwait(false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|