wanshenmean
2025-03-27 48fce55ab5d11a1821ab640742153425d594709c
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineJob.cs
@@ -281,7 +281,8 @@
                                    command.InteractiveSignal = commandWrite.WriteInteractiveSignal;
                                    // 调用处理方法
                                    method.Invoke(this, new object[] { conveyorLine, command, childDeviceCode, count, platform });
                                };
                                }
                                ;
                            }
                        }
                    }
@@ -296,6 +297,7 @@
            }
            return Task.CompletedTask;
        }
        #region 入库
        /// <summary>
@@ -371,7 +373,7 @@
            }
        }
        public string RequestInboundPlatform(string childDeviceCode,string productLine,bool IsTrayBarcode)
        public string RequestInboundPlatform(string childDeviceCode, string productLine, bool IsTrayBarcode)
        {
            try
            {
@@ -383,16 +385,18 @@
                    IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == platform.PLCCode);
                    if (device != null)
                    {
                        int x = 3;
                        CommonConveyorLine conveyorLine = (CommonConveyorLine)device;
                        foreach (var item in Location)
                        {
                            x--;
                            ConveyorLineTaskCommand command1 = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(item);
                            if (command1.InteractiveSignal != 2)
                            {
                                var tasks = _taskRepository.QueryData(x => (x.TaskType == (int)TaskInboundTypeEnum.InTray || x.TaskType == (int)TaskOutboundTypeEnum.OutTray) && x.TargetAddress == childDeviceCode);
                                // 如果已有任务数量小于指定索引
                                if (tasks.Count < Location.Count)
                                if (tasks.Count < Location.Count && tasks.Count < x)
                                {
                                    return childDeviceCode;
                                }
@@ -420,7 +424,7 @@
            {
                ConsoleHelper.WriteErrorLine($"方法RequestInboundPlatform:{ex.Message}");
            }
            return null;
        }
@@ -432,20 +436,19 @@
        /// <param name="conveyorLine">输送线实例对象</param>
        /// <param name="command">读取的请求信息</param>
        /// <param name="childDeviceCode">子设备编号</param>
        public void RequestInNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode,int ProtocalDetailValue)
        public void RequestInNextAddress(CommonConveyorLine conveyorLine, ConveyorLineTaskCommand command, string childDeviceCode, int ProtocalDetailValue)
        {
            var log = $"【{conveyorLine._deviceName}】任务号:【{command.TaskNum}】,托盘条码:【{command.Barcode}】已到达【{childDeviceCode}】请求入库下一地址";
            ConsoleHelper.WriteWarningLine(log);
            _noticeService.Logs(userTokenIds, new { conveyorLine.DeviceName, log = log, time = DateTime.Now.ToString("G"), color = "red" });
            WriteInfo(conveyorLine.DeviceName, log);
            if (childDeviceCode == "1279")
            {
                var stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == childDeviceCode && x.stationPLC == conveyorLine.DeviceCode);
                CreateAndSendEmptyTrayTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue, stationManager);
            }
            //if (childDeviceCode == "1279")
            //{
            //    var stationManager = _stationManagerRepository.QueryFirst(x => x.stationChildCode == childDeviceCode && x.stationPLC == conveyorLine.DeviceCode);
            //    CreateAndSendEmptyTrayTask(conveyorLine, command, childDeviceCode, ProtocalDetailValue, stationManager);
            //}
            Dt_Task task = _taskService.QueryExecutingConveyorLineTask(command.TaskNum, childDeviceCode);
            if (task != null)
            {
@@ -744,8 +747,8 @@
        #endregion 出库
        #region 输送线交互完成
        /// <summary>
        /// 输送线交互完成
        /// </summary>
@@ -776,8 +779,8 @@
                conveyorLine.Communicator.Write(DeviceProAddress, value);
            }
        }
        #endregion
        #endregion
        #region 检测空盘实盘任务
@@ -961,8 +964,8 @@
        #endregion 设备NG口入库
        #region 输出日志
        public async Task LogAndWarn(string deviceName, string log, string color = "red")
        {
            ConsoleHelper.WriteWarningLine(log);
@@ -972,13 +975,11 @@
        #endregion
        private (ConveyorLineTaskCommand, ConveyorLineTaskCommandWrite) ReadCommands(Dt_StationManager station, CommonConveyorLine conveyorLine)
        {
            ConveyorLineTaskCommand command = conveyorLine.ReadCustomer<ConveyorLineTaskCommand>(station.stationChildCode);
            ConveyorLineTaskCommandWrite commandWrite = conveyorLine.ReadCustomer<ConveyorLineTaskCommandWrite>(station.stationChildCode, "DeviceCommand");
            return (command, commandWrite);
        }
    }
}