From 90fa55064597236b9581304f232a607ffc7b730e Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期日, 12 四月 2026 10:50:26 +0800
Subject: [PATCH] fix(WCS): 解决OutboundTaskFlowService与TaskService的循环依赖

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

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs
index b6d645d..74deb07 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs
@@ -1,4 +1,5 @@
-锘縰sing Newtonsoft.Json;
+锘縰sing Autofac;
+using Newtonsoft.Json;
 using System.Diagnostics.CodeAnalysis;
 using WIDESEAWCS_Common.HttpEnum;
 using WIDESEAWCS_Common.TaskEnum;
@@ -27,8 +28,8 @@
         private readonly IRouterService _routerService;
         private readonly HttpClientHelper _httpClientHelper;
         private readonly IRobotTaskService _robotTaskService;
-        private readonly ITaskService _taskService;
         private readonly ITaskRepository _taskRepository;
+        private readonly IComponentContext _componentContext;
 
         /// <summary>
         /// 鍒濆鍖栧嚭搴撲换鍔℃祦绋嬫湇鍔°��
@@ -36,16 +37,21 @@
         /// <param name="routerService">璺敱鏈嶅姟銆�</param>
         /// <param name="httpClientHelper">WMS鎺ュ彛璋冪敤甯姪绫汇��</param>
         /// <param name="robotTaskService">鏈烘鎵嬩换鍔℃湇鍔°��</param>
-        /// <param name="taskService">浠诲姟鏈嶅姟锛堢敤浜庢帴鏀跺叆搴撲换鍔★級銆�</param>
         /// <param name="taskRepository">浠诲姟浠撳偍锛堢敤浜庡垹闄ゅ嚭搴撲换鍔★級銆�</param>
-        public OutboundTaskFlowService(IRouterService routerService, HttpClientHelper httpClientHelper, IRobotTaskService robotTaskService, ITaskService taskService, ITaskRepository taskRepository)
+        /// <param name="componentContext">Autofac缁勪欢涓婁笅鏂囷紙鐢ㄤ簬寤惰繜瑙f瀽ITaskService浠ラ伩鍏嶅惊鐜緷璧栵級銆�</param>
+        public OutboundTaskFlowService(IRouterService routerService, HttpClientHelper httpClientHelper, IRobotTaskService robotTaskService, ITaskRepository taskRepository, IComponentContext componentContext)
         {
             _routerService = routerService;
             _httpClientHelper = httpClientHelper;
             _robotTaskService = robotTaskService;
-            _taskService = taskService;
             _taskRepository = taskRepository;
+            _componentContext = componentContext;
         }
+
+        /// <summary>
+        /// 寤惰繜瑙f瀽ITaskService浠ラ伩鍏嶅惊鐜緷璧�
+        /// </summary>
+        private ITaskService TaskService => _componentContext.Resolve<ITaskService>();
 
         /// <summary>
         /// 鎺ユ敹WMS浠诲姟鏃跺垵濮嬪寲鍑哄簱浠诲姟銆�
@@ -152,7 +158,7 @@
                     _taskRepository.DeleteAndMoveIntoHty(task, OperateTypeEnum.鑷姩瀹屾垚);
 
                     // 璋冪敤ReceiveWMSTask鍒涘缓鏈湴鍏ュ簱浠诲姟
-                    var receiveResult = _taskService.ReceiveWMSTask(new List<WMSTaskDTO> { inboundTaskDto });
+                    var receiveResult = TaskService.ReceiveWMSTask(new List<WMSTaskDTO> { inboundTaskDto });
                     if (!receiveResult.Status)
                     {
                         return content.Error($"鍒涘缓鏈湴鍏ュ簱浠诲姟澶辫触: {receiveResult.Message}");

--
Gitblit v1.9.3