wangxinhui
5 天以前 9ec715d2deb18a269dd49c48da91a36632d08c81
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/×躸²Ö/GroundStationJob_ZH.cs
@@ -66,39 +66,29 @@
                            //device.SetValue(GroundStationDBName.W_TakeRequest, true, item.StationCode);
                            //device.SetValue(GroundStationDBName.W_PutPalletType, 1, item.StationCode);//task.PalletType
                            //device.SetValue(GroundStationDBName.W_TakeFinish, true, item.StationCode);
                            ////判断AGV任务完成,后写给地面站取货完成
                            //device.SetValue(GroundStationDBName.W_TakeRequest, false, item.StationCode);
                            //device.SetValue(GroundStationDBName.W_TakeFinish, false, item.StationCode);
                            Dt_Task task = _taskRepository.QueryFirst(x => x.DeviceCode == item.StackerCraneCode && x.TaskState == TaskStatusEnum.SC_Execute.ObjToInt() && string.IsNullOrEmpty(x.NextAddress));
                            Dt_Task task = _taskRepository.QueryFirst(x => x.DeviceCode == item.StackerCraneCode && x.TaskState == TaskStatusEnum.New.ObjToInt() && x.NextAddress==item.StationCode);
                            if (task != null && isCanPut && !isCanTake && !putRequest && !putFinish && !takeRequest && !takeFinish)
                            {
                                _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, nextAddress: item.StationCode);
                                _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, nextAddress: item.StackerCraneStationCode);
                            }
                        }
                        if (item.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt())
                        {
                            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.AGV_Finish.ObjToInt()) && (x.SourceAddress == item.StationCode || x.CurrentAddress == item.AGVStationCode || x.CurrentAddress == item.StationCode));
                             Dt_Task task = _taskRepository.QueryFirst(x => x.CurrentAddress==item.StationCode && string.IsNullOrEmpty(x.TargetAddress) && string.IsNullOrEmpty(x.NextAddress) && x.TaskState == TaskStatusEnum.AGV_Finish.ObjToInt());
                            if (task != null)
                            {
                                if (isCanPut)
                                {
                                    device.SetValue(GroundStationDBName.W_PutRequest, true, item.StationCode);
                                    device.SetValue(GroundStationDBName.W_PutPalletType, 1, item.StationCode);//task.PalletType
                                }
                                //判断AGV任务完成,后写给地面站放货完成
                                device.SetValue(GroundStationDBName.W_PutFinish, true, item.StationCode);
                                string oldAddress = task.NextAddress;
                                int oldStatus = task.TaskState;
                                Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode);
                                if (stationManger == null)
                                {
                                    WriteError(item.StationName, $"未找到对应站台信息,设备编号:{item.StationCode},任务号:{task.TaskNum}");
                                    continue;
                                }
                                //string? locationCode = "SC01_ZH-001-027-001-02";//
                                string? locationCode = _taskService.RequestAssignLocation(task.TaskNum, stationManger.StackerCraneCode);
                                if (string.IsNullOrEmpty(locationCode))
                                {
@@ -112,34 +102,6 @@
                    catch (Exception ex)
                    {
                        WriteError(device.DeviceCode, $"{item}交互错误", ex);
                    }
                }
                foreach (var item in stationMangers.Where(x => !deviceStations.Contains(x.StationCode)))
                {
                    try
                    {
                        Dt_Task task = _taskRepository.QueryFirst(x => x.TaskState == TaskStatusEnum.New.ObjToInt() && x.SourceAddress == item.StationCode && _taskService.TaskInboundTypes.Contains(x.TaskType));
                        if (task != null)
                        {
                            Dt_StationManger? stationManger = stationMangers.FirstOrDefault(x => x.StationCode == item.StationCode);
                            if (stationManger == null)
                            {
                                WriteError(item.StationName, $"未找到对应站台信息,设备编号:{item.StationCode},任务号:{task.TaskNum}");
                                continue;
                            }
                            string? locationCode = _taskService.RequestAssignLocation(task.TaskNum, stationManger.StackerCraneCode);
                            if (string.IsNullOrEmpty(locationCode))
                            {
                                WriteError(item.StationName, $"请求分配货位返回信息错误,设备编号:{item.StationCode},任务号:{task.TaskNum}");
                                continue;
                            }
                            _taskService.UpdateTask(task, TaskStatusEnum.SC_Execute, currentAddress: stationManger.StackerCraneStationCode, targetAddress: locationCode, nextAddress: locationCode, deviceCode: stationManger.StackerCraneCode);
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }