mahao
1 year ago
17 changed files with 4756 additions and 316 deletions
@ -0,0 +1,21 @@ |
|||
using System; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Attributes |
|||
{ |
|||
/// <summary>
|
|||
/// Excel导入头部描述
|
|||
/// </summary>
|
|||
[AttributeUsage(AttributeTargets.Property)] |
|||
public class ExcelImporterHeadDescAttribute : Attribute |
|||
{ |
|||
/// <summary>
|
|||
/// 行数
|
|||
/// </summary>
|
|||
public int Row { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 列数
|
|||
/// </summary>
|
|||
public int Cell { get; set; } |
|||
} |
|||
} |
@ -0,0 +1,84 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq.Dynamic.Core; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using Microsoft.OpenApi.Extensions; |
|||
using SettleAccount.Domain.BQ; |
|||
using Shouldly; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Caching; |
|||
using Win.Abp.Snowflakes; |
|||
using Win.Sfs.BaseData.ImportExcelCommon; |
|||
using Win.Sfs.SettleAccount.CommonManagers; |
|||
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; |
|||
using Win.Sfs.SettleAccount.ExcelImporter; |
|||
using Win.Sfs.Shared.Filter; |
|||
using Win.Sfs.Shared.RepositoryBase; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Entities.BQ; |
|||
|
|||
/// <summary>
|
|||
/// PUB结算明细
|
|||
/// </summary>
|
|||
[AllowAnonymous] |
|||
[Route("api/settleaccount/[controller]/[action]")]
|
|||
public class PUB_SA_DETAIL_SERVICE : SettleAccountApplicationBase<PUB_SA_DETAIL> |
|||
{ |
|||
/// <summary>
|
|||
/// PUB结算明细仓储
|
|||
/// </summary>
|
|||
private readonly INormalEfCoreRepository<PUB_SA_DETAIL, Guid> _pubSaDetailRepository; |
|||
|
|||
/// <summary>
|
|||
/// PUB结算仓储
|
|||
/// </summary>
|
|||
private readonly INormalEfCoreRepository<PUB_SA, Guid> _pubSaRepository; |
|||
|
|||
/// <summary>
|
|||
/// 构造
|
|||
/// </summary>
|
|||
public PUB_SA_DETAIL_SERVICE(INormalEfCoreRepository<PUB_SA_DETAIL, Guid> pubSaDetailRepository, |
|||
INormalEfCoreRepository<PUB_SA, Guid> pubSaRepository, |
|||
IDistributedCache<PUB_SA_DETAIL> cache, |
|||
IExcelImportAppService excelImportService, |
|||
ISnowflakeIdGenerator snowflakeIdGenerator, |
|||
ICommonManager commonManager |
|||
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) |
|||
{ |
|||
_pubSaDetailRepository = pubSaDetailRepository; |
|||
_pubSaRepository = pubSaRepository; |
|||
} |
|||
|
|||
#region 导出
|
|||
/// <summary>
|
|||
/// 导出
|
|||
/// </summary>
|
|||
[HttpPost] |
|||
public async Task<string> ExportAsync(PUB_SA_DETAIL_EXPORT_REQUEST_DTO input) |
|||
{ |
|||
var pubSaEntity = await _pubSaRepository.FirstOrDefaultAsync(t=>t.BillNum == input.BillNum); |
|||
if (pubSaEntity == null) |
|||
{ |
|||
throw new UserFriendlyException($"导出失败,结算单号不存在!", "400"); |
|||
} |
|||
var businessType = pubSaEntity.BusinessType; |
|||
string fileName = $"{businessType.GetDisplayName()}结算数据_{Guid.NewGuid()}.xlsx"; |
|||
List<FilterCondition> filters = new List<FilterCondition>(); |
|||
filters.Add(new FilterCondition("BillNum", input.BillNum, EnumFilterAction.Equal, EnumFilterLogic.And)); |
|||
|
|||
var entities = await _pubSaDetailRepository.GetListByFilterAsync(filters); |
|||
var dtos = ObjectMapper.Map<List<PUB_SA_DETAIL>, List<PUB_SA_DETAIL_EXPORT_DTO>>(entities); |
|||
|
|||
ExportImporter _exportImporter = new ExportImporter(); |
|||
var result = await _exportImporter.ExcelExporter(dtos); |
|||
result.ShouldNotBeNull(); |
|||
|
|||
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result }); |
|||
return fileName; |
|||
} |
|||
#endregion
|
|||
|
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,24 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Migrations |
|||
{ |
|||
public partial class _202307192 : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.AddColumn<int>( |
|||
name: "BusinessType", |
|||
table: "Set_PUB_SA", |
|||
type: "int", |
|||
nullable: false, |
|||
defaultValue: 0); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropColumn( |
|||
name: "BusinessType", |
|||
table: "Set_PUB_SA"); |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue