|
@ -6,6 +6,7 @@ using System.Linq; |
|
|
using Magicodes.ExporterAndImporter.Excel; |
|
|
using Magicodes.ExporterAndImporter.Excel; |
|
|
using Microsoft.AspNetCore.SignalR; |
|
|
using Microsoft.AspNetCore.SignalR; |
|
|
using Microsoft.OpenApi.Extensions; |
|
|
using Microsoft.OpenApi.Extensions; |
|
|
|
|
|
using SettleAccount.Bases; |
|
|
using SettleAccount.Domain.BQ; |
|
|
using SettleAccount.Domain.BQ; |
|
|
using SettleAccount.Job.SignalR; |
|
|
using SettleAccount.Job.SignalR; |
|
|
using ShardingCore.Extensions; |
|
|
using ShardingCore.Extensions; |
|
@ -34,18 +35,6 @@ namespace SettleAccount.Job.Services.Report |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private readonly SettleAccountDbContext _settleAccountDbContext; |
|
|
private readonly SettleAccountDbContext _settleAccountDbContext; |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 替换件关系仓储
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _tbRePartsRelationshipRepository; |
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// PUB二次比对仓储
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> _pubSeCDetailRepository; |
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Pub结算发运对比Dapper
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private readonly PubSaSeCompareDapperRepository _pubSaSeCompareDapperRepository; |
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 文件容器
|
|
|
/// 文件容器
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private readonly IBlobContainer<MyFileContainer> _fileContainer; |
|
|
private readonly IBlobContainer<MyFileContainer> _fileContainer; |
|
@ -60,16 +49,10 @@ namespace SettleAccount.Job.Services.Report |
|
|
public PubSaSeCompareExportService( |
|
|
public PubSaSeCompareExportService( |
|
|
IHubContext<PageHub> hubContext, |
|
|
IHubContext<PageHub> hubContext, |
|
|
SettleAccountDbContext settleAccountDbContext, |
|
|
SettleAccountDbContext settleAccountDbContext, |
|
|
INormalEfCoreRepository<TB_RePartsRelationship, Guid> tbRePartsRelationshipRepository, |
|
|
|
|
|
INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSeCDetailRepository, |
|
|
|
|
|
PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository, |
|
|
|
|
|
IBlobContainer<MyFileContainer> fileContainer, |
|
|
IBlobContainer<MyFileContainer> fileContainer, |
|
|
IObjectMapper objectMapper) : base(hubContext, settleAccountDbContext) |
|
|
IObjectMapper objectMapper) : base(hubContext, settleAccountDbContext) |
|
|
{ |
|
|
{ |
|
|
_settleAccountDbContext = settleAccountDbContext; |
|
|
_settleAccountDbContext = settleAccountDbContext; |
|
|
_tbRePartsRelationshipRepository = tbRePartsRelationshipRepository; |
|
|
|
|
|
_pubSeCDetailRepository = pubSeCDetailRepository; |
|
|
|
|
|
_pubSaSeCompareDapperRepository = pubSaSeCompareDapperRepository; |
|
|
|
|
|
_fileContainer = fileContainer; |
|
|
_fileContainer = fileContainer; |
|
|
_objectMapper = objectMapper; |
|
|
_objectMapper = objectMapper; |
|
|
} |
|
|
} |
|
@ -102,7 +85,7 @@ namespace SettleAccount.Job.Services.Report |
|
|
} |
|
|
} |
|
|
var filename = exportName.FirstOrDefault(); |
|
|
var filename = exportName.FirstOrDefault(); |
|
|
//var pubSaSeCompareDiffs = _pubSaSeCompareDapperRepository.GetDetailDiffReportList(strBusinessType, version, seStartDateTime, seEndDateTime);
|
|
|
//var pubSaSeCompareDiffs = _pubSaSeCompareDapperRepository.GetDetailDiffReportList(strBusinessType, version, seStartDateTime, seEndDateTime);
|
|
|
var pubSaSeCompareDiffs = GetSaSeCompareData(businessType, version, DateTime.Parse(seStartDateTime), DateTime.Parse(seEndDateTime)); |
|
|
var pubSaSeCompareDiffs = GetSaSeCompareData(businessType, version); |
|
|
|
|
|
|
|
|
HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs); |
|
|
HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs); |
|
|
|
|
|
|
|
@ -123,7 +106,6 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
|
|
|
|
|
#region 结算数据处理
|
|
|
#region 结算数据处理
|
|
|
HandleSaDetails<PUB_CAN_SA_DETAIL, PUB_NOT_SA_DETAIL>(pubSaSeCompareDiffs, businessType, version); |
|
|
HandleSaDetails<PUB_CAN_SA_DETAIL, PUB_NOT_SA_DETAIL>(pubSaSeCompareDiffs, businessType, version); |
|
|
|
|
|
|
|
|
HandleSaDetailsMain<PUB_SA_DETAIL>(pubSaSeCompareDiffs, businessType, version); |
|
|
HandleSaDetailsMain<PUB_SA_DETAIL>(pubSaSeCompareDiffs, businessType, version); |
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
|
|
@ -183,99 +165,12 @@ namespace SettleAccount.Job.Services.Report |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 获取比对数据
|
|
|
/// 获取比对数据
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
[Obsolete] |
|
|
private List<SaSeCompareDiff> GetSaSeCompareData(EnumBusinessType businessType, int version) |
|
|
private List<SaSeCompareDiff> GetSaSeCompareDataOld(EnumBusinessType businessType, int version, DateTime seStartDateTime, DateTime seEndDateTime) |
|
|
|
|
|
{ |
|
|
{ |
|
|
//印度件LU对比
|
|
|
//印度件LU对比
|
|
|
if (businessType == EnumBusinessType.YinDuJian) |
|
|
if (businessType == EnumBusinessType.YinDuJian) |
|
|
{ |
|
|
{ |
|
|
return GetSaSeCompareDataYinDu(version, seStartDateTime, seEndDateTime); |
|
|
return GetSaSeCompareDataYinDu(version); |
|
|
} |
|
|
|
|
|
//结算
|
|
|
|
|
|
var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() |
|
|
|
|
|
where sa.BusinessType == businessType && sa.Version == version |
|
|
|
|
|
group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem |
|
|
|
|
|
select new |
|
|
|
|
|
{ |
|
|
|
|
|
groupItem.Key.PN, |
|
|
|
|
|
groupItem.Key.CustomerPartCodeNoSpace, |
|
|
|
|
|
Qty = groupItem.Sum(t => t.Qty), |
|
|
|
|
|
LU = groupItem.Max(t => t.LU), |
|
|
|
|
|
SettleDate = groupItem.Max(t => t.SettleDate), |
|
|
|
|
|
PartCode = groupItem.Max(t => t.PartCode), |
|
|
|
|
|
}; |
|
|
|
|
|
//发运
|
|
|
|
|
|
var seGroup = from se in _settleAccountDbContext.Set<PUB_SE_DETAIL>() |
|
|
|
|
|
where se.BusinessType == businessType && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime |
|
|
|
|
|
group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem |
|
|
|
|
|
select new |
|
|
|
|
|
{ |
|
|
|
|
|
groupItem.Key.PN, |
|
|
|
|
|
groupItem.Key.CustomerPartCodeNoSpace, |
|
|
|
|
|
Qty = groupItem.Sum(t => t.Qty), |
|
|
|
|
|
LU = groupItem.Max(t => t.LU), |
|
|
|
|
|
WmsBillNum = groupItem.Max(t => t.WmsBillNum), |
|
|
|
|
|
ShippingDate = groupItem.Max(t => t.ShippingDate), |
|
|
|
|
|
FactoryPartCode = groupItem.Max(t => t.FactoryPartCode), |
|
|
|
|
|
ToLocCode = groupItem.Max(t => t.ToLocCode), |
|
|
|
|
|
ToErpLocCode = groupItem.Max(t => t.ToErpLocCode) |
|
|
|
|
|
}; |
|
|
|
|
|
var saSeCompareLeft = from sa in saGroup |
|
|
|
|
|
join se in seGroup |
|
|
|
|
|
on new { sa.PN, sa.CustomerPartCodeNoSpace } equals new { se.PN, se.CustomerPartCodeNoSpace } |
|
|
|
|
|
into temp |
|
|
|
|
|
from se in temp.DefaultIfEmpty() |
|
|
|
|
|
select new SaSeCompareDiff() |
|
|
|
|
|
{ |
|
|
|
|
|
WmsBillNum = se.WmsBillNum, |
|
|
|
|
|
ShippingDate = se.ShippingDate, |
|
|
|
|
|
CustomerOfflineTime = sa.SettleDate, |
|
|
|
|
|
PN = sa.PN, |
|
|
|
|
|
SAQty = sa.Qty, |
|
|
|
|
|
SEQty = se.Qty, |
|
|
|
|
|
ToLocCode = se.ToLocCode, |
|
|
|
|
|
ToErpLocCode = se.ToErpLocCode, |
|
|
|
|
|
SeCustomerPartCode = se.CustomerPartCodeNoSpace, |
|
|
|
|
|
SeFactoryPartCode = se.FactoryPartCode, |
|
|
|
|
|
SaCustomerPartCode = sa.CustomerPartCodeNoSpace, |
|
|
|
|
|
SaFactoryPartCode = sa.PartCode, |
|
|
|
|
|
CustomerPartCode = sa.LU |
|
|
|
|
|
}; |
|
|
|
|
|
var saSeCompareRight = from se in seGroup |
|
|
|
|
|
join sa in saGroup |
|
|
|
|
|
on new { se.PN, se.CustomerPartCodeNoSpace } equals new { sa.PN, sa.CustomerPartCodeNoSpace } |
|
|
|
|
|
into temp |
|
|
|
|
|
from sa in temp.DefaultIfEmpty() |
|
|
|
|
|
select new SaSeCompareDiff() |
|
|
|
|
|
{ |
|
|
|
|
|
WmsBillNum = se.WmsBillNum, |
|
|
|
|
|
ShippingDate = se.ShippingDate, |
|
|
|
|
|
CustomerOfflineTime = sa.SettleDate, |
|
|
|
|
|
PN = se.PN, |
|
|
|
|
|
SAQty = sa.Qty, |
|
|
|
|
|
SEQty = se.Qty, |
|
|
|
|
|
ToLocCode = se.ToLocCode, |
|
|
|
|
|
ToErpLocCode = se.ToErpLocCode, |
|
|
|
|
|
SeCustomerPartCode = se.CustomerPartCodeNoSpace, |
|
|
|
|
|
SeFactoryPartCode = se.FactoryPartCode, |
|
|
|
|
|
SaCustomerPartCode = sa.CustomerPartCodeNoSpace, |
|
|
|
|
|
SaFactoryPartCode = sa.PartCode, |
|
|
|
|
|
CustomerPartCode = sa.LU ?? se.LU |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList(); |
|
|
|
|
|
return saSeCompareFullJoin; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取比对数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private List<SaSeCompareDiff> GetSaSeCompareData(EnumBusinessType businessType, int version, DateTime seStartDateTime, DateTime seEndDateTime) |
|
|
|
|
|
{ |
|
|
|
|
|
//印度件LU对比
|
|
|
|
|
|
if (businessType == EnumBusinessType.YinDuJian) |
|
|
|
|
|
{ |
|
|
|
|
|
return GetSaSeCompareDataYinDu(version, seStartDateTime, seEndDateTime); |
|
|
|
|
|
} |
|
|
} |
|
|
//结算
|
|
|
//结算
|
|
|
var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() |
|
|
var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() |
|
@ -289,7 +184,7 @@ namespace SettleAccount.Job.Services.Report |
|
|
Version = groupItem.Max(t => t.Version), |
|
|
Version = groupItem.Max(t => t.Version), |
|
|
LU = groupItem.Max(t => t.LU), |
|
|
LU = groupItem.Max(t => t.LU), |
|
|
SettleDate = groupItem.Max(t => t.SettleDate), |
|
|
SettleDate = groupItem.Max(t => t.SettleDate), |
|
|
PartCode = groupItem.Max(t => t.PartCode), |
|
|
PartCode = groupItem.Max(t => t.PartCode) |
|
|
}; |
|
|
}; |
|
|
var saGroupByVersion = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() |
|
|
var saGroupByVersion = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() |
|
|
where sa.BusinessType == businessType && sa.Version == version |
|
|
where sa.BusinessType == businessType && sa.Version == version |
|
@ -302,7 +197,7 @@ namespace SettleAccount.Job.Services.Report |
|
|
Version = groupItem.Max(t => t.Version), |
|
|
Version = groupItem.Max(t => t.Version), |
|
|
LU = groupItem.Max(t => t.LU), |
|
|
LU = groupItem.Max(t => t.LU), |
|
|
SettleDate = groupItem.Max(t => t.SettleDate), |
|
|
SettleDate = groupItem.Max(t => t.SettleDate), |
|
|
PartCode = groupItem.Max(t => t.PartCode), |
|
|
PartCode = groupItem.Max(t => t.PartCode) |
|
|
}; |
|
|
}; |
|
|
//发运
|
|
|
//发运
|
|
|
var seGroup = from se in _settleAccountDbContext.Set<PUB_SE_DETAIL>() |
|
|
var seGroup = from se in _settleAccountDbContext.Set<PUB_SE_DETAIL>() |
|
@ -384,21 +279,35 @@ namespace SettleAccount.Job.Services.Report |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 获取比对数据
|
|
|
/// 获取比对数据
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private List<SaSeCompareDiff> GetSaSeCompareDataYinDu(int version, DateTime seStartDateTime, DateTime seEndDateTime) |
|
|
private List<SaSeCompareDiff> GetSaSeCompareDataYinDu(int version) |
|
|
{ |
|
|
{ |
|
|
|
|
|
//结算
|
|
|
var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() |
|
|
var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() |
|
|
|
|
|
where sa.BusinessType == EnumBusinessType.YinDuJian |
|
|
|
|
|
group sa by new { sa.CustomerPartCodeNoSpace } into groupItem |
|
|
|
|
|
select new |
|
|
|
|
|
{ |
|
|
|
|
|
groupItem.Key.CustomerPartCodeNoSpace, |
|
|
|
|
|
Qty = groupItem.Sum(t => t.Qty), |
|
|
|
|
|
Version = groupItem.Max(t => t.Version), |
|
|
|
|
|
LU = groupItem.Max(t => t.LU), |
|
|
|
|
|
SettleDate = groupItem.Max(t => t.SettleDate), |
|
|
|
|
|
PartCode = groupItem.Max(t => t.PartCode) |
|
|
|
|
|
}; |
|
|
|
|
|
var saGroupByVersion = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() |
|
|
where sa.BusinessType == EnumBusinessType.YinDuJian && sa.Version == version |
|
|
where sa.BusinessType == EnumBusinessType.YinDuJian && sa.Version == version |
|
|
group sa by new { sa.CustomerPartCodeNoSpace } into groupItem |
|
|
group sa by new { sa.CustomerPartCodeNoSpace } into groupItem |
|
|
select new |
|
|
select new |
|
|
{ |
|
|
{ |
|
|
groupItem.Key.CustomerPartCodeNoSpace, |
|
|
groupItem.Key.CustomerPartCodeNoSpace, |
|
|
Qty = groupItem.Sum(t => t.Qty), |
|
|
Qty = groupItem.Sum(t => t.Qty), |
|
|
|
|
|
Version = groupItem.Max(t => t.Version), |
|
|
LU = groupItem.Max(t => t.LU), |
|
|
LU = groupItem.Max(t => t.LU), |
|
|
SettleDate = groupItem.Max(t => t.SettleDate), |
|
|
SettleDate = groupItem.Max(t => t.SettleDate), |
|
|
PartCode = groupItem.Max(t => t.PartCode), |
|
|
PartCode = groupItem.Max(t => t.PartCode) |
|
|
}; |
|
|
}; |
|
|
|
|
|
//发运
|
|
|
var seGroup = from se in _settleAccountDbContext.Set<PUB_SE_DETAIL>() |
|
|
var seGroup = from se in _settleAccountDbContext.Set<PUB_SE_DETAIL>() |
|
|
where se.BusinessType == EnumBusinessType.YinDuJian && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime |
|
|
|
|
|
group se by new { se.CustomerPartCodeNoSpace } into groupItem |
|
|
group se by new { se.CustomerPartCodeNoSpace } into groupItem |
|
|
select new |
|
|
select new |
|
|
{ |
|
|
{ |
|
@ -412,33 +321,48 @@ namespace SettleAccount.Job.Services.Report |
|
|
ToErpLocCode = groupItem.Max(t => t.ToErpLocCode) |
|
|
ToErpLocCode = groupItem.Max(t => t.ToErpLocCode) |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
var saSeCompareLeft = from sa in saGroup |
|
|
//有结算无发运
|
|
|
|
|
|
var haveSaNotHaveSeList = (from sa in saGroup |
|
|
join se in seGroup |
|
|
join se in seGroup |
|
|
on sa.CustomerPartCodeNoSpace equals se.CustomerPartCodeNoSpace |
|
|
on sa.CustomerPartCodeNoSpace equals se.CustomerPartCodeNoSpace |
|
|
into temp |
|
|
into temp |
|
|
from se in temp.DefaultIfEmpty() |
|
|
from se in temp.DefaultIfEmpty() |
|
|
|
|
|
where se.CustomerPartCodeNoSpace == null |
|
|
select new SaSeCompareDiff() |
|
|
select new SaSeCompareDiff() |
|
|
{ |
|
|
{ |
|
|
WmsBillNum = se.WmsBillNum, |
|
|
Version = sa.Version, |
|
|
ShippingDate = se.ShippingDate, |
|
|
|
|
|
CustomerOfflineTime = sa.SettleDate, |
|
|
CustomerOfflineTime = sa.SettleDate, |
|
|
SAQty = sa.Qty, |
|
|
SAQty = sa.Qty, |
|
|
SEQty = se.Qty, |
|
|
|
|
|
ToLocCode = se.ToLocCode, |
|
|
|
|
|
ToErpLocCode = se.ToErpLocCode, |
|
|
|
|
|
SeCustomerPartCode = se.CustomerPartCodeNoSpace, |
|
|
|
|
|
SeFactoryPartCode = se.FactoryPartCode, |
|
|
|
|
|
SaCustomerPartCode = sa.CustomerPartCodeNoSpace, |
|
|
SaCustomerPartCode = sa.CustomerPartCodeNoSpace, |
|
|
SaFactoryPartCode = sa.PartCode, |
|
|
SaFactoryPartCode = sa.PartCode, |
|
|
CustomerPartCode = sa.LU |
|
|
CustomerPartCode = sa.LU |
|
|
}; |
|
|
}).ToList(); |
|
|
var saSeCompareRight = from se in seGroup |
|
|
//无结算有发运
|
|
|
|
|
|
var notHaveSaHaveSeList = (from se in seGroup |
|
|
join sa in saGroup |
|
|
join sa in saGroup |
|
|
on se.CustomerPartCodeNoSpace equals sa.CustomerPartCodeNoSpace |
|
|
on se.CustomerPartCodeNoSpace equals sa.CustomerPartCodeNoSpace |
|
|
into temp |
|
|
into temp |
|
|
from sa in temp.DefaultIfEmpty() |
|
|
from sa in temp.DefaultIfEmpty() |
|
|
|
|
|
where sa.CustomerPartCodeNoSpace == null |
|
|
|
|
|
select new SaSeCompareDiff() |
|
|
|
|
|
{ |
|
|
|
|
|
WmsBillNum = se.WmsBillNum, |
|
|
|
|
|
ShippingDate = se.ShippingDate, |
|
|
|
|
|
SEQty = se.Qty, |
|
|
|
|
|
ToLocCode = se.ToLocCode, |
|
|
|
|
|
ToErpLocCode = se.ToErpLocCode, |
|
|
|
|
|
SeCustomerPartCode = se.CustomerPartCodeNoSpace, |
|
|
|
|
|
SeFactoryPartCode = se.FactoryPartCode, |
|
|
|
|
|
CustomerPartCode = se.LU |
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
//有结算有发运
|
|
|
|
|
|
var haveSaHaveSeList = (from sa in saGroupByVersion |
|
|
|
|
|
from se in seGroup |
|
|
|
|
|
where sa.CustomerPartCodeNoSpace == se.CustomerPartCodeNoSpace |
|
|
select new SaSeCompareDiff() |
|
|
select new SaSeCompareDiff() |
|
|
{ |
|
|
{ |
|
|
|
|
|
Version = sa.Version, |
|
|
WmsBillNum = se.WmsBillNum, |
|
|
WmsBillNum = se.WmsBillNum, |
|
|
ShippingDate = se.ShippingDate, |
|
|
ShippingDate = se.ShippingDate, |
|
|
CustomerOfflineTime = sa.SettleDate, |
|
|
CustomerOfflineTime = sa.SettleDate, |
|
@ -450,10 +374,9 @@ namespace SettleAccount.Job.Services.Report |
|
|
SeFactoryPartCode = se.FactoryPartCode, |
|
|
SeFactoryPartCode = se.FactoryPartCode, |
|
|
SaCustomerPartCode = sa.CustomerPartCodeNoSpace, |
|
|
SaCustomerPartCode = sa.CustomerPartCodeNoSpace, |
|
|
SaFactoryPartCode = sa.PartCode, |
|
|
SaFactoryPartCode = sa.PartCode, |
|
|
CustomerPartCode = sa.LU ?? se.LU |
|
|
CustomerPartCode = sa.LU |
|
|
}; |
|
|
}).ToList(); |
|
|
var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList(); |
|
|
return haveSaHaveSeList.Union(haveSaNotHaveSeList).Union(notHaveSaHaveSeList).ToList(); |
|
|
return saSeCompareFullJoin; |
|
|
|
|
|
} |
|
|
} |
|
|
#endregion
|
|
|
#endregion
|
|
|
} |
|
|
} |
|
|