mahao
1 year ago
14 changed files with 4664 additions and 590 deletions
@ -0,0 +1,21 @@ |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Win.Sfs.Shared.Filter; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Bases |
|||
{ |
|||
public class RequestInputBase: PagedAndSortedResultRequestDto |
|||
{ |
|||
/// <summary>
|
|||
/// 导出文件类型
|
|||
/// </summary>
|
|||
public int FileType { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 高级检索
|
|||
/// </summary>
|
|||
[Display(Name = "高级检索")] |
|||
public virtual List<FilterCondition> Filters { get; set; } = new List<FilterCondition>(); |
|||
} |
|||
} |
@ -0,0 +1,150 @@ |
|||
using Castle.Core.Internal; |
|||
using Magicodes.ExporterAndImporter.Core; |
|||
using Magicodes.ExporterAndImporter.Csv; |
|||
using Magicodes.ExporterAndImporter.Excel; |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Shouldly; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Linq; |
|||
using System.Reflection; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Application.Services; |
|||
using Volo.Abp.Domain.Entities; |
|||
using Win.Sfs.BaseData.ImportExcelCommon; |
|||
using Win.Sfs.SettleAccount.Constant; |
|||
using Win.Sfs.SettleAccount.Entities.Prices; |
|||
using Win.Sfs.SettleAccount.ExcelImporter; |
|||
using Win.Sfs.Shared.RepositoryBase; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Bases |
|||
{ |
|||
public abstract class CurdBaseAppService<TEntity, TEntityDto, TRequestInput, TCreateInput, TImportInput, TExportDto> : ApplicationService |
|||
where TEntity : class, IEntity<Guid> |
|||
where TEntityDto : class, IEntityDto<Guid>, new() |
|||
where TRequestInput : RequestInputBase |
|||
where TImportInput : class, new() |
|||
where TExportDto : class, new() |
|||
{ |
|||
private readonly INormalEfCoreRepository<TEntity, Guid> _repository; |
|||
private readonly IExcelImportAppService _excelImportService; |
|||
|
|||
protected CurdBaseAppService(INormalEfCoreRepository<TEntity, Guid> repository, IExcelImportAppService excelImportService) |
|||
{ |
|||
_repository = repository; |
|||
_excelImportService = excelImportService; |
|||
} |
|||
|
|||
#region 导入、导出
|
|||
/// <summary>
|
|||
/// 获取导入模板
|
|||
/// </summary>
|
|||
[HttpPost("import-template")] |
|||
public virtual async Task<IActionResult> ImportTemplateAsync() |
|||
{ |
|||
await Task.CompletedTask; |
|||
return new Microsoft.AspNetCore.Mvc.OkResult(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 导入
|
|||
/// </summary>
|
|||
[HttpPost] |
|||
[Route("Import")] |
|||
public virtual async Task<string> ImportAsync([FromForm] IFormFileCollection files, string version) |
|||
{ |
|||
await Task.CompletedTask; |
|||
return ApplicationConsts.SuccessStr; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 导出
|
|||
/// </summary>
|
|||
[HttpPost] |
|||
[Route("Export")] |
|||
public virtual async Task<string> ExportAsync(TRequestInput input) |
|||
{ |
|||
IExporter _csv = new CsvExporter(); |
|||
IExporter _excel = new ExcelExporter(); |
|||
|
|||
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); |
|||
var dtoDetails = ObjectMapper.Map<List<TEntity>, List<TExportDto>>(entities); |
|||
|
|||
var classDisplayName = typeof(TExportDto).GetCustomAttribute<DisplayAttribute>()?.Name ?? typeof(TExportDto).Name; |
|||
string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx"; |
|||
byte[] result = null; |
|||
|
|||
switch (input.FileType) |
|||
{ |
|||
case 0: |
|||
result = await _csv.ExportAsByteArray(dtoDetails); |
|||
break; |
|||
case 1: |
|||
result = await _excel.ExportAsByteArray(dtoDetails); |
|||
break; |
|||
} |
|||
result.ShouldNotBeNull(); |
|||
|
|||
//保存导出文件到服务器存成二进制
|
|||
await _excelImportService.SaveBlobAsync( |
|||
new SaveExcelImportInputDto |
|||
{ |
|||
Name = _fileName, |
|||
Content = result |
|||
} |
|||
); |
|||
return _fileName; |
|||
} |
|||
#endregion
|
|||
|
|||
#region CURD
|
|||
/// <summary>
|
|||
/// 新增
|
|||
/// </summary>
|
|||
[HttpPost("")] |
|||
public virtual async Task<TEntityDto> CreateAsync(TCreateInput input) |
|||
{ |
|||
var entity = ObjectMapper.Map<TCreateInput, TEntity>(input); |
|||
await _repository.InsertAsync(entity, autoSave: true).ConfigureAwait(continueOnCapturedContext: false); |
|||
return ObjectMapper.Map<TEntity, TEntityDto > (entity); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取列表
|
|||
/// </summary>
|
|||
[HttpPost] |
|||
[Route("list")] |
|||
public virtual async Task<PagedResultDto<TEntityDto>> GetListAsync(TRequestInput input) |
|||
{ |
|||
var entitys = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount); |
|||
var totalCount = await _repository.GetCountByFilterAsync(input.Filters); |
|||
var dtos = ObjectMapper.Map<List<TEntity>, List<TEntityDto>>(entitys); |
|||
return new PagedResultDto<TEntityDto>(totalCount, dtos); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 删除
|
|||
/// </summary>
|
|||
[HttpDelete] |
|||
[Route("{id}")] |
|||
virtual public async Task DeleteAsync(Guid id) |
|||
{ |
|||
await _repository.DeleteAsync(id); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 批量删除
|
|||
/// </summary>
|
|||
[HttpPost] |
|||
[Route("delete")] |
|||
virtual public async Task<bool> DeleteListAsync(List<Guid> ids) |
|||
{ |
|||
return await _repository.DeleteListAsync(ids); |
|||
} |
|||
#endregion
|
|||
|
|||
} |
|||
} |
@ -1,41 +0,0 @@ |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Application.Services; |
|||
using Win.Sfs.BaseData.ImportExcelCommon; |
|||
using Win.Sfs.SettleAccount.Entities.ImportMap; |
|||
using Win.Sfs.SettleAccount.Entities.Prices; |
|||
using Win.Sfs.SettleAccount.Entities.TaskJobs; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Entities.BQ.Prices |
|||
{ |
|||
/// <summary>
|
|||
/// 标准价格单-相关应用服务
|
|||
/// </summary>
|
|||
[Authorize(SettleAccountPermissions.PriceLists.Default)] |
|||
[Route("api/SettleAccount/TB_PRICE_LIST_Service")] |
|||
public class PriceListAppService : ApplicationService |
|||
{ |
|||
private readonly PriceListManager _mng; |
|||
private readonly IExcelImportAppService _excelImportService; |
|||
private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _mapRepository; |
|||
private readonly TaskJobService _service; |
|||
public PriceListAppService( |
|||
IExcelImportAppService excelImportService, |
|||
ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> mapRepository, |
|||
PriceListManager mng, |
|||
TaskJobService service |
|||
) |
|||
{ |
|||
_mapRepository = mapRepository; |
|||
_excelImportService = excelImportService; |
|||
_mng = mng; |
|||
_service = service; |
|||
} |
|||
|
|||
} |
|||
} |
File diff suppressed because it is too large
@ -0,0 +1,33 @@ |
|||
using Microsoft.EntityFrameworkCore.Migrations; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Migrations |
|||
{ |
|||
public partial class _202307111 : Migration |
|||
{ |
|||
protected override void Up(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.AddColumn<string>( |
|||
name: "ClientCode", |
|||
table: "Set_PriceListBJ", |
|||
type: "nvarchar(max)", |
|||
nullable: true); |
|||
|
|||
migrationBuilder.AddColumn<string>( |
|||
name: "LU", |
|||
table: "Set_PriceListBJ", |
|||
type: "nvarchar(max)", |
|||
nullable: true); |
|||
} |
|||
|
|||
protected override void Down(MigrationBuilder migrationBuilder) |
|||
{ |
|||
migrationBuilder.DropColumn( |
|||
name: "ClientCode", |
|||
table: "Set_PriceListBJ"); |
|||
|
|||
migrationBuilder.DropColumn( |
|||
name: "LU", |
|||
table: "Set_PriceListBJ"); |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue