dengjunjie
2024-12-29 7f078e66be9959d94fc78344f195b7b4656812be
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Controllers/AGVController.cs
@@ -46,12 +46,18 @@
                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);
@@ -79,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":
@@ -92,16 +98,37 @@
                            if (!content.Status) throw new Exception(content.Message);
                            task.TaskState = TaskStatusEnum.AGV_Finish.ObjToInt();
                            var up = _taskRepository.DeleteAndMoveIntoHty(task, OperateTypeEnum.自动完成);
                            _taskService.TaskCompleted(task.TaskNum);
                            agvResponseContent.Code = up ? "0" : "1";
                            agvResponseContent.Message = up ? "成功" : "失败";
                            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.CurrentAddress);
                            var content = PutFinish(task.NextAddress);
                            if (!content.Status) throw new Exception(content.Message);
                            task.CurrentAddress = task.NextAddress;
                            task.NextAddress = "";
                            task.TaskState = TaskStatusEnum.SC_Execute.ObjToInt();
                            var up = _taskRepository.UpdateData(task);
                            agvResponseContent.Code = up ? "0" : "1";
@@ -160,7 +187,6 @@
                else
                {
                    otherDevice.SetValue(GroundStationDBName.W_PutRequest, true, stationManger.StationCode);
                    otherDevice.SetValue(GroundStationDBName.W_PutPalletType, (short)palletType, stationManger.StationCode);
                    Thread.Sleep(1000);
                    canPut = otherDevice.GetValue<GroundStationDBName, bool>(GroundStationDBName.R_IsCanPut, stationManger.StationCode);
                    if (canPut)