mahao
1 year ago
10 changed files with 151 additions and 19 deletions
@ -0,0 +1,51 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// PUB结算
|
||||
|
/// </summary>
|
||||
|
public class PUB_SA_DTO : EntityDto<Guid> |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 期间
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "期间")] |
||||
|
public int Version { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 结算单据
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "结算单据")] |
||||
|
public string BillNum { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 状态
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "状态")] |
||||
|
public string State { get; set; } |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 导入
|
||||
|
/// </summary>
|
||||
|
public class PUB_SA_IMPORT_DTO |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 导出
|
||||
|
/// </summary>
|
||||
|
public class PUB_SA_EXPORT_DTO |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
@ -1,43 +1,103 @@ |
|||||
using Microsoft.AspNetCore.Authorization; |
using Microsoft.AspNetCore.Authorization; |
||||
using Microsoft.AspNetCore.Components; |
using Microsoft.AspNetCore.Http; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
using SettleAccount.Domain.BQ; |
using SettleAccount.Domain.BQ; |
||||
|
using Shouldly; |
||||
using System; |
using System; |
||||
using System.Collections.Generic; |
using System.Collections.Generic; |
||||
using System.Linq; |
|
||||
using System.Text; |
|
||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Volo.Abp.Caching; |
||||
|
using Win.Abp.Snowflakes; |
||||
using Win.Sfs.BaseData.ImportExcelCommon; |
using Win.Sfs.BaseData.ImportExcelCommon; |
||||
|
using Win.Sfs.SettleAccount.CommonManagers; |
||||
|
using Win.Sfs.SettleAccount.Constant; |
||||
|
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; |
||||
|
using Win.Sfs.SettleAccount.ExcelImporter; |
||||
using Win.Sfs.Shared.RepositoryBase; |
using Win.Sfs.Shared.RepositoryBase; |
||||
|
|
||||
namespace Win.Sfs.SettleAccount.Entities.BQ |
namespace Win.Sfs.SettleAccount.Entities.BQ |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 公用结算
|
/// PUB结算
|
||||
/// </summary>
|
/// </summary>
|
||||
[AllowAnonymous] |
[AllowAnonymous] |
||||
[Route("api/settleaccount/[controller]/[action]")]
|
[Route("api/settleaccount/[controller]/[action]")]
|
||||
public class PUB_SA_SERVICE |
public class PUB_SA_SERVICE : SettleAccountApplicationBase<TB_RePartsRelationship> |
||||
{ |
{ |
||||
/// <summary>
|
/// <summary>
|
||||
/// 公用结算仓储
|
/// PUB结算仓储
|
||||
/// </summary>
|
/// </summary>
|
||||
private readonly INormalEfCoreRepository<PUB_SA, Guid> _repository; |
private readonly INormalEfCoreRepository<PUB_SA, Guid> _repository; |
||||
|
|
||||
/// <summary>
|
/// <summary>
|
||||
/// excel服务
|
/// 构造
|
||||
/// </summary>
|
/// </summary>
|
||||
private readonly IExcelImportAppService _excelImportService; |
public PUB_SA_SERVICE(INormalEfCoreRepository<PUB_SA, Guid> repository, |
||||
|
IDistributedCache<TB_RePartsRelationship> cache, |
||||
|
IExcelImportAppService excelImportService, |
||||
|
ISnowflakeIdGenerator snowflakeIdGenerator, |
||||
|
ICommonManager commonManager |
||||
|
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) |
||||
|
{ |
||||
|
_repository = repository; |
||||
|
} |
||||
|
|
||||
|
#region 导入、导出
|
||||
/// <summary>
|
/// <summary>
|
||||
/// 构造
|
/// 导入
|
||||
/// </summary>
|
/// </summary>
|
||||
public PUB_SA_SERVICE(INormalEfCoreRepository<PUB_SA, Guid> repository, IExcelImportAppService excelImportService) |
[HttpPost] |
||||
|
public async Task<string> ImportAsync([FromForm] IFormFileCollection files) |
||||
{ |
{ |
||||
_repository = repository; |
ExportImporter _exportImporter = new ExportImporter(); |
||||
_excelImportService = excelImportService; |
var result = await _exportImporter.UploadExcelImport<PUB_SA_IMPORT_DTO>(files, _excelImportService); |
||||
|
var _ls = ObjectMapper.Map<List<PUB_SA_IMPORT_DTO>, List<PUB_SA>>(result); |
||||
|
await _repository.InsertManyAsync(_ls); |
||||
|
return ApplicationConsts.SuccessStr; |
||||
} |
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 导出
|
||||
|
/// </summary>
|
||||
|
[HttpPost] |
||||
|
public async Task<string> ExportAsync(RequestDto input) |
||||
|
{ |
||||
|
string fileName = $"HBPO的EDI数据_{Guid.NewGuid()}.xlsx"; |
||||
|
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); |
||||
|
var dtos = ObjectMapper.Map<List<PUB_SA>, List<PUB_SA_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
|
||||
|
|
||||
|
#region CURD
|
||||
|
/// <summary>
|
||||
|
/// 获取列表
|
||||
|
/// </summary>
|
||||
|
[HttpPost] |
||||
|
public async Task<PagedResultDto<PUB_SA_DTO>> GetListAsync(RequestDto input) |
||||
|
{ |
||||
|
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true); |
||||
|
var totalCount = await _repository.GetCountByFilterAsync(input.Filters); |
||||
|
var dtos = ObjectMapper.Map<List<PUB_SA>, List<PUB_SA_DTO>>(entities); |
||||
|
return new PagedResultDto<PUB_SA_DTO>(totalCount, dtos); |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 删除
|
||||
|
/// </summary>
|
||||
|
[HttpPost] |
||||
|
public async Task DeleteAsync(Guid id) |
||||
|
{ |
||||
|
await _repository.DeleteAsync(id); |
||||
|
} |
||||
|
#endregion
|
||||
|
|
||||
} |
} |
||||
} |
} |
||||
|
Loading…
Reference in new issue