44673626
3 years ago
5 changed files with 811 additions and 3 deletions
@ -0,0 +1,322 @@ |
|||
using Magicodes.ExporterAndImporter.Core; |
|||
using Magicodes.ExporterAndImporter.Csv; |
|||
using Magicodes.ExporterAndImporter.Excel; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Guids; |
|||
using Win.Sfs.BaseData.ImportExcelCommon; |
|||
using Win.Sfs.SettleAccount.Entities.WMSKanBan; |
|||
using Win.Sfs.Shared.Filter; |
|||
using Shouldly; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.Caching; |
|||
using Win.Abp.Snowflakes; |
|||
using Win.Sfs.SettleAccount.CommonManagers; |
|||
using Volo.Abp; |
|||
using Microsoft.AspNetCore.Http; |
|||
using Win.Sfs.SettleAccount.ExcelImporter; |
|||
using EFCore.BulkExtensions; |
|||
using Win.Sfs.SettleAccount.ExportReports; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Win.Sfs.SettleAccount.Constant; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Volo.Abp.Application.Dtos; |
|||
|
|||
namespace Win.Sfs.SettleAccount.Entities.WMS_KanBan |
|||
{ |
|||
/// <summary>
|
|||
/// 大众看板发货明细
|
|||
/// </summary>
|
|||
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|||
//[AllowAnonymous]
|
|||
[Route("api/settleaccount/WMSVWKanBan")] |
|||
public class WMSKanBanAppService : SettleAccountApplicationBase<WMSKanBanSettle>, IWMSVWKanBanAppService |
|||
{ |
|||
private readonly IGuidGenerator _guidGenerator; |
|||
|
|||
private readonly IExcelImportAppService _excelImportService; |
|||
|
|||
private readonly ISettleAccountBranchEfCoreRepository<WMSKanBanVersion, Guid> _versionRepository; |
|||
|
|||
private readonly ISettleAccountBranchEfCoreRepository<WMSKanBanSettle, Guid> _repository; |
|||
/// <summary>
|
|||
/// 构建方法
|
|||
/// </summary>
|
|||
/// <param name="guidGenerator">构建UID</param>
|
|||
/// <param name="repository">仓储接口</param>
|
|||
/// <param name="cache">缓存</param>
|
|||
public WMSKanBanAppService(IGuidGenerator guidGenerator, |
|||
ISettleAccountBranchEfCoreRepository<WMSKanBanVersion, Guid> versionRepository, |
|||
ISettleAccountBranchEfCoreRepository<WMSKanBanSettle, Guid> repository, |
|||
IDistributedCache<WMSKanBanSettle> cache, |
|||
IExcelImportAppService excelImportService, |
|||
ISnowflakeIdGenerator snowflakeIdGenerator, |
|||
ICommonManager commonManager |
|||
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) |
|||
{ |
|||
_versionRepository = versionRepository; |
|||
_guidGenerator = guidGenerator; |
|||
_excelImportService = excelImportService; |
|||
_repository = repository; |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 导入功能
|
|||
/// </summary>
|
|||
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
|
|||
/// <returns></returns>
|
|||
[HttpPost] |
|||
[Route("ExcelImport")] |
|||
[DisableRequestSizeLimit] |
|||
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|||
public async Task<string> WMSVWKanBanUploadExcelImport([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode) |
|||
{ |
|||
if (string.IsNullOrEmpty(version)) |
|||
{ |
|||
throw new BusinessException("版本不能空,必须传入!"); |
|||
} |
|||
List<WMSVWKanBanImportDto> listImport = new List<WMSVWKanBanImportDto>(); |
|||
ExportImporter _exportImporter = new ExportImporter(); |
|||
var result = await _exportImporter.UploadExcelImport<WMSVWKanBanImportDto>(files, _excelImportService); |
|||
var entityList = ObjectMapper.Map<List<WMSVWKanBanImportDto>, List<WMSKanBanSettle>>(result); |
|||
//删除版本
|
|||
var _versionQuery = _versionRepository.Where(p => p.Version == version); |
|||
await _versionQuery.BatchDeleteAsync(); |
|||
//删除明细
|
|||
var _query = _repository.Where(p => p.Version == version); |
|||
await _query.BatchDeleteAsync(); |
|||
//插入数据前检验
|
|||
var checkList = new List<ErrorExportDto>(); |
|||
var _group = entityList.GroupBy(x => new { x.Kanban, x.MaterialCode, x.Version }).Select(p => new { Count = p.Count(), Kanban = p.Key.Kanban, MaterialCode = p.Key.MaterialCode }); |
|||
foreach (var itm in _group) |
|||
{ |
|||
if (itm.Count > 1) |
|||
{ |
|||
checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("导入的零件号{0},其看板条码号{1}有重复数据,请检查!", itm.MaterialCode, itm.Kanban), string.Empty)); |
|||
} |
|||
} |
|||
var _id = GuidGenerator.Create(); |
|||
var _bomList = new List<WMSKanBanVersion>(); |
|||
_bomList.Add(new WMSKanBanVersion(_id, branchId, year, period, version, customerCode)); |
|||
foreach (var itm in entityList) |
|||
{ |
|||
itm.SetValue(GuidGenerator.Create(), branchId, year, period, version, _id); |
|||
} |
|||
if (checkList.Count > 0) |
|||
{ |
|||
return await ExportErrorReportAsync(checkList); |
|||
} |
|||
await _repository.GetDbContext().BulkInsertAsync<WMSKanBanSettle>(entityList); |
|||
await _versionRepository.GetDbContext().BulkInsertAsync(_bomList); |
|||
return ApplicationConsts.SuccessStr; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 按ID获取唯一实体
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 返回实体全部属性
|
|||
/// </remarks>
|
|||
/// <param name="id">ID</param>
|
|||
/// <returns>实体DTO</returns>
|
|||
[HttpGet] |
|||
[Route("{id}")] |
|||
[Authorize(SettleAccountPermissions.SettleAccounts.Default)] |
|||
virtual public async Task<WMSVWKanBanDto> GetAsync(Guid id) |
|||
{ |
|||
var result = await GetFromCacheAsync(id); |
|||
var dto = ObjectMapper.Map<WMSKanBanSettle, WMSVWKanBanDto>(result); |
|||
return dto; |
|||
} |
|||
|
|||
|
|||
private async Task<WMSKanBanSettle> GetFromCacheAsync(Guid id) |
|||
{ |
|||
var result = await _repository.GetAsync(id); |
|||
return result; |
|||
} |
|||
|
|||
|
|||
private async Task<long> GetCountAsync(WMSVWKanBanRequestDto input) |
|||
{ |
|||
return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters); |
|||
} |
|||
|
|||
private async Task<long> GetCountAsync(WMSVWKanBanVersionRequestDto input) |
|||
{ |
|||
return await _versionRepository.GetCountByFilterAsync(input.BranchId, input.Filters); |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 导出文件
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
/// <returns></returns>
|
|||
[HttpPost] |
|||
[Route("Export")] |
|||
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|||
virtual public async Task<string> ExportAsync(WMSVWKanBanRequestDto input) |
|||
{ |
|||
|
|||
IExporter _csv = new CsvExporter(); |
|||
IExporter _excel = new ExcelExporter(); |
|||
|
|||
if (!string.IsNullOrEmpty(input.Version)) |
|||
{ |
|||
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version }); |
|||
} |
|||
var entities = await _repository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, int.MaxValue, |
|||
0, true); |
|||
|
|||
var dtoDetails = ObjectMapper.Map<List<WMSKanBanSettle>, List<WMSVWKanBanExportDto>>(entities); |
|||
|
|||
string _fileName = string.Empty; |
|||
//声明导出容器
|
|||
|
|||
byte[] result = null; |
|||
switch (input.FileType) |
|||
{ |
|||
case 0: |
|||
_fileName = string.Format("大众看板发货明细_{0}.csv", input.UserId.ToString()); |
|||
result = await _csv.ExportAsByteArray(dtoDetails); |
|||
break; |
|||
case 1: |
|||
_fileName = string.Format("大众看板发货明细_{0}.xlsx", input.UserId.ToString()); |
|||
result = await _excel.ExportAsByteArray(dtoDetails); |
|||
break; |
|||
} |
|||
result.ShouldNotBeNull(); |
|||
|
|||
//保存导出文件到服务器存成二进制
|
|||
await _excelImportService.SaveBlobAsync( |
|||
new SaveExcelImportInputDto |
|||
{ |
|||
Name = _fileName, |
|||
Content = result |
|||
} |
|||
); |
|||
return _fileName; |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 根据筛选条件获取实体列表
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
|
|||
/// </remarks>
|
|||
/// <param name="input">请求条件</param>
|
|||
/// <returns>实体DTO列表</returns>
|
|||
[HttpPost] |
|||
[Route("list")] |
|||
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|||
virtual public async Task<PagedResultDto<WMSVWKanBanDto>> GetListAsync(WMSVWKanBanRequestDto input) |
|||
{ |
|||
|
|||
if (!string.IsNullOrEmpty(input.Version)) |
|||
{ |
|||
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version }); |
|||
} |
|||
else |
|||
{ |
|||
return new PagedResultDto<WMSVWKanBanDto>(0, new List<WMSVWKanBanDto>()); |
|||
} |
|||
var entities = await _repository.GetListByFilterAsync(GuidGenerator.Create(), input.Filters, input.Sorting, input.MaxResultCount, |
|||
input.SkipCount, true); |
|||
var totalCount = await GetCountAsync(input); |
|||
var dtos = ObjectMapper.Map<List<WMSKanBanSettle>, List<WMSVWKanBanDto>>(entities); |
|||
return new PagedResultDto<WMSVWKanBanDto>(totalCount, dtos); |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 获取实体总数
|
|||
/// </summary>
|
|||
/// <returns>实体总数</returns>
|
|||
[HttpGet] |
|||
[Route("count")] |
|||
[Authorize(SettleAccountPermissions.SettleAccounts.Default)] |
|||
virtual public async Task<long> GetTotalCountAsync(Guid branchId) |
|||
{ |
|||
return await _repository.GetCountAsync(branchId); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取全部实体列表
|
|||
/// </summary>
|
|||
/// <returns>实体DTO列表</returns>
|
|||
[HttpGet] |
|||
[Route("all")] |
|||
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|||
virtual public async Task<ListResultDto<WMSVWKanBanDto>> GetAllAsync(Guid branchId) |
|||
{ |
|||
var entities = await _repository.GetAllAsync(branchId, true); |
|||
|
|||
|
|||
var dtos = ObjectMapper.Map<List<WMSKanBanSettle>, List<WMSVWKanBanDto>>(entities); |
|||
|
|||
|
|||
return new ListResultDto<WMSVWKanBanDto>(dtos); |
|||
} |
|||
|
|||
|
|||
|
|||
/// <summary>
|
|||
/// 删除实体
|
|||
/// </summary>
|
|||
/// <param name="id">ID</param>
|
|||
/// <returns>无</returns>
|
|||
[HttpDelete] |
|||
[Route("{id}")] |
|||
/// [Authorize(SettleAccountPermissions.SettleAccounts.Delete)]
|
|||
virtual public async Task DeleteAsync(Guid id) |
|||
{ |
|||
await _repository.DeleteAsync(id); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 按IDs删除实体列表
|
|||
/// </summary>
|
|||
/// <param name="ids">IDs</param>
|
|||
/// <returns>是否执行成功</returns>
|
|||
[HttpPost] |
|||
[Route("delete")] |
|||
// [Authorize(SettleAccountPermissions.SettleAccounts.Delete)]
|
|||
virtual public async Task<bool> DeleteListAsync(List<Guid> ids) |
|||
{ |
|||
foreach (var id in ids) |
|||
{ |
|||
var entity = await GetFromCacheAsync(id); |
|||
//await Cache.DeleteAsync<SettleAccount>(id.ToString());
|
|||
} |
|||
|
|||
return await _repository.DeleteListAsync(ids); |
|||
} |
|||
|
|||
|
|||
|
|||
/// <summary>
|
|||
/// 版本列表查询
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
/// <returns></returns>
|
|||
[HttpPost] |
|||
[Route("listversion")] |
|||
public async Task<PagedResultDto<WMSVWKanBanVersionDto>> GetVersionListAsync(WMSVWKanBanVersionRequestDto input) |
|||
{ |
|||
var entities = await _versionRepository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, |
|||
input.SkipCount, true); |
|||
|
|||
var totalCount = await GetCountAsync(input); |
|||
var dtos = ObjectMapper.Map<List<WMSKanBanVersion>, List<WMSVWKanBanVersionDto>>(entities); |
|||
|
|||
return new PagedResultDto<WMSVWKanBanVersionDto>(totalCount, dtos); |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,326 @@ |
|||
using EFCore.BulkExtensions; |
|||
using Magicodes.ExporterAndImporter.Core; |
|||
using Magicodes.ExporterAndImporter.Csv; |
|||
using Magicodes.ExporterAndImporter.Excel; |
|||
using Microsoft.AspNetCore.Authorization; |
|||
using Microsoft.AspNetCore.Http; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.Caching; |
|||
using Volo.Abp.Domain.Repositories; |
|||
using Volo.Abp.Guids; |
|||
using Win.Abp.Snowflakes; |
|||
using Win.Sfs.BaseData.ImportExcelCommon; |
|||
using Win.Sfs.SettleAccount.CommonManagers; |
|||
using Win.Sfs.SettleAccount.Constant; |
|||
using Win.Sfs.SettleAccount.Entities.WMSSparePart; |
|||
using Win.Sfs.SettleAccount.ExcelImporter; |
|||
using Win.Sfs.SettleAccount.ExportReports; |
|||
using Win.Sfs.Shared.Filter; |
|||
using Shouldly; |
|||
|
|||
|
|||
|
|||
|
|||
namespace Win.Sfs.SettleAccount.Entities.WMS_SparePart |
|||
{ |
|||
/// <summary>
|
|||
/// 大众备件服务
|
|||
/// </summary>
|
|||
[Route("api/settleaccount/WMSSparePart")] |
|||
public class WMSSparePartAppService : SettleAccountApplicationBase<WMSSparePart>, IWMSSparePartAppService |
|||
{ |
|||
private readonly IGuidGenerator _guidGenerator; |
|||
|
|||
private readonly IExcelImportAppService _excelImportService; |
|||
|
|||
private readonly ISettleAccountBranchEfCoreRepository<WMSSparePartVersion, Guid> _versionRepository; |
|||
|
|||
private readonly ISettleAccountBranchEfCoreRepository<WMSSparePart, Guid> _repository; |
|||
/// <summary>
|
|||
/// 构建方法
|
|||
/// </summary>
|
|||
/// <param name="guidGenerator">构建UID</param>
|
|||
/// <param name="repository">仓储接口</param>
|
|||
/// <param name="cache">缓存</param>
|
|||
public WMSSparePartAppService(IGuidGenerator guidGenerator, |
|||
ISettleAccountBranchEfCoreRepository<WMSSparePartVersion, Guid> versionRepository, |
|||
ISettleAccountBranchEfCoreRepository<WMSSparePart, Guid> repository, |
|||
IDistributedCache<WMSSparePart> cache, |
|||
IExcelImportAppService excelImportService, |
|||
ISnowflakeIdGenerator snowflakeIdGenerator, |
|||
ICommonManager commonManager |
|||
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) |
|||
{ |
|||
_versionRepository = versionRepository; |
|||
_guidGenerator = guidGenerator; |
|||
_excelImportService = excelImportService; |
|||
_repository = repository; |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 导入功能
|
|||
/// </summary>
|
|||
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
|
|||
/// <returns></returns>
|
|||
[HttpPost] |
|||
[Route("ExcelImport")] |
|||
[DisableRequestSizeLimit] |
|||
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|||
public async Task<string> WMSSparePartUploadExcelImport([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode) |
|||
{ |
|||
if (string.IsNullOrEmpty(version)) |
|||
{ |
|||
throw new BusinessException("版本不能空,必须传入!"); |
|||
} |
|||
ExportImporter _exportImporter = new ExportImporter(); |
|||
var result = await _exportImporter.UploadExcelImport<WMSSparePartImportDto>(files, _excelImportService); |
|||
var entityList = ObjectMapper.Map<List<WMSSparePartImportDto>, List<WMSSparePart>>(result); |
|||
//删除版本
|
|||
var _versionQuery = _versionRepository.Where(p => p.Version == version); |
|||
await _versionQuery.BatchDeleteAsync(); |
|||
//删除明细
|
|||
var _query = _repository.Where(p => p.Version == version); |
|||
await _query.BatchDeleteAsync(); |
|||
//插入数据前检验
|
|||
var checkList = new List<ErrorExportDto>(); |
|||
var _group = entityList.GroupBy(x => new { x.LineNumber, x.MaterialCode, x.Version }).Select(p => new { Count = p.Count(), LineNumber = p.Key.LineNumber, MaterialCode = p.Key.MaterialCode }); |
|||
foreach (var itm in _group) |
|||
{ |
|||
if (string.IsNullOrEmpty(itm.MaterialCode)) |
|||
{ |
|||
checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("导入的行号为{0}的物料代码为空,请检查!", itm.LineNumber), string.Empty)); |
|||
} |
|||
} |
|||
var _id = GuidGenerator.Create(); |
|||
var _bomList = new List<WMSSparePartVersion>(); |
|||
_bomList.Add(new WMSSparePartVersion(_id, branchId, year, period, version, customerCode)); |
|||
foreach (var itm in entityList) |
|||
{ |
|||
itm.SetValue(GuidGenerator.Create(), branchId, year, period, version); |
|||
} |
|||
if (checkList.Count > 0) |
|||
{ |
|||
return await ExportErrorReportAsync(checkList); |
|||
} |
|||
await _repository.GetDbContext().BulkInsertAsync<WMSSparePart>(entityList); |
|||
await _versionRepository.GetDbContext().BulkInsertAsync(_bomList); |
|||
return ApplicationConsts.SuccessStr; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 按ID获取唯一实体
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 返回实体全部属性
|
|||
/// </remarks>
|
|||
/// <param name="id">ID</param>
|
|||
/// <returns>实体DTO</returns>
|
|||
[HttpGet] |
|||
[Route("{id}")] |
|||
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|||
virtual public async Task<WMSSparePartDto> GetAsync(Guid id) |
|||
{ |
|||
var result = await GetFromCacheAsync(id); |
|||
var dto = ObjectMapper.Map<WMSSparePart, WMSSparePartDto>(result); |
|||
return dto; |
|||
} |
|||
|
|||
|
|||
private async Task<WMSSparePart> GetFromCacheAsync(Guid id) |
|||
{ |
|||
var result = await _repository.GetAsync(id); |
|||
return result; |
|||
} |
|||
|
|||
|
|||
private async Task<long> GetCountAsync(WMSSparePartRequestDto input) |
|||
{ |
|||
return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters); |
|||
} |
|||
|
|||
private async Task<long> GetCountAsync(WMSSparePartVersionRequestDto input) |
|||
{ |
|||
return await _versionRepository.GetCountByFilterAsync(input.BranchId, input.Filters); |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 导出文件
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
/// <returns></returns>
|
|||
[HttpPost] |
|||
[Route("Export")] |
|||
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|||
virtual public async Task<string> ExportAsync(WMSSparePartRequestDto input) |
|||
{ |
|||
if (string.IsNullOrEmpty(input.Version)) |
|||
{ |
|||
throw new BusinessException("版本不能空,必须传入!"); |
|||
} |
|||
IExporter _csv = new CsvExporter(); |
|||
IExporter _excel = new ExcelExporter(); |
|||
if (!string.IsNullOrEmpty(input.Version)) |
|||
{ |
|||
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version }); |
|||
} |
|||
var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, |
|||
0, true); |
|||
|
|||
var dtoDetails = ObjectMapper.Map<List<WMSSparePart>, List<WMSSparePartExportDto>>(entities); |
|||
|
|||
string _fileName = string.Empty; |
|||
//声明导出容器
|
|||
|
|||
byte[] result = null; |
|||
switch (input.FileType) |
|||
{ |
|||
case 0: |
|||
_fileName = string.Format("大众备件发货明细_{0}.csv", input.UserId.ToString()); |
|||
result = await _csv.ExportAsByteArray(dtoDetails); |
|||
break; |
|||
case 1: |
|||
_fileName = string.Format("大众备件发货明细_{0}.xlsx", input.UserId.ToString()); |
|||
result = await _excel.ExportAsByteArray(dtoDetails); |
|||
break; |
|||
} |
|||
result.ShouldNotBeNull(); |
|||
|
|||
//保存导出文件到服务器存成二进制
|
|||
await _excelImportService.SaveBlobAsync( |
|||
new SaveExcelImportInputDto |
|||
{ |
|||
Name = _fileName, |
|||
Content = result |
|||
} |
|||
); |
|||
return _fileName; |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 根据筛选条件获取实体列表
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
|
|||
/// </remarks>
|
|||
/// <param name="input">请求条件</param>
|
|||
/// <returns>实体DTO列表</returns>
|
|||
[HttpPost] |
|||
[Route("list")] |
|||
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|||
virtual public async Task<PagedResultDto<WMSSparePartDto>> GetListAsync(WMSSparePartRequestDto input) |
|||
{ |
|||
if (!string.IsNullOrEmpty(input.Version)) |
|||
{ |
|||
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version }); |
|||
} |
|||
else |
|||
{ |
|||
return new PagedResultDto<WMSSparePartDto>(0, new List<WMSSparePartDto>()); |
|||
} |
|||
|
|||
var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, input.MaxResultCount, |
|||
input.SkipCount, true); |
|||
|
|||
var totalCount = await GetCountAsync(input); |
|||
var dtos = ObjectMapper.Map<List<WMSSparePart>, List<WMSSparePartDto>>(entities); |
|||
|
|||
return new PagedResultDto<WMSSparePartDto>(totalCount, dtos); |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 获取实体总数
|
|||
/// </summary>
|
|||
/// <returns>实体总数</returns>
|
|||
[HttpGet] |
|||
[Route("count")] |
|||
[Authorize(SettleAccountPermissions.SettleAccounts.Default)] |
|||
virtual public async Task<long> GetTotalCountAsync(Guid branchId) |
|||
{ |
|||
return await _repository.GetCountAsync(branchId); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取全部实体列表
|
|||
/// </summary>
|
|||
/// <returns>实体DTO列表</returns>
|
|||
[HttpGet] |
|||
[Route("all")] |
|||
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
|
|||
virtual public async Task<ListResultDto<WMSSparePartDto>> GetAllAsync(Guid branchId) |
|||
{ |
|||
var entities = await _repository.GetAllAsync(branchId, true); |
|||
|
|||
|
|||
var dtos = ObjectMapper.Map<List<WMSSparePart>, List<WMSSparePartDto>>(entities); |
|||
|
|||
|
|||
return new ListResultDto<WMSSparePartDto>(dtos); |
|||
} |
|||
|
|||
|
|||
|
|||
/// <summary>
|
|||
/// 删除实体
|
|||
/// </summary>
|
|||
/// <param name="id">ID</param>
|
|||
/// <returns>无</returns>
|
|||
[HttpDelete] |
|||
[Route("{id}")] |
|||
/// [Authorize(SettleAccountPermissions.SettleAccounts.Delete)]
|
|||
virtual public async Task DeleteAsync(Guid id) |
|||
{ |
|||
await _repository.DeleteAsync(id); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 按IDs删除实体列表
|
|||
/// </summary>
|
|||
/// <param name="ids">IDs</param>
|
|||
/// <returns>是否执行成功</returns>
|
|||
[HttpPost] |
|||
[Route("delete")] |
|||
// [Authorize(SettleAccountPermissions.SettleAccounts.Delete)]
|
|||
virtual public async Task<bool> DeleteListAsync(List<Guid> ids) |
|||
{ |
|||
foreach (var id in ids) |
|||
{ |
|||
var entity = await GetFromCacheAsync(id); |
|||
//await Cache.DeleteAsync<SettleAccount>(id.ToString());
|
|||
} |
|||
|
|||
return await _repository.DeleteListAsync(ids); |
|||
} |
|||
|
|||
|
|||
|
|||
/// <summary>
|
|||
/// 版本列表查询
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
/// <returns></returns>
|
|||
[HttpPost] |
|||
[Route("listversion")] |
|||
public async Task<PagedResultDto<WMSSparePartVersionDto>> GetVersionListAsync(WMSSparePartVersionRequestDto input) |
|||
{ |
|||
var entities = await _versionRepository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, |
|||
input.SkipCount, true); |
|||
|
|||
var totalCount = await GetCountAsync(input); |
|||
var dtos = ObjectMapper.Map<List<WMSSparePartVersion>, List<WMSSparePartVersionDto>>(entities); |
|||
|
|||
return new PagedResultDto<WMSSparePartVersionDto>(totalCount, dtos); |
|||
} |
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue