1
hutongqing
2024-12-29 89051aef8a2c1a85d457914cf6317fe70e0e321c
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/²âÊԼܲÖ/GroundStationJob_CSJ.cs
@@ -61,7 +61,7 @@
                        if (item.StationType == StationTypeEnum.StationType_OnlyOutbound.ObjToInt())
                        {
                            Dt_Task task = _taskRepository.QueryFirst(x => x.DeviceCode == item.StackerCraneCode && x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.NextAddress));
                            Dt_Task task = _taskRepository.QueryFirst(x => x.DeviceCode == item.StackerCraneCode && x.TaskState == TaskStatusEnum.SC_Execute.ObjToInt() && string.IsNullOrEmpty(x.NextAddress));
                            if (task != null && isCanPut && !isCanTake && !putRequest && !putFinish && !takeRequest && !takeFinish)
                            {
                                string oldAddress = task.NextAddress;
@@ -74,13 +74,27 @@
                        }
                        if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt())
                        {
                            Dt_Task task = _taskRepository.QueryFirst(x => x.TargetAddress == item.StackerCraneCode && x.TaskState == TaskStatusEnum.New.ObjToInt() && string.IsNullOrEmpty(x.NextAddress));
                            if (task != null && isCanPut && !isCanTake && !putRequest && !putFinish && !takeRequest && !takeFinish)
                            Dt_Task task = _taskRepository.QueryFirst(x => (x.TargetAddress == item.StackerCraneCode || string.IsNullOrEmpty(x.TargetAddress) || x.NextAddress == item.StackerCraneCode || string.IsNullOrEmpty(x.NextAddress)) && (x.TaskState == TaskStatusEnum.New.ObjToInt() || x.TaskState == TaskStatusEnum.SC_Execute.ObjToInt()) && x.SourceAddress == item.StationCode);
                            if (task != null)
                            {
                                string oldAddress = task.NextAddress;
                                int oldStatus = task.TaskState;
                                task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt();
                                task.NextAddress = item.StationCode;
                                Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode);
                                if (stationManger == null)
                                {
                                    WriteInfo(item.StationName, $"未找到对应站台信息,设备编号:{item.StationCode},任务号:{task.TaskNum}");
                                    break;
                                }
                                string? locationCode = _taskService.RequestAssignLocation(task.TaskNum, stationManger.StackerCraneCode);
                                if (string.IsNullOrEmpty(locationCode))
                                {
                                    WriteInfo(item.StationName, $"请求分配货位返回信息错误,设备编号:{item.StationCode},任务号:{task.TaskNum}");
                                    break;
                                }
                                task.CurrentAddress = stationManger.StackerCraneStationCode;
                                task.TargetAddress = locationCode;
                                task.NextAddress = locationCode;
                                task.DeviceCode = stationManger.StackerCraneCode;
                                _taskRepository.UpdateData(task);
                                _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"系统自动流程,目标地址由{oldAddress}变更为{task.NextAddress},任务状态由{oldStatus}变更为{task.TaskState}");
                            }
@@ -111,15 +125,19 @@
                                WriteInfo(item.StationName, $"请求分配货位返回信息错误,设备编号:{item.StationCode},任务号:{task.TaskNum}");
                                break;
                            }
                            string oldAddress = task.NextAddress;
                            int oldStatus = task.TaskState;
                            task.CurrentAddress = stationManger.StackerCraneStationCode;
                            task.TargetAddress = locationCode;
                            task.NextAddress = locationCode;
                            task.DeviceCode = stationManger.StackerCraneCode;
                            task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt();
                            _taskRepository.UpdateData(task);
                            _taskExecuteDetailService.AddTaskExecuteDetail(task.TaskNum, $"系统自动流程,目标地址由{oldAddress}变更为{task.NextAddress},任务状态由{oldStatus}变更为{task.TaskState}");
                        }
                    }
                    catch(Exception ex)
                    catch (Exception ex)
                    {
                    }