|
@ -1,6 +1,7 @@ |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using EFCore.BulkExtensions; |
|
|
using EFCore.BulkExtensions; |
|
|
|
|
|
using Magicodes.ExporterAndImporter.Core.Extension; |
|
|
using Magicodes.ExporterAndImporter.Excel; |
|
|
using Magicodes.ExporterAndImporter.Excel; |
|
|
using Microsoft.AspNetCore.SignalR; |
|
|
using Microsoft.AspNetCore.SignalR; |
|
|
using SettleAccount.Bases; |
|
|
using SettleAccount.Bases; |
|
@ -116,10 +117,26 @@ namespace SettleAccount.Job.Services.Report |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 创建导出文件结构
|
|
|
/// 创建导出文件结构
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public ExcelExporter BindExcelExporter<T>(List<T> pubSaSeCompareDetailExports, string businessTypeDisplayName) where T : SaSeEdiCompareDetailExport, ISaSeEdiCompareDetailExport, new() |
|
|
public ExcelExporter BindExcelExporter<T>(List<T> saSeEdiCompareDetailExports, string businessTypeDisplayName) where T : SaSeEdiCompareDetailExport, ISaSeEdiCompareDetailExport, new() |
|
|
{ |
|
|
{ |
|
|
|
|
|
//详情Sheet行数
|
|
|
|
|
|
var detailMaxRowNumberOnASheet = 500_000; |
|
|
|
|
|
var detailExportExporterAttribute = typeof(T).GetAttribute<ExcelExporterAttribute>(); |
|
|
|
|
|
if (detailExportExporterAttribute != null) |
|
|
|
|
|
{ |
|
|
|
|
|
detailMaxRowNumberOnASheet = detailExportExporterAttribute.MaxRowNumberOnASheet > 0 ? detailExportExporterAttribute.MaxRowNumberOnASheet : detailMaxRowNumberOnASheet; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//汇总Sheet行数
|
|
|
|
|
|
var sumMaxRowNumberOnASheet = 500_000; |
|
|
|
|
|
var sumExportExporterAttribute = typeof(SaSeEdiCompareSumExport).GetAttribute<ExcelExporterAttribute>(); |
|
|
|
|
|
if (sumExportExporterAttribute != null) |
|
|
|
|
|
{ |
|
|
|
|
|
sumMaxRowNumberOnASheet = sumExportExporterAttribute.MaxRowNumberOnASheet > 0 ? sumExportExporterAttribute.MaxRowNumberOnASheet : sumMaxRowNumberOnASheet; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//汇总
|
|
|
//汇总
|
|
|
var pubSaSeCompareSumExports = pubSaSeCompareDetailExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new SaSeEdiCompareSumExport() |
|
|
var saSeEdiCompareSumExports = saSeEdiCompareDetailExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new SaSeEdiCompareSumExport() |
|
|
{ |
|
|
{ |
|
|
FactoryPartCode = p.Key, |
|
|
FactoryPartCode = p.Key, |
|
|
PartCodeDesc = p.FirstOrDefault().PartCodeDesc, |
|
|
PartCodeDesc = p.FirstOrDefault().PartCodeDesc, |
|
@ -129,7 +146,7 @@ namespace SettleAccount.Job.Services.Report |
|
|
}).ToList(); |
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
//有结算有发运
|
|
|
//有结算有发运
|
|
|
var haveSaHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => new EnumSaSeEdiCompareCategory[] { EnumSaSeEdiCompareCategory.HaveSaHaveSeHaveEdi, EnumSaSeEdiCompareCategory.HaveSaHaveSeNotHaveEdi }.Contains(t.Category)); |
|
|
var haveSaHaveSeExports = saSeEdiCompareDetailExports.FindAll(t => new EnumSaSeEdiCompareCategory[] { EnumSaSeEdiCompareCategory.HaveSaHaveSeHaveEdi, EnumSaSeEdiCompareCategory.HaveSaHaveSeNotHaveEdi }.Contains(t.Category)); |
|
|
//有结算有发运汇总
|
|
|
//有结算有发运汇总
|
|
|
var haveSaHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new SaSeEdiCompareSumExport() |
|
|
var haveSaHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new SaSeEdiCompareSumExport() |
|
|
{ |
|
|
{ |
|
@ -140,7 +157,7 @@ namespace SettleAccount.Job.Services.Report |
|
|
EdiQty = p.Sum(t => t.EdiQty) |
|
|
EdiQty = p.Sum(t => t.EdiQty) |
|
|
}).ToList(); |
|
|
}).ToList(); |
|
|
//有结算无发运
|
|
|
//有结算无发运
|
|
|
var haveSaNotHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => new EnumSaSeEdiCompareCategory[] { EnumSaSeEdiCompareCategory.HaveSaNotHaveSeHaveEdi, EnumSaSeEdiCompareCategory.HaveSaNotHaveSeNotHaveEdi }.Contains(t.Category)); |
|
|
var haveSaNotHaveSeExports = saSeEdiCompareDetailExports.FindAll(t => new EnumSaSeEdiCompareCategory[] { EnumSaSeEdiCompareCategory.HaveSaNotHaveSeHaveEdi, EnumSaSeEdiCompareCategory.HaveSaNotHaveSeNotHaveEdi }.Contains(t.Category)); |
|
|
//有结算无发运
|
|
|
//有结算无发运
|
|
|
var haveSaNotHaveSeSumExports = haveSaNotHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new SaSeEdiCompareSumExport() |
|
|
var haveSaNotHaveSeSumExports = haveSaNotHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new SaSeEdiCompareSumExport() |
|
|
{ |
|
|
{ |
|
@ -151,7 +168,7 @@ namespace SettleAccount.Job.Services.Report |
|
|
EdiQty = p.Sum(t => t.EdiQty) |
|
|
EdiQty = p.Sum(t => t.EdiQty) |
|
|
}).ToList(); |
|
|
}).ToList(); |
|
|
//无结算有发运
|
|
|
//无结算有发运
|
|
|
var notHaveSaHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => new EnumSaSeEdiCompareCategory[] { EnumSaSeEdiCompareCategory.NotHaveSaHaveSeHaveEdi, EnumSaSeEdiCompareCategory.NotHaveSaHaveSeNotHaveEdi }.Contains(t.Category)); |
|
|
var notHaveSaHaveSeExports = saSeEdiCompareDetailExports.FindAll(t => new EnumSaSeEdiCompareCategory[] { EnumSaSeEdiCompareCategory.NotHaveSaHaveSeHaveEdi, EnumSaSeEdiCompareCategory.NotHaveSaHaveSeNotHaveEdi }.Contains(t.Category)); |
|
|
//无结算有发运
|
|
|
//无结算有发运
|
|
|
var notHaveSaHaveSeSumExports = notHaveSaHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new SaSeEdiCompareSumExport() |
|
|
var notHaveSaHaveSeSumExports = notHaveSaHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new SaSeEdiCompareSumExport() |
|
|
{ |
|
|
{ |
|
@ -163,20 +180,59 @@ namespace SettleAccount.Job.Services.Report |
|
|
}).ToList(); |
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
ExcelExporter excelExporter = new ExcelExporter(); |
|
|
ExcelExporter excelExporter = new ExcelExporter(); |
|
|
return excelExporter |
|
|
//结算核对明细输出
|
|
|
.Append(pubSaSeCompareDetailExports, $"{businessTypeDisplayName}结算核对明细输出") |
|
|
excelExporter.Append(saSeEdiCompareDetailExports.Take(detailMaxRowNumberOnASheet).ToList(), $"{businessTypeDisplayName}结算核对明细输出"); |
|
|
.SeparateBySheet() |
|
|
for (var i = 1; i < saSeEdiCompareDetailExports.Count / detailMaxRowNumberOnASheet + ((saSeEdiCompareDetailExports.Count % detailMaxRowNumberOnASheet) > 0 ? 1 : 0); i++) |
|
|
.Append(pubSaSeCompareSumExports, $"{businessTypeDisplayName}结算核对汇总输出") |
|
|
{ |
|
|
.SeparateBySheet() |
|
|
var sheetDataItems = saSeEdiCompareDetailExports.Skip(i * detailMaxRowNumberOnASheet) |
|
|
|
|
|
.Take(detailMaxRowNumberOnASheet).ToList(); |
|
|
|
|
|
excelExporter.SeparateBySheet(); |
|
|
|
|
|
excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}结算核对明细输出-{i}"); |
|
|
|
|
|
} |
|
|
|
|
|
//结算核对汇总输出
|
|
|
|
|
|
excelExporter.Append(saSeEdiCompareSumExports.Take(sumMaxRowNumberOnASheet).ToList(), $"{businessTypeDisplayName}结算核对汇总输出"); |
|
|
|
|
|
for (var i = 1; i < saSeEdiCompareSumExports.Count / sumMaxRowNumberOnASheet + ((saSeEdiCompareSumExports.Count % sumMaxRowNumberOnASheet) > 0 ? 1 : 0); i++) |
|
|
|
|
|
{ |
|
|
|
|
|
var sheetDataItems = saSeEdiCompareSumExports.Skip(i * sumMaxRowNumberOnASheet).Take(sumMaxRowNumberOnASheet).ToList(); |
|
|
|
|
|
excelExporter.SeparateBySheet(); |
|
|
|
|
|
excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}结算核对汇总输出-{i}"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
.Append(haveSaHaveSeExports, $"{businessTypeDisplayName}有结算有发货明细输出") |
|
|
//有结算有发货明细输出
|
|
|
.SeparateBySheet() |
|
|
excelExporter.Append(haveSaHaveSeExports.Take(detailMaxRowNumberOnASheet).ToList(), $"{businessTypeDisplayName}有结算有发货明细输出"); |
|
|
.Append(haveSaHaveSeSumExports, $"{businessTypeDisplayName}有结算有发货汇总输出") |
|
|
for (var i = 1; i < haveSaHaveSeExports.Count / detailMaxRowNumberOnASheet + ((haveSaHaveSeExports.Count % detailMaxRowNumberOnASheet) > 0 ? 1 : 0); i++) |
|
|
.SeparateBySheet() |
|
|
{ |
|
|
|
|
|
var sheetDataItems = haveSaHaveSeExports.Skip(i * detailMaxRowNumberOnASheet).Take(detailMaxRowNumberOnASheet).ToList(); |
|
|
|
|
|
excelExporter.SeparateBySheet(); |
|
|
|
|
|
excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}有结算有发货明细输出-{i}"); |
|
|
|
|
|
} |
|
|
|
|
|
//有结算有发货汇总输出
|
|
|
|
|
|
excelExporter.Append(haveSaHaveSeSumExports.Take(sumMaxRowNumberOnASheet).ToList(), $"{businessTypeDisplayName}有结算有发货汇总输出"); |
|
|
|
|
|
for (var i = 1; i < haveSaHaveSeSumExports.Count / sumMaxRowNumberOnASheet + ((haveSaHaveSeSumExports.Count % sumMaxRowNumberOnASheet) > 0 ? 1 : 0); i++) |
|
|
|
|
|
{ |
|
|
|
|
|
var sheetDataItems = haveSaHaveSeSumExports.Skip(i * sumMaxRowNumberOnASheet).Take(sumMaxRowNumberOnASheet).ToList(); |
|
|
|
|
|
excelExporter.SeparateBySheet(); |
|
|
|
|
|
excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}有结算有发货汇总输出-{i}"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//有结算有发货明细输出
|
|
|
|
|
|
excelExporter.Append(haveSaNotHaveSeExports.Take(detailMaxRowNumberOnASheet).ToList(), $"{businessTypeDisplayName}有结算无发货明细输出"); |
|
|
|
|
|
for (var i = 1; i < haveSaNotHaveSeExports.Count / detailMaxRowNumberOnASheet + ((haveSaNotHaveSeExports.Count % detailMaxRowNumberOnASheet) > 0 ? 1 : 0); i++) |
|
|
|
|
|
{ |
|
|
|
|
|
var sheetDataItems = haveSaNotHaveSeExports.Skip(i * detailMaxRowNumberOnASheet).Take(detailMaxRowNumberOnASheet).ToList(); |
|
|
|
|
|
excelExporter.SeparateBySheet(); |
|
|
|
|
|
excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}有结算无发货明细输出-{i}"); |
|
|
|
|
|
} |
|
|
|
|
|
//有结算有发货汇总输出
|
|
|
|
|
|
excelExporter.Append(haveSaNotHaveSeSumExports.Take(sumMaxRowNumberOnASheet).ToList(), $"{businessTypeDisplayName}有结算无发货汇总输出"); |
|
|
|
|
|
for (var i = 1; i < haveSaNotHaveSeSumExports.Count / sumMaxRowNumberOnASheet + ((haveSaNotHaveSeSumExports.Count % sumMaxRowNumberOnASheet) > 0 ? 1 : 0); i++) |
|
|
|
|
|
{ |
|
|
|
|
|
var sheetDataItems = haveSaNotHaveSeSumExports.Skip(i * sumMaxRowNumberOnASheet).Take(sumMaxRowNumberOnASheet).ToList(); |
|
|
|
|
|
excelExporter.SeparateBySheet(); |
|
|
|
|
|
excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}有结算无发货汇总输出-{i}"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
.Append(haveSaNotHaveSeExports, $"{businessTypeDisplayName}有结算无发货明细输出") |
|
|
return excelExporter; |
|
|
.SeparateBySheet() |
|
|
|
|
|
.Append(haveSaNotHaveSeSumExports, $"{businessTypeDisplayName}有结算无发货汇总输出"); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|