first commit
This commit is contained in:
+90
@@ -0,0 +1,90 @@
|
||||
using JSMachine.WMS.App.Dto;
|
||||
using JSMachine.WMS.App.Dto.Enum;
|
||||
using JSMachine.WMS.App.IService;
|
||||
using JSMachine.WMS.App.ServiceImpl;
|
||||
using JSMachine.WMS.Business.RcsCallBack.IService.StrategyPattern;
|
||||
using JSMachine.WMS.Infrastructure.Helper;
|
||||
using JSMachine.WMS.PLC.ModbusImpl.Elevator.Model;
|
||||
using JSMachine.WMS.PLC.ModbusImpl.PaperFeedGroundRack.ModbusIO.Write;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JSMachine.WMS.Business.RcsCallBack.ServiceImpl.StrategyPatternImpl
|
||||
{
|
||||
public class ElevatorStrategy : ITaskCompletionStrategy
|
||||
{
|
||||
private readonly IElevatorPlcQueueService _elevatorPlcQueueService;
|
||||
private readonly IStorageRackService _storageRackService;
|
||||
private readonly IAGVTaskService _agvTaskService;
|
||||
private readonly IElevatorCountService _elevatorCountService;
|
||||
|
||||
public ElevatorStrategy(
|
||||
IElevatorPlcQueueService elevatorPlcQueueService,
|
||||
IStorageRackService storageRackService,
|
||||
IElevatorCountService elevatorCountService,
|
||||
IAGVTaskService agvTaskService)
|
||||
{
|
||||
_elevatorPlcQueueService = elevatorPlcQueueService;
|
||||
_storageRackService = storageRackService;
|
||||
_elevatorCountService = elevatorCountService;
|
||||
_agvTaskService = agvTaskService;
|
||||
}
|
||||
|
||||
public async Task<bool> CompleteTaskAsync(AGVTaskDto agvTask, StorageRackDto destWarehouse)
|
||||
{
|
||||
ElevatorPlcStatus elevatorPlcStatus = new();
|
||||
|
||||
int elevatorNo = destWarehouse.StorageRackName.Contains("1号") ? 1 : 2;
|
||||
elevatorPlcStatus.ElevatorNo = elevatorNo;
|
||||
|
||||
if (destWarehouse.ElevatorChannel == 1001)
|
||||
{
|
||||
elevatorPlcStatus.StockInPutdownChanelTwo = true;
|
||||
}
|
||||
if (destWarehouse.ElevatorChannel == 1011)
|
||||
{
|
||||
elevatorPlcStatus.StockInPutdownChanelOne = true;
|
||||
}
|
||||
|
||||
bool bRet = await ElevatorWrite.WriteElevator(elevatorPlcStatus);
|
||||
|
||||
if (!bRet)
|
||||
{
|
||||
LogHelper.Error($"向 {elevatorPlcStatus.ElevatorNo} 号提升机 {destWarehouse.ElevatorChannel} 网带写放货完成信号失败");
|
||||
return false;
|
||||
}
|
||||
|
||||
ElevatorPlcQueueDto elevatorPlcQueue = new()
|
||||
{
|
||||
ElevatorNo = elevatorNo,
|
||||
ElevatorChannel = destWarehouse.ElevatorChannel.Value,
|
||||
AgvTaskId = agvTask.Id,
|
||||
IsLock = false
|
||||
};
|
||||
|
||||
bRet = await _elevatorPlcQueueService.Add(elevatorPlcQueue);
|
||||
if (!bRet)
|
||||
{
|
||||
LogHelper.Error($"写PLC队列失败");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.Info($"入库:写提升机队列成功 提升机编号 {elevatorPlcQueue.ElevatorNo} 通道号 {elevatorPlcQueue.ElevatorChannel}");
|
||||
}
|
||||
|
||||
agvTask.TaskStatus = TaskStatusEnum.Completed;
|
||||
await _agvTaskService.EditSingalWithSpecificCols(agvTask, ["TaskStatus"]);
|
||||
|
||||
//解锁提升机通道库位
|
||||
await _storageRackService.Unlock(destWarehouse);
|
||||
//提升机计数
|
||||
await _elevatorCountService.IncrementCount(elevatorNo, elevatorPlcQueue.ElevatorChannel);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user