wanshenmean
2025-03-22 af9c3ed5d036ad68faf7e18f566679b3da92d244
CodeManagement/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerStationJob/CommonStackerStationCraneJob.cs
@@ -55,8 +55,6 @@
                CommonStackerStationCrane commonStackerCrane = (CommonStackerStationCrane)context.JobDetail.JobDataMap.Get("JobParams");
                if (commonStackerCrane != null)
                {
                    //EqptAlive(commonStackerCrane);
                    //Console.Out.WriteLine(commonStackerCrane.DeviceName);
                    if (!commonStackerCrane.IsEventSubscribed)
                    {
                        commonStackerCrane.StackerCraneTaskCompletedEventHandler += CommonStackerCrane_StackerCraneTaskCompletedEventHandler;//订阅任务完成事件
@@ -68,12 +66,7 @@
                        if (commonStackerCrane.StackerCraneWorkStatusValue == StackerCraneWorkStatus.Standby)
                        {
                            Dt_Task? task = null;
                            if (StaticVariable.isLineRun)
                            {
                                StaticVariable.isStackerRun = false;
                                task = GetTask(commonStackerCrane);
                            }
                            Dt_Task? task = GetTask(commonStackerCrane);
                            if (task != null)
                            {
                                StackerCraneTaskCommand? stackerCraneTaskCommand = ConvertToStackerCraneTaskCommand(task);
@@ -129,13 +122,7 @@
            catch (Exception ex)
            {
                WriteError("CommonStackerStationCraneJob", "test", ex);
                //Console.WriteLine(nameof(CommonStackerCraneJob) + ":" + ex.ToString());
            }
            finally
            {
                StaticVariable.isStackerRun = true;
            }
            //WriteDebug("CommonStackerStationCraneJob", "test");
            return Task.CompletedTask;
        }
@@ -205,17 +192,37 @@
            if (task != null && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
            {
                // 检查当前出库任务站台是否允许放货
                var occupiedStation = OutTaskStationIsOccupied(task);
                if (occupiedStation == null)
                if (task.TaskType == (int)TaskOutboundTypeEnum.Outbound)
                {
                    // 如果当前出库任务站台不允许放货,排除当前任务,查找其他出库任务
                    ConsoleHelper.WriteErrorLine($"任务号:【{task.TaskNum}】出库地址:【{task.NextAddress}】不允许放货");
                    task = FindAnotherOutboundTask(commonStackerCrane.DeviceCode, task);
                    Dt_StationManager stationManager = _stationManagerRepository.QueryFirst(x => x.Roadway == task.Roadway && x.stationLocation == task.TargetAddress);
                    IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManager.stationPLC);
                    if (device != null)
                    {
                        CommonConveyorLine_After conveyorLine = (CommonConveyorLine_After)device;
                        string str = conveyorLine.DeviceProDTOs.Where(x => x.DeviceChildCode == stationManager.stationChildCode).Select(x => x.DeviceProAddress) + ".0";
                        conveyorLine.Communicator.Write(str, true);
                        return task;
                    }
                    else
                    {
                        _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{task.NextAddress}】对应的通讯对象,无法判断出库站台是否被占用");
                        return null;
                    }
                }
                else
                {
                    return task;
                    // 检查当前出库任务站台是否允许放货
                    var occupiedStation = OutTaskStationIsOccupied(task);
                    if (occupiedStation == null)
                    {
                        // 如果当前出库任务站台不允许放货,排除当前任务,查找其他出库任务
                        ConsoleHelper.WriteErrorLine($"任务号:【{task.TaskNum}】出库地址:【{task.NextAddress}】不允许放货");
                        task = FindAnotherOutboundTask(commonStackerCrane.DeviceCode, task);
                    }
                    else
                    {
                        return task;
                    }
                }
                if (task == null)