wangxinhui
2025-01-10 4bc0e18b94a2bf17c1b7277910d63ef82fbe616a
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs
ÎļþÃû´Ó ´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGVController.cs ÐÞ¸Ä
@@ -29,6 +29,9 @@
            _taskService = taskService;
            _taskRepository = taskRepository;
        }
        /// <summary>
        /// å®‰å…¨ä¿¡å·ç”³è¯· AGV-WCS
        /// </summary>
@@ -41,23 +44,23 @@
            agvResponseContent.ReqCode = secureApplyModel.ReqCode;
            try
            {
                var task = _taskRepository.QueryFirst(x => secureApplyModel.TaskCode== x.AgvTaskNum);
                var task = _taskRepository.QueryFirst(x => secureApplyModel.TaskCode == x.AgvTaskNum);
                if (task == null) throw new Exception("未找到任务");
                if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt())
                {
                    var content = TakeRequest(task.CurrentAddress);
                    if (!content.Status)
                    {
                        throw new Exception(content.Message);
                    }
                    //if (!content.Status)
                    //{
                    //    throw new Exception(content.Message);
                    //}
                }
                else
                {
                    var content = PutRequest(task.NextAddress, task.PalletType);
                    if (!content.Status)
                    {
                        throw new Exception(content.Message);
                    }
                    //if (!content.Status)
                    //{
                    //    throw new Exception(content.Message);
                    //}
                }
                task.TaskState = TaskStatusEnum.AGV_WaitToExecute.ObjToInt();
                var up = _taskRepository.UpdateData(task);
@@ -109,12 +112,12 @@
                            if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt())
                            {
                                var content = TakeRequest(task.CurrentAddress);
                                if (!content.Status) throw new Exception(content.Message);
                                //if (!content.Status) throw new Exception(content.Message);
                            }
                            else
                            {
                                var content = PutRequest(task.NextAddress, task.PalletType);
                                if (!content.Status) throw new Exception(content.Message);
                                //if (!content.Status) throw new Exception(content.Message);
                            }
                            task.TaskState = TaskStatusEnum.AGV_WaitToExecute.ObjToInt();
                            var up = _taskRepository.UpdateData(task);
@@ -127,14 +130,14 @@
                        {
                            var content = PutFinish(task.NextAddress);
                            if (!content.Status) throw new Exception(content.Message);
                            Dt_StationManger dt_Station=_stationMangerRepository.QueryFirst(x=>x.AGVStationCode== task.NextAddress);
                            if (dt_Station==null)
                            Dt_StationManger dt_Station = _stationMangerRepository.QueryFirst(x => x.AGVStationCode == task.NextAddress);
                            if (dt_Station == null)
                            {
                                throw new Exception($"{task.NextAddress}AGV站台未定义");
                            }
                            task.CurrentAddress = dt_Station.StationCode;
                            task.NextAddress = "";
                            task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt();
                            task.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt();
                            task.DeviceCode = "SC01_CSJ";
                            var up = _taskRepository.UpdateData(task);
                            agvResponseContent.Code = up ? "0" : "1";
@@ -188,6 +191,7 @@
                bool canPut = otherDevice.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanPut, stationManger.StationCode);
                if (canPut)
                {
                    otherDevice.SetValue(GroundStationDBName.W_PutRequest, true, stationManger.StationCode);
                    return WebResponseContent.Instance.OK();
                }
                else
@@ -271,6 +275,7 @@
                bool canPut = otherDevice.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanTake, stationManger.StationCode);
                if (canPut)
                {
                    otherDevice.SetValue(GroundStationDBName.W_TakeRequest, true, stationManger.StationCode);
                    return WebResponseContent.Instance.OK();
                }
                else