From f640a3ab00189bb0f55a7bfb65f309f80803e88b Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期六, 18 四月 2026 14:25:25 +0800
Subject: [PATCH] 优化成品移库任务,添加WMS任务号加流水号确保WMS任务号唯一

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/RGVTaskExtend.cs |   76 ++++++++++++++++++++++++++++++--------
 1 files changed, 60 insertions(+), 16 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 a695aa8..c32d74c 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;
@@ -164,7 +165,7 @@
             WebResponseContent content = new WebResponseContent();
             try
             {
-                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();
                 var request = new GetBlockPodContentListDto
                 {
@@ -221,34 +222,69 @@
                         _taskService.UpdateData(tasks);
                         return;
                     }
-                    foreach (var Result in getBlockPod.Result)
+                    #region 鍒ゆ柇鏄惁闇�瑕佺Щ搴�
+                    foreach (var task in tasks)
                     {
-                        foreach (var item in Result.outPods)
+                        var item = getBlockPod.Result[0].outPods.FirstOrDefault(x => x.outPod == task.PalletCode);
+                        if (item != null)
                         {
-                            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_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();
                 }
             }
@@ -528,16 +564,24 @@
             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;
                 List<Dt_RGVLocationInfo> _UpRGVLocationInfos = Items.Item2;
                 if (tasks.Count < blockPods.Count) throw new Exception("鍙Щ搴撶┖璐т綅灏戜簬闇�绉诲簱鎵樼洏鏁伴噺");
-
+                int i = 0;
                 tasks.ForEach(x =>
                 {
+                    i++;
                     x.TaskNum = _taskService.GetTaskNum(nameof(SequenceEnum.SeqTaskNum));
-                    //x.WMSTaskNum = task.WMSTaskNum;
+                    x.WMSTaskNum = $"Move_{i}&" + task.WMSTaskNum;
                 });
                 rGVLocationInfos.ForEach(x =>
                 {

--
Gitblit v1.9.3