|
@ -1,8 +1,11 @@ |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
|
|
|
using EFCore.BulkExtensions; |
|
|
using Magicodes.ExporterAndImporter.Excel; |
|
|
using Magicodes.ExporterAndImporter.Excel; |
|
|
using Microsoft.AspNetCore.SignalR; |
|
|
using Microsoft.AspNetCore.SignalR; |
|
|
|
|
|
using SettleAccount.Bases; |
|
|
using SettleAccount.Job.SignalR; |
|
|
using SettleAccount.Job.SignalR; |
|
|
|
|
|
using Win.Sfs.SettleAccount; |
|
|
using Win.Sfs.SettleAccount.Enums; |
|
|
using Win.Sfs.SettleAccount.Enums; |
|
|
using Win.Sfs.SettleAccount.Reports; |
|
|
using Win.Sfs.SettleAccount.Reports; |
|
|
|
|
|
|
|
@ -17,10 +20,15 @@ namespace SettleAccount.Job.Services.Report |
|
|
/// HubContext
|
|
|
/// HubContext
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private readonly IHubContext<PageHub> _hubContext; |
|
|
private readonly IHubContext<PageHub> _hubContext; |
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// DbContext
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly SettleAccountDbContext _settleAccountDbContext; |
|
|
|
|
|
|
|
|
public SaSeEdiCompareExportBaseService(IHubContext<PageHub> hubContext) |
|
|
public SaSeEdiCompareExportBaseService(IHubContext<PageHub> hubContext, SettleAccountDbContext settleAccountDbContext) |
|
|
{ |
|
|
{ |
|
|
_hubContext = hubContext; |
|
|
_hubContext = hubContext; |
|
|
|
|
|
_settleAccountDbContext = settleAccountDbContext; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public virtual void HandleSaSeEdiCompareDiffList(List<SaSeEdiCompareDiff> ediSeSaCompareDiffs) |
|
|
public virtual void HandleSaSeEdiCompareDiffList(List<SaSeEdiCompareDiff> ediSeSaCompareDiffs) |
|
@ -61,6 +69,50 @@ namespace SettleAccount.Job.Services.Report |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 结算数据处理
|
|
|
|
|
|
/// 写入库位、替换零件号
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public virtual void HandleSaDetails<TCanSa, TNotSa>(List<SaSeEdiCompareDiff> saSeEdiCompareDiff, EnumBusinessType businessType, int version) |
|
|
|
|
|
where TCanSa : SA_CAN_BASE |
|
|
|
|
|
where TNotSa : SA_NOT_BASE |
|
|
|
|
|
{ |
|
|
|
|
|
//写入库位、替换零件号
|
|
|
|
|
|
var haveSaHaveSes = saSeEdiCompareDiff.FindAll(t => t.Category == EnumSaSeEdiCompareCategory.HaveSaHaveSeHaveEdi || t.Category == EnumSaSeEdiCompareCategory.HaveSaHaveSeNotHaveEdi); |
|
|
|
|
|
if (haveSaHaveSes.Any()) |
|
|
|
|
|
{ |
|
|
|
|
|
//可结算单
|
|
|
|
|
|
var canSaDetails = (from sa in _settleAccountDbContext.Set<TCanSa>() |
|
|
|
|
|
where sa.BusinessType == businessType && sa.Version == version |
|
|
|
|
|
select sa).ToList(); |
|
|
|
|
|
if (canSaDetails.Any()) |
|
|
|
|
|
{ |
|
|
|
|
|
var canSaDetailsUpdate = canSaDetails.Join(haveSaHaveSes, o => new { o.PN, o.LU }, i => new { i.PN, LU = i.CustomerPartCode }, (o, i) => |
|
|
|
|
|
{ |
|
|
|
|
|
o.ErpLoc = i.ToErpLocCode; |
|
|
|
|
|
o.RealPartCode = i.ReplaceFactoryPartCode; |
|
|
|
|
|
return o; |
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
_settleAccountDbContext.BulkUpdate(canSaDetailsUpdate); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//不可结算单
|
|
|
|
|
|
var notSaDetails = (from sa in _settleAccountDbContext.Set<TNotSa>() |
|
|
|
|
|
where sa.BusinessType == businessType && sa.Version == version |
|
|
|
|
|
select sa).ToList(); |
|
|
|
|
|
if (notSaDetails.Any()) |
|
|
|
|
|
{ |
|
|
|
|
|
var notSaDetailsUpdate = notSaDetails.Join(haveSaHaveSes, o => new { o.PN, o.LU }, i => new { i.PN, LU = i.CustomerPartCode }, (o, i) => |
|
|
|
|
|
{ |
|
|
|
|
|
o.ErpLoc = i.ToErpLocCode; |
|
|
|
|
|
o.RealPartCode = i.ReplaceFactoryPartCode; |
|
|
|
|
|
return o; |
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
_settleAccountDbContext.BulkUpdate(notSaDetailsUpdate); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 创建导出文件结构
|
|
|
/// 创建导出文件结构
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|