From ba9c1994b95624b88ef606ec00394990d8f2009f Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期三, 15 四月 2026 19:41:27 +0800
Subject: [PATCH] refactor(TaskService): 重构任务服务代码结构,拆分文件并优化逻辑

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs |   42 ++++++++++++++++++------------------------
 1 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs
index e44f6cf..5e1e70b 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs
@@ -56,18 +56,20 @@
         /// </summary>
         /// <param name="task">浠诲姟瀹炰綋銆�</param>
         /// <param name="source">WMS浠诲姟鍘熷鏁版嵁銆�</param>
-        public void InitializeOnReceive([NotNull] Dt_Task task, [NotNull] WMSTaskDTO source)
+        public WebResponseContent InitializeOnReceive([NotNull] Dt_Task task, [NotNull] WMSTaskDTO source)
         {
+            WebResponseContent content = new WebResponseContent();
             int taskType = task.TaskType == (int)TaskOutboundTypeEnum.OutEmpty ? 100 : task.TaskType;
             Dt_Router router = _routerService.QueryNextRoute(source.Roadway, source.TargetAddress, taskType);
             if (router == null)
             {
-                return;
+                return content.Error("鏈壘鍒拌澶囪矾鐢变俊鎭�");
             }
 
             task.TaskStatus = (int)TaskOutStatusEnum.OutNew;
             task.CurrentAddress = source.SourceAddress;
             task.NextAddress = router.ChildPosi;
+            return content.OK();
         }
 
         /// <summary>
@@ -135,15 +137,25 @@
             task.Modifier = "System";
 
             // 閫氱煡WMS鍑哄簱瀹屾垚骞惰幏鍙栬繑鍥炵粨鏋�
+            return  NotifyWMSOutboundFinish(task);
+        }
+
+        /// <summary>
+        /// 閫氱煡WMS鍑哄簱瀹屾垚銆�
+        /// </summary>
+        /// <param name="task">浠诲姟瀹炰綋銆�</param>
+        /// <returns>閫氱煡缁撴灉銆�</returns>
+        private WebResponseContent NotifyWMSOutboundFinish(Dt_Task task)
+        {
+            WebResponseContent content = new WebResponseContent();
+
+            // 閫氱煡WMS鍑哄簱瀹屾垚骞惰幏鍙栬繑鍥炵粨鏋�
             var result = _httpClientHelper.Post<WebResponseContent>(
                 nameof(ConfigKey.OutboundFinishTaskAsync),
                 new StockInfoDTO { PalletCode = task.PalletCode, TaskNum = task.TaskNum }.ToJson());
 
             if (!result.IsSuccess || !result.Data.Status)
-            {
                 return content.Error($"閫氱煡WMS绯荤粺鍫嗗灈鏈哄嚭搴撳畬鎴愬け璐�,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙�:銆恵task.PalletCode}銆�,閿欒淇℃伅:銆恵result.Data?.Message}銆�");
-            }
-
             // 澶勭悊WMS杩斿洖鐨勫叆搴撲换鍔★紙濡傛灉鏈夛級
             if (result.Data?.Data != null)
             {
@@ -171,25 +183,7 @@
                     });
                 }
             }
-
             return content.OK($"閫氱煡WMS绯荤粺鍫嗗灈鏈哄嚭搴撳畬鎴愭垚鍔�,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙�:銆恵task.PalletCode}銆�");
-        }
-
-        /// <summary>
-        /// 閫氱煡WMS鍑哄簱瀹屾垚銆�
-        /// </summary>
-        /// <param name="task">浠诲姟瀹炰綋銆�</param>
-        /// <returns>閫氱煡缁撴灉銆�</returns>
-        private WebResponseContent NotifyWMSOutboundFinish(Dt_Task task)
-        {
-            var result = _httpClientHelper.Post<WebResponseContent>(
-                nameof(ConfigKey.OutboundFinishTaskAsync),
-                new StockInfoDTO { PalletCode = task.PalletCode, TaskNum = task.TaskNum }.ToJson());
-
-            if (!result.IsSuccess || !result.Data.Status)
-                return WebResponseContent.Instance.Error($"閫氱煡WMS绯荤粺鍫嗗灈鏈哄嚭搴撳畬鎴愬け璐�,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙�:銆恵task.PalletCode}銆�,閿欒淇℃伅:銆恵result.Data?.Message}銆�");
-
-            return WebResponseContent.Instance.OK();
         }
 
         /// <summary>
@@ -225,7 +219,7 @@
         {
             var result = _httpClientHelper.Post<WebResponseContent>(
                 nameof(ConfigKey.UpdateTaskByStatus),
-                new UpdateTaskDto { Id = task.TaskNum, NewStatus = task.TaskStatus }.ToJson());
+                new UpdateTaskDto { Id = task.TaskNum, NewStatus = task.TaskStatus, NextAddress = task.NextAddress, CurrentAddress = task.CurrentAddress }.ToJson());
 
             if (!result.IsSuccess || !result.Data.Status)
                 return WebResponseContent.Instance.Error($"璋冪敤WMS鎺ュ彛鏇存柊浠诲姟鐘舵�佸け璐�,浠诲姟鍙�:銆恵task.TaskNum}銆�,閿欒淇℃伅:銆恵result.Data?.Message}銆�");

--
Gitblit v1.9.3