diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs index 145b858b3..165439dc5 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/CustomerProductionReturnNotes/CustomerProductionReturnNoteAppService.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; @@ -54,8 +55,22 @@ public class CustomerProductionReturnNoteAppService : var entity = ObjectMapper.Map(input); + + + + + var parts= input.Details.Select(itm => itm.ItemCode).Distinct(); + + var ls=await IsExistCustomerItemRelationShip(parts.ToList(),input.CustomerCode).ConfigureAwait(false); + + if (ls.Count > 0) + { + throw new UserFriendlyException($"客户零件关系表中没有查到客户为{input.CustomerCode}零件为{string.Join(",", ls.ToArray())}的零件号"); + } + + var custitmDetail = await _customerItemAppService.GetListByPartsAsync(parts.ToList()).ConfigureAwait(false); var checkPart= from itm in entity.Details.ToList() @@ -105,5 +120,22 @@ public class CustomerProductionReturnNoteAppService : } + private async Task> IsExistCustomerItemRelationShip(List partlist, string customerCode) + { + List errorlist = new List(); + foreach (var itm in partlist) + { + var result = await _customerItemAppService.GetByCustomerAndItemAsync(itm, customerCode).ConfigureAwait(false); + if (result == null) + { + errorlist.Add(itm); + } + } + return errorlist; + + + } + + }