Browse Source

导出多Sheet

master
mahao 1 year ago
parent
commit
c0bc6f3b84
  1. 20
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs
  2. 19
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs
  3. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/YinDuSeSyncAppService.cs
  4. 12
      code/src/Modules/SettleAccount/src/SettleAccount.Domain.Shared/Consts/AppConst.cs
  5. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/JisHBPOEidSeCompareReport.cs
  6. 14
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/SaSeEdiCompareDiff.cs
  7. 30
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSeEdiCompareExportService.cs
  8. 30
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSeEdiCompareExportService.cs
  9. 90
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs
  10. 22
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs

20
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs

@ -37,8 +37,7 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable
var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>(); var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
await HandDelEdiDataAsync().ConfigureAwait(false); await HandDelEdiDataAsync().ConfigureAwait(false);
lock (_lockObj)
{
var seDetailGroup = db.Set<BBAC_SE_DETAIL>().Where(t => t.IsHaveEdiData == false).GroupBy(t => new { t.PN, t.CustomerPartCodeNoSpace }).Select(t => new { t.Key.PN, LU = t.Key.CustomerPartCodeNoSpace }); var seDetailGroup = db.Set<BBAC_SE_DETAIL>().Where(t => t.IsHaveEdiData == false).GroupBy(t => new { t.PN, t.CustomerPartCodeNoSpace }).Select(t => new { t.Key.PN, LU = t.Key.CustomerPartCodeNoSpace });
var ediDetailGroup = db.Set<BBAC_SE_EDI>().Where(t => t.IsDeleted == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU }); var ediDetailGroup = db.Set<BBAC_SE_EDI>().Where(t => t.IsDeleted == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU });
@ -57,17 +56,20 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable
var seDetails = seDetailsQuery.Take(5000).ToList(); var seDetails = seDetailsQuery.Take(5000).ToList();
var ediDetails = ediDetailsQuery.Take(5000).ToList(); var ediDetails = ediDetailsQuery.Take(5000).ToList();
seDetails.ForEach(t => t.IsHaveEdiData = true);
ediDetails.ForEach(t => t.IsHaveSeData = true);
if (seDetails.Any()) using var transaction = await db.Database.BeginTransactionAsync().ConfigureAwait(false);
try
{ {
seDetails.ForEach(t => t.IsHaveEdiData = true); await db.BulkUpdateAsync<BBAC_SE_DETAIL>(seDetails).ConfigureAwait(false);
db.BulkUpdate<BBAC_SE_DETAIL>(seDetails); await db.BulkUpdateAsync<BBAC_SE_EDI>(ediDetails).ConfigureAwait(false);
await transaction.CommitAsync().ConfigureAwait(false);
} }
if (ediDetails.Any()) catch (Exception)
{ {
ediDetails.ForEach(t => t.IsHaveSeData = true); await transaction.RollbackAsync().ConfigureAwait(false);
db.BulkUpdate<BBAC_SE_EDI>(ediDetails); throw;
}
} }
} }
catch (Exception) catch (Exception)

19
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs

@ -9,10 +9,8 @@ using LinqToDB;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Uow;
using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi; using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.EntityFrameworkCore; using Win.Sfs.SettleAccount.EntityFrameworkCore;
using Win.Sfs.SettleAccount.MaterialRelationships; using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
@ -126,12 +124,10 @@ public class JitSeSyncAppService : ApplicationService, IInvocable
t.Version = int.Parse(t.BillTime?.ToString("yyyyMM")); t.Version = int.Parse(t.BillTime?.ToString("yyyyMM"));
} }
}); });
await _settleAccountDbContext.BulkInsertAsync(pubSeDetails).ConfigureAwait(false);
if (syncPositionFlag != null) if (syncPositionFlag != null)
{ {
syncPositionFlag.Position = wmsSeRecords.Last().UID.ToString(); syncPositionFlag.Position = wmsSeRecords.Last().UID.ToString();
await _syncPositionFlagRepository.UpdateAsync(syncPositionFlag).ConfigureAwait(false);
} }
else else
{ {
@ -140,7 +136,19 @@ public class JitSeSyncAppService : ApplicationService, IInvocable
TableName = syncTableName, TableName = syncTableName,
Position = wmsSeRecords.Last().UID.ToString() Position = wmsSeRecords.Last().UID.ToString()
}; };
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag).ConfigureAwait(false); }
using var transaction = await _settleAccountDbContext.Database.BeginTransactionAsync().ConfigureAwait(false);
try
{
_settleAccountDbContext.Set<SyncPositionFlag>().AddOrUpdate(t => t.TableName == syncPositionFlag.TableName, syncPositionFlag);
await _settleAccountDbContext.BulkInsertAsync(pubSeDetails).ConfigureAwait(false);
await transaction.CommitAsync().ConfigureAwait(false);
}
catch (Exception)
{
await transaction.RollbackAsync().ConfigureAwait(false);
throw;
} }
foreach (var pubSeDetail in pubSeDetails) foreach (var pubSeDetail in pubSeDetails)
@ -218,7 +226,6 @@ public class JitSeSyncAppService : ApplicationService, IInvocable
if (noHaveLuRePartCodes.Any()) if (noHaveLuRePartCodes.Any())
{ {
await _settleAccountDbContext.BulkInsertAsync(noHaveLuRePartCodes.ToList()).ConfigureAwait(false); await _settleAccountDbContext.BulkInsertAsync(noHaveLuRePartCodes.ToList()).ConfigureAwait(false);
//await _materialRelationshipRepository.InsertManyAsync(noHaveLuRePartCodes).ConfigureAwait(false);
} }
} }
} }

3
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/YinDuSeSyncAppService.cs

@ -7,7 +7,6 @@ using SettleAccount.Domain.BQ;
using Win.Sfs.SettleAccount.Entities.BQ.Managers; using Win.Sfs.SettleAccount.Entities.BQ.Managers;
using Win.Sfs.SettleAccount.Entities.BQ.Vmi; using Win.Sfs.SettleAccount.Entities.BQ.Vmi;
using Win.Sfs.SettleAccount.EntityFrameworkCore; using Win.Sfs.SettleAccount.EntityFrameworkCore;
using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs; namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
@ -45,6 +44,6 @@ public class YinDuSeSyncAppService : JitSeSyncAppService, IJobService
public async Task Invoke(IServiceProvider serviceProvider) public async Task Invoke(IServiceProvider serviceProvider)
{ {
await this.Invoke(); await this.Invoke().ConfigureAwait(false);
} }
} }

12
code/src/Modules/SettleAccount/src/SettleAccount.Domain.Shared/Consts/AppConst.cs

@ -0,0 +1,12 @@
namespace Win.Sfs.SettleAccount.Consts;
/// <summary>
/// 应用常量
/// </summary>
public static class AppConst
{
/// <summary>
/// 单页Sheet默认行数
/// </summary>
public const int DefaultRowNumberOnASheet = 500_000;
}

2
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/JisHBPOEidSeCompareReport.cs

@ -15,7 +15,7 @@ public class JisHBPOEidSeCompareReport
/// <summary> /// <summary>
/// JisHBPO Edi与发运对比导出 /// JisHBPO Edi与发运对比导出
/// </summary> /// </summary>
[ExcelExporter(MaxRowNumberOnASheet = 900000)] [ExcelExporter(MaxRowNumberOnASheet = 500_000)]
public class JisHBPOEidSeCompareExport public class JisHBPOEidSeCompareExport
{ {
/// <summary> /// <summary>

14
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/SaSeEdiCompareDiff.cs

@ -299,6 +299,11 @@ public class SaSeEdiCompareDetailExportJisBBAC : SaSeEdiCompareDetailExport, ISa
/// <summary> /// <summary>
/// 结算与EDI量差 /// 结算与EDI量差
/// </summary> /// </summary>
[ExporterHeader(DisplayName = "结算与WMS发货量差")]
public decimal SaSeQty => SAQty - SEQty;
/// <summary>
/// 结算与EDI量差
/// </summary>
[ExporterHeader(DisplayName = "结算与EDI量差")] [ExporterHeader(DisplayName = "结算与EDI量差")]
public decimal SaEdiQty => SAQty - EdiQty; public decimal SaEdiQty => SAQty - EdiQty;
/// <summary> /// <summary>
@ -310,7 +315,7 @@ public class SaSeEdiCompareDetailExportJisBBAC : SaSeEdiCompareDetailExport, ISa
[ExporterHeader(DisplayName = "是否完全匹配")] [ExporterHeader(DisplayName = "是否完全匹配")]
[ValueMapping("是", true)] [ValueMapping("是", true)]
[ValueMapping("否", false)] [ValueMapping("否", false)]
public bool MateType => SaEdiQty == 0 && SeEdiQty == 0; public bool MateType => SaSeQty == 0 && SaEdiQty == 0 && SeEdiQty == 0;
/// <summary> /// <summary>
/// 定价 /// 定价
/// </summary> /// </summary>
@ -441,6 +446,11 @@ public class SaSeEdiCompareDetailExportJisHBPO : SaSeEdiCompareDetailExport, ISa
/// <summary> /// <summary>
/// 结算与EDI量差 /// 结算与EDI量差
/// </summary> /// </summary>
[ExporterHeader(DisplayName = "结算与WMS发货量差")]
public decimal SaSeQty => SAQty - SEQty;
/// <summary>
/// 结算与EDI量差
/// </summary>
[ExporterHeader(DisplayName = "结算与EDI量差")] [ExporterHeader(DisplayName = "结算与EDI量差")]
public decimal SaEdiQty => SAQty - EdiQty; public decimal SaEdiQty => SAQty - EdiQty;
/// <summary> /// <summary>
@ -452,7 +462,7 @@ public class SaSeEdiCompareDetailExportJisHBPO : SaSeEdiCompareDetailExport, ISa
[ExporterHeader(DisplayName = "是否完全匹配")] [ExporterHeader(DisplayName = "是否完全匹配")]
[ValueMapping("是", true)] [ValueMapping("是", true)]
[ValueMapping("否", false)] [ValueMapping("否", false)]
public bool MateType => SaEdiQty == 0 && SeEdiQty == 0; public bool MateType => SaSeQty == 0 && SaEdiQty == 0 && SeEdiQty == 0;
/// <summary> /// <summary>
/// 定价 /// 定价
/// </summary> /// </summary>

30
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSeEdiCompareExportService.cs

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Dynamic.Core; using System.Linq.Dynamic.Core;
using Magicodes.ExporterAndImporter.Core.Extension;
using Magicodes.ExporterAndImporter.Excel; using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
@ -14,6 +15,7 @@ using Volo.Abp.DependencyInjection;
using Volo.Abp.ObjectMapping; using Volo.Abp.ObjectMapping;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount; using Win.Sfs.SettleAccount;
using Win.Sfs.SettleAccount.Consts;
using Win.Sfs.SettleAccount.Reports; using Win.Sfs.SettleAccount.Reports;
namespace SettleAccount.Job.Services.Report namespace SettleAccount.Job.Services.Report
@ -65,6 +67,14 @@ namespace SettleAccount.Job.Services.Report
var seEndDateTime = DateTime.Parse(strSeEndDateTime); var seEndDateTime = DateTime.Parse(strSeEndDateTime);
var filename = exportName.FirstOrDefault(); var filename = exportName.FirstOrDefault();
// Sheet行数
var maxRowNumberOnASheet = AppConst.DefaultRowNumberOnASheet;
var excelExporterAttribute = typeof(JisBBACEidSeCompareExport).GetAttribute<ExcelExporterAttribute>(inherit: true);
if (excelExporterAttribute != null)
{
maxRowNumberOnASheet = excelExporterAttribute.MaxRowNumberOnASheet > 0 ? excelExporterAttribute.MaxRowNumberOnASheet : maxRowNumberOnASheet;
}
//有EDI无发运 //有EDI无发运
var haveEdiNotHaveSeList = _settleAccountDbContext.Set<BBAC_SE_EDI>().Where(t => t.IsHaveSeData == false) var haveEdiNotHaveSeList = _settleAccountDbContext.Set<BBAC_SE_EDI>().Where(t => t.IsHaveSeData == false)
.GroupBy(t => new { t.LU, t.PN }) .GroupBy(t => new { t.LU, t.PN })
@ -166,11 +176,21 @@ namespace SettleAccount.Job.Services.Report
notHaveEdiHaveSeList.AddRange(haveEdiHaveSeList); notHaveEdiHaveSeList.AddRange(haveEdiHaveSeList);
notHaveEdiHaveSeList.Reverse(); notHaveEdiHaveSeList.Reverse();
ExcelExporter excelExporter = new ExcelExporter(); var excelExporter = new ExcelExporter();
excelExporter // EDI数据和发货对比
.Append(haveEdiNotHaveSeList, $"BBACEDI数据和发货对比") excelExporter.Append(haveEdiNotHaveSeList.Take(maxRowNumberOnASheet).ToList(), $"BBACEDI数据和发货对比");
.SeparateBySheet() for (var i = 1; i < haveEdiNotHaveSeList.Count / maxRowNumberOnASheet + ((haveEdiNotHaveSeList.Count % maxRowNumberOnASheet) > 0 ? 1 : 0); i++)
.Append(notHaveEdiHaveSeList, $"BBAC发货和EDI数据对比"); {
var sheetDataItems = haveEdiNotHaveSeList.Skip(i * maxRowNumberOnASheet).Take(maxRowNumberOnASheet).ToList();
excelExporter.Append(sheetDataItems, $"BBACEDI数据和发货对比-{i}");
}
// 发货和EDI数据对比
excelExporter.Append(notHaveEdiHaveSeList.Take(maxRowNumberOnASheet).ToList(), $"BBAC发货和EDI数据对比");
for (var i = 1; i < notHaveEdiHaveSeList.Count / maxRowNumberOnASheet + ((haveEdiNotHaveSeList.Count % maxRowNumberOnASheet) > 0 ? 1 : 0); i++)
{
var sheetDataItems = notHaveEdiHaveSeList.Skip(i * maxRowNumberOnASheet).Take(maxRowNumberOnASheet).ToList();
excelExporter.Append(sheetDataItems, $"BBAC发货和EDI数据对比-{i}");
}
var result = excelExporter.ExportAppendDataAsByteArray(); var result = excelExporter.ExportAppendDataAsByteArray();
result.ShouldNotBeNull(); result.ShouldNotBeNull();

30
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSeEdiCompareExportService.cs

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Magicodes.ExporterAndImporter.Core.Extension;
using Magicodes.ExporterAndImporter.Excel; using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
@ -12,6 +13,7 @@ using Volo.Abp.BlobStoring;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount; using Win.Sfs.SettleAccount;
using Win.Sfs.SettleAccount.Consts;
using Win.Sfs.SettleAccount.Reports; using Win.Sfs.SettleAccount.Reports;
namespace SettleAccount.Job.Services.Report namespace SettleAccount.Job.Services.Report
@ -62,6 +64,14 @@ namespace SettleAccount.Job.Services.Report
var seEndDateTime = DateTime.Parse(strSeEndDateTime); var seEndDateTime = DateTime.Parse(strSeEndDateTime);
var filename = exportName.FirstOrDefault(); var filename = exportName.FirstOrDefault();
// Sheet行数
var maxRowNumberOnASheet = AppConst.DefaultRowNumberOnASheet;
var excelExporterAttribute = typeof(JisHBPOEidSeCompareExport).GetAttribute<ExcelExporterAttribute>(inherit: true);
if (excelExporterAttribute != null)
{
maxRowNumberOnASheet = excelExporterAttribute.MaxRowNumberOnASheet > 0 ? excelExporterAttribute.MaxRowNumberOnASheet : maxRowNumberOnASheet;
}
//有EDI无发运 //有EDI无发运
var haveEdiNotHaveSeList = _settleAccountDbContext.Set<HBPO_SE_EDI>().Where(t => t.IsHaveSeData == false) var haveEdiNotHaveSeList = _settleAccountDbContext.Set<HBPO_SE_EDI>().Where(t => t.IsHaveSeData == false)
.GroupBy(t => new { t.LU, t.PN }) .GroupBy(t => new { t.LU, t.PN })
@ -165,11 +175,21 @@ namespace SettleAccount.Job.Services.Report
notHaveEdiHaveSeList.AddRange(haveEdiHaveSeList); notHaveEdiHaveSeList.AddRange(haveEdiHaveSeList);
notHaveEdiHaveSeList.Reverse(); notHaveEdiHaveSeList.Reverse();
ExcelExporter excelExporter = new ExcelExporter(); var excelExporter = new ExcelExporter();
excelExporter // EDI数据和发货对比
.Append(haveEdiNotHaveSeList, $"HBPOEDI数据和发货对比") excelExporter.Append(haveEdiNotHaveSeList.Take(maxRowNumberOnASheet).ToList(), $"HBPOEDI数据和发货对比");
.SeparateBySheet() for (var i = 1; i < haveEdiNotHaveSeList.Count / maxRowNumberOnASheet + ((haveEdiNotHaveSeList.Count % maxRowNumberOnASheet) > 0 ? 1 : 0); i++)
.Append(notHaveEdiHaveSeList, $"HBPO发货和EDI数据对比"); {
var sheetDataItems = haveEdiNotHaveSeList.Skip(i * maxRowNumberOnASheet).Take(maxRowNumberOnASheet).ToList();
excelExporter.Append(sheetDataItems, $"HBPOEDI数据和发货对比-{i}");
}
// 发货和EDI数据对比
excelExporter.Append(notHaveEdiHaveSeList.Take(maxRowNumberOnASheet).ToList(), $"HBPO发货和EDI数据对比");
for (var i = 1; i < notHaveEdiHaveSeList.Count / maxRowNumberOnASheet + ((haveEdiNotHaveSeList.Count % maxRowNumberOnASheet) > 0 ? 1 : 0); i++)
{
var sheetDataItems = notHaveEdiHaveSeList.Skip(i * maxRowNumberOnASheet).Take(maxRowNumberOnASheet).ToList();
excelExporter.Append(sheetDataItems, $"HBPO发货和EDI数据对比-{i}");
}
var result = excelExporter.ExportAppendDataAsByteArray(); var result = excelExporter.ExportAppendDataAsByteArray();
result.ShouldNotBeNull(); result.ShouldNotBeNull();

90
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs

@ -1,12 +1,14 @@
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;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using SettleAccount.Job.SignalR; using SettleAccount.Job.SignalR;
using Win.Sfs.SettleAccount; using Win.Sfs.SettleAccount;
using Win.Sfs.SettleAccount.Consts;
using Win.Sfs.SettleAccount.Enums; using Win.Sfs.SettleAccount.Enums;
using Win.Sfs.SettleAccount.Reports; using Win.Sfs.SettleAccount.Reports;
@ -174,10 +176,26 @@ namespace SettleAccount.Job.Services.Report
/// <summary> /// <summary>
/// 创建导出文件结构 /// 创建导出文件结构
/// </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, FactoryPartCode = p.Key,
PartCodeDesc = p.FirstOrDefault().PartCodeDesc, PartCodeDesc = p.FirstOrDefault().PartCodeDesc,
@ -186,7 +204,7 @@ namespace SettleAccount.Job.Services.Report
}).ToList(); }).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() 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) SEQty = p.Sum(t => t.SEQty)
}).ToList(); }).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() 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) SEQty = p.Sum(t => t.SEQty)
}).ToList(); }).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() 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) SEQty = p.Sum(t => t.SEQty)
}).ToList(); }).ToList();
ExcelExporter excelExporter = new ExcelExporter(); var excelExporter = new ExcelExporter();
return excelExporter //结算核对明细输出
.Append(pubSaSeCompareDetailExports, $"{businessTypeDisplayName}结算核对明细输出") excelExporter.Append(saSeCompareDetailExports.Take(detailMaxRowNumberOnASheet).ToList(), $"{businessTypeDisplayName}结算核对明细输出");
.SeparateBySheet() for (var i = 1; i < saSeCompareDetailExports.Count / detailMaxRowNumberOnASheet + ((saSeCompareDetailExports.Count % detailMaxRowNumberOnASheet) > 0 ? 1 : 0); i++)
.Append(pubSaSeCompareSumExports, $"{businessTypeDisplayName}结算核对汇总输出") {
.SeparateBySheet() var sheetDataItems = saSeCompareDetailExports.Skip(i * detailMaxRowNumberOnASheet).Take(detailMaxRowNumberOnASheet).ToList();
excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}结算核对明细输出-{i}");
.Append(haveSaHaveSeExports, $"{businessTypeDisplayName}有结算有发货明细输出") }
.SeparateBySheet() //结算核对汇总输出
.Append(haveSaHaveSeSumExports, $"{businessTypeDisplayName}有结算有发货汇总输出") excelExporter.Append(saSeCompareSumExports.Take(sumMaxRowNumberOnASheet).ToList(), $"{businessTypeDisplayName}结算核对汇总输出");
.SeparateBySheet() for (var i = 1; i < saSeCompareSumExports.Count / sumMaxRowNumberOnASheet + ((saSeCompareSumExports.Count % sumMaxRowNumberOnASheet) > 0 ? 1 : 0); i++)
{
.Append(haveSaNotHaveSeExports, $"{businessTypeDisplayName}有结算无发货明细输出") var sheetDataItems = saSeCompareSumExports.Skip(i * sumMaxRowNumberOnASheet).Take(sumMaxRowNumberOnASheet).ToList(); ;
.SeparateBySheet() excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}结算核对汇总输出-{i}");
.Append(haveSaNotHaveSeSumExports, $"{businessTypeDisplayName}有结算无发货汇总输出"); }
//有结算有发货明细输出
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> /// <summary>

22
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs

@ -7,6 +7,7 @@ using Microsoft.AspNetCore.SignalR;
using SettleAccount.Bases; using SettleAccount.Bases;
using SettleAccount.Job.SignalR; using SettleAccount.Job.SignalR;
using Win.Sfs.SettleAccount; using Win.Sfs.SettleAccount;
using Win.Sfs.SettleAccount.Consts;
using Win.Sfs.SettleAccount.Enums; using Win.Sfs.SettleAccount.Enums;
using Win.Sfs.SettleAccount.Reports; using Win.Sfs.SettleAccount.Reports;
@ -120,16 +121,16 @@ namespace SettleAccount.Job.Services.Report
public ExcelExporter BindExcelExporter<T>(List<T> saSeEdiCompareDetailExports, string businessTypeDisplayName) where T : SaSeEdiCompareDetailExport, ISaSeEdiCompareDetailExport, new() public ExcelExporter BindExcelExporter<T>(List<T> saSeEdiCompareDetailExports, string businessTypeDisplayName) where T : SaSeEdiCompareDetailExport, ISaSeEdiCompareDetailExport, new()
{ {
//详情Sheet行数 //详情Sheet行数
var detailMaxRowNumberOnASheet = 500_000; var detailMaxRowNumberOnASheet = AppConst.DefaultRowNumberOnASheet;
var detailExportExporterAttribute = typeof(T).GetAttribute<ExcelExporterAttribute>(); var detailExportExporterAttribute = typeof(T).GetAttribute<ExcelExporterAttribute>(inherit: true);
if (detailExportExporterAttribute != null) if (detailExportExporterAttribute != null)
{ {
detailMaxRowNumberOnASheet = detailExportExporterAttribute.MaxRowNumberOnASheet > 0 ? detailExportExporterAttribute.MaxRowNumberOnASheet : detailMaxRowNumberOnASheet; detailMaxRowNumberOnASheet = detailExportExporterAttribute.MaxRowNumberOnASheet > 0 ? detailExportExporterAttribute.MaxRowNumberOnASheet : detailMaxRowNumberOnASheet;
} }
//汇总Sheet行数 //汇总Sheet行数
var sumMaxRowNumberOnASheet = 500_000; var sumMaxRowNumberOnASheet = AppConst.DefaultRowNumberOnASheet;
var sumExportExporterAttribute = typeof(SaSeEdiCompareSumExport).GetAttribute<ExcelExporterAttribute>(); var sumExportExporterAttribute = typeof(SaSeEdiCompareSumExport).GetAttribute<ExcelExporterAttribute>(inherit: true);
if (sumExportExporterAttribute != null) if (sumExportExporterAttribute != null)
{ {
sumMaxRowNumberOnASheet = sumExportExporterAttribute.MaxRowNumberOnASheet > 0 ? sumExportExporterAttribute.MaxRowNumberOnASheet : sumMaxRowNumberOnASheet; sumMaxRowNumberOnASheet = sumExportExporterAttribute.MaxRowNumberOnASheet > 0 ? sumExportExporterAttribute.MaxRowNumberOnASheet : sumMaxRowNumberOnASheet;
@ -179,22 +180,19 @@ namespace SettleAccount.Job.Services.Report
EdiQty = p.Sum(t => t.EdiQty) EdiQty = p.Sum(t => t.EdiQty)
}).ToList(); }).ToList();
ExcelExporter excelExporter = new ExcelExporter(); var excelExporter = new ExcelExporter();
//结算核对明细输出 //结算核对明细输出
excelExporter.Append(saSeEdiCompareDetailExports.Take(detailMaxRowNumberOnASheet).ToList(), $"{businessTypeDisplayName}结算核对明细输出"); excelExporter.Append(saSeEdiCompareDetailExports.Take(detailMaxRowNumberOnASheet).ToList(), $"{businessTypeDisplayName}结算核对明细输出");
for (var i = 1; i < saSeEdiCompareDetailExports.Count / detailMaxRowNumberOnASheet + ((saSeEdiCompareDetailExports.Count % detailMaxRowNumberOnASheet) > 0 ? 1 : 0); i++) for (var i = 1; i < saSeEdiCompareDetailExports.Count / detailMaxRowNumberOnASheet + ((saSeEdiCompareDetailExports.Count % detailMaxRowNumberOnASheet) > 0 ? 1 : 0); i++)
{ {
var sheetDataItems = saSeEdiCompareDetailExports.Skip(i * detailMaxRowNumberOnASheet) var sheetDataItems = saSeEdiCompareDetailExports.Skip(i * detailMaxRowNumberOnASheet).Take(detailMaxRowNumberOnASheet).ToList();
.Take(detailMaxRowNumberOnASheet).ToList();
excelExporter.SeparateBySheet();
excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}结算核对明细输出-{i}"); excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}结算核对明细输出-{i}");
} }
//结算核对汇总输出 //结算核对汇总输出
excelExporter.Append(saSeEdiCompareSumExports.Take(sumMaxRowNumberOnASheet).ToList(), $"{businessTypeDisplayName}结算核对汇总输出"); excelExporter.Append(saSeEdiCompareSumExports.Take(sumMaxRowNumberOnASheet).ToList(), $"{businessTypeDisplayName}结算核对汇总输出");
for (var i = 1; i < saSeEdiCompareSumExports.Count / sumMaxRowNumberOnASheet + ((saSeEdiCompareSumExports.Count % sumMaxRowNumberOnASheet) > 0 ? 1 : 0); i++) for (var i = 1; i < saSeEdiCompareSumExports.Count / sumMaxRowNumberOnASheet + ((saSeEdiCompareSumExports.Count % sumMaxRowNumberOnASheet) > 0 ? 1 : 0); i++)
{ {
var sheetDataItems = saSeEdiCompareSumExports.Skip(i * sumMaxRowNumberOnASheet).Take(sumMaxRowNumberOnASheet).ToList(); var sheetDataItems = saSeEdiCompareSumExports.Skip(i * sumMaxRowNumberOnASheet).Take(sumMaxRowNumberOnASheet).ToList();;
excelExporter.SeparateBySheet();
excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}结算核对汇总输出-{i}"); excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}结算核对汇总输出-{i}");
} }
@ -203,7 +201,6 @@ namespace SettleAccount.Job.Services.Report
for (var i = 1; i < haveSaHaveSeExports.Count / detailMaxRowNumberOnASheet + ((haveSaHaveSeExports.Count % detailMaxRowNumberOnASheet) > 0 ? 1 : 0); i++) for (var i = 1; i < haveSaHaveSeExports.Count / detailMaxRowNumberOnASheet + ((haveSaHaveSeExports.Count % detailMaxRowNumberOnASheet) > 0 ? 1 : 0); i++)
{ {
var sheetDataItems = haveSaHaveSeExports.Skip(i * detailMaxRowNumberOnASheet).Take(detailMaxRowNumberOnASheet).ToList(); var sheetDataItems = haveSaHaveSeExports.Skip(i * detailMaxRowNumberOnASheet).Take(detailMaxRowNumberOnASheet).ToList();
excelExporter.SeparateBySheet();
excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}有结算有发货明细输出-{i}"); excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}有结算有发货明细输出-{i}");
} }
//有结算有发货汇总输出 //有结算有发货汇总输出
@ -211,7 +208,6 @@ namespace SettleAccount.Job.Services.Report
for (var i = 1; i < haveSaHaveSeSumExports.Count / sumMaxRowNumberOnASheet + ((haveSaHaveSeSumExports.Count % sumMaxRowNumberOnASheet) > 0 ? 1 : 0); i++) for (var i = 1; i < haveSaHaveSeSumExports.Count / sumMaxRowNumberOnASheet + ((haveSaHaveSeSumExports.Count % sumMaxRowNumberOnASheet) > 0 ? 1 : 0); i++)
{ {
var sheetDataItems = haveSaHaveSeSumExports.Skip(i * sumMaxRowNumberOnASheet).Take(sumMaxRowNumberOnASheet).ToList(); var sheetDataItems = haveSaHaveSeSumExports.Skip(i * sumMaxRowNumberOnASheet).Take(sumMaxRowNumberOnASheet).ToList();
excelExporter.SeparateBySheet();
excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}有结算有发货汇总输出-{i}"); excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}有结算有发货汇总输出-{i}");
} }
@ -220,7 +216,6 @@ namespace SettleAccount.Job.Services.Report
for (var i = 1; i < haveSaNotHaveSeExports.Count / detailMaxRowNumberOnASheet + ((haveSaNotHaveSeExports.Count % detailMaxRowNumberOnASheet) > 0 ? 1 : 0); i++) for (var i = 1; i < haveSaNotHaveSeExports.Count / detailMaxRowNumberOnASheet + ((haveSaNotHaveSeExports.Count % detailMaxRowNumberOnASheet) > 0 ? 1 : 0); i++)
{ {
var sheetDataItems = haveSaNotHaveSeExports.Skip(i * detailMaxRowNumberOnASheet).Take(detailMaxRowNumberOnASheet).ToList(); var sheetDataItems = haveSaNotHaveSeExports.Skip(i * detailMaxRowNumberOnASheet).Take(detailMaxRowNumberOnASheet).ToList();
excelExporter.SeparateBySheet();
excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}有结算无发货明细输出-{i}"); excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}有结算无发货明细输出-{i}");
} }
//有结算有发货汇总输出 //有结算有发货汇总输出
@ -228,7 +223,6 @@ namespace SettleAccount.Job.Services.Report
for (var i = 1; i < haveSaNotHaveSeSumExports.Count / sumMaxRowNumberOnASheet + ((haveSaNotHaveSeSumExports.Count % sumMaxRowNumberOnASheet) > 0 ? 1 : 0); i++) for (var i = 1; i < haveSaNotHaveSeSumExports.Count / sumMaxRowNumberOnASheet + ((haveSaNotHaveSeSumExports.Count % sumMaxRowNumberOnASheet) > 0 ? 1 : 0); i++)
{ {
var sheetDataItems = haveSaNotHaveSeSumExports.Skip(i * sumMaxRowNumberOnASheet).Take(sumMaxRowNumberOnASheet).ToList(); var sheetDataItems = haveSaNotHaveSeSumExports.Skip(i * sumMaxRowNumberOnASheet).Take(sumMaxRowNumberOnASheet).ToList();
excelExporter.SeparateBySheet();
excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}有结算无发货汇总输出-{i}"); excelExporter.Append(sheetDataItems, $"{businessTypeDisplayName}有结算无发货汇总输出-{i}");
} }

Loading…
Cancel
Save