From 821af8301009019a0f0e81a3ea2a0ae7952b5025 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期三, 28 一月 2026 11:43:30 +0800
Subject: [PATCH] 更新
---
项目代码/WCSServices/WIDESEAWCS_TaskInfoService/InvokeAGVService.cs | 103 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 99 insertions(+), 4 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_TaskInfoService/InvokeAGVService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_TaskInfoService/InvokeAGVService.cs"
index 47c5b5f..d3f1524 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_TaskInfoService/InvokeAGVService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCSServices/WIDESEAWCS_TaskInfoService/InvokeAGVService.cs"
@@ -51,12 +51,80 @@
return content;
}
/// <summary>
+ /// AGV鏌ヨ璋冪敤鍙奧MS鏁呴殰涓婃姤
+ /// </summary>
+ public void AgvSearchStatus1(Dt_ErrorInfo e2)
+ {
+ if (e2 != null)
+ {
+ // 鏌ヨ鏄惁鏈夐敊璇病鏈夊氨娣诲姞锛屾湁灏卞彇娑�
+ List<Dt_ErrorInfo> existingErrors = _errorInfoRepository.QueryData(x =>
+ x.RobotCode == e2.RobotCode &&
+ x.ErrorType == 2); // 鍙煡璇㈡晠闅滅被鍨嬩负2鐨勮褰�
+
+ string? ErrorBack = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.WMSErrorBack.ToString())?.ApiAddress;
+ if (string.IsNullOrEmpty(ErrorBack))
+ throw new Exception($"鏈壘鍒癢MS鏁呴殰涓婃姤鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+
+ // 濡傛灉鏄晠闅滀笂鎶�(e2.ErrorType == 2)
+ if (e2.ErrorType == 2)
+ {
+ // 妫�鏌ユ槸鍚﹀凡瀛樺湪鐩稿悓鏈哄櫒浜虹殑鏁呴殰璁板綍
+ if (existingErrors.Count == 0)
+ {
+ _errorInfoRepository.AddData(e2);
+ // 鍙戦�佺粰WMS - 鏁呴殰涓婃姤
+ TaskError taskError = new TaskError()
+ {
+ MsgID = e2.Id,
+ StationCode = e2.StationCode,
+ MsgCode = 1, // 1琛ㄧず鏁呴殰
+ Msg = e2.Message
+ };
+ string reqErrorBack = JsonConvert.SerializeObject(taskError, settings);
+ HttpHelper.Post(ErrorBack, reqErrorBack);
+ }
+ // 濡傛灉宸插瓨鍦ㄦ晠闅滆褰曪紝鍒欎笉閲嶅娣诲姞
+ }
+ // 濡傛灉鏄甯哥姸鎬�(e2.ErrorType == 0)涓斿瓨鍦ㄦ晠闅滆褰曪紝鍒欐墽琛屾晠闅滄仮澶�
+ else if (e2.ErrorType == 0 && existingErrors.Count > 0)
+ {
+ // 鍒犻櫎鏁呴殰璁板綍
+ if (_errorInfoRepository.DeleteData(existingErrors))
+ {
+ // 鍙戦�佺粰WMS - 鏁呴殰鎭㈠
+ foreach (var error in existingErrors)
+ {
+ TaskError taskError = new TaskError()
+ {
+ MsgID = error.Id,
+ StationCode = error.StationCode,
+ MsgCode = 0, // 0琛ㄧず鎭㈠
+ Msg = "鏁呴殰鎭㈠"
+ };
+ string reqErrorBack = JsonConvert.SerializeObject(taskError, settings);
+ HttpHelper.Post(ErrorBack, reqErrorBack);
+ }
+ }
+ }
+ return;
+ }
+ }
+ /// <summary>
/// AGV鐘舵�佹煡璇㈣皟鐢ㄥ強WMS鏁呴殰涓婃姤
/// </summary>
public void AgvSearchStatus()
{
try
{
+ // 鏌ヨ鏄惁鏈変换鍔�
+ List<Dt_Task> tasks = BaseDal.QueryData();
+ // 濡傛灉娌℃湁浠诲姟锛岀洿鎺ヨ繑鍥�
+ if (tasks == null || tasks.Count == 0)
+ {
+ return;
+ }
+
AgvSearchStatusDTO agvSearchStatusDTO = new AgvSearchStatusDTO();
string? apiAddress = _apiInfoRepository.QueryFirst(x => x.ApiCode == APIEnum.AgvSearchStatus.ToString())?.ApiAddress;
if (string.IsNullOrEmpty(apiAddress)) throw new Exception($"鏈壘鍒癆GV鐘舵�佹煡璇㈡帴鍙�,璇锋鏌ユ帴鍙i厤缃�");
@@ -67,12 +135,12 @@
AgvStatusContent agvContent = response.DeserializeObject<AgvStatusContent>() ?? throw new Exception("AGV鐘舵�佹煡璇㈡湭杩斿洖缁撴灉");
//鑾峰彇鎵�鏈夋晠闅滀俊鎭�
- List <Dt_ErrorInfo> errorInfos = _errorInfoRepository.QueryData();
+ List <Dt_ErrorInfo> errorInfos = _errorInfoRepository.QueryData(x => x.ErrorType == 1);
int errorId = errorInfos.Count > 0 ? errorInfos.Max(x => x.Id) : 0;
List<Dt_ErrorInfo> delErrorInfos = new List<Dt_ErrorInfo>();
List<Dt_ErrorInfo> addErrorInfos = new List<Dt_ErrorInfo>();
//鑾峰彇浠诲姟淇℃伅
- List<Dt_Task> tasks = BaseDal.QueryData();
+ //List<Dt_Task> tasks = BaseDal.QueryData();
if (agvContent.Success)
{
foreach (var item in agvContent.Data.Where(x => errorInfos.Select(x => x.RobotCode).Contains(x.RobotId) && x.Status != 7))
@@ -90,7 +158,8 @@
Dt_ErrorInfo errorInfo = new Dt_ErrorInfo()
{
RobotCode = item.RobotId,
- Message = "鏁呴殰"
+ Message = "鏁呴殰",
+ ErrorType = 1,
};
if (task.TaskType==TaskTypeEnum.Inbound.ObjToInt())
{
@@ -109,7 +178,7 @@
_errorInfoRepository.DeleteData(delErrorInfos);
_errorInfoRepository.AddData(addErrorInfos);
_unitOfWorkManage.CommitTran();
- List<Dt_ErrorInfo> newErrInfos = _errorInfoRepository.QueryData(x=>x.Id > errorId);
+ List<Dt_ErrorInfo> newErrInfos = _errorInfoRepository.QueryData(x=>x.Id > errorId && x.ErrorType == 2);
if (delErrorInfos.Count>0)
{
foreach (var item in delErrorInfos)
@@ -123,6 +192,7 @@
};
string reqErrorBack = JsonConvert.SerializeObject(taskError, settings);
HttpHelper.Post(apiErrorBack, reqErrorBack);
+
}
}
if (newErrInfos.Count>0)
@@ -149,5 +219,30 @@
}
}
+ public WebResponseContent AgvCancelTask(AgvTaskCancelDTO taskModel, APIEnum SendTask = APIEnum.AgvTaskCancel)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ string? apiAddress = _apiInfoRepository.QueryFirst(x => x.ApiCode == SendTask.ToString())?.ApiAddress;
+ if (string.IsNullOrEmpty(apiAddress)) throw new Exception($"鏈壘鍒板彂閫丄GV浠诲姟鎺ュ彛,璇锋鏌ユ帴鍙i厤缃�");
+ string request = JsonConvert.SerializeObject(taskModel, settings);
+ string response = HttpHelper.Post(apiAddress, request);
+ AgvResponseContent agvContent = response.DeserializeObject<AgvResponseContent>() ?? throw new Exception("AGV浠诲姟鍙戦�佹湭杩斿洖缁撴灉");
+ if (agvContent.Success)
+ {
+ content.OK();
+ }
+ else
+ {
+ content.Error(agvContent.Message);
+ }
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
+ return content;
+ }
}
}
--
Gitblit v1.9.3