From ceda5ecff7ccff9d3a7a72b5123d7f32f2ce336c Mon Sep 17 00:00:00 2001 From: mahao Date: Tue, 16 May 2023 16:38:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=9B=9E=E5=86=B2=E7=9A=84?= =?UTF-8?q?=E9=9B=B6=E4=BB=B6=E6=8F=8F=E8=BF=B0=E4=B8=BA=E7=A9=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BackFlushNotes/BackFlushNoteAppService.cs | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/BackFlushNotes/BackFlushNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/BackFlushNotes/BackFlushNoteAppService.cs index 90f9f8fd1..07e300af2 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/BackFlushNotes/BackFlushNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/BackFlushNotes/BackFlushNoteAppService.cs @@ -1,14 +1,15 @@ +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; using Win_in.Sfs.Wms.Store.Domain.Shared; namespace Win_in.Sfs.Wms.Store.Application; -using System.Collections.Generic; - [Authorize] [Route($"{StoreConsts.RootPath}backFlush-note")] public class BackFlushNoteAppService : @@ -17,17 +18,22 @@ public class BackFlushNoteAppService : IBackFlushNoteAppService { private readonly IBackFlushNoteManager _backFlushNoteManager; + private readonly IItemBasicAppService _itemBasicAppService; - public BackFlushNoteAppService(IBackFlushNoteRepository repository, IBackFlushNoteManager backFlushNoteManager) : + public BackFlushNoteAppService(IBackFlushNoteRepository repository, IBackFlushNoteManager backFlushNoteManager, IItemBasicAppService itemBasicAppService) : base(repository) { _backFlushNoteManager = backFlushNoteManager; + _itemBasicAppService = itemBasicAppService; } + [HttpPost("create-many")] public virtual async Task> CreateManyAsync(List inputs) { var entities = ObjectMapper.Map, List>(inputs); + entities = await ProcessingBackFlushNoteData(entities).ConfigureAwait(false); + entities = await _backFlushNoteManager.CreateManyAsync(entities).ConfigureAwait(false); var dtos = ObjectMapper.Map, List>(entities); @@ -43,4 +49,33 @@ public class BackFlushNoteAppService : return ObjectMapper.Map, List>(entities); } + + /// + /// 处理数据 + /// + /// + private async Task> ProcessingBackFlushNoteData(List backFlushNotes) + { + if (backFlushNotes != null && backFlushNotes.Count > 0) + { + var itemCodes = backFlushNotes.Select(t => t.ItemCode); + List itemBasicDtos = await _itemBasicAppService.GetByCodesAsync(itemCodes).ConfigureAwait(false); + + backFlushNotes.ForEach(t => + { + var itemBasicDto = itemBasicDtos.FirstOrDefault(w => w.Code == t.ItemCode); + if (itemBasicDto != null) + { + t.ItemDesc1 = itemBasicDto.Desc1; + t.ItemDesc2 = itemBasicDto.Desc2; + t.Details.ForEach(tDetail => + { + tDetail.ItemDesc1 = itemBasicDto.Desc1; + tDetail.ItemDesc2 = itemBasicDto.Desc2; + }); + } + }); + } + return backFlushNotes; + } }