68 lines
2.2 KiB
C#
68 lines
2.2 KiB
C#
using JSMachine.WMS.App.Dto;
|
|
using JSMachine.WMS.App.Dto.Enum;
|
|
using JSMachine.WMS.Infrastructure.Helper;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace JSMachine.WMS.Business.StockIn.ServiceImpl.ResponsibilityChain
|
|
{
|
|
/// <summary>
|
|
/// 和其他不同批次的货物混合放置
|
|
/// </summary>
|
|
public class StockInByMixing : StockInHandler
|
|
{
|
|
public override async Task<StorageRackDto> CalculateWarehouse(
|
|
TransportEnum startArea,
|
|
FloorEnum floor,
|
|
string materialBatch,
|
|
List<StorageRackDto> storageRacks)
|
|
{
|
|
if (storageRacks.IsNullOrEmpty())
|
|
{
|
|
storageRacks = await base.GetStorageRackExceptStockout(floor);
|
|
}
|
|
|
|
if (storageRacks.IsNullOrEmpty())
|
|
{
|
|
LogHelper.Info("没有可用库位");
|
|
return null;
|
|
}
|
|
|
|
List<StorageRackDto> wareHousesSorted = storageRacks.OrderBy(p => p.AreaNumSort).ToList();
|
|
|
|
IEnumerable<IGrouping<long, StorageRackDto>> groupByColumn = wareHousesSorted.GroupBy(p => p.ReservoirAreaColumnId);
|
|
|
|
StorageRackDto destStorageRack = null;
|
|
foreach (var columnGroup in groupByColumn)
|
|
{
|
|
bool unlockedColumn = columnGroup.All(p => !p.IsLock);
|
|
if (unlockedColumn)
|
|
{
|
|
destStorageRack = columnGroup
|
|
.Where(p => string.IsNullOrEmpty(p.BarCode))
|
|
.OrderByDescending(p => p.NumSort)
|
|
.FirstOrDefault();
|
|
|
|
if (destStorageRack != null)
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (destStorageRack == null && startArea != TransportEnum.TransitArea)
|
|
{
|
|
destStorageRack = await _storageRackService.GetUsableTransferStorageRack();
|
|
|
|
if (destStorageRack == null)
|
|
{
|
|
LogHelper.Warn($"存储区和中转区均无可用的库位");
|
|
}
|
|
}
|
|
|
|
return destStorageRack;
|
|
}
|
|
}
|
|
}
|