1
wangxinhui
2024-12-30 5732962e2fe146d81273b4b02faaec87c05f0417
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGVController.cs
@@ -41,7 +41,7 @@
            agvResponseContent.ReqCode = secureApplyModel.ReqCode;
            try
            {
                var task = _taskRepository.QueryFirst(x => secureApplyModel.TaskCode.ObjToInt() == x.TaskNum);
                var task = _taskRepository.QueryFirst(x => secureApplyModel.TaskCode== x.AgvTaskNum);
                if (task == null) throw new Exception("未找到任务");
                if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt())
                {
@@ -85,8 +85,8 @@
            {
                if (agvUpdateModel == null) throw new Exception("未获取到请求参数");
                agvResponseContent.ReqCode = agvUpdateModel.ReqCode;
                var task = _taskRepository.QueryFirst(x => agvUpdateModel.TaskCode.ObjToInt() == x.TaskNum);
                if (task == null) throw new Exception("未找到任务");
                var task = _taskRepository.QueryFirst(x => agvUpdateModel.TaskCode == x.AgvTaskNum);
                if (task == null) throw new Exception($"未找到任务,任务号【{agvUpdateModel.TaskCode}】");
                switch (agvUpdateModel.Method)
                {
                    case "start":
@@ -104,14 +104,38 @@
                            return agvResponseContent;
                        }
                        break;
                    case "getSafetySignal"://安全信号申请
                        {
                            if (task.TaskType == TaskTypeEnum.Outbound.ObjToInt())
                            {
                                var content = TakeRequest(task.CurrentAddress);
                                if (!content.Status) throw new Exception(content.Message);
                            }
                            else
                            {
                                var content = PutRequest(task.NextAddress, task.PalletType);
                                if (!content.Status) throw new Exception(content.Message);
                            }
                            task.TaskState = TaskStatusEnum.AGV_WaitToExecute.ObjToInt();
                            var up = _taskRepository.UpdateData(task);
                            agvResponseContent.Code = up ? "0" : "1";
                            agvResponseContent.Message = up ? "成功" : "失败";
                            return agvResponseContent;
                        }
                    case "end"://入库根据这个信号判断放货完成
                        if (task.TaskType != TaskTypeEnum.Outbound.ObjToInt())
                        {
                            var content = PutFinish(task.NextAddress);
                            if (!content.Status) throw new Exception(content.Message);
                            task.CurrentAddress = task.NextAddress;
                            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.DeviceCode = "SC01_CSJ";
                            var up = _taskRepository.UpdateData(task);
                            agvResponseContent.Code = up ? "0" : "1";
                            agvResponseContent.Message = up ? "成功" : "失败";
@@ -294,7 +318,8 @@
                OtherDevice otherDevice = (OtherDevice)device;
                otherDevice.SetValue(GroundStationDBName.W_TakeFinish, true, stationManger.StationCode);
                Thread.Sleep(1000);
                otherDevice.SetValue(GroundStationDBName.W_TakeFinish, false, stationManger.StationCode);
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)