From ce1292c9cf37195b6abd2699dfc5d6cb3e143c9b Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期日, 12 四月 2026 23:38:19 +0800
Subject: [PATCH] feat(MES): 添加MES接口相关实体和DTO JS扩展文件至JSX格式并更新配置

---
 Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs |   88 ++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 77 insertions(+), 11 deletions(-)

diff --git a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs
index 5a3b045..6082140 100644
--- a/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs
+++ b/Code/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/Flows/OutboundTaskFlowService.cs
@@ -1,16 +1,18 @@
-锘縰sing Newtonsoft.Json;
+锘縰sing Autofac;
+using Newtonsoft.Json;
 using System.Diagnostics.CodeAnalysis;
+using WIDESEA_Core;
 using WIDESEAWCS_Common.HttpEnum;
 using WIDESEAWCS_Common.TaskEnum;
-using WIDESEA_Core;
 using WIDESEAWCS_Core;
+using WIDESEAWCS_Core.BaseRepository;
+using WIDESEAWCS_Core.Enums;
 using WIDESEAWCS_Core.Helper;
 using WIDESEAWCS_DTO;
 using WIDESEAWCS_DTO.Stock;
 using WIDESEAWCS_DTO.TaskInfo;
 using WIDESEAWCS_ITaskInfoService;
 using WIDESEAWCS_Model.Models;
-using WIDESEAWCS_QuartzJob.DTO;
 using WIDESEAWCS_QuartzJob.Models;
 using WIDESEAWCS_QuartzJob.Service;
 
@@ -25,6 +27,8 @@
         private readonly IRouterService _routerService;
         private readonly HttpClientHelper _httpClientHelper;
         private readonly IRobotTaskService _robotTaskService;
+        private readonly IComponentContext _componentContext;
+        private readonly IUnitOfWorkManage _unitOfWorkManage;
 
         /// <summary>
         /// 鍒濆鍖栧嚭搴撲换鍔℃祦绋嬫湇鍔°��
@@ -32,12 +36,20 @@
         /// <param name="routerService">璺敱鏈嶅姟銆�</param>
         /// <param name="httpClientHelper">WMS鎺ュ彛璋冪敤甯姪绫汇��</param>
         /// <param name="robotTaskService">鏈烘鎵嬩换鍔℃湇鍔°��</param>
-        public OutboundTaskFlowService(IRouterService routerService, HttpClientHelper httpClientHelper, IRobotTaskService robotTaskService)
+        /// <param name="componentContext">Autofac缁勪欢涓婁笅鏂囷紙鐢ㄤ簬寤惰繜瑙f瀽ITaskService浠ラ伩鍏嶅惊鐜緷璧栵級銆�</param>
+        public OutboundTaskFlowService(IRouterService routerService, HttpClientHelper httpClientHelper, IRobotTaskService robotTaskService, IComponentContext componentContext, IUnitOfWorkManage unitOfWorkManage)
         {
             _routerService = routerService;
             _httpClientHelper = httpClientHelper;
             _robotTaskService = robotTaskService;
+            _componentContext = componentContext;
+            _unitOfWorkManage = unitOfWorkManage;
         }
+
+        /// <summary>
+        /// 寤惰繜瑙f瀽ITaskService浠ラ伩鍏嶅惊鐜緷璧�
+        /// </summary>
+        private ITaskService TaskService => _componentContext.Resolve<ITaskService>();
 
         /// <summary>
         /// 鎺ユ敹WMS浠诲姟鏃跺垵濮嬪寲鍑哄簱浠诲姟銆�
@@ -79,7 +91,12 @@
 
             if (task.TaskStatus == (int)TaskOutStatusEnum.Line_OutFinish && task.TaskType == (int)TaskOutboundTypeEnum.OutEmpty)
             {
-                return _robotTaskService.GetWMSRobotTask(task);
+                WebResponseContent content = _robotTaskService.GetWMSRobotTask(task);
+                if (!content.Status)
+                {
+                    return content;
+                }
+                return OutboundFinishTaskTray(task);
             }
 
             if (task.TaskStatus == (int)TaskOutStatusEnum.Line_OutExecuting)
@@ -117,13 +134,45 @@
             task.ModifyDate = DateTime.Now;
             task.Modifier = "System";
 
-            content = NotifyWMSOutboundFinish(task);
-            if (!content.Status)
+            // 閫氱煡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;
+                return content.Error($"閫氱煡WMS绯荤粺鍫嗗灈鏈哄嚭搴撳畬鎴愬け璐�,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙�:銆恵task.PalletCode}銆�,閿欒淇℃伅:銆恵result.Data?.Message}銆�");
             }
 
-            return content.Error($"閫氱煡WMS绯荤粺鍫嗗灈鏈哄嚭搴撳畬鎴愭垚鍔�,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙�:銆恵task.PalletCode}銆�");
+            // 澶勭悊WMS杩斿洖鐨勫叆搴撲换鍔★紙濡傛灉鏈夛級
+            if (result.Data?.Data != null)
+            {
+                var inboundTaskJson = result.Data.Data.ToString();
+                var inboundTaskDto = JsonConvert.DeserializeObject<WMSTaskDTO>(inboundTaskJson);
+
+                if (inboundTaskDto != null)
+                {
+                    _unitOfWorkManage.BeginTran(() =>
+                    {
+                        // 鍏堝垹闄ゆ湰鍦板嚭搴撲换鍔★紝閬垮厤鎵樼洏鍙峰敮涓�閿啿绐�
+                        bool isDeleted = TaskService.Repository.DeleteAndMoveIntoHty(task, OperateTypeEnum.鑷姩瀹屾垚);
+                        if (!isDeleted)
+                        {
+                            return content.Error($"鍒犻櫎鏈湴鍑哄簱浠诲姟澶辫触,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙�:銆恵task.PalletCode}銆�");
+                        }
+
+                        // 璋冪敤ReceiveWMSTask鍒涘缓鏈湴鍏ュ簱浠诲姟
+                        var receiveResult = TaskService.ReceiveWMSTask(new List<WMSTaskDTO> { inboundTaskDto });
+                        if (!receiveResult.Status)
+                        {
+                            return content.Error($"鍒涘缓鏈湴鍏ュ簱浠诲姟澶辫触: {receiveResult.Message}");
+                        }
+                        return content.OK("鍒涘缓鏈湴鍏ュ簱浠诲姟鎴愬姛");
+                    });
+                }
+            }
+
+            return content.OK($"閫氱煡WMS绯荤粺鍫嗗灈鏈哄嚭搴撳畬鎴愭垚鍔�,浠诲姟鍙�:銆恵task.TaskNum}銆�,鎵樼洏鍙�:銆恵task.PalletCode}銆�");
         }
 
         /// <summary>
@@ -176,7 +225,24 @@
         {
             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}銆�");
+
+            return WebResponseContent.Instance.OK();
+        }
+
+        /// <summary>
+        /// 绌烘墭鐩樺嚭搴撳畬鎴愬悓姝ュ埌WMS銆�
+        /// </summary>
+        /// <param name="task">浠诲姟瀹炰綋銆�</param>
+        /// <returns>鍚屾缁撴灉銆�</returns>
+        private WebResponseContent OutboundFinishTaskTray(Dt_Task task)
+        {
+            var result = _httpClientHelper.Post<WebResponseContent>(
+                nameof(ConfigKey.OutboundFinishTaskTray),
+                new CreateTaskDto { PalletCode = task.PalletCode, SourceAddress = task.SourceAddress }.ToJson());
 
             if (!result.IsSuccess || !result.Data.Status)
                 return WebResponseContent.Instance.Error($"璋冪敤WMS鎺ュ彛鏇存柊浠诲姟鐘舵�佸け璐�,浠诲姟鍙�:銆恵task.TaskNum}銆�,閿欒淇℃伅:銆恵result.Data?.Message}銆�");
@@ -184,4 +250,4 @@
             return WebResponseContent.Instance.OK();
         }
     }
-}
+}
\ No newline at end of file

--
Gitblit v1.9.3