From 7680bc7561730f1f37ae655646c0bc785a1fe2f3 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期五, 10 四月 2026 14:40:54 +0800
Subject: [PATCH] 添加任务异常信息表,设备反馈异常代码处理
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs | 50 +++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 39 insertions(+), 11 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
index 2191f2d..cff5f1d 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskMethods.cs"
@@ -8,6 +8,7 @@
using System.Reflection.Metadata;
using System.Text;
using System.Text.Json;
+using System.Text.RegularExpressions;
using System.Threading.Tasks;
using WIDESEAWCS_Common;
using WIDESEAWCS_Common.LocationEnum;
@@ -393,12 +394,18 @@
}
if (Rgv.content.status == 5)
{
- if (task.TaskState == (int)TaskStatusEnum.Execut)
+ task.ExceptionMessage = Rgv.content.errorReason;
+ var Error = _taskErrorMessageService.Repository.QueryFirst(x => x.ErrorCode == Rgv.content.errorCode && x.DeviceType == (int)deviceTypeEnum);
+ if (Error != null)
{
- task.TaskState = (int)TaskStatusEnum.New;
- task.Remark = "鍥涘悜杞﹀弽棣堝け璐�,閲嶆柊涓嬪彂";
- BaseDal.UpdateData(task);
+ task.ExceptionMessage = Error.ExceptionMessage;
+ MatchCollection matches = Regex.Matches(Rgv.content.errorReason, @"\(([^)]+)\)");
+ if (matches.Count > 0)
+ task.ExceptionMessage = ReplacePlaceholders(Rgv.content.errorReason, Error.ExceptionMessage);
+ ErrorTaskFeedback(task, true, Error.ErrorCode.ToString());
}
+ else
+ ErrorTaskFeedback(task, true);
}
}
}
@@ -414,6 +421,30 @@
_trackloginfoService.AddTrackLog(TaskDTO, content, $"{deviceName}浠诲姟鐘舵�佸弽棣�", "", "");
}
return content;
+ }
+ #endregion
+
+ #region 寮傚父淇℃伅杞崲
+ /// <summary>
+ /// 寮傚父淇℃伅()鍐呭杞崲
+ /// </summary>
+ /// <param name="source"></param>
+ /// <param name="targetTemplate"></param>
+ /// <returns></returns>
+ public string ReplacePlaceholders(string source, string targetTemplate)
+ {
+ // 鎻愬彇婧愬瓧绗︿覆涓殑鎵�鏈夋嫭鍙峰��
+ var values = Regex.Matches(source, @"\(([^)]+)\)")
+ .Cast<Match>()
+ .Select(m => m.Groups[1].Value)
+ .ToList();
+
+ // 鏇挎崲鐩爣妯℃澘涓殑鎵�鏈� (%v)
+ int idx = 0;
+ string result = Regex.Replace(targetTemplate, @"\(\%v\)", _ =>
+ idx < values.Count ? values[idx++] : "");
+
+ return result;
}
#endregion
@@ -692,7 +723,7 @@
}
#endregion
#region 澶辫触浠诲姟涓婃姤WMS骞跺垹闄や换鍔�
- public WebResponseContent ErrorTaskFeedback(Dt_Task dt_Task, bool Del)
+ public WebResponseContent ErrorTaskFeedback(Dt_Task dt_Task, bool Del = false, string ErrorCode = "")
{
WebResponseContent content = new WebResponseContent();
WMSInOutBoundCompleteFeedback boundCompleteFeedback = new WMSInOutBoundCompleteFeedback();
@@ -708,7 +739,7 @@
boundCompleteFeedback.fromStationCode = dt_Task.SourceAddress;
boundCompleteFeedback.toLocationCode = dt_Task.TargetAddress;
boundCompleteFeedback.status = 3;
- boundCompleteFeedback.custStatus = "";
+ boundCompleteFeedback.custStatus = ErrorCode;
boundCompleteFeedback.memo = dt_Task.ExceptionMessage;
string response = HttpHelper.Post(apiInfo.ApiAddress, boundCompleteFeedback.Serialize());
agvContent = response.DeserializeObject<WMSReturn>();
@@ -729,15 +760,12 @@
finally
{
_trackloginfoService.AddTrackLog(boundCompleteFeedback, content, "鍑哄叆搴撲换鍔$姸鎬佸弽棣圵MS", "", "");
- if (agvContent != null && agvContent.code == 200 && Del) BaseDal.DeleteAndMoveIntoHty(dt_Task, OperateTypeEnum.鑷姩鍒犻櫎);
+ if (agvContent != null && agvContent.code == 200 && Del)
+ BaseDal.DeleteAndMoveIntoHty(dt_Task, OperateTypeEnum.鑷姩鍒犻櫎);
else BaseDal.UpdateData(dt_Task);
}
return content;
}
#endregion
-
-
-
-
}
}
--
Gitblit v1.9.3