|
|
@ -1,12 +1,14 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using EFCore.BulkExtensions; |
|
|
|
using Magicodes.ExporterAndImporter.Core.Extension; |
|
|
|
using Magicodes.ExporterAndImporter.Excel; |
|
|
|
using Microsoft.AspNetCore.SignalR; |
|
|
|
using SettleAccount.Bases; |
|
|
|
using SettleAccount.Domain.BQ; |
|
|
|
using SettleAccount.Job.SignalR; |
|
|
|
using Win.Sfs.SettleAccount; |
|
|
|
using Win.Sfs.SettleAccount.Consts; |
|
|
|
using Win.Sfs.SettleAccount.Enums; |
|
|
|
using Win.Sfs.SettleAccount.Reports; |
|
|
|
|
|
|
@ -174,10 +176,26 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
/// <summary>
|
|
|
|
/// 创建导出文件结构
|
|
|
|
/// </summary>
|
|
|
|
public ExcelExporter BindExcelExporter<T>(List<T> pubSaSeCompareDetailExports, string businessTypeDisplayName) where T : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport, new() |
|
|
|
public ExcelExporter BindExcelExporter<T>(List<T> saSeCompareDetailExports, string businessTypeDisplayName) where T : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport, new() |
|
|
|
{ |
|
|
|
//详情Sheet行数
|
|
|
|
var detailMaxRowNumberOnASheet = AppConst.DefaultRowNumberOnASheet; |
|
|
|
var detailExportExporterAttribute = typeof(T).GetAttribute<ExcelExporterAttribute>(inherit: true); |
|
|
|
if (detailExportExporterAttribute != null) |
|
|
|
{ |
|
|
|
detailMaxRowNumberOnASheet = detailExportExporterAttribute.MaxRowNumberOnASheet > 0 ? detailExportExporterAttribute.MaxRowNumberOnASheet : detailMaxRowNumberOnASheet; |
|
|
|
} |
|
|
|
|
|
|
|
//汇总Sheet行数
|
|
|
|
var sumMaxRowNumberOnASheet = AppConst.DefaultRowNumberOnASheet; |
|
|
|
var sumExportExporterAttribute = typeof(PubSaSeCompareSumExport).GetAttribute<ExcelExporterAttribute>(inherit: true); |
|
|
|
if (sumExportExporterAttribute != null) |
|
|
|
{ |
|
|
|
sumMaxRowNumberOnASheet = sumExportExporterAttribute.MaxRowNumberOnASheet > 0 ? sumExportExporterAttribute.MaxRowNumberOnASheet : sumMaxRowNumberOnASheet; |
|
|
|
} |
|
|
|
|
|
|
|
//结算核对汇总
|
|
|
|
var pubSaSeCompareSumExports = pubSaSeCompareDetailExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport() |
|
|
|
var saSeCompareSumExports = saSeCompareDetailExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport() |
|
|
|
{ |
|
|
|
FactoryPartCode = p.Key, |
|
|
|
PartCodeDesc = p.FirstOrDefault().PartCodeDesc, |
|
|
@ -186,7 +204,7 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
//有结算有发运
|
|
|
|
var haveSaHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe); |
|
|
|
var haveSaHaveSeExports = saSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe); |
|
|
|
//有结算有发运汇总
|
|
|
|
var haveSaHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport() |
|
|
|
{ |
|
|
@ -196,7 +214,7 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
SEQty = p.Sum(t => t.SEQty) |
|
|
|
}).ToList(); |
|
|
|
//有结算无发运
|
|
|
|
var haveSaNotHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe); |
|
|
|
var haveSaNotHaveSeExports = saSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe); |
|
|
|
//有结算无发运
|
|
|
|
var haveSaNotHaveSeSumExports = haveSaNotHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport() |
|
|
|
{ |
|
|
@ -206,7 +224,7 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
SEQty = p.Sum(t => t.SEQty) |
|
|
|
}).ToList(); |
|
|
|
//无结算有发运
|
|
|
|
var notHaveSaHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); |
|
|
|
var notHaveSaHaveSeExports = saSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe); |
|
|
|
//无结算有发运
|
|
|
|
var notHaveSaHaveSeSumExports = notHaveSaHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport() |
|
|
|
{ |
|
|
@ -216,21 +234,53 @@ namespace SettleAccount.Job.Services.Report |
|
|
|
SEQty = p.Sum(t => t.SEQty) |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
ExcelExporter excelExporter = new ExcelExporter(); |
|
|
|
return excelExporter |
|
|
|
.Append(pubSaSeCompareDetailExports, $"{businessTypeDisplayName}结算核对明细输出") |
|
|
|
.SeparateBySheet() |
|
|
|
.Append(pubSaSeCompareSumExports, $"{businessTypeDisplayName}结算核对汇总输出") |
|
|
|
.SeparateBySheet() |
|
|
|
|
|
|
|
.Append(haveSaHaveSeExports, $"{businessTypeDisplayName}有结算有发货明细输出") |
|
|
|
.SeparateBySheet() |
|
|
|
.Append(haveSaHaveSeSumExports, $"{businessTypeDisplayName}有结算有发货汇总输出") |
|
|
|
.SeparateBySheet() |
|
|
|
|
|
|
|
.Append(haveSaNotHaveSeExports, $"{businessTypeDisplayName}有结算无发货明细输出") |
|
|
|
.SeparateBySheet() |
|
|
|
.Append(haveSaNotHaveSeSumExports, $"{businessTypeDisplayName}有结算无发货汇总输出"); |
|
|
|
var excelExporter = new ExcelExporter(); |
|
|
|
//结算核对明细输出
|
|
|
|
excelExporter.Append(saSeCompareDetailExports.Take(detailMaxRowNumberOnASheet).ToList(), $"{businessTypeDisplayName}结算核对明细输出"); |
|
|
|
for (var i = 1; i < saSeCompareDetailExports.Count / detailMaxRowNumberOnASheet + ((saSeCompareDetailExports.Count % detailMaxRowNumberOnASheet) > 0 ? 1 : 0); i++) |
|
|
|
{ |
|
|
|
var sheetDataItems = saSeCompareDetailExports.Skip(i * detailMaxRowNumberOnASheet).Take(detailMaxRowNumberOnASheet).ToList(); |
|
|
|
excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}结算核对明细输出-{i}"); |
|
|
|
} |
|
|
|
//结算核对汇总输出
|
|
|
|
excelExporter.Append(saSeCompareSumExports.Take(sumMaxRowNumberOnASheet).ToList(), $"{businessTypeDisplayName}结算核对汇总输出"); |
|
|
|
for (var i = 1; i < saSeCompareSumExports.Count / sumMaxRowNumberOnASheet + ((saSeCompareSumExports.Count % sumMaxRowNumberOnASheet) > 0 ? 1 : 0); i++) |
|
|
|
{ |
|
|
|
var sheetDataItems = saSeCompareSumExports.Skip(i * sumMaxRowNumberOnASheet).Take(sumMaxRowNumberOnASheet).ToList(); ; |
|
|
|
excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}结算核对汇总输出-{i}"); |
|
|
|
} |
|
|
|
|
|
|
|
//有结算有发货明细输出
|
|
|
|
excelExporter.Append(haveSaHaveSeExports.Take(detailMaxRowNumberOnASheet).ToList(), $"{businessTypeDisplayName}有结算有发货明细输出"); |
|
|
|
for (var i = 1; i < haveSaHaveSeExports.Count / detailMaxRowNumberOnASheet + ((haveSaHaveSeExports.Count % detailMaxRowNumberOnASheet) > 0 ? 1 : 0); i++) |
|
|
|
{ |
|
|
|
var sheetDataItems = haveSaHaveSeExports.Skip(i * detailMaxRowNumberOnASheet).Take(detailMaxRowNumberOnASheet).ToList(); |
|
|
|
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.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.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.Append(sheetDataItems, $"{businessTypeDisplayName}有结算无发货汇总输出-{i}"); |
|
|
|
} |
|
|
|
|
|
|
|
return excelExporter; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|