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; + } }