Browse Source

添加校验 客户零件关系

dev_DY_CC
郑勃旭 8 months ago
parent
commit
ef3a7660ee
  1. 1
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/CustomerItems/ICustomerItemAppService.cs
  2. 8
      be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application/CustomerItems/CustomerItemAppService.cs
  3. 29
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/DeliverNotes/DeliverNoteAppService.cs

1
be/Modules/BaseData/src/Win_in.Sfs.Basedata.Application.Contracts/CustomerItems/ICustomerItemAppService.cs

@ -12,4 +12,5 @@ public interface ICustomerItemAppService
{ {
Task<string> GetFirstLocationCodeByItemCode(string itemCode); Task<string> GetFirstLocationCodeByItemCode(string itemCode);
Task<List<CustomerItem>> GetListByPartsAsync(List<string> inputs); Task<List<CustomerItem>> GetListByPartsAsync(List<string> inputs);
Task<CustomerItemDTO> GetByCustomerAndItemAsync(string itemCode,string customerCode);
} }

8
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.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Volo.Abp.Caching; using Volo.Abp.Caching;
using Volo.Abp.ObjectMapping;
using Win_in.Sfs.Basedata.Application.Contracts; using Win_in.Sfs.Basedata.Application.Contracts;
using Win_in.Sfs.Basedata.Domain; using Win_in.Sfs.Basedata.Domain;
using Win_in.Sfs.Basedata.Domain.Shared; using Win_in.Sfs.Basedata.Domain.Shared;
@ -74,5 +75,10 @@ public class CustomerItemAppService : SfsBaseDataAppServiceBase<CustomerItem, Cu
return code; return code;
} }
[HttpPost("get-by-customer-by-item")]
public virtual async Task<CustomerItemDTO> GetByCustomerAndItemAsync(string itemCode,string customerCode)
{
var entity=await _repository.FindAsync(p => p.ItemCode == itemCode && p.CustomerCode == customerCode).ConfigureAwait(false);
return ObjectMapper.Map<CustomerItem, CustomerItemDTO>(entity);
}
} }

29
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 System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Win_in.Sfs.Basedata.Application.Contracts;
using Win_in.Sfs.Shared.Domain.Shared; using Win_in.Sfs.Shared.Domain.Shared;
using Win_in.Sfs.Wms.Store.Application.Contracts; using Win_in.Sfs.Wms.Store.Application.Contracts;
using Win_in.Sfs.Wms.Store.Domain; using Win_in.Sfs.Wms.Store.Domain;
@ -28,13 +30,14 @@ public class DeliverNoteAppService :
IDeliverNoteAppService IDeliverNoteAppService
{ {
private readonly IDeliverNoteManager _deliverNoteManager; private readonly IDeliverNoteManager _deliverNoteManager;
private readonly ICustomerItemAppService _customerItemAppService;
public DeliverNoteAppService( public DeliverNoteAppService(
IDeliverNoteRepository repository, IDeliverNoteRepository repository,
IDeliverNoteManager deliverNoteManager IDeliverNoteManager deliverNoteManager, ICustomerItemAppService customerItemAppService) : base(repository)
) : base(repository)
{ {
_deliverNoteManager = deliverNoteManager; _deliverNoteManager = deliverNoteManager;
_customerItemAppService = customerItemAppService;
} }
/// <summary> /// <summary>
@ -49,6 +52,10 @@ public class DeliverNoteAppService :
await _deliverNoteManager.CreateAsync(entity).ConfigureAwait(false); await _deliverNoteManager.CreateAsync(entity).ConfigureAwait(false);
var dto = ObjectMapper.Map<DeliverNote, DeliverNoteDTO>(entity); var dto = ObjectMapper.Map<DeliverNote, DeliverNoteDTO>(entity);
foreach (var detail in dto.Details)
{
CheckCustomerItem(detail.ItemCode,dto.CustomerCode);
}
return dto; return dto;
} }
/// <summary> /// <summary>
@ -63,6 +70,15 @@ public class DeliverNoteAppService :
await _deliverNoteManager.CreateManyAsync(entitys).ConfigureAwait(false); await _deliverNoteManager.CreateManyAsync(entitys).ConfigureAwait(false);
var dtos = ObjectMapper.Map<List<DeliverNote>, List<DeliverNoteDTO>>(entitys); var dtos = ObjectMapper.Map<List<DeliverNote>, List<DeliverNoteDTO>>(entitys);
foreach (var dto in dtos)
{
foreach (var detail in dto.Details)
{
CheckCustomerItem(detail.ItemCode, dto.CustomerCode);
}
}
return dtos; return dtos;
} }
/// <summary> /// <summary>
@ -161,4 +177,13 @@ public class DeliverNoteAppService :
await _repository.UpdateAsync(entity).ConfigureAwait(false); 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料号没有客户物品对应关系");
}
}
} }

Loading…
Cancel
Save