Browse Source

发运、EDI对比

master
mahao 1 year ago
parent
commit
7ffc29083a
  1. 53
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs
  2. 53
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs
  3. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs
  4. 12
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSeEdiCompareExportService.cs
  5. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs
  6. 12
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSeEdiCompareExportService.cs
  7. 11
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs

53
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs

@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Coravel.Invocable;
@ -37,20 +36,20 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable
await HandDelEdiDataAsync().ConfigureAwait(false);
var seDetailGroup = db.Set<BBAC_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<BBAC_SE_EDI>().Where(t => t.IsDeleted == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU });
var seDetailGroup = db.Set<BBAC_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<BBAC_SE_EDI>().Where(t => t.IsDeleted == 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<BBAC_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<BBAC_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();
@ -90,24 +89,38 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable
*/
using var serviceScope = _serviceProvider.CreateScope();
var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
//Edi 删除的数据(有发运数据)
var ediDelKeyCodes = db.Set<BBAC_SE_EDI>().Where(t => t.IsDeleted == true && t.IsHaveSeData == true).Select(t => new { t.PN, t.LU }).Distinct().ToList();
if (ediDelKeyCodes.Any())
var seed = 0;
while (seed < 10)
{
var seDetails = db.Set<BBAC_SE_DETAIL>().Join(ediDelKeyCodes, a => new { a.PN, LU = a.CustomerPartCodeNoSpace }, b => new { b.PN, b.LU }, (a, b) => a);
var ediDetails = db.Set<BBAC_SE_EDI>().Join(ediDelKeyCodes, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (a, b) => a);
if (seDetails.Any())
seed++;
//Edi 删除的数据(有发运数据)
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())
{
seDetails.ForEach(t => t.IsHaveEdiData = false);
db.Set<BBAC_SE_DETAIL>().UpdateRange(seDetails);
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);
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);
await db.BulkUpdateAsync<HBPO_SE_EDI>(ediDetails).ConfigureAwait(false);
}
}
if (ediDetails.Any())
else
{
ediDetails.ForEach(t => t.IsHaveSeData = false);
db.Set<BBAC_SE_EDI>().UpdateRange(ediDetails);
break;
}
await db.SaveChangesAsync().ConfigureAwait(false);
}
}
}

53
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs

@ -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>();
//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();
if (ediDelKeyCodes.Any())
var seed = 0;
while (seed < 10)
{
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);
if (seDetails.Any())
seed++;
//Edi 删除的数据(有发运数据)
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())
{
seDetails.ForEach(t => t.IsHaveEdiData = false);
db.Set<HBPO_SE_DETAIL>().UpdateRange(seDetails);
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);
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);
await db.BulkUpdateAsync<HBPO_SE_EDI>(ediDetails).ConfigureAwait(false);
}
}
if (ediDetails.Any())
else
{
ediDetails.ForEach(t => t.IsHaveSeData = false);
db.Set<HBPO_SE_EDI>().UpdateRange(ediDetails);
break;
}
await db.SaveChangesAsync().ConfigureAwait(false);
}
}
}

9
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs

@ -149,16 +149,17 @@ namespace SettleAccount.Job.Services.Report
//Edi
var ediGroup = from edi in _settleAccountDbContext.Set<BBAC_SE_EDI>()
where edi.IsDeleted == false && edi.IsHaveSeData == true
group edi by new { edi.PN, edi.LU } into groupItem
group edi by new { edi.PN, edi.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty)
groupItem.Key.CustomerPartCodeNoSpace,
Qty = groupItem.Sum(t => t.Qty),
LU = groupItem.Max(t => t.LU)
};
var seEdiGroup = from se in seGroup
join edi in ediGroup
on new { se.PN, se.CustomerPartCodeNoSpace } equals new { edi.PN, CustomerPartCodeNoSpace = edi.LU }
on new { se.PN, se.CustomerPartCodeNoSpace } equals new { edi.PN, edi.CustomerPartCodeNoSpace }
into ediTemp
from edi in ediTemp.DefaultIfEmpty()
select new

12
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSeEdiCompareExportService.cs

@ -77,7 +77,7 @@ namespace SettleAccount.Job.Services.Report
//有EDI无发运
var haveEdiNotHaveSeList = _settleAccountDbContext.Set<BBAC_SE_EDI>().Where(t => t.IsHaveSeData == false)
.GroupBy(t => new { t.LU, t.PN })
.GroupBy(t => new { t.PN, t.CustomerPartCodeNoSpace })
.Select(t => new JisBBACEidSeCompareExport()
{
Category = "JIS",
@ -86,7 +86,7 @@ namespace SettleAccount.Job.Services.Report
SequenceNumber = t.Max(t => t.Extend3),
ParType = t.Max(t => t.Extend2),
PN = t.Key.PN,
MaterialNumber = t.Key.LU,
MaterialNumber = t.Max(t => t.LU),
EdiQty = t.Sum(t => t.Qty),
AssemblyDate = default,
MatchNumber = default,
@ -95,7 +95,7 @@ namespace SettleAccount.Job.Services.Report
}).ToList();
//无EDI有发运
var notHaveEdiHaveSeList = _settleAccountDbContext.Set<BBAC_SE_DETAIL>().Where(t => t.IsHaveEdiData == false)
.GroupBy(t => new { t.CustomerPartCodeNoSpace, t.PN })
.GroupBy(t => new { t.PN, t.CustomerPartCodeNoSpace })
.Select(t => new JisBBACEidSeCompareExport()
{
Category = "JIS",
@ -115,11 +115,11 @@ namespace SettleAccount.Job.Services.Report
//有EDI有发运
var ediGroup = from edi in _settleAccountDbContext.Set<BBAC_SE_EDI>()
where edi.IsDeleted == false && edi.IsHaveSeData == true
group edi by new { edi.PN, edi.LU } into groupItem
group edi by new { edi.PN, edi.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
groupItem.Key.CustomerPartCodeNoSpace,
Qty = groupItem.Sum(t => t.Qty),
Extend2 = groupItem.Max(t => t.Extend2),
Extend3 = groupItem.Max(t => t.Extend3),
@ -146,7 +146,7 @@ namespace SettleAccount.Job.Services.Report
};
var haveEdiHaveSeList = (from edi in ediGroup
join se in seGroup
on new { edi.PN, edi.LU } equals new { se.PN, LU = se.CustomerPartCodeNoSpace }
on new { edi.PN, edi.CustomerPartCodeNoSpace } equals new { se.PN, se.CustomerPartCodeNoSpace }
select new JisBBACEidSeCompareExport()
{
Category = "JIS",

9
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs

@ -164,16 +164,17 @@ namespace SettleAccount.Job.Services.Report
//Edi
var ediGroup = from edi in _settleAccountDbContext.Set<HBPO_SE_EDI>()
where edi.IsDeleted == false && edi.IsHaveSeData == true
group edi by new { edi.PN, edi.LU } into groupItem
group edi by new { edi.PN, edi.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty)
groupItem.Key.CustomerPartCodeNoSpace,
Qty = groupItem.Sum(t => t.Qty),
LU = groupItem.Max(t => t.LU)
};
var seEdiGroup = from se in seGroup
join edi in ediGroup
on new { se.PN, se.CustomerPartCodeNoSpace } equals new { edi.PN, CustomerPartCodeNoSpace = edi.LU }
on new { se.PN, se.CustomerPartCodeNoSpace } equals new { edi.PN, edi.CustomerPartCodeNoSpace }
into ediTemp
from edi in ediTemp.DefaultIfEmpty()
select new

12
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSeEdiCompareExportService.cs

@ -74,7 +74,7 @@ namespace SettleAccount.Job.Services.Report
//有EDI无发运
var haveEdiNotHaveSeList = _settleAccountDbContext.Set<HBPO_SE_EDI>().Where(t => t.IsHaveSeData == false)
.GroupBy(t => new { t.LU, t.PN })
.GroupBy(t => new { t.PN, t.CustomerPartCodeNoSpace })
.Select(t => new JisHBPOEidSeCompareExport()
{
Category = "JIS",
@ -83,7 +83,7 @@ namespace SettleAccount.Job.Services.Report
SequenceNumber = t.Max(t => t.SeqNumber),
ParType = "01",
PN = t.Key.PN,
MaterialNumber = t.Key.LU,
MaterialNumber = t.Max(t => t.LU),
EdiQty = t.Sum(t => t.Qty),
AssemblyDate = default,
MatchNumber = default,
@ -92,7 +92,7 @@ namespace SettleAccount.Job.Services.Report
}).ToList();
//无EDI有发运
var notHaveEdiHaveSeList = _settleAccountDbContext.Set<HBPO_SE_DETAIL>().Where(t => t.IsHaveEdiData == false)
.GroupBy(t => new { t.CustomerPartCodeNoSpace, t.PN })
.GroupBy(t => new { t.PN, t.CustomerPartCodeNoSpace })
.Select(t => new JisHBPOEidSeCompareExport()
{
Category = "JIS",
@ -114,11 +114,11 @@ namespace SettleAccount.Job.Services.Report
//有EDI有发运
var ediGroup = from edi in _settleAccountDbContext.Set<HBPO_SE_EDI>()
where edi.IsDeleted == false && edi.IsHaveSeData == true
group edi by new { edi.PN, edi.LU } into groupItem
group edi by new { edi.PN, edi.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
groupItem.Key.CustomerPartCodeNoSpace,
Qty = groupItem.Sum(t => t.Qty),
SeqNumber = groupItem.Max(t => t.SeqNumber)
};
@ -143,7 +143,7 @@ namespace SettleAccount.Job.Services.Report
};
var haveEdiHaveSeList = (from edi in ediGroup
join se in seGroup
on new { edi.PN, edi.LU } equals new { se.PN, LU = se.CustomerPartCodeNoSpace }
on new { edi.PN, edi.CustomerPartCodeNoSpace } equals new { se.PN, se.CustomerPartCodeNoSpace }
select new JisHBPOEidSeCompareExport()
{
Category = "JIS",

11
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs

@ -4,10 +4,10 @@ using EFCore.BulkExtensions;
using Magicodes.ExporterAndImporter.Core.Extension;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore;
using SettleAccount.Bases;
using SettleAccount.Domain.BQ;
using SettleAccount.Job.SignalR;
using Volo.Abp;
using Win.Sfs.SettleAccount;
using Win.Sfs.SettleAccount.Consts;
using Win.Sfs.SettleAccount.Enums;
@ -184,9 +184,10 @@ namespace SettleAccount.Job.Services.Report
if (haveSaHaveSes.Any())
{
//结算详情
var saDetails = (from sa in _settleAccountDbContext.Set<T>()
where sa.BusinessType == businessType && sa.Version == version
select sa).ToList();
var saDetails = _settleAccountDbContext.Set<T>()
.Where(t => t.BusinessType == businessType)
.Where(t => t.Version == version)
.ToList();
if (saDetails.Any())
{
var saDetailsUpdate = saDetails.Join(haveSaHaveSes, o => new { o.PN, o.LU }, i => new { i.PN, LU = i.CustomerPartCode }, (o, i) =>
@ -202,6 +203,8 @@ namespace SettleAccount.Job.Services.Report
return o;
}).ToList();
_settleAccountDbContext.BulkUpdate(saDetailsUpdate);
_settleAccountDbContext.Set<BBAC_SA_DETAIL>().FromSqlInterpolated($"SELECT * FROM dbo.Blogs");
_settleAccountDbContext.Database.ExecuteSqlInterpolated($"SELECT * FROM dbo.Blogs");
}
}
}

Loading…
Cancel
Save