| | |
| | | using Microsoft.Extensions.Logging; |
| | | //using Microsoft.Extensions.Logging; |
| | | using Quartz; |
| | | using Serilog; |
| | | using WIDESEA_Core; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Common.Constants; |
| | | using WIDESEAWCS_Core.LogHelper; |
| | | using WIDESEAWCS_ITaskInfoRepository; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | |
| | | using WIDESEAWCS_QuartzJob.Service; |
| | | using WIDESEAWCS_QuartzJob.StackerCrane; |
| | | using WIDESEAWCS_QuartzJob.StackerCrane.Enum; |
| | | using WIDESEAWCS_Common.Constants; |
| | | using WIDESEAWCS_Tasks.StackerCraneJob; |
| | | |
| | | namespace WIDESEAWCS_Tasks |
| | |
| | | /// <summary> |
| | | /// 日志记录器 |
| | | /// </summary> |
| | | private readonly ILogger<CommonStackerCraneJob> _logger; |
| | | private readonly ILogger _logger; |
| | | |
| | | /// <summary> |
| | | /// 堆垛机设备编码 |
| | |
| | | ITaskRepository taskRepository, |
| | | IRouterService routerService, |
| | | HttpClientHelper httpClientHelper, |
| | | ILogger<CommonStackerCraneJob> logger) |
| | | ILogger logger) |
| | | { |
| | | _taskService = taskService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | |
| | | { |
| | | try |
| | | { |
| | | //QuartzLogger.Info($"CommonStackerCraneJob Execute:开始执行堆垛机任务调度 【{DateTime.Now.ToString("F")}】", "CommonStackerCraneJob Execute "); |
| | | // 从 JobDataMap 获取堆垛机设备参数 |
| | | 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"); |
| | | return Task.CompletedTask; |
| | |
| | | |
| | | // ========== 检查是否可以发送新任务 ========== |
| | | //if (!commonStackerCrane.IsCanSendTask(commonStackerCrane.Communicator, commonStackerCrane.DeviceProDTOs, commonStackerCrane.DeviceProtocolDetailDTOs)) |
| | | if (commonStackerCrane.StackerCraneStatusValue != StackerCraneStatus.Normal ) |
| | | if (commonStackerCrane.StackerCraneStatusValue != StackerCraneStatus.Normal) |
| | | { |
| | | // 堆垛机不可用(如正在执行上一任务),直接返回 |
| | | return Task.CompletedTask; |
| | |
| | | // 记录异常 |
| | | QuartzLogHelper.LogError(_logger, ex, "Execute:执行异常,设备: {DeviceCode}", $"执行异常: {ex.Message}", _deviceCode, _deviceCode); |
| | | } |
| | | finally |
| | | { |
| | | QuartzLogHelper.LogInfo(_logger, $"CommonStackerCraneJob Execute:堆垛机任务调度执行完成 【{DateTime.Now.ToString("F")}】", _deviceCode); |
| | | } |
| | | |
| | | return Task.CompletedTask; |
| | | } |