first commit
This commit is contained in:
+106
@@ -0,0 +1,106 @@
|
||||
using JSMachine.WMS.App.Dto;
|
||||
using JSMachine.WMS.App.Dto.Enum;
|
||||
using JSMachine.WMS.App.IService;
|
||||
using JSMachine.WMS.Domain.Entity;
|
||||
using JSMachine.WMS.Infrastructure;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JSMachine.WMS.Business.StockIn.ServiceImpl.ResponsibilityChain
|
||||
{
|
||||
/// <summary>
|
||||
/// 责任链模式。入库处理基类 。责任流动方向:StockInByExist=》StockInByNew=》StockInByMixing
|
||||
/// </summary>
|
||||
public abstract class StockInHandler
|
||||
{
|
||||
protected StockInHandler _nextHandler;
|
||||
protected static IStorageRackService _storageRackService = GlobalServericeProvidor.GetService<IStorageRackService>();
|
||||
protected static IAGVTaskService _agvTaskService = GlobalServericeProvidor.GetService<IAGVTaskService>();
|
||||
protected static IERPTaskService _erpTaskService = GlobalServericeProvidor.GetService<IERPTaskService>();
|
||||
|
||||
protected static IStorageRackService StorageRackService = GlobalServericeProvidor.GetService<IStorageRackService>();
|
||||
protected static readonly SemaphoreSlim _SemaphoreSlim = new(1,1);
|
||||
|
||||
public void SetNextHandler(StockInHandler nextHandler)
|
||||
{
|
||||
_nextHandler = nextHandler;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算目标库位
|
||||
/// </summary>
|
||||
/// <param name="startStorageRack">起点</param>
|
||||
/// <param name="materialBatch">批次</param>
|
||||
/// <param name="storageRacks">所有未禁用的库位</param>
|
||||
/// <returns></returns>
|
||||
public abstract Task<StorageRackDto> CalculateWarehouse(
|
||||
TransportEnum startArea, FloorEnum floor, string materialBatch, List<StorageRackDto> storageRacks);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 有下一个处理者,则继续执行下一个处理者的逻辑
|
||||
/// </summary>
|
||||
/// <param name="startStorageRack">起点</param>
|
||||
/// <param name="materialBatch">批次</param>
|
||||
/// <param name="storageRacks">所有未禁用的库位</param>
|
||||
/// <returns></returns>
|
||||
public async Task<StorageRackDto> HandleByNext(
|
||||
TransportEnum startArea,
|
||||
FloorEnum floor,
|
||||
string materialBatch,
|
||||
List<StorageRackDto> storageRacks)
|
||||
{
|
||||
if (_nextHandler != null)
|
||||
{
|
||||
return await _nextHandler.CalculateWarehouse(startArea, floor, materialBatch, storageRacks);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<StorageRackDto>> GetStorageRackExceptStockout(FloorEnum floor)
|
||||
{
|
||||
List<StorageRackDto> storageRacks = await StorageRackService.GetListByExpression(p =>
|
||||
p.Floor == floor &&
|
||||
p.Transport == TransportEnum.NormalArea);
|
||||
|
||||
if(storageRacks.IsNullOrEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<ERPTaskDto> erpTaskStockOuts = await _erpTaskService
|
||||
.GetListByExpression(p =>
|
||||
p.CreationTime > DateTime.Now.AddDays(-1) &&
|
||||
p.TaskStatus == TaskStatusEnum.InExecution &&
|
||||
(p.TaskType == TaskTypeEnum.SaleOut || p.TaskType == TaskTypeEnum.ProductionOut)
|
||||
);
|
||||
|
||||
if (!erpTaskStockOuts.IsNullOrEmpty())
|
||||
{
|
||||
List<AGVTaskDto> agvTaks = await _agvTaskService.GetListByExpression(p =>
|
||||
p.CreationTime > DateTime.Now.AddDays(-1) &&
|
||||
erpTaskStockOuts.Select(x => x.Id).Contains(p.ErpTaskId)
|
||||
);
|
||||
|
||||
if (!agvTaks.IsNullOrEmpty())
|
||||
{
|
||||
List<StorageRackDto> startStorageRacks = await StorageRackService.GetListByExpression(p =>
|
||||
agvTaks.Select(x => x.StartPositionCode).Contains(p.StorageRackNo));
|
||||
|
||||
List<long> exceptCols = startStorageRacks.Select(p => p.ReservoirAreaColumnId).Distinct().ToList();
|
||||
|
||||
storageRacks.RemoveAll(p => exceptCols.Contains(p.ReservoirAreaColumnId));
|
||||
}
|
||||
}
|
||||
|
||||
return storageRacks;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user