学 赵
1 year ago
16 changed files with 402 additions and 40 deletions
@ -0,0 +1,94 @@ |
|||||
|
using Shouldly; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Services; |
||||
|
using Volo.Abp.Caching; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Domain.Entities; |
||||
|
using Win.Abp.Snowflakes; |
||||
|
using Win.Sfs.BaseData.ImportExcelCommon; |
||||
|
using Win.Sfs.SettleAccount.CommonManagers; |
||||
|
using Win.Sfs.SettleAccount.Constant; |
||||
|
using Win.Sfs.SettleAccount.ExcelImporter; |
||||
|
using Win.Sfs.SettleAccount.ExportReports; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Bases |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
public abstract class BASE_SERVICE: ApplicationService, ITransientDependency |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
protected readonly IExcelImportAppService _excelImportService; |
||||
|
|
||||
|
protected readonly ISnowflakeIdGenerator _snowflakeIdGenerator; |
||||
|
|
||||
|
protected readonly ICommonManager _commonManager; |
||||
|
|
||||
|
protected BASE_SERVICE() { } |
||||
|
|
||||
|
protected BASE_SERVICE( |
||||
|
|
||||
|
IExcelImportAppService excelImportService, |
||||
|
ISnowflakeIdGenerator snowflakeIdGenerator, |
||||
|
ICommonManager commonManager) |
||||
|
{ |
||||
|
_excelImportService = excelImportService; |
||||
|
_snowflakeIdGenerator = snowflakeIdGenerator; |
||||
|
_commonManager = commonManager; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 输出报错信息
|
||||
|
/// </summary>
|
||||
|
/// <param name="errorList"></param>
|
||||
|
/// <param name="fileName"></param>
|
||||
|
/// <returns></returns>
|
||||
|
protected async Task<string> ExportErrorReportAsync(List<ErrorExportDto> errorList, string fileName = "") |
||||
|
{ |
||||
|
//没有信息返回成功
|
||||
|
if (errorList == null || errorList.Count == 0) |
||||
|
{ |
||||
|
return ApplicationConsts.SuccessStr; |
||||
|
} |
||||
|
|
||||
|
if (string.IsNullOrEmpty(fileName)) |
||||
|
{ |
||||
|
//导出文件名称
|
||||
|
fileName = CommonMethod.GetExcelFileNameByUserID(ApplicationConsts.CheckErroFileName, _snowflakeIdGenerator.Create().ToString(), ApplicationConsts.FileExtension); |
||||
|
} |
||||
|
|
||||
|
errorList = errorList.Distinct().OrderBy(p => p.Type).ThenBy(p => p.Model).ThenBy(p => p.ItemCode).ToList(); |
||||
|
|
||||
|
//声明导出容器
|
||||
|
ExportImporter _exportImporter = new ExportImporter(); |
||||
|
|
||||
|
var result = await _exportImporter.ExcelExporter(errorList); |
||||
|
|
||||
|
result.ShouldNotBeNull(); |
||||
|
|
||||
|
//保存导出文件到服务器存成二进制
|
||||
|
await _excelImportService.SaveBlobAsync( |
||||
|
new SaveExcelImportInputDto |
||||
|
{ |
||||
|
Name = fileName, |
||||
|
Content = result |
||||
|
} |
||||
|
); |
||||
|
return fileName; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
Loading…
Reference in new issue