xiazhengtongxue
2026-03-17 4f3b0a6727ecfa555892ebea64bd76e5a07cd6fb
ÏîÄ¿´úÂë/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs
@@ -3,6 +3,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
using Org.BouncyCastle.Asn1.Ocsp;
using System.Text;
using System.Text.RegularExpressions;
using WIDESEA_DTO.Agv;
@@ -25,6 +26,7 @@
using WIDESEAWCS_QuartzJob.DTO;
using WIDESEAWCS_QuartzJob.Models;
using WIDESEAWCS_QuartzJob.Repository;
using WIDESEAWCS_TaskInfoService;
using WIDESEAWCS_Tasks;
using WIDESEAWCS_Tasks.DBNames;
using static Dm.net.buffer.ByteArrayBuffer;
@@ -57,6 +59,31 @@
            WebResponseContent content = new WebResponseContent();
            try
            {
                WriteLog.Write_Log("AGV任务更新接口", "AGV任务更新接口", "更新任务", $"任务:{agvUpdateDTO.ToJson()}");
                if (agvUpdateDTO.Message != null && agvUpdateDTO.Message == "ROBOT_ERROR-haiUnknownError")
                {
                    var task1 = _taskRepository.QueryFirst(x => (agvUpdateDTO.MissionCode ?? "") == x.GroupId);
                    if (task1 != null)
                    {
                        Dt_ErrorInfo errorInfo = new Dt_ErrorInfo()
                        {
                            RobotCode = agvUpdateDTO.RobotId,
                            Message = agvUpdateDTO.Message,
                            ErrorType = 2
                        };
                        if (task1.TaskType == 500)
                        {
                            errorInfo.Message = "入库异常";
                            errorInfo.StationCode = task1.CurrentAddress;
                        }
                        else
                        {
                            errorInfo.Message = "出库异常";
                            errorInfo.StationCode = task1.NextAddress;
                        }
                        _taskService.AgvSearchStatus1(errorInfo);
                    }
                }
                var task = _taskRepository.QueryFirst(x => (agvUpdateDTO.ContainerCode ?? "") == x.PalletCode);
                switch (agvUpdateDTO.MissionStatus)
                {
@@ -110,28 +137,7 @@
                    default:
                        break;
                }
                if (agvUpdateDTO.Message != null && agvUpdateDTO.Message == "ROBOT_ERROR-haiUnknownError")
                {
                    var task1 = _taskRepository.QueryFirst(x => (agvUpdateDTO.MissionCode ?? "") == x.GroupId);
                    if (task1 == null) throw new Exception($"未找到料箱【{agvUpdateDTO.ContainerCode}】任务");
                    Dt_ErrorInfo errorInfo = new Dt_ErrorInfo()
                    {
                        RobotCode = agvUpdateDTO.RobotId,
                        Message = agvUpdateDTO.Message,
                        ErrorType = 2
                    };
                    if (task1.TaskType == 500)
                    {
                        errorInfo.Message = "入库异常";
                        errorInfo.StationCode = task1.CurrentAddress;
                    }
                    else
                    {
                        errorInfo.Message = "出库异常";
                        errorInfo.StationCode = task1.NextAddress;
                    }
                    _taskService.AgvSearchStatus1(errorInfo);
                }
                content.OK();
            }
            catch (Exception ex)
@@ -150,6 +156,7 @@
            AgvTaskReqContent content = new AgvTaskReqContent();
            try
            {
                WriteLog.Write_Log("AGV任务请求", "AGV任务请求接口", "任务", $"任务:{agvTaskRequestDTO.ToJson()}");
                //获取任务
                Dt_Task? taskExist = _taskRepository.QueryFirst(x=>x.PalletCode==agvTaskRequestDTO.ContainerCode) ?? throw new Exception($"未找到料箱{agvTaskRequestDTO.ContainerCode}任务");
                //获取站台
@@ -186,6 +193,7 @@
            AgvTaskReqContent content = new AgvTaskReqContent();
            try
            {
                WriteLog.Write_Log("AGV作业完成", "AGV作业完成接口", "任务", $"任务:{agvTaskRequestDTO.ToJson()}");
                //获取站台
                Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.StationCode == agvTaskRequestDTO.PositionId) ?? throw new Exception($"未找到{agvTaskRequestDTO.PositionId}站台位置");
                IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == stationManger.StationDeviceCode) ?? throw new Exception($"未找到对应设备{stationManger.StationDeviceCode}");