diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/ExchangeDatas/IExchangeDataAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/ExchangeDatas/IExchangeDataAppService.cs index dd22afc56..922964398 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/ExchangeDatas/IExchangeDataAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/ExchangeDatas/IExchangeDataAppService.cs @@ -11,4 +11,7 @@ public interface IExchangeDataAppService // Task ImportMergeAsync(IFormFile formFile, EnumFileType fileType = EnumFileType.Excel, EnumImportMethod method = EnumImportMethod.Update, bool isAllowPartImport = false); Task> GetToBeProcessedListAsync(int batchSize); Task ReSendByNumberAsync(Guid id); + Task> GetToBeProcessedListPostAsync(int batchSize); + Task> GetToBeProcessedListOnlyReadAsync(int batchSize); + Task> UpdateStatusByIdListAsync(List list); } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/ExchangeDatas/ExchangeDataAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/ExchangeDatas/ExchangeDataAppService.cs index dd2845396..382096e38 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/ExchangeDatas/ExchangeDataAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/ExchangeDatas/ExchangeDataAppService.cs @@ -1,9 +1,14 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; +using Castle.Components.DictionaryAdapter; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; using Volo.Abp; +using Volo.Abp.Domain.Entities; +using Volo.Abp.Domain.Repositories; using Volo.Abp.ObjectMapping; using Win_in.Sfs.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Application.Contracts; @@ -72,4 +77,69 @@ public class ExchangeDataAppService return new ExchangeDataDTO() { Id = entityNew.Id }; } + + [HttpPost("by-batchsize-post")] + public virtual async Task> GetToBeProcessedListPostAsync(int batchSize) + { + var resultList=new List(); + + var entities = await + (await _repository.GetDbSetAsync().ConfigureAwait(false)) + .Where(p => p.Status == EnumExchangeDataStatus.Unread) + .OrderBy(p => p.WriteTime) + .Take(batchSize) + .ToListAsync().ConfigureAwait(false); + + foreach (var entity in entities) + { + entity.Status = EnumExchangeDataStatus.Success; + entity.ReadTime = Clock.Now; + entity.Reader = "DataExchange.Agent"; + resultList.Add(await _repository.UpdateAsync(entity).ConfigureAwait(false)); + } + + var dtos = ObjectMapper.Map, List>(resultList); + return dtos; + } + + [HttpPost("by-batchsize-only-read")] + public virtual async Task> GetToBeProcessedListOnlyReadAsync(int batchSize) + { + var entities = await + (await _repository.GetDbSetAsync().ConfigureAwait(false)) + .Where(p => p.Status == EnumExchangeDataStatus.Unread) + .OrderBy(p => p.WriteTime) + .Take(batchSize) + .ToListAsync().ConfigureAwait(false); + + var dtos = ObjectMapper.Map, List>(entities); + return dtos; + } + + [HttpPost("update-status-by-id-list")] + public virtual async Task> UpdateStatusByIdListAsync(List list) + { + List listExchangeDatas = new EditableList(); + var resultList = new List(); + + foreach (var id in list) + { + listExchangeDatas.Add(await _repository.GetAsync(id).ConfigureAwait(false)); + } + + listExchangeDatas.ForEach(p => + { + p.Status = EnumExchangeDataStatus.Success; + p.ReadTime = Clock.Now; + p.Reader = "DataExchange.Agent"; + }); + + foreach (var entity in listExchangeDatas) + { + resultList.Add(await _repository.UpdateAsync(entity).ConfigureAwait(false)); + } + + var dtos = ObjectMapper.Map, List>(resultList); + return dtos; + } }