From 28cdf5214cc6b7bbc6e90c4c3cd8c194adbe4fbf Mon Sep 17 00:00:00 2001
From: wankeda <Administrator@DESKTOP-HAU3ST3>
Date: 星期二, 31 三月 2026 09:19:17 +0800
Subject: [PATCH] 1

---
 WMS/WIDESEA_WMSServer/WIDESEA_RecordService/Service/StockQuantityChangeRecordService.cs |   32 ++++++++++++++++++++++++++++++++
 WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs                            |   13 +++++++++----
 WMS/WIDESEA_WMSServer/WIDESEA_IRecordService/IStockQuantityChangeRecordService.cs       |    2 ++
 3 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_IRecordService/IStockQuantityChangeRecordService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_IRecordService/IStockQuantityChangeRecordService.cs
index 1661fb6..b96cbc7 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_IRecordService/IStockQuantityChangeRecordService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_IRecordService/IStockQuantityChangeRecordService.cs
@@ -15,5 +15,7 @@
         IStockQuantityChangeRecordRepository Repository { get; }
 
         void AddStockChangeRecord(Dt_StockInfo stockInfo, List<Dt_StockInfoDetail> stockInfoDetails, decimal beforeQuantity, decimal totalQuantity, StockChangeType changeType,int? taskNum = null);
+
+        void NEWAddStockChangeRecord(Dt_StockInfo stockInfo, List<Dt_StockInfoDetail> stockInfoDetails, decimal beforeQuantity, decimal totalQuantity, StockChangeType changeType, int? taskNum = null);
     }
 }
diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_RecordService/Service/StockQuantityChangeRecordService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_RecordService/Service/StockQuantityChangeRecordService.cs
index 55648df..4892c24 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_RecordService/Service/StockQuantityChangeRecordService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_RecordService/Service/StockQuantityChangeRecordService.cs
@@ -53,5 +53,37 @@
                 throw new Exception(ex.Message);
             }
         }
+
+        public void NEWAddStockChangeRecord(Dt_StockInfo stockInfo, List<Dt_StockInfoDetail> stockInfoDetails, decimal beforeQuantity, decimal totalQuantity, StockChangeType changeType, int? taskNum = null)
+        {
+            try
+            {
+                List<Dt_StockQuantityChangeRecord> stockQuantityChangeRecords = new List<Dt_StockQuantityChangeRecord>();
+                stockQuantityChangeRecords = _mapper.Map<List<Dt_StockQuantityChangeRecord>>(stockInfoDetails);
+                int index = 0;
+                decimal currentQuantity = 0;
+                stockQuantityChangeRecords.ForEach(x =>
+                {
+                    x.PalleCode = stockInfo.PalletCode;
+                    x.BeforeQuantity = beforeQuantity;
+                    if (totalQuantity <= beforeQuantity)
+                    {
+                        x.ChangeQuantity = stockInfoDetails[index].OutboundQuantity;
+                        currentQuantity += stockInfoDetails[index].OutboundQuantity;
+                        x.AfterQuantity = beforeQuantity - stockInfoDetails[index].OutboundQuantity ;
+                    }
+                    x.ChangeType = changeType.ObjToInt();
+                    beforeQuantity -= x.ChangeQuantity;
+                    x.TaskNum = taskNum;
+                    index++;
+                });
+                BaseDal.AddData(stockQuantityChangeRecords);
+            }
+            catch (Exception ex)
+            {
+                throw new Exception(ex.Message);
+            }
+        }
+
     }
 }
diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
index 97ca58c..b9aeaa2 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -1431,7 +1431,7 @@
 
             _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(
                 stockInfo, stockInfo.Details,
-                stockInfo.Details.Sum(x => x.StockQuantity),
+                0,
                 stockInfo.Details.Sum(x => x.StockQuantity),
                 StockChangeType.Inbound, task.TaskNum);
         }
@@ -2488,6 +2488,7 @@
                 // 娣诲姞鐘舵�佸彉鏇磋褰�
                 AddStatusChangeRecord(task, stockInfo, locationInfo);
 
+               
                 // 鏍规嵁璁㈠崟绫诲瀷澶勭悊涓嶅悓閫昏緫
 
                 var outboundOrder = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrder>()
@@ -2563,7 +2564,6 @@
         private void DWANDYSUpdateOutboundOrderDetails(Dt_StockInfo stockInfo, Dt_OutboundOrder inboundOrder, ref List<Dt_OutboundOrderDetail> inboundOrderDetails)
         {
             List<Dt_OutboundOrderDetail> newOutboundOrderDetails = inboundOrderDetails;
-            int overCount = inboundOrder.Details.Count(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt());
             foreach (var newOutboundOrderDetail in newOutboundOrderDetails)
             {
                 string BatchNo = newOutboundOrderDetail.BatchNo;
@@ -2582,7 +2582,6 @@
                         if (newOutboundOrderDetail.OverOutQuantity == newOutboundOrderDetail.OrderQuantity)
                         {
                             newOutboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt();
-                            overCount++;
                         }
                         else if (newOutboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt())
                         {
@@ -2591,7 +2590,7 @@
                         }
                     }
                 }
-                if (inboundOrder.Details.Count() == overCount)
+                if (newOutboundOrderDetails.All(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()))
                 {
                     inboundOrder.OrderStatus = OutboundStatusEnum.鍑哄簱瀹屾垚.ObjToInt();
                 }
@@ -2627,6 +2626,12 @@
                 StockChangeType.Outbound.ObjToInt(),
                 stockInfo.Details.FirstOrDefault()?.OrderNo ?? "",
                 task.TaskNum);
+
+            _recordService.StockQuantityChangeRecordService.NEWAddStockChangeRecord(
+                stockInfo, stockInfo.Details,
+                stockInfo.Details.Sum(x => x.StockQuantity),
+                stockInfo.Details.Sum(x => x.OutboundQuantity),
+                StockChangeType.Outbound, task.TaskNum);
         }
 
         private void ProcessNormalOutbound(Dt_Task task, Dt_StockInfo stockInfo,

--
Gitblit v1.9.3