diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/CustomerItems/ICustomerItemAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/CustomerItems/ICustomerItemAppService.cs index 8e721681c..1af4f50da 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/CustomerItems/ICustomerItemAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/CustomerItems/ICustomerItemAppService.cs @@ -12,4 +12,5 @@ public interface ICustomerItemAppService { Task GetFirstLocationCodeByItemCode(string itemCode); Task> GetListByPartsAsync(List inputs); + Task GetByCustomerAndItemAsync(string itemCode,string customerCode); } diff --git a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/CustomerItems/CustomerItemAppService.cs b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/CustomerItems/CustomerItemAppService.cs index 3f1400a4e..3b1f0b463 100644 --- a/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/CustomerItems/CustomerItemAppService.cs +++ b/be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/CustomerItems/CustomerItemAppService.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Volo.Abp.Caching; +using Volo.Abp.ObjectMapping; using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Basedata.Domain; using Win_in.Sfs.Basedata.Domain.Shared; @@ -74,5 +75,10 @@ public class CustomerItemAppService : SfsBaseDataAppServiceBase GetByCustomerAndItemAsync(string itemCode,string customerCode) + { + var entity=await _repository.FindAsync(p => p.ItemCode == itemCode && p.CustomerCode == customerCode).ConfigureAwait(false); + return ObjectMapper.Map(entity); + } } diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/DeliverNotes/DeliverNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/DeliverNotes/DeliverNoteAppService.cs index 03ab41c6e..218e1dd9d 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/DeliverNotes/DeliverNoteAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/DeliverNotes/DeliverNoteAppService.cs @@ -5,7 +5,9 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Volo.Abp; using Volo.Abp.Application.Dtos; +using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Domain; @@ -28,13 +30,14 @@ public class DeliverNoteAppService : IDeliverNoteAppService { private readonly IDeliverNoteManager _deliverNoteManager; + private readonly ICustomerItemAppService _customerItemAppService; public DeliverNoteAppService( IDeliverNoteRepository repository, - IDeliverNoteManager deliverNoteManager - ) : base(repository) + IDeliverNoteManager deliverNoteManager, ICustomerItemAppService customerItemAppService) : base(repository) { _deliverNoteManager = deliverNoteManager; + _customerItemAppService = customerItemAppService; } /// @@ -49,6 +52,10 @@ public class DeliverNoteAppService : await _deliverNoteManager.CreateAsync(entity).ConfigureAwait(false); var dto = ObjectMapper.Map(entity); + foreach (var detail in dto.Details) + { + CheckCustomerItem(detail.ItemCode,dto.CustomerCode); + } return dto; } /// @@ -63,6 +70,15 @@ public class DeliverNoteAppService : await _deliverNoteManager.CreateManyAsync(entitys).ConfigureAwait(false); var dtos = ObjectMapper.Map, List>(entitys); + + foreach (var dto in dtos) + { + foreach (var detail in dto.Details) + { + CheckCustomerItem(detail.ItemCode, dto.CustomerCode); + } + } + return dtos; } /// @@ -161,4 +177,13 @@ public class DeliverNoteAppService : await _repository.UpdateAsync(entity).ConfigureAwait(false); } + + private void CheckCustomerItem(string customerCode, string itemCode) + { + var dto=_customerItemAppService.GetByCustomerAndItemAsync(itemCode, customerCode); + if (dto == null) + { + throw new UserFriendlyException($"{customerCode}客户零件号,{itemCode}Erp料号没有客户物品对应关系"); + } + } }