|
|
@ -1,3 +1,4 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
@ -6,7 +7,9 @@ using IdentityServer4.Models; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Application.Dtos; |
|
|
|
using Volo.Abp.Domain.Entities; |
|
|
|
using Volo.Abp.Domain.Entities.Events.Distributed; |
|
|
|
using Volo.Abp.Guids; |
|
|
|
using Volo.Abp.ObjectMapping; |
|
|
|
using Win_in.Sfs.Basedata; |
|
|
@ -78,38 +81,47 @@ public class IntegrationPackingNoteAppService : |
|
|
|
throw new UserFriendlyException($"此物料已经被【任务编号:{outDtos.First().JobNumber}】占用"); |
|
|
|
} |
|
|
|
|
|
|
|
var dto = await base.CreateAsync(input).ConfigureAwait(false); |
|
|
|
var entity = input.ToObject<IntegrationPackingNote>(); |
|
|
|
var number = await GenerateNumberAsync(nameof(IntegrationPackingNote), Clock.Now).ConfigureAwait(false); |
|
|
|
entity.Number = number; |
|
|
|
entity.SetId(GuidGenerator.Create()); |
|
|
|
entity.SetIdAndNumberWithDetails(GuidGenerator, entity.Number); |
|
|
|
entity.WarehouseCode = string.Empty; |
|
|
|
entity.Details.ForEach(p=>p.WarehouseCode=string.Empty); |
|
|
|
|
|
|
|
entity = await _repository.InsertAsync(entity).ConfigureAwait(false); |
|
|
|
|
|
|
|
foreach (var detailInput in input.Details) |
|
|
|
{ |
|
|
|
//库存移动
|
|
|
|
var transferLogEditInput = |
|
|
|
await BuildTransferLogsAsync(dto, detailInput) |
|
|
|
await BuildTransferLogsAsync(entity, detailInput) |
|
|
|
.ConfigureAwait(false); |
|
|
|
transferLogEditInputs.Add(transferLogEditInput); |
|
|
|
} |
|
|
|
|
|
|
|
await _transferLogAppService.AddManyAsync(transferLogEditInputs).ConfigureAwait(false); |
|
|
|
|
|
|
|
var dto = entity.ToObject<IntegrationPackingNoteDTO>(); |
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 构造 库存转移日志实体
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="dto"></param>
|
|
|
|
/// <param name="entity"></param>
|
|
|
|
/// <param name="detailInput"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private async Task<TransferLogEditInput> BuildTransferLogsAsync( |
|
|
|
IntegrationPackingNoteDTO dto, |
|
|
|
IntegrationPackingNote entity, |
|
|
|
IntegrationPackingNoteDetailInput detailInput) |
|
|
|
{ |
|
|
|
var fromLocationDto = await _locationAppService.GetByCodeAsync(detailInput.LocationCode).ConfigureAwait(false); |
|
|
|
var toLocationDto = await _locationAppService.GetByCodeAsync(dto.LocationCode).ConfigureAwait(false); |
|
|
|
var toLocationDto = await _locationAppService.GetByCodeAsync(entity.LocationCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
var transferLogEditInput = new TransferLogEditInput |
|
|
|
{ |
|
|
|
Worker = dto.Worker, |
|
|
|
Worker = entity.Worker, |
|
|
|
Qty = detailInput.Qty, |
|
|
|
ItemCode = detailInput.ItemCode, |
|
|
|
FromLocationCode = fromLocationDto.Code, |
|
|
@ -122,25 +134,25 @@ public class IntegrationPackingNoteAppService : |
|
|
|
ToLocationArea = toLocationDto.AreaCode, |
|
|
|
ToLocationGroup = toLocationDto.LocationGroupCode, |
|
|
|
ToWarehouseCode = toLocationDto.WarehouseCode, |
|
|
|
ToPackingCode = dto.PackingCode, |
|
|
|
Remark = dto.Remark, |
|
|
|
ArriveDate = dto.ArriveDate, |
|
|
|
ToPackingCode = entity.PackingCode, |
|
|
|
Remark = entity.Remark, |
|
|
|
ArriveDate = entity.ArriveDate, |
|
|
|
DocNumber = string.Empty, |
|
|
|
ExpireDate = dto.ExpireDate, |
|
|
|
ExpireDate = entity.ExpireDate, |
|
|
|
FromContainerCode = detailInput.ContainerCode, |
|
|
|
FromLot = detailInput.Lot, |
|
|
|
FromPackingCode = detailInput.PackingCode, |
|
|
|
Uom = detailInput.Uom, |
|
|
|
FromStatus = EnumInventoryStatus.OK, |
|
|
|
JobNumber = string.Empty, |
|
|
|
ItemDesc1 = dto.ItemDesc1, |
|
|
|
StdPackQty = dto.StdPackQty, |
|
|
|
ItemDesc1 = entity.ItemDesc1, |
|
|
|
StdPackQty = entity.StdPackQty, |
|
|
|
TransType = EnumTransType.Transfer, |
|
|
|
ToLot = dto.Lot, |
|
|
|
ItemDesc2 = dto.ItemDesc2, |
|
|
|
ItemName = dto.ItemName, |
|
|
|
ProduceDate = dto.ProduceDate, |
|
|
|
SupplierBatch = dto.SupplierBatch, |
|
|
|
ToLot = entity.Lot, |
|
|
|
ItemDesc2 = entity.ItemDesc2, |
|
|
|
ItemName = entity.ItemName, |
|
|
|
ProduceDate = entity.ProduceDate, |
|
|
|
SupplierBatch = entity.SupplierBatch, |
|
|
|
ToContainerCode = detailInput.ContainerCode, |
|
|
|
ToStatus = EnumInventoryStatus.OK, |
|
|
|
TransSubType = EnumTransSubType.Transfer_Integration, |
|
|
|