Browse Source

添加 推荐库存查询

dev_DY_CC
郑勃旭 12 months ago
parent
commit
466db5ef9a
  1. 84
      be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Inventories/BalanceController.cs
  2. 2
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/KittingIssueRequestEventHandler.cs

84
be/Hosts/WmsPda.Host/Win_in.Sfs.Wms.Pda.Host/Controllers/Inventories/BalanceController.cs

@ -1,9 +1,14 @@
using DocumentFormat.OpenXml.Drawing.Charts;
using Volo.Abp.AutoMapper;
namespace Win_in.Sfs.Wms.Pda.Controllers.Inventories;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AutoMapper;
using Castle.Components.DictionaryAdapter;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Volo.Abp;
@ -26,12 +31,11 @@ using JsonSerializer = System.Text.Json.JsonSerializer;
public class BalanceController : AbpController
{
private readonly IBalanceAppService _balanceAppService;
private readonly IItemBasicAppService _itemBasicAppService;
private readonly ILocationAppService _locationAppService;
private readonly IExpectOutAppService _expectOutAppService;
private readonly IProductionLineItemAppService _productionLineItemAppService;
private IMapper _mapper;
/// <summary>
///
@ -43,11 +47,12 @@ public class BalanceController : AbpController
public BalanceController(
IBalanceAppService balanceAppService,
IItemBasicAppService itemBasicAppService,
ILocationAppService locationAppService, IExpectOutAppService expectOutAppService)
ILocationAppService locationAppService, IExpectOutAppService expectOutAppService, IProductionLineItemAppService productionLineItemAppService)
{
this._balanceAppService = balanceAppService;
this._locationAppService = locationAppService;
_expectOutAppService = expectOutAppService;
_productionLineItemAppService = productionLineItemAppService;
this._itemBasicAppService = itemBasicAppService;
}
@ -482,6 +487,77 @@ public class BalanceController : AbpController
return await this._balanceAppService.GetPagedListByFilterAsync(input, false).ConfigureAwait(false);
}
/// <summary>
///
/// </summary>
/// <param name="itemCode"></param>
/// <param name="productLine"></param>
/// <returns></returns>
[HttpPost("get-recommend-balance")]
public async Task<List<SortBalance>> GetRecommendBalance(string itemCode,string productLine)
{
var productionLineItemDto = await _productionLineItemAppService.GetByProductLineCodeAndItemCodeAsync(productLine, itemCode).ConfigureAwait(false);
//获取可用库存
var input = new RecommendBalanceRequestInput
{
ItemCode = itemCode,
Qty = decimal.MaxValue,
Statuses = new EditableList<EnumInventoryStatus> { EnumInventoryStatus.OK },
Locations =
JsonSerializer.Deserialize<List<string>>(productionLineItemDto.RawLocationCodeListJson),
IsPackingCode = true
};
var usableList = await _balanceAppService.GetUsableListAsync(input).ConfigureAwait(false);
return await SortByFifoAsync(usableList).ConfigureAwait(false);
}
/// <summary>
/// 排序规则 1.批次正序 2.底层 3.到货日期正序 4.数量倒序(整箱优先) 5.库位正序 6.箱码正序
/// </summary>
/// <param name="balances"></param>
/// <returns></returns>
private async Task<List<SortBalance>> SortByFifoAsync(List<BalanceDTO> balances)
{
var sortBalances = new List<SortBalance>();
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<BalanceDTO, SortBalance>()
.Ignore(x => x.LocationRow);
});
_mapper = new Mapper(config);
var resultBalances = _mapper.Map<List<BalanceDTO>, List<SortBalance>>(balances);
foreach (var resultBalance in resultBalances)
{
var locationDto = await _locationAppService.GetByCodeAsync(resultBalance.LocationCode).ConfigureAwait(false);
resultBalance.LocationRow = locationDto.RowCode;
}
resultBalances
.OrderBy(p => p.Lot)
.ThenBy(p => p.LocationRow)
.ThenBy(p => p.PutInTime)
.ThenBy(p => p.Qty)//2023-9-14 苑静雯 从小数开始发料
.ThenBy(p => p.LocationCode)
.ThenBy(p => p.PackingCode)
.ToList();
return resultBalances;
}
/// <summary>
///
/// </summary>
public class SortBalance : BalanceDTO
{
/// <summary>
///
/// </summary>
public int LocationRow { get; set; }
}
/*
/// <summary>
/// 查询库余额

2
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Event/Requests/KittingIssueRequestEventHandler.cs

@ -690,7 +690,7 @@ public class KittingIssueRequestEventHandler
resultBalances
.OrderBy(p => p.Lot)
.OrderBy(p=>p.LocationRow)
.ThenBy(p=>p.LocationRow)
.ThenBy(p => p.PutInTime)
.ThenBy(p => p.Qty)//2023-9-14 苑静雯 从小数开始发料
.ThenBy(p => p.LocationCode)

Loading…
Cancel
Save