#region << 版 本 注 释 >>
|
|
/*----------------------------------------------------------------
|
* 命名空间:WIDESEAWCS_Tasks.ConveyorLineJob
|
* 创建者:胡童庆
|
* 创建时间:2024/8/2 16:13:36
|
* 版本:V1.0.0
|
* 描述:
|
*
|
* ----------------------------------------------------------------
|
* 修改人:
|
* 修改时间:
|
* 版本:V1.0.1
|
* 修改说明:
|
*
|
*----------------------------------------------------------------*/
|
|
#endregion << 版 本 注 释 >>
|
|
using AutoMapper;
|
using WIDESEAWCS_Common.TaskEnum;
|
using WIDESEAWCS_Core;
|
using WIDESEAWCS_Core.Helper;
|
using WIDESEAWCS_ITaskInfoService;
|
using WIDESEAWCS_Model.Models;
|
using WIDESEAWCS_QuartzJob;
|
using WIDESEAWCS_QuartzJob.Service;
|
|
namespace WIDESEAWCS_Tasks
|
{
|
public class ConveyorLineDispatchHandler
|
{
|
private readonly ITaskService _taskService;
|
private readonly ITaskExecuteDetailService _taskExecuteDetailService;
|
private readonly IRouterService _routerService;
|
private readonly IMapper _mapper;
|
|
private readonly ConveyorLineTaskFilter _taskFilter;
|
private readonly ConveyorLineTargetAddressSelector _targetAddressSelector;
|
|
public ConveyorLineDispatchHandler(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper)
|
{
|
_taskService = taskService;
|
_taskExecuteDetailService = taskExecuteDetailService;
|
_routerService = routerService;
|
_mapper = mapper;
|
|
_taskFilter = new ConveyorLineTaskFilter(taskService);
|
_targetAddressSelector = new ConveyorLineTargetAddressSelector();
|
}
|
|
/// <summary>
|
/// 心跳处理
|
/// </summary>
|
public void HeartBeat(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, string childDeviceCode)
|
{
|
conveyorLine.SetValue(ConveyorLineDBNameNew.TaskNo, 0, childDeviceCode);
|
}
|
|
/// <summary>
|
/// 输送线请求入库
|
/// </summary>
|
public void RequestInbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, string childDeviceCode)
|
{
|
if (_taskFilter.RequestWmsTask(command.Barcode, childDeviceCode))
|
{
|
Dt_Task? task = _taskFilter.QueryPendingTask(conveyorLine.DeviceCode, childDeviceCode);
|
if (task != null)
|
{
|
ConveyorLineTaskCommandNew taskCommand = _mapper.Map<ConveyorLineTaskCommandNew>(task);
|
taskCommand.WCS_ACK = command.WCS_ACK;
|
conveyorLine.SendCommand(taskCommand, childDeviceCode);
|
|
_taskService.UpdateTaskStatusToNext(task);
|
}
|
}
|
}
|
|
/// <summary>
|
/// 输送线请求入库下一地址
|
/// </summary>
|
public void RequestInNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, string childDeviceCode)
|
{
|
Dt_Task? task = _taskFilter.QueryExecutingTask(command.TaskNo, childDeviceCode);
|
if (task == null)
|
{
|
return;
|
}
|
|
_targetAddressSelector.HandleInboundNextAddress(conveyorLine, task.NextAddress, childDeviceCode);
|
|
Dt_Task? newTask = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
|
if (newTask != null)
|
{
|
if (_taskService.UpdateTaskStatusToNext(newTask).Status && newTask.TaskState == (int)TaskInStatusEnum.Line_InFinish)
|
{
|
conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_STB, 1, childDeviceCode);
|
}
|
}
|
}
|
|
/// <summary>
|
/// 输送线入库完成
|
/// </summary>
|
public void ConveyorLineInFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, string childDeviceCode)
|
{
|
Dt_Task? task = _taskFilter.QueryExecutingTask(command.TaskNo, childDeviceCode);
|
if (task != null)
|
{
|
conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 1, childDeviceCode);
|
WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
|
Console.Out.WriteLine(content.Serialize());
|
}
|
}
|
|
/// <summary>
|
/// 输送线请求出信息
|
/// </summary>
|
public void RequestOutbound(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, string childDeviceCode)
|
{
|
Dt_Task? task = _taskFilter.QueryPendingTask(conveyorLine.DeviceCode, childDeviceCode);
|
if (task != null)
|
{
|
conveyorLine.SetValue(ConveyorLineDBNameNew.TaskNo, task.TaskNum, childDeviceCode);
|
conveyorLine.SetValue(ConveyorLineDBNameNew.Barcode, task.PalletCode, childDeviceCode);
|
conveyorLine.SetValue(ConveyorLineDBNameNew.Target, task.TargetAddress, childDeviceCode);
|
conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 1, childDeviceCode);
|
|
_taskService.UpdateTaskStatusToNext(task);
|
}
|
}
|
|
/// <summary>
|
/// 输送线请求出库下一地址
|
/// </summary>
|
public void RequestOutNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, string childDeviceCode)
|
{
|
Dt_Task? task = _taskFilter.QueryExecutingTask(command.TaskNo, childDeviceCode);
|
if (task == null)
|
{
|
return;
|
}
|
|
_targetAddressSelector.HandleOutboundNextAddress(conveyorLine, task.NextAddress, childDeviceCode);
|
|
_ = _taskService.UpdatePosition(task.TaskNum, task.CurrentAddress);
|
}
|
|
/// <summary>
|
/// 输送线出库完成
|
/// </summary>
|
public void ConveyorLineOutFinish(CommonConveyorLine conveyorLine, ConveyorLineTaskCommandNew command, string childDeviceCode)
|
{
|
Dt_Task? task = _taskFilter.QueryExecutingTask(command.TaskNo, childDeviceCode);
|
if (task != null)
|
{
|
conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 1, childDeviceCode);
|
WebResponseContent content = _taskService.UpdateTaskStatusToNext(task);
|
Console.Out.WriteLine(content.Serialize());
|
}
|
}
|
}
|
}
|