Browse Source

三方比对按类别生成

master
zhouhongjun 4 months ago
parent
commit
ab16c5eb60
  1. 71
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/NopiDataToExcel.cs
  2. 13
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs
  3. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SeEdiCompareExportBaseService.cs

71
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/NopiDataToExcel.cs

@ -37,7 +37,7 @@ namespace SettleAccount.Job.Services.Report
/// <param name="sheetName">页签名称</param>
/// <param name="data">数据</param>
/// <param name="chunkSize">缓存文件行数</param>
public async Task<string> WriteDataToExcelInParallel(string sheetName, List<T> data, int chunkSize,string zipFileName, List<SaSeEdiCompareSumReport> sumdata)
public async Task<string> WriteDataToExcelInParallel(string sheetName, List<T> data, int chunkSize,string zipFileName, List<SaSeEdiCompareSumReport> sumdata,bool isFinish)
{
var count = data.Count / 1000000 + ((data.Count % 1000000) > 0 ? 1 : 0);
for (var i = 1; i <= count; i++)
@ -61,54 +61,55 @@ namespace SettleAccount.Job.Services.Report
}
string[] filePaths = excelFiles.Select(x => x.FileName).ToArray();
string zipPath = zipFileName;
using (var archive = ZipFile.Open(zipPath, ZipArchiveMode.Create))
if(isFinish)
{
foreach (var file in filePaths)
string[] filePaths = excelFiles.Select(x => x.FileName).ToArray();
string zipPath = zipFileName;
using (var archive = ZipFile.Open(zipPath, ZipArchiveMode.Create))
{
archive.CreateEntryFromFile(file, Path.GetFileName(file));
foreach (var file in filePaths)
{
archive.CreateEntryFromFile(file, Path.GetFileName(file));
}
}
}
for (var i = 0; i < count; i++)
{
var filelist = excelFiles.Select(p => p.FileName).ToList();
foreach (var file in filelist)
for (var i = 0; i < count; i++)
{
File.Delete(file);
var filelist = excelFiles.Select(p => p.FileName).ToList();
foreach (var file in filelist)
{
File.Delete(file);
}
}
}
using (FileStream fileStream = new FileStream(zipPath, FileMode.Open))
{
var minioClient = new MinioClient(EndPoint, AccessKey, SecretKey, "");
try
using (FileStream fileStream = new FileStream(zipPath, FileMode.Open))
{
await minioClient.PutObjectAsync(BucketName, "host/"+zipPath, fileStream, fileStream.Length, "application/zip").ConfigureAwait(false);
var minioClient = new MinioClient(EndPoint, AccessKey, SecretKey, "");
try
{
await minioClient.PutObjectAsync(BucketName, "host/" + zipPath, fileStream, fileStream.Length, "application/zip").ConfigureAwait(false);
}
catch (Exception ex)
{
Console.WriteLine($"上传文件到 MinIO 时发生错误: {ex.Message}");
}
finally
{
if (fileStream != null)
}
catch (Exception ex)
{
Console.WriteLine($"上传文件到 MinIO 时发生错误: {ex.Message}");
}
finally
{
fileStream.Close();
File.Delete(zipPath);
if (fileStream != null)
{
fileStream.Close();
File.Delete(zipPath);
}
}
}
}
//using (FileStream fileStream = new FileStream(zipPath, FileMode.Open))
//{
// return fileStream.GetAllBytes();
//}
return zipFileName;
}

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

@ -240,7 +240,7 @@ namespace SettleAccount.Job.Services.Report
/// <remarks>
/// 根据单Sheel最大行数配置分Sheel页导出
/// </remarks>
public string BindExcelExporter<T>(List<T> saSeEdiCompareDetailExports, string businessTypeDisplayName,string fileName) where T : SaSeEdiCompareDetailReport, new()
public string BindExcelExporter<T>(List<T> saSeEdiCompareDetailExports, string businessTypeDisplayName,string fileName) where T : SaSeEdiCompareDetailReport, new()
{
//详情Sheet行数
var detailMaxRowNumberOnASheet = AppConst.DefaultRowNumberOnASheet;
@ -308,9 +308,9 @@ namespace SettleAccount.Job.Services.Report
#region 多线程生成Excel
haveSaNotHaveSeExport.AddRange(notHaveSaHaveSeExports);
//haveSaNotHaveSeExport.AddRange(notHaveSaHaveSeExports);
haveSaNotHaveSeExport.AddRange(haveSaHaveSeExport);
//haveSaNotHaveSeExport.AddRange(haveSaHaveSeExport);
NopiExtendExcel<T> nopiExcel = new NopiExtendExcel<T>();
@ -322,8 +322,13 @@ namespace SettleAccount.Job.Services.Report
nopiExcel.EndPoint = _cfg.GetValue("MinIO:EndPoint", "localhost:10684");
var uploadResult = nopiExcel.WriteDataToExcelInParallel($"{businessTypeDisplayName}结算数据和发货对比", haveSaNotHaveSeExport, 500000, fileName, haveSaHaveSeSumExports).ConfigureAwait(false);
//var uploadResult = nopiExcel.WriteDataToExcelInParallel($"{businessTypeDisplayName}结算数据和发货对比", haveSaNotHaveSeExport, 500000, fileName, haveSaHaveSeSumExports, false).ConfigureAwait(false);
nopiExcel.WriteDataToExcelInParallel($"{businessTypeDisplayName}结算和发货对比_有结无发", haveSaNotHaveSeExport, 500000, fileName, null, false).ConfigureAwait(false);
nopiExcel.WriteDataToExcelInParallel($"{businessTypeDisplayName}结算和发货对比_有发无结", notHaveSaHaveSeExports, 500000, fileName, null, false).ConfigureAwait(false);
nopiExcel.WriteDataToExcelInParallel($"{businessTypeDisplayName}结算和发货对比_有结有发", haveSaHaveSeExport, 500000, fileName, haveSaHaveSeSumExports, true).ConfigureAwait(false);
return fileName;
#endregion

2
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SeEdiCompareExportBaseService.cs

@ -232,7 +232,7 @@ namespace SettleAccount.Job.Services.Report
nopiExcelHaveEdiNotHaveSe.EndPoint = _cfg.GetValue("MinIO:EndPoint", "localhost:10684");
var uploadResult = nopiExcelHaveEdiNotHaveSe.WriteDataToExcelInParallel($"{businessTypeDisplayName}EDI数据和发货对比", haveEdiNotHaveSeList, 500000,fileName,null).ConfigureAwait(false);
var uploadResult = nopiExcelHaveEdiNotHaveSe.WriteDataToExcelInParallel($"{businessTypeDisplayName}EDI数据和发货对比", haveEdiNotHaveSeList, 500000,fileName,null,true).ConfigureAwait(false);
return fileName;

Loading…
Cancel
Save