|
|
@ -1,6 +1,11 @@ |
|
|
|
using System.Threading.Tasks; |
|
|
|
using DocumentFormat.OpenXml.Bibliography; |
|
|
|
using FluentValidation.Validators; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Volo.Abp.ObjectMapping; |
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
|
using Win_in.Sfs.Shared.Event; |
|
|
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
|
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|
|
|
using Win_in.Sfs.Wms.Store.Domain; |
|
|
@ -22,24 +27,53 @@ public class RecycledMaterialReceiptNoteAppService : |
|
|
|
{ |
|
|
|
private readonly IRecycledMaterialReceiptNoteManager _RecycledMaterialReceiptNoteManager; |
|
|
|
private readonly ILocationCapacityAppService _locationCapacityAppService; |
|
|
|
private readonly ILocationAppService _locationAppService; |
|
|
|
private readonly IItemBasicAppService _itemBasicAppService; |
|
|
|
|
|
|
|
public RecycledMaterialReceiptNoteAppService(IRecycledMaterialReceiptNoteRepository repository, |
|
|
|
IRecycledMaterialReceiptNoteManager RecycledMaterialReceiptNoteManager, |
|
|
|
ILocationCapacityAppService locationCapacityAppService) : base(repository) |
|
|
|
ILocationCapacityAppService locationCapacityAppService, |
|
|
|
ILocationAppService locationAppService, |
|
|
|
IItemBasicAppService itemBasicAppService) : base(repository) |
|
|
|
{ |
|
|
|
_RecycledMaterialReceiptNoteManager = RecycledMaterialReceiptNoteManager; |
|
|
|
_locationCapacityAppService = locationCapacityAppService; |
|
|
|
_locationAppService = locationAppService; |
|
|
|
_itemBasicAppService = itemBasicAppService; |
|
|
|
} |
|
|
|
|
|
|
|
[HttpPost("")] |
|
|
|
//[Authorize(RecycledMaterialReceiptNotePermissions.Create)]
|
|
|
|
/// <summary>
|
|
|
|
/// 新增实体
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input">CreateInput</param>
|
|
|
|
public override async Task<RecycledMaterialReceiptNoteDTO> CreateAsync(RecycledMaterialReceiptNoteEditInput input) |
|
|
|
{ |
|
|
|
var entity= ObjectMapper.Map<RecycledMaterialReceiptNoteEditInput, RecycledMaterialReceiptNote>(input); |
|
|
|
await _RecycledMaterialReceiptNoteManager.CreateAsync(entity).ConfigureAwait(false); |
|
|
|
|
|
|
|
var dto = ObjectMapper.Map<RecycledMaterialReceiptNote, RecycledMaterialReceiptNoteDTO>(entity); |
|
|
|
entity.Number=string.IsNullOrEmpty(input.Number) |
|
|
|
? await GenerateNumberAsync(nameof(RecycledMaterialReceiptNote), input.ActiveDate) |
|
|
|
.ConfigureAwait(false) |
|
|
|
: input.Number; |
|
|
|
|
|
|
|
foreach (var detail in entity.Details) |
|
|
|
{ |
|
|
|
var detailNumber = await GenerateNumberAsync(nameof(RecycledMaterialReceiptNote), input.ActiveDate) |
|
|
|
.ConfigureAwait(false); |
|
|
|
detail.Number=detailNumber; |
|
|
|
var locationDto = await _locationAppService.GetByCodeAsync(detail.LocationCode).ConfigureAwait(false); |
|
|
|
detail.LocationErpCode = locationDto.ErpLocationCode; |
|
|
|
detail.LocationArea = locationDto.AreaCode; |
|
|
|
detail.LocationGroup = locationDto.LocationGroupCode; |
|
|
|
detail.WarehouseCode=locationDto.WarehouseCode; |
|
|
|
var itemBasicDto=await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); |
|
|
|
detail.StdPackQty = itemBasicDto.StdPackQty; |
|
|
|
detail.Uom = itemBasicDto.BasicUom; |
|
|
|
} |
|
|
|
|
|
|
|
entity=await _repository.InsertAsync(entity).ConfigureAwait(false); |
|
|
|
|
|
|
|
await LocalEventBus.PublishAsync(new SfsCreatedEntityEventData<RecycledMaterialReceiptNote>(entity),false).ConfigureAwait(false); |
|
|
|
|
|
|
|
return dto; |
|
|
|
return ObjectMapper.Map<RecycledMaterialReceiptNote, RecycledMaterialReceiptNoteDTO>(entity); |
|
|
|
} |
|
|
|
} |
|
|
|