Browse Source

修改 库存调拨 异常生成接口数据

master
郑勃旭 4 months ago
parent
commit
ac9c6ca8ef
  1. 17
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/TransferRequestEventHandler.cs

17
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/TransferRequestEventHandler.cs

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using DocumentFormat.OpenXml.Bibliography; using DocumentFormat.OpenXml.Bibliography;
using Volo.Abp;
using Volo.Abp.EventBus; using Volo.Abp.EventBus;
using Volo.Abp.EventBus.Local; using Volo.Abp.EventBus.Local;
using Volo.Abp.SettingManagement; using Volo.Abp.SettingManagement;
@ -9,6 +10,7 @@ using Volo.Abp.Uow;
using Win_in.Sfs.Basedata.Application.Contracts; 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.Shared.Event; using Win_in.Sfs.Shared.Event;
using Win_in.Sfs.Wms.Inventory.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;
@ -26,14 +28,16 @@ public class TransferRequestEventHandler
private readonly ITransferNoteManager _transferNoteManager; private readonly ITransferNoteManager _transferNoteManager;
private readonly ILocationAppService _locationAppService; private readonly ILocationAppService _locationAppService;
private readonly ITransferRequestManager _transferRequestManager; private readonly ITransferRequestManager _transferRequestManager;
private readonly IBalanceAppService _balanceAppService;
protected ILocalEventBus LocalEventBus => LazyServiceProvider.LazyGetRequiredService<ILocalEventBus>(); protected ILocalEventBus LocalEventBus => LazyServiceProvider.LazyGetRequiredService<ILocalEventBus>();
public TransferRequestEventHandler( public TransferRequestEventHandler(
ITransferNoteManager transferNoteManager, ILocationAppService locationAppService, ITransferRequestManager transferRequestManager) ITransferNoteManager transferNoteManager, ILocationAppService locationAppService, ITransferRequestManager transferRequestManager, IBalanceAppService balanceAppService)
{ {
_transferNoteManager = transferNoteManager; _transferNoteManager = transferNoteManager;
_locationAppService = locationAppService; _locationAppService = locationAppService;
_transferRequestManager = transferRequestManager; _transferRequestManager = transferRequestManager;
_balanceAppService = balanceAppService;
} }
@ -53,6 +57,17 @@ public class TransferRequestEventHandler
{ {
var input = ObjectMapper.Map<TransferRequest, TransferNote>(entity); var input = ObjectMapper.Map<TransferRequest, TransferNote>(entity);
foreach (var detail in input.Details)
{
var balanceDto=await _balanceAppService.GetRealQtyByPackingCodeAndItemCodeAndLocationCodeAndStatusAsync(
detail.FromPackingCode, detail.ItemCode, detail.FromLocationCode, EnumInventoryStatus.OK).ConfigureAwait(false);
if (balanceDto.Qty < detail.Qty)
{
throw new UserFriendlyException($"{detail.ItemCode}库存不足,申请数量{detail.Qty},现有可用库存{balanceDto.Qty}");
}
}
//获取在途库 //获取在途库
var locationDto = await _locationAppService.GetFirstByTypeAsync(EnumLocationType.TRANSPORT) var locationDto = await _locationAppService.GetFirstByTypeAsync(EnumLocationType.TRANSPORT)
.ConfigureAwait(false); .ConfigureAwait(false);

Loading…
Cancel
Save