| | |
| | | using MapsterMapper; |
| | | using Masuit.Tools; |
| | | using Microsoft.Extensions.Configuration; |
| | | using Microsoft.Extensions.Logging; |
| | | using Newtonsoft.Json; |
| | | using Quartz; |
| | | using Serilog; |
| | | using SqlSugar; |
| | | using WIDESEA_Core; |
| | | using WIDESEAWCS_Common.TaskEnum; |
| | | using WIDESEAWCS_Core; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_Core.LogHelper; |
| | | using WIDESEAWCS_DTO.TaskInfo; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | |
| | | /// 任务服务 |
| | | /// </summary> |
| | | private readonly ITaskService _taskService; |
| | | |
| | | |
| | | /// <summary> |
| | | /// 机器人任务服务 |
| | |
| | | /// <summary> |
| | | /// 日志记录器 |
| | | /// </summary> |
| | | private readonly ILogger<CommonConveyorLineNewJob> _logger; |
| | | private readonly ILogger _logger; |
| | | |
| | | /// <summary> |
| | | /// 目标地址到设备类型的映射 |
| | |
| | | /// <remarks> |
| | | /// </remarks> |
| | | private static List<string> AddressToDeviceType = new List<string> { "11020", "11028" }; |
| | | |
| | | /// <summary> |
| | | /// 托盘检查位置的最近执行时间(用于30秒间隔限制) |
| | | /// </summary> |
| | | private static readonly Dictionary<string, DateTime> _lastPalletCheckTime = new(); |
| | | |
| | | /// <summary> |
| | | /// 构造函数 |
| | |
| | | /// <param name="mapper">对象映射器</param> |
| | | /// <param name="httpClientHelper">HTTP 客户端帮助类</param> |
| | | /// <param name="logger">日志记录器</param> |
| | | public CommonConveyorLineNewJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, HttpClientHelper httpClientHelper, ILogger<CommonConveyorLineNewJob> logger, IRobotTaskService robotTaskService) |
| | | public CommonConveyorLineNewJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, HttpClientHelper httpClientHelper, ILogger logger, IRobotTaskService robotTaskService) |
| | | { |
| | | _taskService = taskService; |
| | | _taskExecuteDetailService = taskExecuteDetailService; |
| | |
| | | // 如果当前设备在检查列表中 |
| | | if (checkPalletPositions.Any(x => x.Code == childDeviceCode)) |
| | | { |
| | | // 30秒间隔限制 |
| | | if (_lastPalletCheckTime.TryGetValue(childDeviceCode, out var lastTime) && |
| | | (DateTime.Now - lastTime).TotalSeconds < 30) |
| | | { |
| | | continue; |
| | | } |
| | | |
| | | // 检查输送线状态(是否有托盘) |
| | | if (command.CV_State == 2) |
| | | { |
| | |
| | | TargetAddress = childDeviceCode |
| | | }.Serialize()); |
| | | |
| | | _lastPalletCheckTime[childDeviceCode] = DateTime.Now; |
| | | |
| | | // 如果请求成功,接收 WMS 返回的任务 |
| | | if (responseResult.IsSuccess && responseResult.Data.Status) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | #endregion 检测是否需要空托盘 |
| | | |
| | | // ========== 检查 PLC_STB 标志 ========== |
| | | // 只有当 PLC_STB 为 1 时才处理任务 |
| | |
| | | RobotTargetAddressLineCode = childDeviceCode, |
| | | RobotTaskNum = num, // 生成任务号 |
| | | RobotDispatchertime = DateTime.Now, |
| | | |
| | | }; |
| | | if (_robotTaskService.AddData(robotTask).Status) |
| | | { |