From 0875bfa35d389e238ae82142ce45b71c9715133b Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期五, 17 四月 2026 17:37:39 +0800
Subject: [PATCH] Merge branch 'master' of http://115.159.85.185:8098/r/RuiShengZhiNeng/GaoPuLiTiKu

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/RGVTaskExtend.cs |  123 +++++++++++++++++++++++++++++++---------
 1 files changed, 95 insertions(+), 28 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 71c5c1c..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;
@@ -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,50 +178,113 @@
                         }
                     }
                 };
-                requestData = request;  // 淇濆瓨璇锋眰鏁版嵁鐢ㄤ簬鏃ュ織
-                //content.candidatePodIDs = tasks.Select(x => x.PalletCode).ToList();
                 //string response = HttpHelper.Post("http://127.0.0.1:4523/m2/6165241-5857331-default/440906899?apifoxApiId=440906899", request.Serialize());
-
-                string response = HttpHelper.Post(apiInfo.ApiAddress, request.Serialize());
-                FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>();
-                content.OK(data: fOURBOTReturn);
+                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();
                 }
             }
@@ -234,7 +294,7 @@
             }
             finally
             {
-                _trackloginfoService.AddTrackLog(requestData, content, "澶勭悊鍑哄簱浠诲姟鏄惁闇�瑕佺Щ搴�", "", "");
+                //_trackloginfoService.AddTrackLog(requestData, content, "澶勭悊鍑哄簱浠诲姟鏄惁闇�瑕佺Щ搴�", "", "");
             }
         }
         #endregion
@@ -504,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;

--
Gitblit v1.9.3