From b46690f78879bb47db2d0e98fcefafa87332abe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Wed, 6 Nov 2024 13:34:32 +0800 Subject: [PATCH] up --- .../CustomerProductionReturnNoteAppService.cs | 6 +- .../DeliverNotes/DeliverNoteAppService.cs | 1 + .../DeliverRequestFisAppService.cs | 74 +++++++++++++++---- 3 files changed, 62 insertions(+), 19 deletions(-) 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 f652332a0..171d6981b 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 @@ -64,14 +64,14 @@ public class CustomerProductionReturnNoteAppService : if (ls.Count > 0) { - throw new UserFriendlyException($"销售价格表中没有查到客户为{input.CustomerCode},零件号为{string.Join(",", ls.ToArray())}的零件关系和价格"); + throw new UserFriendlyException($"销售价格表中没有查到客户为{input.CustomerCode}零件号为{string.Join(",", ls.ToArray())}的零件关系和价格"); } var errlist= await CheckCustomerItem(parts.ToList(), input.CustomerCode).ConfigureAwait(false); if (errlist.Count > 0) { - throw new UserFriendlyException($"客户零件关系表中没有查到客户为{input.CustomerCode},零件号为{string.Join(",", ls.ToArray())}的零件关系"); + throw new UserFriendlyException($"客户零件关系表中没有查到客户为{input.CustomerCode}零件号为{string.Join(",", ls.ToArray())}的零件关系"); } var custitmDetail = await _customerItemAppService.GetListByPartsAsync(parts.ToList()).ConfigureAwait(false); @@ -128,7 +128,7 @@ public class CustomerProductionReturnNoteAppService : List errorlist = new List(); foreach (var itm in partlist) { - var result = await _salePriceSheetAppService.GetByItemCodeAndCustomerCode(itm, customerCode).ConfigureAwait(false); + var result = await _customerItemAppService.GetByCustomerAndItemAsync(itm, customerCode).ConfigureAwait(false); if (result == null) { errorlist.Add(itm); 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 218e1dd9d..0ef200164 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 @@ -32,6 +32,7 @@ public class DeliverNoteAppService : private readonly IDeliverNoteManager _deliverNoteManager; private readonly ICustomerItemAppService _customerItemAppService; + public DeliverNoteAppService( IDeliverNoteRepository repository, IDeliverNoteManager deliverNoteManager, ICustomerItemAppService customerItemAppService) : base(repository) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestFisAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestFisAppService.cs index 456d2def7..f269ac5f1 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestFisAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestFisAppService.cs @@ -37,6 +37,7 @@ public class DeliverRequestFisAppService : private readonly ITransactionTypeAppService _transactionTypeAppService; private readonly IBalanceAppService _balanceAppService; private readonly IItemBasicAppService _itemBasicAppService; + private readonly ICustomerItemAppService _customerItemAppService; private readonly ISalePriceSheetAppService _salePriceSheetAppService; @@ -49,8 +50,8 @@ public class DeliverRequestFisAppService : ITransactionTypeAppService transactionTypeAppService, IBalanceAppService balanceAppService, IItemBasicAppService itemBasicAppService, - ISalePriceSheetAppService salePriceSheetAppService - + ISalePriceSheetAppService salePriceSheetAppService, + ICustomerItemAppService customerItemAppService ) : base(repository, deliverRequestManager) @@ -63,6 +64,7 @@ public class DeliverRequestFisAppService : _balanceAppService = balanceAppService; _itemBasicAppService = itemBasicAppService; _salePriceSheetAppService = salePriceSheetAppService; + _customerItemAppService= customerItemAppService; } /// /// 删除 @@ -113,11 +115,6 @@ public class DeliverRequestFisAppService : await SetRequestAutoPropertiesAsync(itemTransformRequest).ConfigureAwait(false); foreach (var detail in itemTransformRequest.Details) { - - - //_salePriceSheetAppService.GetByItemCodeAndCustomerCode(detail.ItemCode,itemTransformRequest.CustomerCode) - - var itemBasicDto = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); CheckItemBasic(itemBasicDto, detail.ItemCode); @@ -146,11 +143,20 @@ public class DeliverRequestFisAppService : detail.ItemName = itemBasicDto.Name; detail.Uom = itemBasicDto.BasicUom; detail.StdPackQty=itemBasicDto.StdPackQty; - - // CheckPrice(detail); - - } + var itemlist=itemTransformRequest.Details.Select(p => p.ItemCode).Distinct(); + var customerCode = itemTransformRequest.CustomerCode; + var errors=await CheckCustomerItem(itemlist.ToList(),customerCode).ConfigureAwait(false); + if (errors.Count > 0) + { + throw new UserFriendlyException($"客户零件关系表中没有查到客户为{customerCode},零件号为{string.Join(",", errors.ToArray())}的零件关系"); + } + var priceErrors=await IsExistCustomerItemPrice(itemlist.ToList(), customerCode).ConfigureAwait(false); + if (priceErrors.Count > 0) + { + throw new UserFriendlyException($"销售价格表中没有查到客户为{customerCode},零件号为{string.Join(",", priceErrors.ToArray())}的零件关系和价格"); + } + } return dictionary; @@ -173,12 +179,34 @@ public class DeliverRequestFisAppService : - //private static void CheckPrice(DeliverRequestDetail detail - // ) - //{ - - //} + private async Task> CheckCustomerItem(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; + } + private async Task> IsExistCustomerItemPrice(List partlist, string customerCode) + { + List errorlist = new List(); + foreach (var itm in partlist) + { + var result = await _salePriceSheetAppService.GetByItemCodeAndCustomerCode(itm, customerCode).ConfigureAwait(false); + if (result == null) + { + errorlist.Add(itm); + } + } + return errorlist; + + } @@ -248,6 +276,20 @@ public class DeliverRequestFisAppService : { var entity = ObjectMapper.Map(input); + var itemlist = entity.Details.Select(p => p.ItemCode).Distinct(); + var customerCode = entity.CustomerCode; + var errors = await CheckCustomerItem(itemlist.ToList(), customerCode).ConfigureAwait(false); + if (errors.Count > 0) + { + throw new UserFriendlyException($"客户零件关系表中没有查到客户为{customerCode},零件号为{string.Join(",", errors.ToArray())}的零件关系"); + } + var priceErrors = await IsExistCustomerItemPrice(itemlist.ToList(), customerCode).ConfigureAwait(false); + if (priceErrors.Count > 0) + { + throw new UserFriendlyException($"销售价格表中没有查到客户为{customerCode},零件号为{string.Join(",", priceErrors.ToArray())}的零件关系和价格"); + } + + await _deliverRequestManager.CreateAsync(entity).ConfigureAwait(false); var dto = ObjectMapper.Map(entity);