From 782aceccc76b0f2a2da18fd61816211d821bca72 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期一, 30 三月 2026 14:14:19 +0800
Subject: [PATCH] feat(TaskService): 任务完成方法传入正确的OperateType

---
 Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs |   61 +++++++++++++++++++++++++++---
 1 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
index 82545f8..609c664 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -31,6 +31,8 @@
         private readonly IConfiguration _configuration;
         private readonly RoundRobinService _roundRobinService;
         private readonly IMesService _mesService;
+        private readonly ITask_HtyService _task_HtyService;
+        private readonly IStockInfo_HtyService _stockInfo_HtyService;
 
         public IRepository<Dt_Task> Repository => BaseDal;
 
@@ -51,7 +53,9 @@
             HttpClientHelper httpClientHelper,
             IConfiguration configuration,
             RoundRobinService roundRobinService,
-            IMesService mesService) : base(BaseDal)
+            IMesService mesService,
+            ITask_HtyService task_HtyService,
+            IStockInfo_HtyService stockInfo_HtyService) : base(BaseDal)
         {
             _mapper = mapper;
             _stockInfoService = stockInfoService;
@@ -60,6 +64,8 @@
             _configuration = configuration;
             _roundRobinService = roundRobinService;
             _mesService = mesService;
+            _task_HtyService = task_HtyService;
+            _stockInfo_HtyService = stockInfo_HtyService;
         }
 
         #region WCS閫昏緫澶勭悊
@@ -248,7 +254,7 @@
                     {
                         return content.Error($"浠诲姟瀹屾垚澶辫触锛歁ES杩涚珯澶辫触: {inboundResult?.Data?.Msg ?? inboundResult?.ErrorMessage ?? "鏈煡閿欒"}");
                     }
-                    return await CompleteTaskAsync(task);
+                    return await CompleteTaskAsync(task, "鍏ュ簱瀹屾垚");
                 });
             }
             catch (Exception ex)
@@ -302,7 +308,7 @@
                         return content.Error($"浠诲姟瀹屾垚澶辫触锛歁ES鍑虹珯澶辫触: {outboundResult?.Data?.Msg ?? outboundResult?.ErrorMessage ?? "鏈煡閿欒"}");
                     }
 
-                    return await CompleteTaskAsync(task);
+                    return await CompleteTaskAsync(task, "鍑哄簱瀹屾垚");
                 });
             }
             catch (Exception ex)
@@ -348,7 +354,7 @@
                     if (!updateSourceResult || !updateTargetResult || !updateStockResult)
                         return WebResponseContent.Instance.Error("绉诲簱浠诲姟瀹屾垚澶辫触");
 
-                    return await CompleteTaskAsync(task);
+                    return await CompleteTaskAsync(task, "绉诲簱瀹屾垚");
                 });
             }
             catch (Exception ex)
@@ -469,6 +475,47 @@
         }
 
         /// <summary>
+        /// 绌烘墭鐩樺嚭搴撳畬鎴�
+        /// </summary>
+        public async Task<WebResponseContent> OutboundFinishTaskTrayAsync(CreateTaskDto taskDto)
+        {
+            try
+            {
+                var task = await BaseDal.QueryFirstAsync(s => s.PalletCode == taskDto.PalletCode);
+                if (task == null) return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑浠诲姟");
+
+                var location = await _locationInfoService.GetLocationInfo(task.Roadway, task.SourceAddress);
+                if (location == null) return WebResponseContent.Instance.Error("鏈壘鍒板搴旂殑璐т綅");
+
+                var stockInfo = await _stockInfoService.GetStockInfoAsync(taskDto.PalletCode);
+                if (stockInfo == null) return WebResponseContent.Instance.Error("鏈壘鍒板搴斿簱瀛樹俊鎭�");
+
+                return await ExecuteWithinTransactionAsync(async () =>
+                {
+                    stockInfo.LocationId = 0;
+                    stockInfo.LocationCode = null;
+                    stockInfo.StockStatus = StockStatusEmun.鍑哄簱瀹屾垚.GetHashCode();
+
+                    location.LocationStatus = LocationStatusEnum.Free.GetHashCode();
+
+                    var updateLocationResult = await _locationInfoService.UpdateLocationInfoAsync(location);
+                    var updateStockResult = await _stockInfoService.UpdateStockAsync(stockInfo);
+                    if (!updateLocationResult || !updateStockResult)
+                        return WebResponseContent.Instance.Error("浠诲姟瀹屾垚澶辫触");
+
+                    var deleteResult = await BaseDal.DeleteDataAsync(task);
+                    if (!deleteResult) return WebResponseContent.Instance.Error("浠诲姟瀹屾垚澶辫触");
+
+                    return WebResponseContent.Instance.OK("浠诲姟瀹屾垚");
+                });
+            }
+            catch (Exception ex)
+            {
+                return WebResponseContent.Instance.Error($"瀹屾垚浠诲姟澶辫触: {ex.Message}");
+            }
+        }
+
+        /// <summary>
         /// 淇敼浠诲姟鐘舵�侊紙鏍规嵁浠诲姟ID淇敼涓烘寚瀹氱姸鎬侊級
         /// </summary>
         /// <param name="taskId"></param>
@@ -518,14 +565,16 @@
         /// <summary>
         /// 瀹屾垚浠诲姟鍚庣粺涓�澶勭悊锛堝垹闄や换鍔℃暟鎹級
         /// </summary>
-        private async Task<WebResponseContent> CompleteTaskAsync(Dt_Task task)
+        private async Task<WebResponseContent> CompleteTaskAsync(Dt_Task task, string operateType = "")
         {
             var deleteTaskResult = await BaseDal.DeleteDataAsync(task);
             if (!deleteTaskResult) return WebResponseContent.Instance.Error("浠诲姟瀹屾垚澶辫触");
 
-            // 淇濈暀鍘嗗彶瀵硅薄鏋勫缓閫昏緫锛屽悗缁彲鎺ュ叆鍘嗗彶琛ㄨ惤搴�
             var historyTask = _mapper.Map<Dt_Task_Hty>(task);
             historyTask.InsertTime = DateTime.Now;
+            historyTask.OperateType = operateType;
+            var saveResult = await _task_HtyService.Repository.AddDataAsync(historyTask) > 0;
+            if (!saveResult) return WebResponseContent.Instance.Error("浠诲姟鍘嗗彶淇濆瓨澶辫触");
 
             return WebResponseContent.Instance.OK("浠诲姟瀹屾垚");
         }

--
Gitblit v1.9.3