Browse Source

BBAC三方对比报表分页

master
mahao 1 year ago
parent
commit
3fc3b3611f
  1. 97
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SE_DETAIL_SERVICE.cs
  2. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs
  3. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/JisBBACEidSeCompareReport.cs
  4. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/SaSeEdiCompareDiff.cs
  5. 21
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSeEdiCompareExportService.cs
  6. 90
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs

97
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SE_DETAIL_SERVICE.cs

@ -1,6 +1,13 @@
using Castle.Core.Internal;
using DocumentFormat.OpenXml.Office2010.Excel;
using DocumentFormat.OpenXml.Spreadsheet;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using Magicodes.ExporterAndImporter.Excel.Utility;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.OpenApi.Extensions;
using NPOI.HPSF;
using SettleAccount.Domain.BQ;
using Shouldly;
using SqlSugar;
@ -8,12 +15,15 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Security.Cryptography;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.BlobStoring;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.Reports;
using Win.Sfs.Shared.Filter;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ
@ -34,14 +44,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// excel服务
/// </summary>
private readonly IExcelImportAppService _excelImportService;
/// <summary>
/// 文件容器
/// </summary>
private readonly IBlobContainer<MyFileContainer> _fileContainer;
/// <summary>
/// 构造
/// </summary>
public PUB_SE_DETAIL_SERVICE(INormalEfCoreRepository<PUB_SE_DETAIL, Guid> repository, IExcelImportAppService excelImportService)
public PUB_SE_DETAIL_SERVICE(INormalEfCoreRepository<PUB_SE_DETAIL, Guid> repository, IExcelImportAppService excelImportService, IBlobContainer<MyFileContainer> fileContainer)
{
_repository = repository;
_excelImportService = excelImportService;
_fileContainer = fileContainer;
}
#region 导出
@ -70,6 +85,86 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result }).ConfigureAwait(false);
return fileName;
}
[HttpGet]
public async Task<string> TextExportAsync()
{
var fileName = $"发运数据_{Guid.NewGuid()}.xlsx";
var haveEdiHaveSeList = new List<JisBBACEidSeCompareExport>();
for (int i = 0; i < 2_000_000; i++)
{
haveEdiHaveSeList.Add(new JisBBACEidSeCompareExport()
{
Category = "JIS",
WmsBillNum = i.ToString(),
CarModeCode = i.ToString(),
LineStationcode = i.ToString(),
SequenceNumber = i.ToString(),
ParType = i.ToString(),
MESConfigCode = i.ToString(),
ShippingDate = DateTime.Now,
PN = i.ToString(),
Seq = i.ToString(),
PjsNum = i.ToString(),
MaterialNumber = i.ToString(),
MaterialDes = i.ToString(),
SEQty = 1,
EdiQty = 1,
AssemblyDate = DateTime.Now,
MatchNumber = i.ToString(),
InjectionCode = i.ToString(),
MateType = "是",
DiffDesc = "WMS有发货EDI有订单"
});
}
var jisBBACEidSeCompareEexcelExporterAttribute = typeof(JisBBACEidSeCompareExport).GetAttribute<ExcelExporterAttribute>();
var jisBBACEidSeCompareEexcelMaxRowNumberOnASheet = 9_000_000;
if (jisBBACEidSeCompareEexcelExporterAttribute != null)
{
jisBBACEidSeCompareEexcelMaxRowNumberOnASheet = jisBBACEidSeCompareEexcelExporterAttribute.MaxRowNumberOnASheet > 0 ? jisBBACEidSeCompareEexcelExporterAttribute.MaxRowNumberOnASheet : jisBBACEidSeCompareEexcelMaxRowNumberOnASheet;
}
ExcelExporter excelExporter = new ExcelExporter();
excelExporter.Append(haveEdiHaveSeList.Take(jisBBACEidSeCompareEexcelMaxRowNumberOnASheet).ToList(), $"BBACEDI数据和发货对比");
var ediSheetCount = (int)(haveEdiHaveSeList.Count / jisBBACEidSeCompareEexcelMaxRowNumberOnASheet) + ((haveEdiHaveSeList.Count % jisBBACEidSeCompareEexcelMaxRowNumberOnASheet) > 0 ? 1 : 0);
if (ediSheetCount > 1)
{
for (int i = 1; i < ediSheetCount; i++)
{
var sheetDataItems = haveEdiHaveSeList.Skip(i * jisBBACEidSeCompareEexcelMaxRowNumberOnASheet)
.Take(jisBBACEidSeCompareEexcelMaxRowNumberOnASheet).ToList();
excelExporter.SeparateBySheet();
excelExporter.Append(sheetDataItems, $"BBACEDI数据和发货对比-{i}");
}
}
excelExporter.Append(haveEdiHaveSeList.Take(jisBBACEidSeCompareEexcelMaxRowNumberOnASheet).ToList(), $"BBAC发货和EDI数据对比");
var seSheetCount = (int)(haveEdiHaveSeList.Count / jisBBACEidSeCompareEexcelMaxRowNumberOnASheet) + ((haveEdiHaveSeList.Count % jisBBACEidSeCompareEexcelMaxRowNumberOnASheet) > 0 ? 1 : 0);
if (seSheetCount > 1)
{
for (int i = 1; i < seSheetCount; i++)
{
var sheetDataItems = haveEdiHaveSeList.Skip(i * jisBBACEidSeCompareEexcelMaxRowNumberOnASheet)
.Take(jisBBACEidSeCompareEexcelMaxRowNumberOnASheet).ToList();
excelExporter.SeparateBySheet();
excelExporter.Append(sheetDataItems, $"BBAC发货和EDI数据对比-{i}");
}
}
//excelExporter
// .Append(haveEdiHaveSeList, $"BBACEDI数据和发货对比");
//.SeparateBySheet()
////.Append(haveEdiHaveSeList, $"BBAC发货和EDI数据对比");
var result = excelExporter.ExportAppendDataAsByteArray();
await result.ShouldNotBeNull().ConfigureAwait(false);
await _fileContainer.SaveAsync(fileName, result.Result, true).ConfigureAwait(false);
return fileName;
}
#endregion
#region 查询

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs

@ -92,8 +92,6 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable
ediDetails.ForEach(t => t.IsHaveSeData = true);
db.BulkUpdate<HBPO_SE_EDI>(ediDetails);
}
await uow.SaveChangesAsync().ConfigureAwait(false);
//db.SaveChanges();
}
}
catch (Exception)

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

@ -15,7 +15,7 @@ public class JisBBACEidSeCompareReport
/// <summary>
/// JisBBAC Edi、发运对比导出
/// </summary>
[ExcelExporter(MaxRowNumberOnASheet = 900000)]
[ExcelExporter(MaxRowNumberOnASheet = 500_000)]
public class JisBBACEidSeCompareExport
{
/// <summary>

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

@ -135,7 +135,7 @@ public class SaSeEdiCompareDiff
/// <summary>
/// 结算、发运、Eid对比明细
/// </summary>
[ExcelExporter(MaxRowNumberOnASheet = 900000)]
[ExcelExporter(MaxRowNumberOnASheet = 500_000)]
public class SaSeEdiCompareDetailExport
{
}
@ -192,7 +192,6 @@ public interface ISaSeEdiCompareDetailExport
/// <summary>
/// JisBBAC结算、发运、Eid对比明细
/// </summary>
public class SaSeEdiCompareDetailExportJisBBAC : SaSeEdiCompareDetailExport, ISaSeEdiCompareDetailExport
{
/// <summary>
@ -477,7 +476,7 @@ public class SaSeEdiCompareDetailExportJisHBPO : SaSeEdiCompareDetailExport, ISa
/// <summary>
/// PUB结算与发运对比汇总
/// </summary>
[ExcelExporter(MaxRowNumberOnASheet = 900000)]
[ExcelExporter(MaxRowNumberOnASheet = 500_000)]
public class SaSeEdiCompareSumExport
{
/// <summary>

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

@ -71,10 +71,10 @@ namespace SettleAccount.Job.Services.Report
.Select(t => new JisBBACEidSeCompareExport()
{
Category = "JIS",
CarModeCode = default,
LineStationcode = default,
SequenceNumber = t.Max(t => t.SeqNumber),
ParType = "01",
CarModeCode = t.Max(t => t.Extend4),
LineStationcode = t.Max(t => t.LineStationCode),
SequenceNumber = t.Max(t => t.Extend3),
ParType = t.Max(t => t.Extend2),
PN = t.Key.PN,
MaterialNumber = t.Key.LU,
EdiQty = t.Sum(t => t.Qty),
@ -111,7 +111,10 @@ namespace SettleAccount.Job.Services.Report
groupItem.Key.PN,
groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty),
SeqNumber = groupItem.Max(t => t.SeqNumber)
Extend2 = groupItem.Max(t => t.Extend2),
Extend3 = groupItem.Max(t => t.Extend3),
Extend4 = groupItem.Max(t => t.Extend4),
LineStationCode = groupItem.Max(t => t.LineStationCode)
};
var seGroup = from se in _settleAccountDbContext.Set<BBAC_SE_DETAIL>()
where se.IsHaveEdiData == true && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime
@ -138,10 +141,10 @@ namespace SettleAccount.Job.Services.Report
{
Category = "JIS",
WmsBillNum = se.BillNum,
CarModeCode = default,
LineStationcode = default,
SequenceNumber = edi.SeqNumber,
ParType = "01",
CarModeCode = edi.Extend4,
LineStationcode = edi.LineStationCode,
SequenceNumber = edi.Extend3,
ParType = edi.Extend2,
MESConfigCode = se.MESConfigCode,
ShippingDate = se.BillTime,
PN = se.PN,

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

@ -1,6 +1,7 @@
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;
@ -116,10 +117,26 @@ namespace SettleAccount.Job.Services.Report
/// <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,
PartCodeDesc = p.FirstOrDefault().PartCodeDesc,
@ -129,7 +146,7 @@ namespace SettleAccount.Job.Services.Report
}).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()
{
@ -140,7 +157,7 @@ namespace SettleAccount.Job.Services.Report
EdiQty = p.Sum(t => t.EdiQty)
}).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()
{
@ -151,7 +168,7 @@ namespace SettleAccount.Job.Services.Report
EdiQty = p.Sum(t => t.EdiQty)
}).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()
{
@ -163,20 +180,59 @@ namespace SettleAccount.Job.Services.Report
}).ToList();
ExcelExporter excelExporter = new ExcelExporter();
return excelExporter
.Append(pubSaSeCompareDetailExports, $"{businessTypeDisplayName}结算核对明细输出")
.SeparateBySheet()
.Append(pubSaSeCompareSumExports, $"{businessTypeDisplayName}结算核对汇总输出")
.SeparateBySheet()
//结算核对明细输出
excelExporter.Append(saSeEdiCompareDetailExports.Take(detailMaxRowNumberOnASheet).ToList(), $"{businessTypeDisplayName}结算核对明细输出");
for (var i = 1; i < saSeEdiCompareDetailExports.Count / detailMaxRowNumberOnASheet + ((saSeEdiCompareDetailExports.Count % detailMaxRowNumberOnASheet) > 0 ? 1 : 0); i++)
{
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()
.Append(haveSaHaveSeSumExports, $"{businessTypeDisplayName}有结算有发货汇总输出")
.SeparateBySheet()
//有结算有发货明细输出
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.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}有结算无发货明细输出")
.SeparateBySheet()
.Append(haveSaNotHaveSeSumExports, $"{businessTypeDisplayName}有结算无发货汇总输出");
return excelExporter;
}
/// <summary>

Loading…
Cancel
Save