From 4f3b0a6727ecfa555892ebea64bd76e5a07cd6fb Mon Sep 17 00:00:00 2001
From: xiazhengtongxue <133085197+xiazhengtongxue@users.noreply.github.com>
Date: 星期二, 17 三月 2026 10:01:38 +0800
Subject: [PATCH] feat: 新增WMS异常上报自动恢复异常按钮

---
 项目代码/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs |   63 +++++++++++++++++++++++++++++--
 1 files changed, 58 insertions(+), 5 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs"
index 8207280..a49db76 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_Server/Controllers/AGV/AGVController.cs"
@@ -2,6 +2,8 @@
 using Microsoft.AspNetCore.Authorization;
 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;
@@ -24,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;
@@ -56,17 +59,50 @@
             WebResponseContent content = new WebResponseContent();
             try
             {
-                var task = _taskRepository.QueryFirst(x => (agvUpdateDTO.ContainerCode ?? "")==x.PalletCode);
+                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)
                 {
                     case nameof(AGVStatusEnum.PICKER_RECEIVE):
                         if (task == null) throw new Exception($"鏈壘鍒版枡绠便�恵agvUpdateDTO.ContainerCode}銆戜换鍔�");
                         _taskService.UpdateTask(task, TaskStatusEnum.AGV_TakeFinish);
+                        Dt_ErrorInfo e1 = new Dt_ErrorInfo()
+                        {
+                            RobotCode = agvUpdateDTO.RobotId,
+                            Message = agvUpdateDTO.Message,
+                            ErrorType = 0
+                        };
+                        _taskService.AgvSearchStatus1(e1);
+
                         break;
                     case nameof(AGVStatusEnum.PICKER_SEND):
                         if (task == null) throw new Exception($"鏈壘鍒版枡绠便�恵agvUpdateDTO.ContainerCode}銆戜换鍔�");
-                        Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x=>x.PickStationCode==task.NextAddress);
-                        if (task.IsCancel>0 && stationManger!=null && stationManger.StationCode!= agvUpdateDTO.CurrentPosition)
+                        Dt_StationManger? stationManger = _stationMangerRepository.QueryFirst(x => x.PickStationCode == task.NextAddress);
+                        if (task.IsCancel > 0 && stationManger != null && stationManger.StationCode != agvUpdateDTO.CurrentPosition)
                         {
                             _taskService.TaskCancelCompleted(task.TaskNum);
                         }
@@ -74,19 +110,34 @@
                         {
                             _taskService.TaskCompleted(task.TaskNum);
                         }
+                        Dt_ErrorInfo e2 = new Dt_ErrorInfo()
+                        {
+                            RobotCode = agvUpdateDTO.RobotId,
+                            Message = agvUpdateDTO.Message,
+                            ErrorType = 0
+                        };
+                        _taskService.AgvSearchStatus1(e2);
                         break;
                     case nameof(AGVStatusEnum.WAITFEEDBACK):
                         //AGV鏀捐
-                        List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x=>x.StationType==StationTypeEnum.StationType_OnlyInbound.ObjToInt());
-                        if (!stationMangers.Select(x=>x.StationCode).Contains(agvUpdateDTO.CurrentPosition))
+                        List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationType == StationTypeEnum.StationType_OnlyInbound.ObjToInt());
+                        if (!stationMangers.Select(x => x.StationCode).Contains(agvUpdateDTO.CurrentPosition))
                         {
                             WebResponseContent responseContent = _taskService.AgvTaskFlow(agvUpdateDTO.MissionCode);
                             if (!responseContent.Status) throw new Exception($"{responseContent.Message}");
                         }
+                        Dt_ErrorInfo e3 = new Dt_ErrorInfo()
+                        {
+                            RobotCode = agvUpdateDTO.RobotId,
+                            Message = agvUpdateDTO.Message,
+                            ErrorType = 0
+                        };
+                        _taskService.AgvSearchStatus1(e3);
                         break;
                     default:
                         break;
                 }
+
                 content.OK();
             }
             catch (Exception ex)
@@ -105,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}浠诲姟");
                 //鑾峰彇绔欏彴
@@ -141,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}");

--
Gitblit v1.9.3