From 6707a8f0736ea2835ea31cf7634feb6969ac2b95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A6=20=E8=B5=B5?= <89237069@qq.com> Date: Tue, 31 Dec 2024 09:08:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=9B=E5=BB=BA=E5=8F=91?= =?UTF-8?q?=E8=BF=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DeliverRequestAppService.cs | 80 ++++++++++++++++++- 1 file changed, 78 insertions(+), 2 deletions(-) diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs index 124ba207e..c6afd39bd 100644 --- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs +++ b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using Org.BouncyCastle.Asn1.Ocsp; using Volo.Abp; using Volo.Abp.Application.Dtos; using Volo.Abp.Domain.Entities; @@ -15,6 +16,7 @@ using Volo.Abp.Domain.Entities.Events.Distributed; using Volo.Abp.ObjectMapping; using Win_in.Sfs.Basedata.Application; using Win_in.Sfs.Basedata.Application.Contracts; +using Win_in.Sfs.Basedata.Domain; using Win_in.Sfs.Shared.Application.Contracts; using Win_in.Sfs.Shared.Domain; using Win_in.Sfs.Shared.Domain.Shared; @@ -37,20 +39,35 @@ public class DeliverRequestAppService : private readonly ICustomerAppService _customerApp; private readonly ICustomerAddressAppService _customerAddressApp; private readonly IItemBasicAppService _itemBasicAppService; + private readonly ICustomerItemAppService _customerItemAppService; + private readonly ISalePriceSheetRepository _salePriceSheetRepository; + + + + public DeliverRequestAppService( IDeliverRequestRepository repository , IDeliverRequestManager deliverRequestManager , IAreaAppService areaApp , ICustomerAppService customerApp - , ICustomerAddressAppService customerAddressApp, -IItemBasicAppService itemBasicAppService) + , ICustomerAddressAppService customerAddressApp + , IItemBasicAppService itemBasicAppService, + ICustomerItemAppService customerItemAppService, + + ISalePriceSheetRepository salePriceSheetRepository + + ) : base(repository, deliverRequestManager) { + _customerItemAppService = customerItemAppService; + _deliverRequestManager = deliverRequestManager; _areaApp = areaApp; _customerApp = customerApp; _customerAddressApp = customerAddressApp; _itemBasicAppService = itemBasicAppService; + _customerItemAppService = customerItemAppService; + _salePriceSheetRepository = salePriceSheetRepository; } protected override async Task> ImportProcessingEntityAsync(Dictionary dictionary) @@ -76,8 +93,12 @@ IItemBasicAppService itemBasicAppService) { request.DeliverPlanNumber = request.Details.First().MesDeliveryPlan; } + + await CheckCustomerItem(request).ConfigureAwait(false); + foreach (var detail in request.Details) { + var itemBasicDto = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); CheckItemBasic(itemBasicDto, detail.ItemCode); detail.ItemDesc1 = itemBasicDto.Desc1; @@ -90,6 +111,52 @@ IItemBasicAppService itemBasicAppService) return dictionary; } + private async Task CheckSalePrice(List requests) + { + List errors=new List(); + foreach (var request in requests) + { + foreach (var itm in request.Details) + { + var price = await _salePriceSheetRepository.FindAsync(p => p.ItemCode == itm.ItemCode && p.CustomerCode == request.CustomerCode).ConfigureAwait(false); + if (price == null) + { + errors.Add($"请求单号:{request.Number}零件编号:{itm.ItemCode}客户编号:{request.CustomerCode}"); + } + } + } + if (errors.Count > 0) + { + throw new UserFriendlyException($"{string.Format(",",errors.ToArray())+"销售价格单里不存在价格!"}"); + } + + + } + + private async Task CheckCustomerItem(DeliverRequest request) + { + List errors= new List(); + foreach (var detail in request.Details) + { + + var entity = await _customerItemAppService.GetByCustomerAndItemAsync(detail.ItemCode, request.CustomerCode).ConfigureAwait(false); + if (entity == null) + { + errors.Add($"零件编号:{detail.ItemCode}客户编号:{request.CustomerCode}|"); + } + } + + if (errors.Count > 0) + { + throw new UserFriendlyException(string.Format(",",errors.ToArray())+ "在客户零件关系表里不存在!"); + } + + + + } + + + protected override async Task SaveImportAsync(Dictionary dict) { var addList = dict.Where(p => p.Value == EntityState.Added).Select(p => p.Key).ToList(); @@ -182,6 +249,11 @@ IItemBasicAppService itemBasicAppService) entitys.ForEach(r => { r.MesTruckNumber = truckNumber; }); Check.NotNull(entitys, typeof(DeliverRequest).Name); + + + + await CheckSalePrice(entitys).ConfigureAwait(false); + var result = await _deliverRequestManager.HandleListAsync(entitys).ConfigureAwait(false); var dtos = ObjectMapper.Map, List>(entitys); return dtos; @@ -209,6 +281,10 @@ IItemBasicAppService itemBasicAppService) { var entity = ObjectMapper.Map(input); await SetRequestAutoPropertiesAsync(entity).ConfigureAwait(false); + + + await CheckCustomerItem(entity).ConfigureAwait(false); + await _deliverRequestManager.CreateAsync(entity).ConfigureAwait(false); var dto = ObjectMapper.Map(entity);