|
|
@ -11,6 +11,10 @@ using SettleAccount.Domain.BQ; |
|
|
|
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; |
|
|
|
using Shouldly; |
|
|
|
using Volo.Abp.BlobStoring; |
|
|
|
using Win.Sfs.SettleAccount.Reports; |
|
|
|
using Newtonsoft.Json.Schema; |
|
|
|
using Win.Sfs.SettleAccount; |
|
|
|
using Win.Sfs.SettleAccount.Entities.Prices; |
|
|
|
|
|
|
|
namespace SettleAccount.Job.Services.Report |
|
|
|
{ |
|
|
@ -29,6 +33,11 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
/// </summary>
|
|
|
|
private readonly INormalEfCoreRepository<PUB_SE_DETAIL, Guid> _pubSeDetailRepository; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 替换件关系仓储
|
|
|
|
/// </summary>
|
|
|
|
private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _tbRePartsRelationshipRepository; |
|
|
|
|
|
|
|
private readonly PubSaSeCompareDapperRepository _pubSaSeCompareDapperRepository; |
|
|
|
|
|
|
|
private readonly IBlobContainer<MyFileContainer> _fileContainer; |
|
|
@ -38,11 +47,13 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
/// </summary>
|
|
|
|
public PubSaSeCompareExportService(INormalEfCoreRepository<PUB_SA_DETAIL, Guid> pubSaDetailRepository, |
|
|
|
INormalEfCoreRepository<PUB_SE_DETAIL, Guid> pubSeDetailRepository, |
|
|
|
INormalEfCoreRepository<TB_RePartsRelationship, Guid> tbRePartsRelationshipRepository, |
|
|
|
PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository, |
|
|
|
IBlobContainer<MyFileContainer> fileContainer) |
|
|
|
{ |
|
|
|
_pubSaDetailRepository = pubSaDetailRepository; |
|
|
|
_pubSeDetailRepository = pubSeDetailRepository; |
|
|
|
_tbRePartsRelationshipRepository = tbRePartsRelationshipRepository; |
|
|
|
_pubSaSeCompareDapperRepository = pubSaSeCompareDapperRepository; |
|
|
|
_fileContainer = fileContainer; |
|
|
|
} |
|
|
@ -55,21 +66,71 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
var version = property.Where(p => p.Name == "Version").FirstOrDefault().Value; |
|
|
|
var businessType = property.Where(t => t.Name == "BusinessType").FirstOrDefault().Value; |
|
|
|
var filename = exportName.FirstOrDefault(); |
|
|
|
var pubSaSeCompareDiffs = _pubSaSeCompareDapperRepository.GetDetailDiffReportList(version, businessType); |
|
|
|
var pubSaSeCompareDiffs = _pubSaSeCompareDapperRepository.GetDetailDiffReportList(businessType); |
|
|
|
|
|
|
|
//有结算有发运
|
|
|
|
var haveSaHaveSe = new List<PubSaSeCompareDiff>(); |
|
|
|
//有结算无发运
|
|
|
|
var haveSaNotHaveSe = new List<PubSaSeCompareDiff>(); |
|
|
|
//无结算有发运
|
|
|
|
var notHaveSaHaveSe = new List<PubSaSeCompareDiff>(); |
|
|
|
|
|
|
|
haveSaHaveSe = pubSaSeCompareDiffs.FindAll(t => !string.IsNullOrEmpty(t.SaLU) && !string.IsNullOrEmpty(t.SeLU)); |
|
|
|
haveSaNotHaveSe = pubSaSeCompareDiffs.FindAll(t => !string.IsNullOrEmpty(t.SaLU) && string.IsNullOrEmpty(t.SeLU)); |
|
|
|
notHaveSaHaveSe = pubSaSeCompareDiffs.FindAll(t => string.IsNullOrEmpty(t.SaLU) && !string.IsNullOrEmpty(t.SeLU)); |
|
|
|
|
|
|
|
//二次对比(替换零件号)
|
|
|
|
var repLUs = notHaveSaHaveSe.Select(t => t.SeLU).Distinct().ToList(); |
|
|
|
var tbRePartsRelationships = _tbRePartsRelationshipRepository.GetListAsync(t => repLUs.Contains(t.RepLU) && ((int)t.BusinessType).ToString() == businessType).Result; |
|
|
|
|
|
|
|
tbRePartsRelationships.ForEach(tbRePartsRelationship => |
|
|
|
{ |
|
|
|
notHaveSaHaveSe.FindAll(t => t.SeLU == tbRePartsRelationship.RepLU).ForEach(t => |
|
|
|
{ |
|
|
|
t.RepLU = t.SeLU; |
|
|
|
t.SeLU = tbRePartsRelationship.LU; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pubSaSeCompareDiffs.Join() |
|
|
|
|
|
|
|
|
|
|
|
ExcelExporter excelExporter = new ExcelExporter(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var add = from item1 in haveSaNotHaveSe
|
|
|
|
// join item2 in notHaveSaHaveSe
|
|
|
|
// on new { item1.SaLU, item1.SaPN }
|
|
|
|
// equals new { item2.SeLU, item2.SePN }
|
|
|
|
// into temp
|
|
|
|
// from itm3 in temp.DefaultIfEmpty()
|
|
|
|
// where itm3 == null
|
|
|
|
// select item1;
|
|
|
|
|
|
|
|
//var query = BlobProviderSelectorExtensions
|
|
|
|
|
|
|
|
ExcelExporter excelExporter = new ExcelExporter(); |
|
|
|
var result = excelExporter |
|
|
|
.Append(pubSaSeCompareDiffs, "差异明细表") |
|
|
|
.Append(pubSaSeCompareDiffs, "汇总表") |
|
|
|
.SeparateBySheet() |
|
|
|
.Append(pubSaSeCompareDiffs, "数量差异汇总表") |
|
|
|
.Append(haveSaHaveSe, "有结算有发运") |
|
|
|
.SeparateBySheet() |
|
|
|
.Append(pubSaSeCompareDiffs, "按物料价格差异明细表") |
|
|
|
.Append(haveSaNotHaveSe, "有结算无发运") |
|
|
|
.SeparateBySheet() |
|
|
|
.Append(pubSaSeCompareDiffs, "差异汇总验证表") |
|
|
|
.Append(notHaveSaHaveSe, "无结算有发运") |
|
|
|
.ExportAppendDataAsByteArray(); |
|
|
|
result.ShouldNotBeNull(); |
|
|
|
_fileContainer.SaveAsync(filename, result.Result, true); |
|
|
|
//_fileContainer.SaveAsync(filename, result.Result, true);
|
|
|
|
|
|
|
|
return id.ToString(); |
|
|
|
|
|
|
|