| | |
| | | using Microsoft.Extensions.Logging; |
| | | using WIDESEAWCS_Core.LogHelper; |
| | | using WIDESEAWCS_ITaskInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | |
| | |
| | | private readonly ITaskService _taskService; |
| | | |
| | | /// <summary> |
| | | /// 日志记录器 |
| | | /// </summary> |
| | | private readonly ILogger _logger; |
| | | |
| | | /// <summary> |
| | | /// 构造函数 |
| | | /// </summary> |
| | | /// <param name="taskService">任务服务实例</param> |
| | | public ConveyorLineTaskFilter(ITaskService taskService) |
| | | /// <param name="logger">日志记录器</param> |
| | | public ConveyorLineTaskFilter(ITaskService taskService, ILogger logger) |
| | | { |
| | | _taskService = taskService; |
| | | _logger = logger; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns>待处理的任务对象,如果没有则返回 null</returns> |
| | | public Dt_Task? QueryPendingTask(string deviceCode, string childDeviceCode) |
| | | { |
| | | return _taskService.QueryConveyorLineTask(deviceCode, childDeviceCode); |
| | | var task = _taskService.QueryConveyorLineTask(deviceCode, childDeviceCode); |
| | | _logger.LogDebug("QueryPendingTask:设备 {DeviceCode},子设备 {ChildDeviceCode},查询结果: {TaskNum}", deviceCode, childDeviceCode, task?.TaskNum); |
| | | QuartzLogger.Debug($"QueryPendingTask:设备 {deviceCode},子设备 {childDeviceCode},查询结果: {task?.TaskNum}", deviceCode); |
| | | return task; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns>执行中的任务对象,如果没有则返回 null</returns> |
| | | public Dt_Task? QueryExecutingTask(int taskNo, string childDeviceCode) |
| | | { |
| | | return _taskService.QueryExecutingConveyorLineTask(taskNo, childDeviceCode); |
| | | var task = _taskService.QueryExecutingConveyorLineTask(taskNo, childDeviceCode); |
| | | _logger.LogDebug("QueryExecutingTask:任务号 {TaskNo},子设备 {ChildDeviceCode},查询结果: {Found}", taskNo, childDeviceCode, task != null); |
| | | QuartzLogger.Debug($"QueryExecutingTask:任务号 {taskNo},子设备 {childDeviceCode},查询结果: {(task != null)}", childDeviceCode); |
| | | return task; |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <returns>请求是否成功</returns> |
| | | public bool RequestWmsTask(string barcode, string childDeviceCode) |
| | | { |
| | | return _taskService.RequestWMSTask(barcode, childDeviceCode).Status; |
| | | _logger.LogInformation("RequestWmsTask:向WMS请求任务,条码: {Barcode},子设备: {ChildDeviceCode}", barcode, childDeviceCode); |
| | | QuartzLogger.Info($"向WMS请求任务,条码: {barcode}", childDeviceCode); |
| | | var result = _taskService.RequestWMSTask(barcode, childDeviceCode); |
| | | return result.Status; |
| | | } |
| | | } |
| | | } |