From ef3a7660ee2f2f54c2e9f6f44dcf614bb17e38ed Mon Sep 17 00:00:00 2001 From: "boxu.zheng" Date: Thu, 19 Sep 2024 15:30:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A0=A1=E9=AA=8C=20?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E9=9B=B6=E4=BB=B6=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomerItems/ICustomerItemAppService.cs | 1 + .../CustomerItems/CustomerItemAppService.cs | 8 ++++- .../DeliverNotes/DeliverNoteAppService.cs | 29 +++++++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) 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料号没有客户物品对应关系"); + } + } }