using Newtonsoft.Json;
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
|
using System.Threading.Tasks;
|
using WIDESEAWCS_Common;
|
using WIDESEAWCS_Common.TaskEnum;
|
using WIDESEAWCS_Core;
|
using WIDESEAWCS_Core.Helper;
|
using WIDESEAWCS_DTO.TaskInfo;
|
using WIDESEAWCS_Model.Models;
|
using WIDESEAWCS_QuartzJob;
|
using WIDESEAWCS_QuartzJob.Models;
|
using WIDESEAWCS_Tasks.ConveyorLineJob;
|
|
namespace WIDESEAWCS_Tasks
|
{
|
public partial class ConveyorLineJob_YL2ndFloor
|
{
|
/// <summary>
|
/// 处理新任务
|
/// </summary>
|
private void HandleNewTask(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, Dt_StationManger stationManger)
|
{
|
switch (stationManger.StationType)
|
{
|
case 1:
|
RequestWmsRoadwayNo(conveyorLine, command, stationManger);
|
break;
|
case 21:
|
ConveyorLineInFinish(conveyorLine, command, stationManger);
|
break;
|
}
|
|
}
|
|
/// <summary>
|
/// 请求WMS任务
|
/// </summary>
|
private void RequestWmsRoadwayNo(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, Dt_StationManger stationManager)
|
{
|
try
|
{
|
var AGVFinishTask = _taskService.QueryBarCodeAGVFinishTask(command.TaskNum, stationManager.StationCode);
|
if (AGVFinishTask == null)
|
{
|
var log = $"时间:【{DateTime.Now}】【{conveyorLine.DeviceName}】托盘号:【{command.Barcode}】任务号:【{command.TaskNum}】设备编码:【{stationManager.StationCode}】【未找到任务】";
|
ConsoleHelper.WriteErrorLine(log);
|
|
WriteInfo(conveyorLine.DeviceName, log);
|
return;
|
}
|
WebResponseContent content = _taskService.UpdateTaskStatusToNext(AGVFinishTask, stationManager);
|
|
if (content.Status)
|
{
|
var ExecuteTask = _taskService.QueryLineExecuteTaskByBarcode(command.TaskNum, stationManager.StationCode);
|
if (ExecuteTask != null)
|
{
|
ConveyorLineTaskCommandWrite taskCommand = _mapper.Map<ConveyorLineTaskCommandWrite>(ExecuteTask);
|
bool sendFlag = SendCommand(taskCommand, conveyorLine, stationManager.StationCode);
|
if (sendFlag)
|
{
|
_taskService.UpdateTaskStatusToNext(ExecuteTask, stationManager);
|
}
|
}
|
}
|
else
|
{
|
WriteInfo(conveyorLine.DeviceName, content.Message);
|
}
|
}
|
catch (Exception ex)
|
{
|
WriteInfo(conveyorLine.DeviceName, $"【{conveyorLine.DeviceName}】托盘号:【{command.Barcode}】请求点位:【{stationManager.StationCode}】异常信息【{ex.Message}】异常行【{ex.StackTrace}】");
|
}
|
}
|
}
|
}
|