Files
ww-jst/wmsjst/JSMachine.WMS.Business/RcsCallBack/ServiceImpl/StatePattern/PutdownCompleted/ElevatorDeliveryHandler.cs
T
2026-09-02 16:31:50 +08:00

105 lines
3.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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.SSE;
using JSMachine.WMS.Infrastructure;
using JSMachine.WMS.Infrastructure.Helper;
using JSMachine.WMS.PLC.ModbusImpl.Elevator.Model;
using JSMachine.WMS.PLC.ModbusImpl.PaperFeedGroundRack.ModbusIO.Write;
using JSMachine.WMS.RPC.RcsRPC.Dto.In;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JSMachine.WMS.Business.RcsCallBack.ServiceImpl.StatePattern.PutdownCompleted
{
/// <summary>
/// 提升机处理器
/// </summary>
public class ElevatorDeliveryHandler : PutdownCompletedStateHandler
{
public ElevatorDeliveryHandler
(IStorageRackService storageRackService,
IAGVTaskService agvTaskService,
IElevatorPlcQueueService elevatorPlcQueueService,
IElevatorCountService elevatorCountService,
IERPTaskService erpTaskService) :
base(storageRackService, agvTaskService, elevatorPlcQueueService, elevatorCountService, erpTaskService)
{
}
public async override Task<bool> HandleAsync(AgvExcutionInfo agvExcutionInfo, AGVTaskDto agvTask, StorageRackDto destWarehouse)
{
var elevatorPlcStatus = new ElevatorPlcStatus();
//2.1 写PLC放货完成
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;
}
if (destWarehouse.ElevatorChannel == 2001)
{
elevatorPlcStatus.StockOutPutdownChanelTwo = true;
}
if (destWarehouse.ElevatorChannel == 2011)
{
elevatorPlcStatus.StockOutPutdownChanelOne = true;
}
bool bRet = await ElevatorWrite.WriteElevator(elevatorPlcStatus);
if (!bRet)
{
LogHelper.Error($"{agvTask.TaskType.GetDescription()}: " +
$"向 {elevatorPlcStatus.ElevatorNo} 号提升机 {destWarehouse.ElevatorChannel} 网带写放货完成信号失败");
return false;
}
if(agvTask.TaskType!=TaskTypeEnum.Carry)
{
//2.2 写PLC队列信息
ElevatorPlcQueueDto elevatorPlcQueue = new()
{
ElevatorNo = elevatorNo,
ElevatorChannel = destWarehouse.ElevatorChannel.Value,
AgvTaskId = agvTask.Id,
IsLock = false
};
bRet = await _elevatorPlcQueueService.Add(elevatorPlcQueue);
if (!bRet)
{
LogHelper.Error($"{agvTask.TaskType.GetDescription()}:写PLC队列失败");
return false;
}
else
{
LogHelper.Info($"{agvTask.TaskType.GetDescription()}:" +
$"写PLC队列成功,提升机编号 {elevatorPlcQueue.ElevatorNo} 通道号 {elevatorPlcQueue.ElevatorChannel}");
}
//提升机计数
await _elevatorCountService.IncrementCount(elevatorNo, elevatorPlcQueue.ElevatorChannel);
}
//2.3 更新agvtask的状态为完成
await base.CompleteTask(agvTask);
//2.4 解锁提升机库位
await _storageRackService.Unlock(destWarehouse);
//发送广播通知前端网站刷新页面
SseEngine.BrodCast(agvTask.Floor.ToString());
return true;
}
}
}