helongyang
2026-03-31 8fcd7a67e4391a5f1fbdb590c2a3f913aeb2a0a0
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/PP仓/AGV_PPExtend.cs
@@ -20,45 +20,70 @@
            try
            {
                var newTasks = _taskService.Db.Queryable<Dt_Task>().Where(x => (x.TaskState == TaskStatusEnum.New.ObjToInt()||x.TaskState==TaskStatusEnum.AGV_Execute.ObjToInt()) && nameof(AGV_PPJob).Contains(x.DeviceCode) && !string.IsNullOrEmpty(x.DeviceCode)).ToList().OrderBy(x => x.Grade).ThenBy(x => x.CreateDate).ToList();
                foreach (var task in newTasks)
                foreach (var agvTask in newTasks)
                {
                    try
                    {
                        AgvTaskDTO TaskDTO = new AgvTaskDTO()
                        string taskTyp;
                        if (agvTask.TaskType == TaskTypeEnum.MesPPMove.ObjToInt())
                        {
                            TaskCode = task.AgvTaskNum,
                            ReqCode = DateTime.Now.ToString("yyMMddHHmmss") + task.AgvTaskNum,
                            TaskTyp = task.TaskType < TaskTypeEnum.Inbound.ObjToInt() ? "FLC" : "FLR",
                            ctnrCode = task.PalletCode,
                            taskTyp = "110";
                        }
                        else if (agvTask.PalletType < 2)
                        {
                            taskTyp = "008";
                        }
                        else
                        {
                            taskTyp = "004";
                        }
                        AgvTaskDTO taskDTO = new AgvTaskDTO()
                        {
                            ReqCode = Guid.NewGuid().ToString().Replace("-", ""),
                            TaskTyp = taskTyp,
                            PositionCodePath = new List<CodePath>()
                        {
                            new CodePath()
                            {
                                type="00",
                                positionCode=task.CurrentAddress
                                new CodePath()
                                {
                                    type = "00",
                                    positionCode = agvTask.CurrentAddress
                                },
                                new CodePath()
                                {
                                    type = (agvTask.TaskType == TaskTypeEnum.PPPKInbound.ObjToInt()||agvTask.TaskType == TaskTypeEnum.MesPPCutOutbound.ObjToInt()) ? "00" : "04",
                                    positionCode = agvTask.NextAddress
                                }
                            },
                            new CodePath()
                            {
                                type="00",
                                positionCode=task.NextAddress
                            }
                        },
                            TaskCode = agvTask.AgvTaskNum,
                        };
                        WebResponseContent content = _taskService.AgvSendTask(TaskDTO, APIEnum.Agv_PPSendTask);
                        if (!content.Status) throw new Exception(content.Message);
                        task.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt();
                        WebResponseContent content = _taskService.AgvSendTask(taskDTO);
                        if (content.Status)
                        {
                            agvTask.TaskState = TaskStatusEnum.AGV_Executing.ObjToInt();
                            //agvTask.Remark = content.Data.ObjToString();
                            _taskService.UpdateTask(agvTask, TaskStatusEnum.AGV_Executing);
                        }
                        else
                        {
                            agvTask.TaskState = TaskStatusEnum.Exception.ObjToInt();
                            //agvTask.Remark = content.Data.ObjToString();
                            agvTask.ExceptionMessage = content.Message;
                        }
                    }
                    catch (Exception ex)
                    {
                        task.TaskState = TaskStatusEnum.Exception.ObjToInt();
                        task.ExceptionMessage = ex.Message;
                        agvTask.TaskState = TaskStatusEnum.Exception.ObjToInt();
                        //agvTask.Remark = content.Data.ObjToString();
                        agvTask.ExceptionMessage = ex.Message;
                        WriteError(nameof(AGV_PPJob), ex.Message, ex);
                    }
                }
                _taskService.UpdateData(newTasks);
            }
            catch (Exception ex)
            {
                WriteError(nameof(AGV_FLJob), ex.Message, ex);
                WriteError(nameof(AGV_PPJob), ex.Message, ex);
            }
        }
    }