| | |
| | | bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value); |
| | | if (!flag || value is not CommonStackerCrane commonStackerCrane) |
| | | { |
| | | _logger.Information("Execute:参数无效,未找到 JobParams 或类型不匹配"); |
| | | // 参数无效,直接返回 |
| | | QuartzLogHelper.LogWarn(_logger, "Execute:参数无效", "Execute:参数无效", "CommonStackerCraneJob"); |
| | | QuartzLogHelper.LogInfo(_logger, "Execute:参数无效", "CommonStackerCraneJob"); |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | | |
| | | |
| | | // ========== 构建命令 ========== |
| | | // 命令构建下沉到专用构建器 |
| | | object? stackerCraneTaskCommand = _commandBuilder.ConvertToStackerCraneTaskCommand(task); |
| | | if (stackerCraneTaskCommand == null) |
| | | { |
| | | // 命令构建失败 |
| | | QuartzLogHelper.LogWarn(_logger, "Execute:命令构建失败,设备: {DeviceCode},任务号: {TaskNum}", $"命令构建失败,任务号: {task.TaskNum}", _deviceCode, _deviceCode, task.TaskNum); |
| | | QuartzLogHelper.LogInfo(_logger, $"Execute:命令构建失败,设备: {_deviceCode},任务号: {task.TaskNum}", _deviceCode); |
| | | return Task.CompletedTask; |
| | | } |
| | | |
| | |
| | | commonStackerCrane.LastTaskType = task.TaskType; |
| | | _taskService.UpdateTaskStatusToNext(task.TaskNum); |
| | | |
| | | QuartzLogHelper.LogInfo(_logger, "Execute:命令发送成功,设备: {DeviceCode},任务号: {TaskNum}", $"命令发送成功,任务号: {task.TaskNum}", _deviceCode, _deviceCode, task.TaskNum); |
| | | QuartzLogHelper.LogInfo(_logger, $"Execute:命令发送成功,设备: {_deviceCode},任务号: {task.TaskNum}", _deviceCode); |
| | | } |
| | | else |
| | | { |
| | | QuartzLogHelper.LogError(_logger, "Execute:命令发送失败,设备: {DeviceCode},任务号: {TaskNum}", $"命令发送失败", _deviceCode, _deviceCode, task.TaskNum); |
| | | QuartzLogHelper.LogInfo(_logger, $"Execute:命令发送失败,设备: {_deviceCode},任务号: {task.TaskNum}", _deviceCode); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // 记录异常 |
| | | QuartzLogHelper.LogError(_logger, ex, "Execute:执行异常,设备: {DeviceCode}", $"执行异常: {ex.Message}", _deviceCode, _deviceCode); |
| | | QuartzLogHelper.LogError(_logger, ex, $"Execute:执行异常,设备: {_deviceCode}", $"执行异常: {ex.Message}", _deviceCode, _deviceCode); |
| | | } |
| | | finally |
| | | { |
| | |
| | | if (stackerCrane != null) |
| | | { |
| | | // 记录日志 |
| | | QuartzLogHelper.LogInfo(_logger, "CommonStackerCrane_StackerCraneTaskCompletedEventHandler:任务完成,任务号: {TaskNum}", $"任务完成,任务号: {e.TaskNum}", stackerCrane.DeviceCode, e.TaskNum); |
| | | QuartzLogHelper.LogInfo(_logger, $"CommonStackerCrane_StackerCraneTaskCompletedEventHandler:任务完成,任务号: {e.TaskNum}", stackerCrane.DeviceCode); |
| | | |
| | | // 更新任务状态为完成 |
| | | if (_taskService.StackCraneTaskCompleted(e.TaskNum).Status) |