|
|
@ -1,6 +1,10 @@ |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Omu.ValueInjecter; |
|
|
|
using Volo.Abp; |
|
|
|
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; |
|
|
@ -20,11 +24,21 @@ public class CustomerProductionReturnNoteAppService : |
|
|
|
{ |
|
|
|
private readonly ICustomerProductionReturnNoteManager _CustomerProductionReturnNoteManager; |
|
|
|
|
|
|
|
|
|
|
|
private readonly ICustomerItemAppService _customerItemAppService; |
|
|
|
|
|
|
|
public CustomerProductionReturnNoteAppService( |
|
|
|
ICustomerProductionReturnNoteRepository repository |
|
|
|
, ICustomerProductionReturnNoteManager CustomerProductionReturnNoteManager |
|
|
|
, ICustomerItemAppService customerItemAppService |
|
|
|
) : base(repository) |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
_customerItemAppService = customerItemAppService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_CustomerProductionReturnNoteManager = CustomerProductionReturnNoteManager; |
|
|
|
} |
|
|
|
|
|
|
@ -37,16 +51,56 @@ public class CustomerProductionReturnNoteAppService : |
|
|
|
//[Authorize(CustomerProductionReturnNotePermissions.Create)]
|
|
|
|
public override async Task<CustomerProductionReturnNoteDTO> CreateAsync(CustomerProductionReturnNoteEditInput input) |
|
|
|
{ |
|
|
|
var entity = ObjectMapper.Map<CustomerProductionReturnNoteEditInput, CustomerProductionReturnNote>(input); |
|
|
|
var entity = ObjectMapper.Map<CustomerProductionReturnNoteEditInput, CustomerProductionReturnNote>(input); |
|
|
|
|
|
|
|
|
|
|
|
var parts= input.Details.Select(itm => itm.ItemCode).Distinct(); |
|
|
|
|
|
|
|
var custitmDetail = await _customerItemAppService.GetListByPartsAsync(parts.ToList()).ConfigureAwait(false); |
|
|
|
|
|
|
|
var checkPart= from itm in entity.Details.ToList() |
|
|
|
join itm1 in custitmDetail |
|
|
|
on itm.ItemCode equals itm1.ItemCode |
|
|
|
into temp |
|
|
|
from tm in temp.DefaultIfEmpty() |
|
|
|
where tm == null |
|
|
|
select itm; |
|
|
|
|
|
|
|
var partErr = checkPart.Select(x => x.ItemCode).Distinct().ToList(); |
|
|
|
if (partErr.Count > 0) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"客户零件{string.Join(",",partErr)}不在零件关系表中,不能退货!"); |
|
|
|
} |
|
|
|
var checkCustomer= from itm in entity.Details.ToList() |
|
|
|
join itm1 in custitmDetail |
|
|
|
on itm.ItemCode equals itm1.ItemCode |
|
|
|
select itm1; |
|
|
|
|
|
|
|
var custErr= checkCustomer.Select(x => x.CustomerCode).Distinct().ToList(); |
|
|
|
if (custErr.Count > 1) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"提交客户退货零件{string.Join(",", custErr)}存在多个客户,不能退货!"); |
|
|
|
} |
|
|
|
if(entity.Details.Count>0) |
|
|
|
{ |
|
|
|
entity.CustomerCode = checkCustomer.FirstOrDefault().CustomerCode; |
|
|
|
} |
|
|
|
foreach (var itm in entity.Details) |
|
|
|
{ |
|
|
|
itm.FromLocationCode = "HOLD"; |
|
|
|
itm.FromLocationCode = "OK"; |
|
|
|
itm.FromStatus = EnumInventoryStatus.OK; |
|
|
|
itm.ToStatus=EnumInventoryStatus.OK; |
|
|
|
itm.FromLocationArea = "OK"; |
|
|
|
itm.FromLocationErpCode= "OK"; |
|
|
|
itm.FromLot = "NONE"; |
|
|
|
itm.FromPackingCode = "NONE"; |
|
|
|
itm.FromWarehouseCode = "OK"; |
|
|
|
itm.FromLocationGroup = "OK"; |
|
|
|
itm.FromContainerCode = "OK"; |
|
|
|
itm.ToContainerCode =string.IsNullOrEmpty(itm.ToContainerCode)? "OK": itm.ToContainerCode; |
|
|
|
itm.ToWarehouseCode= string.IsNullOrEmpty(itm.ToWarehouseCode)? "OK": itm.ToContainerCode; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await _CustomerProductionReturnNoteManager.CreateAsync(entity).ConfigureAwait(false); |
|
|
|
var dto = ObjectMapper.Map<CustomerProductionReturnNote, CustomerProductionReturnNoteDTO>(entity); |
|
|
|
return dto; |
|
|
|