|
@ -4,11 +4,18 @@ using System.Threading.Tasks; |
|
|
using IdentityServer4.Models; |
|
|
using IdentityServer4.Models; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
|
|
using Volo.Abp; |
|
|
using Volo.Abp.ObjectMapping; |
|
|
using Volo.Abp.ObjectMapping; |
|
|
|
|
|
using Win_in.Sfs.Basedata; |
|
|
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
|
|
|
using Win_in.Sfs.Basedata.Domain.Shared; |
|
|
|
|
|
using Win_in.Sfs.Label.Application.Contracts; |
|
|
|
|
|
using Win_in.Sfs.Shared.Domain.Shared; |
|
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
|
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
|
|
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; |
|
|
using Win_in.Sfs.Wms.Store.Domain.Shared; |
|
|
using Win_in.Sfs.Wms.Store.Domain.Shared; |
|
|
|
|
|
using LabelStatus = Win_in.Sfs.Label.Domain.Shared.LabelStatus; |
|
|
|
|
|
|
|
|
namespace Win_in.Sfs.Wms.Store.Application; |
|
|
namespace Win_in.Sfs.Wms.Store.Application; |
|
|
|
|
|
|
|
@ -32,48 +39,198 @@ public class IntegrationPackingNoteAppService : |
|
|
{ |
|
|
{ |
|
|
private readonly IIntegrationPackingNoteManager _integrationPackingNoteManager; |
|
|
private readonly IIntegrationPackingNoteManager _integrationPackingNoteManager; |
|
|
private readonly IBalanceAppService _balanceAppService; |
|
|
private readonly IBalanceAppService _balanceAppService; |
|
|
|
|
|
private readonly ILocationAppService _locationAppService; |
|
|
|
|
|
private readonly ISplitPackingRecAppService _splitPackingRecAppService; |
|
|
|
|
|
private readonly IInventoryLabelAppService _inventoryLabelAppService; |
|
|
|
|
|
private readonly ITransferLogAppService _transferLogAppService; |
|
|
|
|
|
private readonly IExpectOutAppService _expectOutAppService; |
|
|
|
|
|
|
|
|
public IntegrationPackingNoteAppService( |
|
|
public IntegrationPackingNoteAppService( |
|
|
IIntegrationPackingNoteRepository repository, |
|
|
IIntegrationPackingNoteRepository repository, |
|
|
IIntegrationPackingNoteManager integrationPackingNoteManager, IBalanceAppService balanceAppService) : base(repository) |
|
|
IIntegrationPackingNoteManager integrationPackingNoteManager, |
|
|
|
|
|
IBalanceAppService balanceAppService, |
|
|
|
|
|
ILocationAppService locationAppService, |
|
|
|
|
|
ISplitPackingRecAppService splitPackingRecAppService, |
|
|
|
|
|
IInventoryLabelAppService inventoryLabelAppService, ITransferLogAppService transferLogAppService, |
|
|
|
|
|
IExpectOutAppService expectOutAppService) : base(repository) |
|
|
{ |
|
|
{ |
|
|
_integrationPackingNoteManager = integrationPackingNoteManager; |
|
|
_integrationPackingNoteManager = integrationPackingNoteManager; |
|
|
_balanceAppService = balanceAppService; |
|
|
_balanceAppService = balanceAppService; |
|
|
|
|
|
_locationAppService = locationAppService; |
|
|
|
|
|
_splitPackingRecAppService = splitPackingRecAppService; |
|
|
|
|
|
_inventoryLabelAppService = inventoryLabelAppService; |
|
|
|
|
|
_transferLogAppService = transferLogAppService; |
|
|
|
|
|
_expectOutAppService = expectOutAppService; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
[HttpPost("")] |
|
|
[HttpPost("")] |
|
|
public override Task<IntegrationPackingNoteDTO> CreateAsync(IntegrationPackingNoteEditInput input) |
|
|
public override async Task<IntegrationPackingNoteDTO> CreateAsync(IntegrationPackingNoteEditInput input) |
|
|
{ |
|
|
{ |
|
|
//标签记录
|
|
|
var transferLogEditInputs = new List<TransferLogEditInput>(); |
|
|
|
|
|
var outDtos=await _expectOutAppService.GetListByPackingCodeAsync(input.PackingCode).ConfigureAwait(false); |
|
|
|
|
|
if (outDtos.Any()) |
|
|
|
|
|
{ |
|
|
|
|
|
throw new UserFriendlyException($"此物料已经被【任务编号:{outDtos.First().JobNumber}】占用"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//库存移动
|
|
|
foreach (var detailInput in input.Details) |
|
|
|
|
|
{ |
|
|
|
|
|
//标签记录
|
|
|
|
|
|
var splitPackingRecDtos = await _splitPackingRecAppService.GetListByToPackingCode(new List<string> { input.PackingCode }).ConfigureAwait(false); |
|
|
|
|
|
var splitPackingRecDto = splitPackingRecDtos.First(); |
|
|
|
|
|
var inventoryLabelWithoutCodeCreateInput = new InventoryLabelWithoutCodeCreateInput |
|
|
|
|
|
{ |
|
|
|
|
|
Qty = detailInput.Qty, ItemCode = detailInput.ItemCode, |
|
|
|
|
|
SupplierCode = detailInput.SupplierCode, |
|
|
|
|
|
Lot = detailInput.Lot, |
|
|
|
|
|
Uom = detailInput.Uom, |
|
|
|
|
|
LocationErpCode = detailInput.LocationErpCode, |
|
|
|
|
|
ItemDesc1 = detailInput.ItemDesc1, |
|
|
|
|
|
ArriveDate = detailInput.ArriveDate, |
|
|
|
|
|
StdPackQty = detailInput.StdPackQty, |
|
|
|
|
|
ProdLine = string.Empty, |
|
|
|
|
|
AsnNumber = detailInput.PurchaseInfo_AsnNumber, |
|
|
|
|
|
ContainerCode = detailInput.ContainerCode, |
|
|
|
|
|
ExpireDate = detailInput.ExpireDate, |
|
|
|
|
|
FullBarcodeString = string.Empty, |
|
|
|
|
|
ItemDesc2 = detailInput.ItemDesc2, |
|
|
|
|
|
ItemName = detailInput.ItemName, |
|
|
|
|
|
SupplierName = detailInput.SupplierName, |
|
|
|
|
|
Remark = detailInput.Remark, |
|
|
|
|
|
LabelStatus = LabelStatus.Enable, |
|
|
|
|
|
LabelType = detailInput.LabelType, |
|
|
|
|
|
PlanArriveDate = detailInput.PlanArriveDate, |
|
|
|
|
|
PoNumber = detailInput.PurchaseInfo_PoNumber, |
|
|
|
|
|
ProduceDate = detailInput.ProduceDate, |
|
|
|
|
|
QLevel = string.Empty, |
|
|
|
|
|
QualityFile = string.Empty, |
|
|
|
|
|
RecommendLocationCode = detailInput.RecommendLocationCode, |
|
|
|
|
|
RpNumber = detailInput.RpNumber, |
|
|
|
|
|
Shift = string.Empty, |
|
|
|
|
|
Specifications = string.Empty, |
|
|
|
|
|
SupplierBatch = detailInput.SupplierBatch, |
|
|
|
|
|
SupplierItemCode = detailInput.ItemCode, |
|
|
|
|
|
SupplierItemName = detailInput.SupplierItemName, |
|
|
|
|
|
SupplierSimpleName = detailInput.SupplierSimpleName, |
|
|
|
|
|
Team = string.Empty, |
|
|
|
|
|
}; |
|
|
|
|
|
var inventoryLabelDto=await _inventoryLabelAppService.GenerateAndCreateAsync(inventoryLabelWithoutCodeCreateInput).ConfigureAwait(false); |
|
|
|
|
|
var splitPackingRecEditInputs = new List<SplitPackingRecEditInput>() |
|
|
|
|
|
{ |
|
|
|
|
|
new SplitPackingRecEditInput() |
|
|
|
|
|
{ |
|
|
|
|
|
ItemCode = inventoryLabelDto.ItemCode, |
|
|
|
|
|
SupplierCode = inventoryLabelDto.SupplierCode, |
|
|
|
|
|
ToPackingCode = inventoryLabelDto.Code, |
|
|
|
|
|
FromPackingCode = input.PackingCode, |
|
|
|
|
|
LocationErpCode = inventoryLabelDto.LocationErpCode, |
|
|
|
|
|
ItemDesc1 = inventoryLabelDto.ItemDesc1, |
|
|
|
|
|
FromLot = input.Lot, |
|
|
|
|
|
ToLot = inventoryLabelDto.Lot, |
|
|
|
|
|
ArriveDate = inventoryLabelDto.ArriveDate, |
|
|
|
|
|
ItemName = inventoryLabelDto.ItemName, |
|
|
|
|
|
ItemDesc2 = inventoryLabelDto.ItemDesc2, |
|
|
|
|
|
PurchaseInfo_PoNumber = inventoryLabelDto.PoNumber, |
|
|
|
|
|
LabelType = (EnumLabelType)inventoryLabelDto.LabelType, |
|
|
|
|
|
RecommendLocationCode = inventoryLabelDto.RecommendLocationCode, |
|
|
|
|
|
RpNumber = inventoryLabelDto.RpNumber, |
|
|
|
|
|
SupplierName = inventoryLabelDto.SupplierName, |
|
|
|
|
|
Remark = inventoryLabelDto.Remark, |
|
|
|
|
|
FromQty = input.Qty, |
|
|
|
|
|
ToQty = inventoryLabelDto.Qty, |
|
|
|
|
|
PurchaseInfo_AsnNumber = inventoryLabelDto.AsnNumber, |
|
|
|
|
|
ExpireDate = inventoryLabelDto.ExpireDate, |
|
|
|
|
|
FullBarcodeString = inventoryLabelDto.FullBarcodeString, |
|
|
|
|
|
SupplierBatch = inventoryLabelDto.SupplierBatch, |
|
|
|
|
|
ProduceDate = inventoryLabelDto.ProduceDate, |
|
|
|
|
|
LabelStatus = Basedata.LabelStatus.Enable, |
|
|
|
|
|
SupplierSimpleName = inventoryLabelDto.SupplierSimpleName, |
|
|
|
|
|
SupplierItemCode = inventoryLabelDto.SupplierItemCode, |
|
|
|
|
|
SupplierItemName = inventoryLabelDto.SupplierItemName, |
|
|
|
|
|
PlanArriveDate = inventoryLabelDto.PlanArriveDate, |
|
|
|
|
|
FromStdPackQty = input.StdPackQty, |
|
|
|
|
|
FromUom = input.Uom, |
|
|
|
|
|
OprType = OprTypeEnum.SplitBox, |
|
|
|
|
|
ReceiptRecNumber = inventoryLabelDto.RpNumber, |
|
|
|
|
|
ToStdPackQty = inventoryLabelDto.StdPackQty, |
|
|
|
|
|
ToUom = inventoryLabelDto.Uom, |
|
|
|
|
|
TaskOrderNumber = detailInput.TaskOrderNumber, |
|
|
|
|
|
ArrivalNoticNumber = detailInput.ArrivalNoticNumber, |
|
|
|
|
|
PutOnShelfNumber = detailInput.PutOnShelfNumber, |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
await _splitPackingRecAppService.BatchInsertAsync(splitPackingRecEditInputs).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
//创建标签
|
|
|
//创建标签
|
|
|
return base.CreateAsync(input); |
|
|
var dto= await base.CreateAsync(input).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
//库存移动
|
|
|
|
|
|
var transferLogEditInput=await BuildTransferLogsAsync(dto, detailInput, splitPackingRecEditInputs.First()).ConfigureAwait(false); |
|
|
|
|
|
transferLogEditInputs.Add(transferLogEditInput); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await _transferLogAppService.AddManyAsync(transferLogEditInputs).ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 构造 库存转移日志实体
|
|
|
/// 构造 库存转移日志实体
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="dto"></param>
|
|
|
/// <param name="dto"></param>
|
|
|
|
|
|
/// <param name="detailInput"></param>
|
|
|
|
|
|
/// <param name="splitPackingRecEditInput"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
private List<TransferLogEditInput> BuildTransferLogs(IntegrationPackingNoteDTO dto) |
|
|
private async Task<TransferLogEditInput> BuildTransferLogsAsync( |
|
|
|
|
|
IntegrationPackingNoteDTO dto, |
|
|
|
|
|
IntegrationPackingNoteDetailInput detailInput, |
|
|
|
|
|
SplitPackingRecEditInput splitPackingRecEditInput) |
|
|
{ |
|
|
{ |
|
|
var transferLogCreateInputs = new List<TransferLogEditInput>(); |
|
|
var fromLocationDto = await _locationAppService.GetByCodeAsync(dto.LocationCode).ConfigureAwait(false); |
|
|
|
|
|
var toLocationDto = await _locationAppService.GetByCodeAsync(detailInput.LocationCode).ConfigureAwait(false); |
|
|
//foreach (var detail in dto.Details.Where(detail => detail.Qty != 0))
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var transferLog = ObjectMapper.Map<DeliverNoteDetail, TransferLogEditInput>(detail);
|
|
|
|
|
|
|
|
|
|
|
|
// transferLog.TransType = TransType;
|
|
|
var transferLogEditInput = new TransferLogEditInput |
|
|
// transferLog.TransSubType = ConvertToTransSubType(deliverNote.DeliverRequestType);
|
|
|
{ |
|
|
// transferLog.Worker = deliverNote.Worker;
|
|
|
Worker = dto.Worker, |
|
|
// transferLog.DocNumber = deliverNote.Number;
|
|
|
Qty = detailInput.Qty, |
|
|
// transferLog.JobNumber = deliverNote.JobNumber;
|
|
|
ItemCode = detailInput.ItemCode, |
|
|
|
|
|
FromLocationCode = fromLocationDto.Code, |
|
|
|
|
|
FromLocationErpCode = fromLocationDto.ErpLocationCode, |
|
|
|
|
|
FromLocationArea = fromLocationDto.AreaCode, |
|
|
|
|
|
FromLocationGroup = fromLocationDto.LocationGroupCode, |
|
|
|
|
|
FromWarehouseCode = fromLocationDto.WarehouseCode, |
|
|
|
|
|
ToLocationCode = toLocationDto.Code, |
|
|
|
|
|
ToLocationErpCode = toLocationDto.ErpLocationCode, |
|
|
|
|
|
ToLocationArea = toLocationDto.AreaCode, |
|
|
|
|
|
ToLocationGroup = toLocationDto.LocationGroupCode, |
|
|
|
|
|
ToWarehouseCode = toLocationDto.WarehouseCode, |
|
|
|
|
|
ToPackingCode = splitPackingRecEditInput.ToPackingCode, |
|
|
|
|
|
Remark = splitPackingRecEditInput.Remark, |
|
|
|
|
|
ArriveDate = splitPackingRecEditInput.ArriveDate, |
|
|
|
|
|
DocNumber = string.Empty, |
|
|
|
|
|
ExpireDate = splitPackingRecEditInput.ExpireDate, |
|
|
|
|
|
FromContainerCode = detailInput.ContainerCode, |
|
|
|
|
|
FromLot = splitPackingRecEditInput.FromLot, |
|
|
|
|
|
FromPackingCode = dto.PackingCode, |
|
|
|
|
|
Uom = splitPackingRecEditInput.FromUom, |
|
|
|
|
|
FromStatus = EnumInventoryStatus.OK, |
|
|
|
|
|
JobNumber = string.Empty, |
|
|
|
|
|
ItemDesc1 = splitPackingRecEditInput.ItemDesc1, |
|
|
|
|
|
StdPackQty = splitPackingRecEditInput.FromStdPackQty, |
|
|
|
|
|
TransType = EnumTransType.Transfer, |
|
|
|
|
|
ToLot = splitPackingRecEditInput.ToLot, |
|
|
|
|
|
ItemDesc2 = splitPackingRecEditInput.ItemDesc2, |
|
|
|
|
|
ItemName = splitPackingRecEditInput.ItemName, |
|
|
|
|
|
ProduceDate = splitPackingRecEditInput.ProduceDate, |
|
|
|
|
|
SupplierBatch = splitPackingRecEditInput.SupplierBatch, |
|
|
|
|
|
ToContainerCode = detailInput.ContainerCode, |
|
|
|
|
|
ToStatus = EnumInventoryStatus.OK, |
|
|
|
|
|
TransSubType = EnumTransSubType.Transfer_SplitPacking |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
// transferLogCreateInputs.Add(transferLog);
|
|
|
return transferLogEditInput; |
|
|
//}
|
|
|
} |
|
|
|
|
|
|
|
|
return transferLogCreateInputs; |
|
|
private async Task CreateLabelAsync() |
|
|
|
|
|
{ |
|
|
|
|
|
var batchInsert=await _splitPackingRecAppService.BatchInsertAsync().ConfigureAwait(false); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|