From 92cb868a512feca65d6445ad7b1cf4a09d2ade37 Mon Sep 17 00:00:00 2001 From: "boxu.zheng" Date: Thu, 12 Oct 2023 09:19:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9Edatachange=E7=9A=84=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=92=8C=E4=BF=AE=E6=94=B9=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExchangeDatas/IExchangeDataAppService.cs | 3 + .../ExchangeDatas/ExchangeDataAppService.cs | 70 +++++++++++++++++++ 2 files changed, 73 insertions(+) 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; + } }