|
|
@ -22,6 +22,7 @@ using Win_in.Sfs.Shared.Domain; |
|
|
|
using Win_in.Sfs.Shared.Domain.Shared; |
|
|
|
using Win_in.Sfs.Shared.Event; |
|
|
|
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
|
|
|
using Win_in.Sfs.Wms.Inventory.Domain; |
|
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|
|
|
using Win_in.Sfs.Wms.Store.Domain; |
|
|
|
using Win_in.Sfs.Wms.Store.Domain.Shared; |
|
|
@ -50,6 +51,7 @@ public class ThirdLocationRequestAppService : SfsStoreRequestAppServiceBase<Thir |
|
|
|
private readonly IBalanceAppService _balanceAppService; |
|
|
|
private readonly IThirdLocationJobAppService _thirdLocationJobAppService; |
|
|
|
private readonly IThirdLocationJobRepository _thirdLocationJobRepository; |
|
|
|
private readonly IBalanceManager _balanceManager; |
|
|
|
|
|
|
|
public ThirdLocationRequestAppService( |
|
|
|
IThirdLocationRequestRepository repository, |
|
|
@ -65,6 +67,7 @@ public class ThirdLocationRequestAppService : SfsStoreRequestAppServiceBase<Thir |
|
|
|
ITransactionTypeAppService transactionTypeAppService, |
|
|
|
IExpectOutAppService expectOutAppService, |
|
|
|
IBalanceAppService balanceAppService, |
|
|
|
IBalanceManager balanceManager, |
|
|
|
IInjectionIssueJobAppService issueJobAppService) |
|
|
|
: base(repository, thirdLocationRequestManager) |
|
|
|
{ |
|
|
@ -80,6 +83,7 @@ public class ThirdLocationRequestAppService : SfsStoreRequestAppServiceBase<Thir |
|
|
|
_balanceAppService= balanceAppService; |
|
|
|
_thirdLocationJobAppService= thirdLocationJobAppService; |
|
|
|
_thirdLocationJobRepository= thirdLocationJobRepository; |
|
|
|
_balanceManager= balanceManager; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -147,26 +151,56 @@ public class ThirdLocationRequestAppService : SfsStoreRequestAppServiceBase<Thir |
|
|
|
CheckLocation(toLocationDto, detailInput.ToLocationCode); |
|
|
|
|
|
|
|
var itemBasicDto = await _itemBasicAppService.GetByCodeAsync(detailInput.ItemCode).ConfigureAwait(false); |
|
|
|
CheckItemBasic(itemBasicDto, detailInput.ItemCode); |
|
|
|
var balanceNums= await _balanceAppService.GetListByLocationCodeAndItemCodeAsync(detailInput.FromLocationCode, detailInput.ItemCode).ConfigureAwait(false); |
|
|
|
decimal balanceSum = 0; |
|
|
|
foreach (var item in balanceNums) |
|
|
|
CheckItemBasic(itemBasicDto, detailInput.ItemCode); |
|
|
|
|
|
|
|
List<string> locationCodes=new List<string>(); |
|
|
|
locationCodes.Add(detailInput.FromLocationCode); |
|
|
|
List<EnumInventoryStatus> inventoryStatusList = new List<EnumInventoryStatus>(); |
|
|
|
inventoryStatusList.Add(EnumInventoryStatus.OK); |
|
|
|
|
|
|
|
var fromLocationDto = await _locationAppService.GetByCodeAsync(detailInput.FromLocationCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
List<Balance> inventoryBalances; |
|
|
|
if (fromLocationDto.Type== EnumLocationType.RAW) |
|
|
|
{ |
|
|
|
balanceSum += item.Qty; |
|
|
|
inventoryBalances = await _balanceManager.GetUsableListAsync(detailInput.ItemCode, locationCodes, inventoryStatusList, true).ConfigureAwait(false); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
inventoryBalances = await _balanceManager.GetUsableListAsync(detailInput.ItemCode, locationCodes, inventoryStatusList, false).ConfigureAwait(false); |
|
|
|
} |
|
|
|
var expectOutNums= await _expectOutAppService.GetListByItemAsync(detailInput.ItemCode).ConfigureAwait(false); |
|
|
|
decimal expectOutSum = 0; |
|
|
|
foreach (var item in expectOutNums) |
|
|
|
|
|
|
|
decimal balanceSum = 0; |
|
|
|
foreach (var item in inventoryBalances) |
|
|
|
{ |
|
|
|
expectOutSum += item.Qty; |
|
|
|
balanceSum += item.Qty; |
|
|
|
} |
|
|
|
decimal realityBalance = balanceSum - expectOutSum; |
|
|
|
if (detailInput.Qty> realityBalance) |
|
|
|
|
|
|
|
if (detailInput.Qty > balanceSum) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException($"{detailInput.ItemCode} 物品的库存为 {realityBalance} ,库存不够"); |
|
|
|
throw new UserFriendlyException($"{detailInput.ItemCode} 物品的库存为 {balanceSum} ,库存不够"); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//var balanceNums= await _balanceAppService.GetListByLocationCodeAndItemCodeAsync(detailInput.FromLocationCode, detailInput.ItemCode).ConfigureAwait(false);
|
|
|
|
//decimal balanceSum = 0;
|
|
|
|
//foreach (var item in balanceNums)
|
|
|
|
//{
|
|
|
|
// balanceSum += item.Qty;
|
|
|
|
//}
|
|
|
|
//var expectOutNums= await _expectOutAppService.GetListByItemAsync(detailInput.ItemCode).ConfigureAwait(false);
|
|
|
|
//decimal expectOutSum = 0;
|
|
|
|
//foreach (var item in expectOutNums)
|
|
|
|
//{
|
|
|
|
// expectOutSum += item.Qty;
|
|
|
|
//}
|
|
|
|
//decimal realityBalance = balanceSum - expectOutSum;
|
|
|
|
//if (detailInput.Qty> realityBalance)
|
|
|
|
//{
|
|
|
|
// throw new UserFriendlyException($"{detailInput.ItemCode} 物品的库存为 {realityBalance} ,库存不够");
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
detailInput.ToLocationErpCode = toLocationDto.ErpLocationCode; |
|
|
|
|
|
|
|
|
|
|
|