You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
94 lines
2.7 KiB
94 lines
2.7 KiB
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
|
|
{
|
|
|
|
|
|
private 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<ERR_EXP_DTO> 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;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|