From 90ac374a64e47e2bd97ee9245f4cafb50ad5dbbb Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期五, 17 四月 2026 17:31:02 +0800
Subject: [PATCH] 添加成品出库任务等待移库上报WMS
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/RGVTaskExtend.cs | 139 ++++++++++++++++++++++++++++++++++-----------
1 files changed, 104 insertions(+), 35 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/RGVTaskExtend.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/RGVTaskExtend.cs"
index d1d3cfd..9c6fff4 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/RGVTaskExtend.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/RGVTaskExtend.cs"
@@ -4,6 +4,7 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
+using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Common;
@@ -32,10 +33,8 @@
try
{
Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(FOURBOTnewMovePodTask)) ?? throw new Exception("鏈壘鍒板洓鍚戣溅浠诲姟涓嬪彂鎺ュ彛閰嶇疆淇℃伅锛佽妫�鏌ユ帴鍙i厤缃�");
- int i = 0;
foreach (var task in tasks)
{
- i++;
fOURBOTnewMovePodTask = new()
{
priority = task.Grade,
@@ -65,11 +64,16 @@
task.RGVTaskId = fOURBO.taskID;
task.ExceptionMessage = "";
task.TaskState = (int)TaskStatusEnum.Execut;
- task.Dispatchertime=DateTime.Now;
+ task.Dispatchertime = DateTime.Now;
}
catch (Exception ex)
{
task.ExceptionMessage = ex.Message;
+ content.Error(ex.Message);
+ }
+ finally
+ {
+ _trackloginfoService.AddTrackLog(fOURBOTnewMovePodTask, content, "涓嬪彂鍥涘悜杞︽柊寤哄叆搴撲换鍔�", "", "");
}
}
var uptasks = tasks.Where(task => string.IsNullOrEmpty(task.ExceptionMessage)).ToList();
@@ -79,6 +83,7 @@
{
foreach (var item in errortasks)
{
+ Thread.Sleep(500);
_taskService.ErrorTaskFeedback(item, true);
}
}
@@ -87,10 +92,6 @@
catch (Exception ex)
{
content.Error(ex.Message);
- }
- finally
- {
- _trackloginfoService.AddTrackLog(fOURBOTnewMovePodTask, content, "涓嬪彂鍥涘悜杞︽柊寤哄叆搴撲换鍔�", "", "");
}
}
@@ -161,15 +162,11 @@
/// <param name="tasks"></param>
public void IsMoveTask(List<Dt_Task> tasks)
{
-
- object requestData = null; // 娣诲姞鍙橀噺璁板綍璇锋眰鏁版嵁
WebResponseContent content = new WebResponseContent();
try
{
- Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(GetBlockPodContentDto)) ?? throw new Exception("鏈壘鍒版壒閲忚幏鍙栭樆纰嶆墭鐩樺叧绯绘帴鍙i厤缃俊鎭紒璇锋鏌ユ帴鍙i厤缃�");
- List<Dt_Task> dt_Tasks = new List<Dt_Task>();
+ //List<Dt_Task> dt_Tasks = new List<Dt_Task>();
var PalletCodes = tasks.Select(x => x.PalletCode).ToList();
- //GetBlockPodContentDto content = new GetBlockPodContentDto();
var request = new GetBlockPodContentListDto
{
content = new List<GetBlockPodContentDto>
@@ -181,48 +178,113 @@
}
}
};
- requestData = request; // 淇濆瓨璇锋眰鏁版嵁鐢ㄤ簬鏃ュ織
- //content.candidatePodIDs = tasks.Select(x => x.PalletCode).ToList();
- string response = HttpHelper.Post(apiInfo.ApiAddress, request.Serialize());
- FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>();
- content.OK(data: fOURBOTReturn);
+ //string response = HttpHelper.Post("http://127.0.0.1:4523/m2/6165241-5857331-default/440906899?apifoxApiId=440906899", request.Serialize());
+ content = _apiInfoService.PostInterfaceRequest(nameof(GetBlockPodContentDto), request.Serialize(), "鎵归噺鑾峰彇闃荤鎵樼洏鍏崇郴");
+ if (!content.Status)
+ {
+ foreach (var item in tasks)
+ {
+ item.ExceptionMessage = content.Message;
+ }
+ _taskService.UpdateData(tasks);
+ return;
+ }
+ FOURBOTReturn fOURBOTReturn = content.Data as FOURBOTReturn;
if (fOURBOTReturn.returnCode == 0)
{
//ReturnBlockPodResultDto getBlockPod = fOURBOTReturn.data as ReturnBlockPodResultDto ?? throw new Exception("鏈幏鍙栧埌闃荤鎵樼洏鍏崇郴鏁版嵁");
var dataJson = fOURBOTReturn.data.ToString();
+ if (string.IsNullOrEmpty(dataJson))
+ {
+ foreach (var item in tasks)
+ {
+ item.ExceptionMessage = "鑾峰彇闃荤鎵樼洏鍏崇郴澶辫触锛�";
+ }
+ _taskService.UpdateData(tasks);
+ return;
+ }
ReturnBlockPodResultDto? getBlockPod = JsonConvert.DeserializeObject<ReturnBlockPodResultDto>(dataJson);
+ if (getBlockPod == null)
+ {
+ foreach (var item in tasks)
+ {
+ item.ExceptionMessage = "闃荤鎵樼洏鍏崇郴鏁版嵁杞崲瀹炰綋澶辫触锛�";
+ }
+ _taskService.UpdateData(tasks);
+ return;
+ }
if (getBlockPod.Result.Count == 0)
{
- throw new Exception("鏈幏鍙栧埌闃荤鎵樼洏鍏崇郴鏁版嵁");
- }
- foreach (var Result in getBlockPod.Result)
- {
- foreach (var item in Result.outPods)
+ foreach (var item in tasks)
{
- var task = tasks.First(x => x.PalletCode == item.outPod);
+ item.ExceptionMessage = "鏈幏鍙栧埌闃荤鎵樼洏鍏崇郴鏁版嵁锛�";
+ }
+ _taskService.UpdateData(tasks);
+ return;
+ }
+ #region 鍒ゆ柇鏄惁闇�瑕佺Щ搴�
+ foreach (var task in tasks)
+ {
+ var item = getBlockPod.Result[0].outPods.FirstOrDefault(x => x.outPod == task.PalletCode);
+ if (item != null)
+ {
if (item.blockPods != null && item.blockPods.Count > 0)
item.blockPods = item.blockPods.Except(PalletCodes).ToList();
if (item.blockPods != null && item.blockPods.Count > 0)
{
- #region 鍒ゆ柇闃荤鎵樻槸鍚︿负鍑哄簱浠诲姟
- //var except = item.blockPods.Except(PalletCodes).ToList();
- #endregion
var responseContent = AddMoveTask(item.blockPods, task);//娣诲姞绉诲簱浠诲姟
if (!responseContent.Status) task.ExceptionMessage = responseContent.Message;
- else
- {
- task.TaskState = (int)TaskStatusEnum.RGV_WaitMoveToExecute;
- }
- dt_Tasks.Add(task);
+ else task.TaskState = (int)TaskStatusEnum.RGV_WaitMoveToExecute;
+ #region 绉诲簱鐘舵�佸弽棣堢粰WMS
+ WMSInOutBoundCompleteFeedback boundCompleteFeedback = new WMSInOutBoundCompleteFeedback();
+ boundCompleteFeedback.taskCode = task.WMSTaskNum;
+ boundCompleteFeedback.containerCode = task.PalletCode;
+ boundCompleteFeedback.fromStationCode = task.SourceAddress;
+ boundCompleteFeedback.toLocationCode = task.TargetAddress;
+ boundCompleteFeedback.status = 5;
+ boundCompleteFeedback.custStatus = "";
+ _apiInfoService.PostInterfaceRequest(nameof(WMSInOutBoundCompleteFeedback), boundCompleteFeedback.Serialize(), "鎴愬搧鍑哄簱浠诲姟绛夊緟绉诲簱涓婃姤WMS");
+ #endregion
}
else
{
task.TaskState = (int)TaskStatusEnum.RGV_WaitSend;
- dt_Tasks.Add(task);
}
}
+ else task.ExceptionMessage = $"RCS鏈弽棣堛�恵task.PalletCode}銆戝彲鍑哄簱鎵樼洏淇℃伅,璇︽儏璇锋煡鐪嬫壒閲忚幏鍙栭樆纰嶆墭鐩樺叧绯绘帴鍙f棩蹇楋紒";
}
- _taskService.UpdateData(dt_Tasks);
+ _taskService.Repository.UpdateData(tasks);
+ #endregion
+ #region MyRegion
+ //foreach (var Result in getBlockPod.Result)
+ //{
+ // foreach (var item in Result.outPods)
+ // {
+ // var task = tasks.First(x => x.PalletCode == item.outPod);
+ // if (item.blockPods != null && item.blockPods.Count > 0)
+ // item.blockPods = item.blockPods.Except(PalletCodes).ToList();
+ // if (item.blockPods != null && item.blockPods.Count > 0)
+ // {
+ // #region 鍒ゆ柇闃荤鎵樻槸鍚︿负鍑哄簱浠诲姟
+ // //var except = item.blockPods.Except(PalletCodes).ToList();
+ // #endregion
+ // var responseContent = AddMoveTask(item.blockPods, task);//娣诲姞绉诲簱浠诲姟
+ // if (!responseContent.Status) task.ExceptionMessage = responseContent.Message;
+ // else
+ // {
+ // task.TaskState = (int)TaskStatusEnum.RGV_WaitMoveToExecute;
+ // }
+ // dt_Tasks.Add(task);
+ // }
+ // else
+ // {
+ // task.TaskState = (int)TaskStatusEnum.RGV_WaitSend;
+ // dt_Tasks.Add(task);
+ // }
+ // }
+ //}
+ //_taskService.UpdateData(dt_Tasks);
+ #endregion
content.OK();
}
}
@@ -232,7 +294,7 @@
}
finally
{
- _trackloginfoService.AddTrackLog(requestData, content, "澶勭悊鍑哄簱浠诲姟鏄惁闇�瑕佺Щ搴�", "", "");
+ //_trackloginfoService.AddTrackLog(requestData, content, "澶勭悊鍑哄簱浠诲姟鏄惁闇�瑕佺Щ搴�", "", "");
}
}
#endregion
@@ -502,6 +564,13 @@
try
{
List<Dt_RGVLocationInfo> rGVLocationInfos = _rGVLocationInfoService.Repository.QueryData(x => blockPods.Contains(x.PalletCode));
+ var palletCodes = rGVLocationInfos.Select(x => x.PalletCode).ToList();
+ // 鑾峰彇 blockPods 涓瓨鍦ㄤ絾 palletCodes 涓笉瀛樺湪鐨勬墭鐩樼爜
+ var missingPalletCodes = blockPods.Except(palletCodes).ToList();
+ if (missingPalletCodes.Any())
+ {
+ throw new Exception($"鏈壘鍒颁互涓嬮樆纰嶆墭璐т綅淇℃伅锛歿string.Join(",", missingPalletCodes)}");
+ }
var Items = _rGVLocationInfoService.GetMoveFreeLocationInfo(rGVLocationInfos);
List<Dt_Task> tasks = Items.Item1;
@@ -608,7 +677,7 @@
{
foreach (var item in tasks)
{
- var takes = _taskService.Repository.QueryFirst(x => x.Roadway == item.Roadway && x.TaskType == (int)TaskTypeEnum.CPMoveInventory);
+ var takes = _taskService.Repository.QueryFirst(x => x.Roadway == item.Roadway && x.TaskType == (int)TaskTypeEnum.CPMoveInventory && (x.TaskState == (int)TaskStatusEnum.RGV_NewMoveTask || x.TaskState == (int)TaskStatusEnum.RGV_MoveTaskSend));
if (takes == null)
{
item.TaskState = (int)TaskStatusEnum.RGV_WaitSend;
--
Gitblit v1.9.3