From b06b33248bcc19f8ea6c574124d5c536b7fa6c49 Mon Sep 17 00:00:00 2001
From: huangxiaoqiang <huangxiaoqiang@hnkhzn.com>
Date: 星期三, 16 七月 2025 19:22:27 +0800
Subject: [PATCH] 添加常温直接出库功能,增加实框入库存在任务发往异常口

---
 CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs |   42 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
index 1904e7d..503a2bd 100644
--- a/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
+++ b/CodeManagement/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
@@ -1,4 +1,5 @@
-锘縰sing Masuit.Tools;
+锘縰sing Mapster;
+using Masuit.Tools;
 using SqlSugar;
 using WIDESEA_Common.CustomModels;
 using WIDESEA_Core.Const;
@@ -581,17 +582,42 @@
 
     #region 鐩存帴鍑哄簱浠诲姟瀹屾垚
 
-    public async Task<WebResponseContent> CompleteInToOutTaskAsync(Dt_Task task)
+    public async Task<WebResponseContent> CompleteInToOutTaskAsync(Dt_Task task, DtStockInfo stock)
     {
         WebResponseContent content = new WebResponseContent();
         try
         {
-            //娣诲姞鍘嗗彶
-            var taskHty = CreateHistoricalTask(task);
-            // 娣诲姞鍘嗗彶浠诲姟
-            var isTaskHtyAdd = await _task_HtyRepository.AddDataAsync(taskHty) > 0;
-            //鍒犻櫎浠诲姟
-            BaseDal.DeleteData(task);
+            DtStockInfo_Hty stockInfo_Hty = null;
+            if (stock != null)
+            {
+                stockInfo_Hty = stock.Adapt<DtStockInfo_Hty>();
+                stockInfo_Hty.ModifyDate = DateTime.Now;
+            }
+            var taskHty = task.Adapt<Dt_Task_Hty>();
+            taskHty.FinishTime = DateTime.Now;
+            taskHty.OperateType = App.User.UserName != null ? (int)OperateTypeEnum.浜哄伐瀹屾垚 : (int)OperateTypeEnum.鑷姩瀹屾垚;
+            taskHty.Creater = App.User.UserName != null ? App.User.UserName : "System";
+
+            var location = _locationRepository.QueryFirst(x => x.LocationCode == task.SourceAddress && x.RoadwayNo == task.Roadway);
+            int lastStatus = location.LocationStatus;
+            location.LocationStatus = (int)LocationEnum.Free;
+            task.TaskState = (int)TaskOutStatusEnum.OutFinish;
+
+            _locationStatusChangeRecordRepository.AddLocationStatusChangeRecord(location, lastStatus, (int)StatusChangeTypeEnum.AutomaticDelivery, task.TaskNum);
+            // 浜嬪姟澶勭悊
+            await _unitOfWorkManage.UseTranAsync(async () =>
+            {
+                if (stockInfo_Hty != null)
+                {
+                    await DeleteStockInfoAsync(stock.Id);
+                    await DeleteStockInfoDetailsAsync(stock.StockInfoDetails);
+                    await AddStockInfoHtyAsync(stockInfo_Hty);
+                }
+
+                await UpdateLocationAsync(location);
+                await DeleteTaskAsync(task.TaskId);
+                await AddTaskHtyAsync(taskHty);
+            });
 
             return content.OK();
         }

--
Gitblit v1.9.3