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 { /// /// 处理新任务 /// 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; } } /// /// 请求WMS任务 /// private void RequestWmsRoadwayNo(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, Dt_StationManger stationManager) { try { if (command.Barcode.IsNullOrEmpty()) return; var AGVFinishTask = _taskService.QueryBarCodeAGVFinishTask(command.TaskNum, stationManager.StationCode); if (AGVFinishTask == null) { var log = $"时间:【{DateTime.Now}】【{conveyorLine.DeviceName}】托盘号:【{command.Barcode}】任务号:【{command.TaskNum}】设备编码:【{stationManager.StationCode}】【未找到任务】"; ConsoleHelper.WriteSuccessLine(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(ExecuteTask); bool sendFlag = SendCommand(taskCommand, conveyorLine, stationManager.StationCode); if (sendFlag) { //_taskService.UpdateTask(task, TaskStatusEnum.Line_Executing); _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}】"); } } } }