66 lines
2.4 KiB
C#
66 lines
2.4 KiB
C#
using JSMachine.WMS.App.Dto;
|
|||
|
|
using JSMachine.WMS.App.Dto.Enum;
|
||
|
|
using JSMachine.WMS.App.IService;
|
||
|
|
using JSMachine.WMS.Business.StockIn.IService;
|
||
|
|
using JSMachine.WMS.Infrastructure;
|
||
|
|
using JSMachine.WMS.Infrastructure.Helper;
|
||
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Text;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
using static JSMachine.WMS.App.Dto.StorageRackDto;
|
||
|
|
|
||
|
|
namespace JSMachine.WMS.Business.StockIn.ServiceImpl.Strategy
|
||
|
|
{
|
||
|
|
/// <summary>
|
||
|
|
/// 完全混放策略
|
||
|
|
/// </summary>
|
||
|
|
public class CompleteMixingStrategy : IStockInStrategy
|
||
|
|
{
|
||
|
|
private static readonly IStorageRackService StorageRackService = GlobalServericeProvidor.GetService<IStorageRackService>();
|
||
|
|
private FloorEnum _floor;
|
||
|
|
private TransportEnum _startArea;
|
||
|
|
private string _materiaBatch;
|
||
|
|
|
||
|
|
public CompleteMixingStrategy(TransportEnum startArea, FloorEnum floor, string materiaBatch)
|
||
|
|
{
|
||
|
|
_startArea = startArea;
|
||
|
|
_materiaBatch = materiaBatch;
|
||
|
|
_floor = floor;
|
||
|
|
}
|
||
|
|
|
||
|
|
public async Task<StorageRackDto> CalCulateWarehouse()
|
||
|
|
{
|
||
|
|
//如果某一列有一个库位被锁定,说明该列有未完成的任务(任务完成会解锁库位),因此该列不可以再生成新的任务
|
||
|
|
|
||
|
|
//获取楼层的所有库位
|
||
|
|
List<StorageRackDto> wareHouses = await StorageRackService.GetListByExpression(p =>
|
||
|
|
p.Floor == _floor && p.Transport == TransportEnum.NormalArea);
|
||
|
|
|
||
|
|
if (wareHouses.IsNullOrEmpty())
|
||
|
|
{
|
||
|
|
LogHelper.Warn($"{_floor} 层没有空余库位");
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
wareHouses = wareHouses.OrderBy(p => p.AreaNumSort).ToList();
|
||
|
|
|
||
|
|
IEnumerable<IGrouping<long, StorageRackDto>> groupByColumn = wareHouses.GroupBy(p => p.ReservoirAreaColumnId);
|
||
|
|
|
||
|
|
StorageRackDto destStorageRack = null;
|
||
|
|
foreach (var columnGroup in groupByColumn)
|
||
|
|
{
|
||
|
|
bool emptyColumn = columnGroup.All(p => !p.IsLock && !p.IsDisabled && string.IsNullOrEmpty(p.BarCode));
|
||
|
|
if (emptyColumn)
|
||
|
|
{
|
||
|
|
destStorageRack = columnGroup.OrderByDescending(p => p.NumSort).First();
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return destStorageRack;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|