|
@ -1,20 +1,24 @@ |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using Magicodes.ExporterAndImporter.Excel; |
|
|
using System.ComponentModel.DataAnnotations; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
|
|
|
using Magicodes.ExporterAndImporter.Excel; |
|
|
|
|
|
using Microsoft.OpenApi.Extensions; |
|
|
|
|
|
using NetTopologySuite.Operation.Buffer; |
|
|
|
|
|
using SettleAccount.Domain.BQ; |
|
|
|
|
|
using Shouldly; |
|
|
using TaskJob.EventArgs; |
|
|
using TaskJob.EventArgs; |
|
|
using TaskJob.Interfaces; |
|
|
using TaskJob.Interfaces; |
|
|
|
|
|
using Volo.Abp.BlobStoring; |
|
|
using Volo.Abp.DependencyInjection; |
|
|
using Volo.Abp.DependencyInjection; |
|
|
|
|
|
using Volo.Abp.ObjectMapping; |
|
|
using Win.Sfs.BaseData.ImportExcelCommon; |
|
|
using Win.Sfs.BaseData.ImportExcelCommon; |
|
|
using Win.Sfs.Shared.RepositoryBase; |
|
|
|
|
|
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; |
|
|
using Win.Sfs.SettleAccount.Entities.Prices; |
|
|
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; |
|
|
|
|
|
using Win.Sfs.SettleAccount.Enums; |
|
|
|
|
|
using Win.Sfs.SettleAccount.Reports; |
|
|
|
|
|
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; |
|
|
|
|
|
using Win.Sfs.Shared.RepositoryBase; |
|
|
|
|
|
|
|
|
namespace SettleAccount.Job.Services.Report |
|
|
namespace SettleAccount.Job.Services.Report |
|
|
{ |
|
|
{ |
|
@ -42,6 +46,8 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
|
|
|
|
|
private readonly IBlobContainer<MyFileContainer> _fileContainer; |
|
|
private readonly IBlobContainer<MyFileContainer> _fileContainer; |
|
|
|
|
|
|
|
|
|
|
|
private readonly IObjectMapper _objectMapper; |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 构造
|
|
|
/// 构造
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
@ -49,25 +55,54 @@ namespace SettleAccount.Job.Services.Report |
|
|
INormalEfCoreRepository<PUB_SE_DETAIL, Guid> pubSeDetailRepository, |
|
|
INormalEfCoreRepository<PUB_SE_DETAIL, Guid> pubSeDetailRepository, |
|
|
INormalEfCoreRepository<TB_RePartsRelationship, Guid> tbRePartsRelationshipRepository, |
|
|
INormalEfCoreRepository<TB_RePartsRelationship, Guid> tbRePartsRelationshipRepository, |
|
|
PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository, |
|
|
PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository, |
|
|
IBlobContainer<MyFileContainer> fileContainer) |
|
|
IBlobContainer<MyFileContainer> fileContainer, |
|
|
|
|
|
IObjectMapper objectMapper) |
|
|
{ |
|
|
{ |
|
|
_pubSaDetailRepository = pubSaDetailRepository; |
|
|
_pubSaDetailRepository = pubSaDetailRepository; |
|
|
_pubSeDetailRepository = pubSeDetailRepository; |
|
|
_pubSeDetailRepository = pubSeDetailRepository; |
|
|
_tbRePartsRelationshipRepository = tbRePartsRelationshipRepository; |
|
|
_tbRePartsRelationshipRepository = tbRePartsRelationshipRepository; |
|
|
_pubSaSeCompareDapperRepository = pubSaSeCompareDapperRepository; |
|
|
_pubSaSeCompareDapperRepository = pubSaSeCompareDapperRepository; |
|
|
_fileContainer = fileContainer; |
|
|
_fileContainer = fileContainer; |
|
|
|
|
|
_objectMapper = objectMapper; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 导出
|
|
|
/// 导出
|
|
|
|
|
|
/// 输出报表
|
|
|
|
|
|
/// 结算核对明细输出
|
|
|
|
|
|
/// 结算核对汇总输出
|
|
|
|
|
|
/// 有结算有发货明细输出
|
|
|
|
|
|
/// 有结算有发货汇总输出
|
|
|
|
|
|
/// 有结算无发货明细输出
|
|
|
|
|
|
/// 有结算无发货汇总输出
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property) |
|
|
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property) |
|
|
{ |
|
|
{ |
|
|
var version = property.Where(p => p.Name == "Version").FirstOrDefault().Value; |
|
|
var version = property.Where(p => p.Name == "Version").FirstOrDefault().Value; |
|
|
var businessType = property.Where(t => t.Name == "BusinessType").FirstOrDefault().Value; |
|
|
var businessType = property.Where(t => t.Name == "BusinessType").FirstOrDefault().Value; |
|
|
|
|
|
var lu = property.Where(p => p.Name == "LU").FirstOrDefault().Value; |
|
|
|
|
|
var pn = property.Where(p => p.Name == "PN").FirstOrDefault().Value; |
|
|
|
|
|
|
|
|
|
|
|
var businessTypeDisplayName = businessType.ToString(); |
|
|
|
|
|
DisplayAttribute attributeOfType = ((EnumBusinessType)Enum.Parse(typeof(EnumBusinessType), businessType)).GetAttributeOfType<DisplayAttribute>(); |
|
|
|
|
|
if (attributeOfType != null) |
|
|
|
|
|
{ |
|
|
|
|
|
businessTypeDisplayName = attributeOfType.Name; |
|
|
|
|
|
} |
|
|
var filename = exportName.FirstOrDefault(); |
|
|
var filename = exportName.FirstOrDefault(); |
|
|
var pubSaSeCompareDiffs = _pubSaSeCompareDapperRepository.GetDetailDiffReportList(businessType); |
|
|
var pubSaSeCompareDiffs = _pubSaSeCompareDapperRepository.GetDetailDiffReportList(businessType); |
|
|
|
|
|
|
|
|
|
|
|
pubSaSeCompareDiffs.ForEach(p => |
|
|
|
|
|
{ |
|
|
|
|
|
p.Category = (string.IsNullOrEmpty(p.SaLU), string.IsNullOrEmpty(p.SeLU)) switch |
|
|
|
|
|
{ |
|
|
|
|
|
(false, false) => EnumPubSaSeCompareCategory.HaveSaHaveSe, |
|
|
|
|
|
(false, true) => EnumPubSaSeCompareCategory.HaveSaNotHaveSe, |
|
|
|
|
|
(true, false) => EnumPubSaSeCompareCategory.NotHaveSaHaveSe, |
|
|
|
|
|
_ => EnumPubSaSeCompareCategory.None, |
|
|
|
|
|
}; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
//有结算有发运
|
|
|
//有结算有发运
|
|
|
var haveSaHaveSe = new List<PubSaSeCompareDiff>(); |
|
|
var haveSaHaveSe = new List<PubSaSeCompareDiff>(); |
|
|
//有结算无发运
|
|
|
//有结算无发运
|
|
@ -79,9 +114,10 @@ namespace SettleAccount.Job.Services.Report |
|
|
haveSaNotHaveSe = 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)); |
|
|
notHaveSaHaveSe = pubSaSeCompareDiffs.FindAll(t => string.IsNullOrEmpty(t.SaLU) && !string.IsNullOrEmpty(t.SeLU)); |
|
|
|
|
|
|
|
|
|
|
|
#region 二次对比
|
|
|
//二次对比(替换零件号)
|
|
|
//二次对比(替换零件号)
|
|
|
var repLUs = notHaveSaHaveSe.Select(t => t.SeLU).Distinct().ToList(); |
|
|
var repLUs = notHaveSaHaveSe.Select(t => t.SeLU).Distinct().ToList(); |
|
|
var tbRePartsRelationships = _tbRePartsRelationshipRepository.GetListAsync(t => repLUs.Contains(t.RepLU) && ((int)t.BusinessType).ToString() == businessType).Result; |
|
|
var tbRePartsRelationships = _tbRePartsRelationshipRepository.GetListAsync(t => repLUs.Contains(t.RepLU) && ((int)t.BusinessType).ToString() == businessType).Result; |
|
|
|
|
|
|
|
|
tbRePartsRelationships.ForEach(tbRePartsRelationship => |
|
|
tbRePartsRelationships.ForEach(tbRePartsRelationship => |
|
|
{ |
|
|
{ |
|
@ -91,9 +127,48 @@ namespace SettleAccount.Job.Services.Report |
|
|
t.SeLU = tbRePartsRelationship.LU; |
|
|
t.SeLU = tbRePartsRelationship.LU; |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(lu) == false) |
|
|
|
|
|
{ |
|
|
|
|
|
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.SaLU == lu || p.SeLU == lu); |
|
|
|
|
|
} |
|
|
|
|
|
if (string.IsNullOrEmpty(pn) == false) |
|
|
|
|
|
{ |
|
|
|
|
|
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.SaPN == pn || p.SePN == pn); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var pubSaSeCompareDiffExports = _objectMapper.Map<List<PubSaSeCompareDiff>, List<PubSaSeCompareDetailExport>>(pubSaSeCompareDiffs); |
|
|
|
|
|
|
|
|
|
|
|
//有结算有发运
|
|
|
|
|
|
var haveSaHaveSeExports = pubSaSeCompareDiffExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe); |
|
|
|
|
|
////有结算有发运汇总
|
|
|
|
|
|
//var haveSaHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport()
|
|
|
|
|
|
//{
|
|
|
|
|
|
// LU= p.Key,
|
|
|
|
|
|
// MaterialDes = p.FirstOrDefault().MaterialDes,
|
|
|
|
|
|
// SAQty =
|
|
|
|
|
|
//});
|
|
|
|
|
|
//有结算无发运
|
|
|
|
|
|
var haveSaNotHaveSeExports = pubSaSeCompareDiffExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe); |
|
|
|
|
|
//无结算有发运
|
|
|
|
|
|
var notHaveSaHaveSeExports = pubSaSeCompareDiffExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region MyRegion
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var add = from item1 in pubSaSeCompareDiffs
|
|
|
|
|
|
// join item2 in pubSaSeCompareDiffs
|
|
|
|
|
|
// on new { item1.SaLU, item1.SaPN }
|
|
|
|
|
|
// equals new { item2.SeLU, item2.SePN }
|
|
|
|
|
|
// into temp
|
|
|
|
|
|
// from itm3 in temp.DefaultIfEmpty()
|
|
|
|
|
|
// where itm3 == null
|
|
|
|
|
|
// select item1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -115,18 +190,19 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
|
|
|
|
|
//var query = BlobProviderSelectorExtensions
|
|
|
//var query = BlobProviderSelectorExtensions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ExcelExporter excelExporter = new ExcelExporter(); |
|
|
ExcelExporter excelExporter = new ExcelExporter(); |
|
|
var result = excelExporter |
|
|
var result = excelExporter |
|
|
.Append(pubSaSeCompareDiffs, "汇总表") |
|
|
.Append(pubSaSeCompareDiffExports, $"{businessTypeDisplayName}汇总表") |
|
|
.SeparateBySheet() |
|
|
.SeparateBySheet() |
|
|
.Append(haveSaHaveSe, "有结算有发运") |
|
|
.Append(haveSaHaveSeExports, $"{businessTypeDisplayName}有结算有发运") |
|
|
.SeparateBySheet() |
|
|
.SeparateBySheet() |
|
|
.Append(haveSaNotHaveSe, "有结算无发运") |
|
|
.Append(haveSaNotHaveSeExports, $"{businessTypeDisplayName}有结算无发运") |
|
|
.SeparateBySheet() |
|
|
.SeparateBySheet() |
|
|
.Append(notHaveSaHaveSe, "无结算有发运") |
|
|
.Append(notHaveSaHaveSeExports, $"{businessTypeDisplayName}无结算有发运") |
|
|
.ExportAppendDataAsByteArray(); |
|
|
.ExportAppendDataAsByteArray(); |
|
|
result.ShouldNotBeNull(); |
|
|
result.ShouldNotBeNull(); |
|
|
//_fileContainer.SaveAsync(filename, result.Result, true);
|
|
|
_fileContainer.SaveAsync(filename, result.Result, true); |
|
|
|
|
|
|
|
|
return id.ToString(); |
|
|
return id.ToString(); |
|
|
|
|
|
|
|
|