肖洋
2024-12-13 fcfafddcbe3748beda400e1ecd21d329b2a25c81
Code Management/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/StackerCraneJob/CommonStackerCraneJob.cs
@@ -142,10 +142,12 @@
                {
                    //Console.Out.WriteLine("TaskCompleted" + e.TaskNum);
                    ConsoleHelper.WriteColorLine($"【{commonStackerCrane.DeviceName}】任务完成,任务号:【{e.TaskNum}】", ConsoleColor.Blue);
                    if (commonStackerCrane.DeviceCode.Contains("GW"))
                    {
                        var task = _taskRepository.QueryFirst(x => x.TaskNum == e.TaskNum);
                    var task = _taskRepository.QueryFirst(x => x.TaskNum == e.TaskNum);
                    if (task == null) commonStackerCrane.SetValue(StackerCraneDBName.WorkType, 5);
                    if (commonStackerCrane.DeviceCode.Contains("GW") && task.TaskType.GetTaskTypeGroup() == TaskTypeGroup.OutbondGroup)
                    {
                        var station = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.TargetAddress);
                        IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == station.stationPLC);
@@ -156,7 +158,7 @@
                            if (!isResult)
                            {
                                var result = conveyorLine.GetValue<ConveyorLineDBName_After, string>(ConveyorLineDBName_After.ConveyorLineBarcode, task.TargetAddress);
                                if(result!= task.PalletCode)
                                if (result != task.PalletCode)
                                {
                                    conveyorLine.SetValue(ConveyorLineDBName_After.ConveyorLineBarcode, task.PalletCode, task.TargetAddress);
                                }
@@ -179,7 +181,7 @@
        private Dt_Task? GetTask(CommonStackerCrane commonStackerCrane)
        {
            Dt_Task task;
            var taskRun = _taskRepository.QueryFirst(x => x.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting || x.TaskState == (int)TaskInStatusEnum.SC_InExecuting);
            var taskRun = _taskRepository.QueryFirst(x => x.Roadway == commonStackerCrane.DeviceCode && (x.TaskState == (int)TaskOutStatusEnum.SC_OutExecuting || x.TaskState == (int)TaskInStatusEnum.SC_InExecuting));
            if (taskRun != null) { return null; }
            if (commonStackerCrane.LastTaskType == null)
            {
@@ -241,34 +243,44 @@
            {
                if (router != null)
                {
                    IDevice? device = null;
                    if (task.Roadway.Contains("CW"))
                    {
                        device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == router.ChildPosiDeviceCode);
                    }
                    else
                    {
                        device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1015");
                    }
                    if (device != null)
                    {
                        CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)device;
                        if (conveyorLine.IsOccupied(task.TargetAddress))//出库站台未被占用
                        if (device != null)
                        {
                            return task;
                            CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)device;
                            if (conveyorLine.IsOccupied(task.NextAddress))//出库站台未被占用
                            {
                                return task;
                            }
                        }
                    }
                    else
                    {
                        _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{task.TargetAddress}】对应的通讯对象,无法判断出库站台是否被占用");
                        else
                        {
                            _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{task.NextAddress}】对应的通讯对象,无法判断出库站台是否被占用");
                        }
                    }
                }
                else
                {
                    _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到站台【{task.NextAddress}】信息,无法校验站台");
                    IDevice? device = null;
                    if (task.Roadway.Contains("GW"))
                    {
                        device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "1015");
                        if (device != null)
                        {
                            CommonConveyorLine_GW conveyorLine = (CommonConveyorLine_GW)device;
                            if (conveyorLine.IsOccupied(task.TargetAddress))//出库站台未被占用
                            {
                                return task;
                            }
                        }
                        else
                        {
                            _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到出库站台【{task.TargetAddress}】对应的通讯对象,无法判断出库站台是否被占用");
                        }
                    }
                    _taskService.UpdateTaskExceptionMessage(task.TaskNum, $"未找到站台【{task.TargetAddress}】信息,无法校验站台");
                }
            }
            else