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

---
 Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs |   84 ++++++++++++++++++++++++++++--------------
 1 files changed, 56 insertions(+), 28 deletions(-)

diff --git a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs b/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
index f8c87c9..c0fedb2 100644
--- a/Code Management/WMS/WIDESEA_WMSServer/WIDESEA_StorageTaskServices/Task/Partial/Dt_TaskService.cs
+++ b/Code Management/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;
@@ -183,26 +184,28 @@
 
             if (!result.Success)
             {
-                var taskNG = new Dt_Task
-                {
-                    CurrentAddress = input.Position,
-                    Grade = 1,
-                    Roadway = input.Roadways,
-                    TargetAddress = stationManager.stationNGLocation,
-                    Dispatchertime = DateTime.Now,
-                    MaterialNo = "",
-                    NextAddress = stationManager.stationNGChildCode,
-                    OrderNo = null,
-                    PalletCode = input.PalletCode,
-                    SourceAddress = stationManager.stationLocation,
-                    TaskState = (int)TaskInStatusEnum.Line_InFinish,
-                    TaskType = (int)TaskOutboundTypeEnum.InToOut,
-                    TaskNum = await BaseDal.GetTaskNo(),
-                    Creater = "System",
-                    ProductionLine = result.ProductionLine,
-                    ProcessCode = result.ProcessCode,
-                };
-                return taskNG;
+                //var taskNG = new Dt_Task
+                //{
+                //    CurrentAddress = input.Position,
+                //    Grade = 1,
+                //    Roadway = input.Roadways,
+                //    TargetAddress = stationManager.stationNGLocation,
+                //    Dispatchertime = DateTime.Now,
+                //    MaterialNo = "",
+                //    NextAddress = stationManager.stationNGChildCode,
+                //    OrderNo = null,
+                //    PalletCode = input.PalletCode,
+                //    SourceAddress = stationManager.stationLocation,
+                //    TaskState = (int)TaskInStatusEnum.Line_InFinish,
+                //    TaskType = (int)TaskOutboundTypeEnum.InToOut,
+                //    TaskNum = await BaseDal.GetTaskNo(),
+                //    Creater = "System",
+                //    ProductionLine = result.ProductionLine,
+                //    ProcessCode = result.ProcessCode,
+                //};
+                //return taskNG;
+                Console.WriteLine($"{result.MOMMessage}");
+                return null;
             }
 
             if (result.SerialNos.Count <= 0)
@@ -586,17 +589,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