wanshenmean
6 天以前 5171d3f59b89389bf75293afd210cfa6de4ccff7
Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineNewJob/CommonConveyorLineNewJob.cs
@@ -4,8 +4,6 @@
using Newtonsoft.Json;
using Quartz;
using SqlSugar;
using System.Text;
using System.Text.Json;
using WIDESEA_Core;
using WIDESEAWCS_Common.TaskEnum;
using WIDESEAWCS_Core;
@@ -79,6 +77,13 @@
        private readonly ILogger<CommonConveyorLineNewJob> _logger;
        /// <summary>
        /// 目标地址到设备类型的映射
        /// </summary>
        /// <remarks>
        /// </remarks>
        private static List<string> AddressToDeviceType = new List<string> { "11020", "11028" };
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="taskService">任务服务</param>
@@ -139,8 +144,8 @@
                    //    MaxDegreeOfParallelism = Math.Min(childDeviceCodes.Count, Environment.ProcessorCount * 2),
                    //};
                    _logger.LogDebug("Execute:开始并行处理输送线 {DeviceCode},子设备数量: {Count}", conveyorLine.DeviceCode, childDeviceCodes.Count);
                    QuartzLogger.Debug($"开始并行处理输送线,子设备数量: {childDeviceCodes.Count}", conveyorLine.DeviceCode);
                    //_logger.LogDebug("Execute:开始并行处理输送线 {DeviceCode},子设备数量: {Count}", conveyorLine.DeviceCode, childDeviceCodes.Count);
                    //QuartzLogger.Debug($"开始并行处理输送线,子设备数量: {childDeviceCodes.Count}", conveyorLine.DeviceCode);
                    // 并行处理每个子设备
                    //Parallel.For(0, childDeviceCodes.Count, parallelOptions, i =>
@@ -161,9 +166,6 @@
                                continue;
                            }
                            // 如果 WCS_ACK 为 1,先清除(表示处理过上一次请求)
                            if (command.WCS_ACK == 1)
                                conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, 0, childDeviceCode);
                            // ========== 检查特定位置是否有托盘 ==========
                            // 从配置中读取需要检查托盘的位置列表
@@ -207,7 +209,10 @@
                            // 只有当 PLC_STB 为 1 时才处理任务
                            if (command.PLC_STB != 1)
                            {
                                return Task.CompletedTask;
                                // 如果 WCS_ACK 为 1,先清除(表示处理过上一次请求)
                                if (command.WCS_ACK == 1)
                                    conveyorLine.SetValue(ConveyorLineDBNameNew.WCS_ACK, (short)0, childDeviceCode);
                                continue;
                            }
                            // ========== 处理无托盘条码的情况 ==========
@@ -217,7 +222,7 @@
                                _logger.LogDebug("Execute:子设备 {ChildDeviceCode} 无托盘条码,请求出库任务", childDeviceCode);
                                QuartzLogger.Debug($"子设备 {childDeviceCode} 无托盘条码,请求出库任务", conveyorLine.DeviceCode);
                                _conveyorLineDispatch.RequestOutbound(conveyorLine, command, childDeviceCode);
                                return Task.CompletedTask;
                                continue;
                            }
                            // ========== 处理已有任务号的情况 ==========
@@ -286,7 +291,13 @@
            {
                case InExecuting:
                    // 入库执行中,调用下一地址处理
                    _conveyorLineDispatch.RequestInNextAddress(conveyorLine, command, childDeviceCode);
                    if (AddressToDeviceType.Contains(childDeviceCode))
                        // 到达目标地址,调用入库完成
                        _conveyorLineDispatch.ConveyorLineInFinish(conveyorLine, command, childDeviceCode);
                    else
                        // 未到达目标地址,调用入库下一地址处理
                        _conveyorLineDispatch.RequestInNextAddress(conveyorLine, command, childDeviceCode);
                    break;
                case OutExecuting:
@@ -311,4 +322,4 @@
            }
        }
    }
}
}