first commit

This commit is contained in:
2026-09-02 16:31:50 +08:00
commit a461727193
911 changed files with 692450 additions and 0 deletions
@@ -0,0 +1,65 @@
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;
}
}
}
@@ -0,0 +1,35 @@
using JSMachine.WMS.App.Dto;
using JSMachine.WMS.App.Dto.Enum;
using JSMachine.WMS.Business.StockIn.IService;
using JSMachine.WMS.Business.StockIn.ServiceImpl.ResponsibilityChain;
namespace JSMachine.WMS.Business.StockIn.ServiceImpl.Strategy
{
/// <summary>
/// 混合模式策略。同批次的优先放同一列,如果没有库位则混放
/// </summary>
public class MixedModeStrategy : IStockInStrategy
{
private FloorEnum _floor;
private TransportEnum _startArea;
private string _materiaBatch;
public MixedModeStrategy(TransportEnum startArea, FloorEnum floor, string materiaBatch)
{
_floor = floor;
_startArea = startArea;
_materiaBatch = materiaBatch;
}
public async Task<StorageRackDto> CalCulateWarehouse()
{
StockInByExist stockInByExist = new();
StockInByNew stockInByNew = new();
StockInByMixing stockInByMixing = new();
stockInByExist.SetNextHandler(stockInByNew);
stockInByNew.SetNextHandler(stockInByMixing);
return await stockInByExist.CalculateWarehouse(_startArea, _floor, _materiaBatch, null);
}
}
}
@@ -0,0 +1,43 @@
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.Business.StockIn.ServiceImpl.ResponsibilityChain;
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 NoMixingStrategy : IStockInStrategy
{
private static readonly IStorageRackService StorageRackService = GlobalServericeProvidor.GetService<IStorageRackService>();
private FloorEnum _floor;
private TransportEnum _startArea;
private string _materiaBatch;
public NoMixingStrategy(TransportEnum startArea, FloorEnum floor, string materiaBatch)
{
_floor = floor;
_startArea = startArea;
_materiaBatch = materiaBatch;
}
public async Task<StorageRackDto> CalCulateWarehouse()
{
StockInByExist stockInByExist = new();
StockInByNew stockInByNew = new();
stockInByExist.SetNextHandler(stockInByNew);
return await stockInByExist.CalculateWarehouse(_startArea, _floor, _materiaBatch, null);
}
}
}
@@ -0,0 +1,42 @@
using JSMachine.WMS.App.Dto.Enum;
using JSMachine.WMS.App.Dto;
using JSMachine.WMS.Business.StockIn.IService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JSMachine.WMS.Common;
using JSMachine.WMS.Infrastructure;
using JSMachine.WMS.App.IService;
namespace JSMachine.WMS.Business.StockIn.ServiceImpl.Strategy
{
/// <summary>
/// 根据楼层和配置的混放模式选择入库库位计算策略。
/// </summary>
public class StrategyFactory
{
/// <summary>
/// 0-完全不混放 1-混合模式,优先同批次放一列,没有空库位再混放 2-完全混放模式,不用批次货物放一起
/// </summary>
/// <param name="startArea">入库起始区域。</param>
/// <param name="floor">目标楼层。</param>
/// <param name="materiaBatch">物料批次。</param>
/// <returns>与当前入库条件匹配的库位计算策略。</returns>
public static IStockInStrategy CreateStockInStrategy(TransportEnum startArea, FloorEnum floor, string materiaBatch)
{
switch (floor == FloorEnum.FirstFloor ? 0 : Global.AppSettings.PlcaementMod)
{
case 0:
return new NoMixingStrategy(startArea, floor, materiaBatch);
case 1:
return new MixedModeStrategy(startArea, floor, materiaBatch);
case 2:
return new CompleteMixingStrategy(startArea, floor, materiaBatch);
default:
return new NoMixingStrategy(startArea, floor, materiaBatch);
}
}
}
}