From f27080d8476a177b809045d1f036a24dac782ba5 Mon Sep 17 00:00:00 2001
From: wankeda <Administrator@DESKTOP-HAU3ST3>
Date: 星期四, 22 一月 2026 15:45:01 +0800
Subject: [PATCH] 1

---
 WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/2a767928-fd5b-4e36-8c14-d55cf9bf3c7e.vsidx |    0 
 WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/CodeChunks.db-wal            |    0 
 WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs                            |   29 ++
 WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/SemanticSymbols.db-wal       |    0 
 WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/927f8f99-0da5-491f-9629-b7444b682f34.vsidx |    0 
 WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/PalletTypeInfoService.cs                                |   34 +-
 WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs                     |  182 +++++++++++++++-
 WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs                                            |  171 +++++++++++----
 WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/00351db1-9e11-40ea-ae5a-60b802e9090b.vsidx |    0 
 WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/9af5db90-4300-4bcc-9ffe-576081c855e3.vsidx |    0 
 WMS/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundOrderDetailService.cs                           |    8 
 WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/SemanticSymbols.db-shm       |    0 
 WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Basic/PalletTypeInfoController.cs                   |    8 
 WMS/WIDESEA_WMSServer/WIDESEA_StockService/Service/StockInfoService.cs                                  |  192 +++++++++-------
 WMS/WIDESEA_WMSServer/WIDESEA_IStockService/IStockInfoService.cs                                        |   11 
 WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/CodeChunks.db-shm            |    0 
 16 files changed, 472 insertions(+), 163 deletions(-)

diff --git a/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/CodeChunks.db-shm b/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/CodeChunks.db-shm
new file mode 100644
index 0000000..d72bac3
--- /dev/null
+++ b/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/CodeChunks.db-shm
Binary files differ
diff --git a/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/CodeChunks.db-wal b/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/CodeChunks.db-wal
new file mode 100644
index 0000000..aea7539
--- /dev/null
+++ b/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/CodeChunks.db-wal
Binary files differ
diff --git a/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/SemanticSymbols.db-shm b/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/SemanticSymbols.db-shm
new file mode 100644
index 0000000..e4ea337
--- /dev/null
+++ b/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/SemanticSymbols.db-shm
Binary files differ
diff --git a/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/SemanticSymbols.db-wal b/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/SemanticSymbols.db-wal
new file mode 100644
index 0000000..1d58581
--- /dev/null
+++ b/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/CopilotIndices/17.14.995.13737/SemanticSymbols.db-wal
Binary files differ
diff --git a/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/00351db1-9e11-40ea-ae5a-60b802e9090b.vsidx b/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/00351db1-9e11-40ea-ae5a-60b802e9090b.vsidx
new file mode 100644
index 0000000..fe07517
--- /dev/null
+++ b/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/00351db1-9e11-40ea-ae5a-60b802e9090b.vsidx
Binary files differ
diff --git a/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/2a767928-fd5b-4e36-8c14-d55cf9bf3c7e.vsidx b/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/2a767928-fd5b-4e36-8c14-d55cf9bf3c7e.vsidx
new file mode 100644
index 0000000..680118c
--- /dev/null
+++ b/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/2a767928-fd5b-4e36-8c14-d55cf9bf3c7e.vsidx
Binary files differ
diff --git a/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/927f8f99-0da5-491f-9629-b7444b682f34.vsidx b/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/927f8f99-0da5-491f-9629-b7444b682f34.vsidx
new file mode 100644
index 0000000..86b0d25
--- /dev/null
+++ b/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/927f8f99-0da5-491f-9629-b7444b682f34.vsidx
Binary files differ
diff --git a/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/9af5db90-4300-4bcc-9ffe-576081c855e3.vsidx b/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/9af5db90-4300-4bcc-9ffe-576081c855e3.vsidx
new file mode 100644
index 0000000..a6260bf
--- /dev/null
+++ b/WMS/WIDESEA_WMSServer/.vs/WIDESEA_WMSServer/FileContentIndex/9af5db90-4300-4bcc-9ffe-576081c855e3.vsidx
Binary files differ
diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/PalletTypeInfoService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/PalletTypeInfoService.cs
index 52f4b6f..87000a5 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/PalletTypeInfoService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/PalletTypeInfoService.cs
@@ -33,9 +33,13 @@
                 List<string> PalletCodes = new List<string>();
                 for (int i = 0; i < num; i++)
                 {
-                    //PalletCodes.Add(GetOrderPintCode("PalletCodes"),palletCodeType);
+                    PalletCodes.Add(GetOrderPintCode($"{palletCodeType}PalletCodes",palletCodeType));
                 }
-                content= PrintPallet(PalletCodes);
+                //content= PrintPallet(PalletCodes);
+                foreach(var PalletCode in PalletCodes)
+                {
+                    Console.WriteLine(PalletCode);
+                }
                 return content.OK();
             }
             catch (Exception ex)
@@ -52,20 +56,20 @@
         public string GetOrderPintCode(string printCode,string palletCodeType)
         {
             string PrintCode = "";
-            //var PrintSetting = SqlSugarHelper.DbWMS.Queryable<Dt_PrintSetting>().Where(x => x.PrintCode == printCode).ToList().FirstOrDefault();
+            var PrintSetting = Db.Queryable<Dt_PrintSetting>().Where(x => x.PrintCode == printCode).ToList().FirstOrDefault();
 
-            //if (PrintSetting.Spare1 == DateTime.Now.ToString("yyyyMMdd"))
-            //{
-            //    PrintCode = PrintSetting.Spare1 + PrintSetting.PrintNo.ToString().PadLeft(PrintSetting.Spare2, '0');
-            //    PrintSetting.PrintNo = PrintSetting.PrintNo + 1;
-            //}
-            //else
-            //{
-            //    PrintSetting.Spare1 = DateTime.Now.ToString("yyyyMMdd");
-            //    PrintSetting.PrintNo = 2;
-            //    PrintCode = PrintSetting.Spare1 + 1.ToString().PadLeft(PrintSetting.Spare2, '0');
-            //}
-            //SqlSugarHelper.DbWMS.Updateable(PrintSetting).ExecuteCommand();
+            if (PrintSetting.Spare1 == DateTime.Now.ToString("yyyyMMdd"))
+            {
+                PrintCode = palletCodeType+PrintSetting.Spare1 + PrintSetting.PrintNo.ToString().PadLeft(PrintSetting.Spare2, '0');
+                PrintSetting.PrintNo = PrintSetting.PrintNo + 1;
+            }
+            else
+            {
+                PrintSetting.Spare1 = DateTime.Now.ToString("yyyyMMdd");
+                PrintSetting.PrintNo = 2;
+                PrintCode = palletCodeType+PrintSetting.Spare1 + 1.ToString().PadLeft(PrintSetting.Spare2, '0');
+            }
+           Db.Updateable(PrintSetting).ExecuteCommand();
             return PrintCode;
         }
 
diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundOrderDetailService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundOrderDetailService.cs
index 2dbe63d..260656f 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundOrderDetailService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_IOutboundService/IOutboundOrderDetailService.cs
@@ -28,6 +28,14 @@
         /// <param name="outboundOrderDetails"></param>
         /// <returns></returns>
         (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(List<Dt_OutboundOrderDetail> outboundOrderDetails);
+
+        /// <summary>
+        /// 浣庢俯銆佽嵂姘村嚭搴撻�昏緫
+        /// </summary>
+        /// <param name="outboundOrderDetails"></param>
+        /// <returns></returns>
+        public (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) DWANDYSAssignStockOutbound(List<Dt_OutboundOrderDetail> outboundOrderDetails);
+
         WebResponseContent LockOutboundStock(int orderDetailId, List<StockSelectViewDTO> stockSelectViews);
 
         WebResponseContent LockOutboundStock(int[] keys);
diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_IStockService/IStockInfoService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_IStockService/IStockInfoService.cs
index 3ca9c01..3c8444c 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_IStockService/IStockInfoService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_IStockService/IStockInfoService.cs
@@ -32,7 +32,16 @@
 
         List<Dt_StockInfo> GetOutboundStocks(List<Dt_StockInfo> stockInfos, string materielCode, decimal needQuantity, out decimal residueQuantity);
 
-        public List<Dt_StockInfo> DWANDYSGetOutboundStocks(List<Dt_StockInfo> stockInfos, string materielCode, string batchNo, decimal needQuantity, out decimal residueQuantity);
+        public List<Dt_StockInfo> DWANDYSGetOutboundStocks(List<Dt_StockInfo> stockInfos,List<Dt_OutboundOrderDetail> dt_OutboundOrderDetails, out List<residueQuantity> residueQuantitys);
 
+        /// <summary>
+        /// 
+        /// </summary>
+        public class residueQuantity
+        {
+            public string MaterielCode { get; set; }
+            public string BatchNo { get; set; }
+            public decimal NewNeendQuantity { get; set; }
+        }
     }
 }
diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs
index 493c5f0..55c8af9 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/Service/OutboundOrderDetailService.cs
@@ -348,7 +348,7 @@
                 }
                 else
                 {
-                   stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, warehouse);
+                    stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, warehouse);
                 }
                     
                 if (!stockInfos.Any())
@@ -357,16 +357,10 @@
                 }
                 List<Dt_StockInfo> autoAssignStocks = new List<Dt_StockInfo>();
                 decimal newResidueQuantity = 0; 
-                if (warehouse.Any(x => x.WarehouseCode.Contains("DW")) || warehouse.Any(x => x.WarehouseCode.Contains("YS")))
-                {
-                    autoAssignStocks = _stockService.StockInfoService.DWANDYSGetOutboundStocks(stockInfos, item.MaterielCode, item.BatchNo, needQuantity,out decimal residueQuantity);
-                    newResidueQuantity = residueQuantity;   
-                }
-                else
-                {
-                    autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, item.MaterielCode, needQuantity, out decimal residueQuantity);
-                    newResidueQuantity = residueQuantity;
-                }
+
+                 autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, item.MaterielCode, needQuantity, out decimal residueQuantity);
+                 newResidueQuantity = residueQuantity;
+              
                 item.LockQuantity += needQuantity - newResidueQuantity;
                 outStocks.AddRange(autoAssignStocks);
                 decimal assignQuantity = needQuantity - newResidueQuantity;
@@ -419,9 +413,173 @@
 
                 locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList()));
             }
-
             return (outStocks, outboundOrderDetails, outStockLockInfos, locationInfos);
         }
+
+        /// <summary>
+        /// 浣庢俯銆佽嵂姘村簱瀛樺垎閰�
+        /// </summary>
+        /// <param name="outboundOrderDetails"></param>
+        /// <returns></returns>
+        /// <exception cref="Exception"></exception>
+        public (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) DWANDYSAssignStockOutbound(List<Dt_OutboundOrderDetail> outboundOrderDetails)
+        {
+            if (!outboundOrderDetails.Any())
+            {
+                throw new Exception($"鏈壘鍒板嚭搴撳崟鏄庣粏淇℃伅");
+            }
+
+            if (outboundOrderDetails.GroupBy(x => x.OrderId).Count() > 1)
+            {
+                throw new Exception($"璇峰嬁鍚屾椂鎿嶄綔澶氫釜鍗曟嵁鏄庣粏");
+            }
+            Dt_OutboundOrder outboundOrder = _outboundRepository.OutboundOrderRepository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId);
+            List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>();
+            List<Dt_OutboundOrderDetail> groupDetails = outboundOrderDetails.GroupBy(x => new { x.MaterielCode, x.BatchNo, x.LocationName }).Select(x => new Dt_OutboundOrderDetail { OrderQuantity = x.Sum(v => v.OrderQuantity) - x.Sum(v => v.LockQuantity), MaterielCode = x.Key.MaterielCode, BatchNo = x.Key.BatchNo, LocationName = x.Key.LocationName }).ToList();
+            List<Dt_Warehouse> warehouse = new List<Dt_Warehouse>();
+
+            warehouse = _basicService.WarehouseService.Repository.QueryData(x => x.WarehouseDes == outboundOrder.OutWareHouse);
+
+            List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
+            List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
+            List<string> PalletCodes = new List<string>();
+            foreach(var groupDetail in groupDetails)
+            {
+                Dt_StockInfo dt_StockInfo = new Dt_StockInfo();
+                List<Dt_StockInfoDetail> dt_StockInfoDetails = _stockService.StockInfoDetailService.Repository.QueryData(x => x.MaterielCode == groupDetail.MaterielCode && x.BatchNo == groupDetail.BatchNo);
+                foreach(var stockInfoDetail in dt_StockInfoDetails)
+                {
+                    dt_StockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.Id == stockInfoDetail.StockId && x.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt());
+                    if(dt_StockInfo != null)
+                    {
+                        PalletCodes.Add(dt_StockInfo.PalletCode);
+                    }
+                }
+                
+                if(!PalletCodes.Any())
+                {
+                    throw new Exception($"鏈壘鍒板彲鍒嗛厤搴撳瓨");
+                }
+              
+            }
+            foreach(var PalletCode in PalletCodes.Distinct()) 
+            {
+                List<Dt_StockInfo> stockInfos = new List<Dt_StockInfo>();
+                if (outboundOrderDetails.All(x => x.OrderQuantity == x.LockQuantity)) break;
+                foreach (var item in groupDetails)
+                {
+                    if (item.OrderQuantity == item.LockQuantity) continue;
+                    ///鍑哄簱鎸囧畾搴撲綅鍑哄簱鍒ゆ柇
+                    if (item.LocationName != null && item.LocationName != "")
+                    {
+                        //stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, warehouse).Where(x => x.LocationCode == item.LocationName).ToList();
+                        List<Dt_StockInfo> nowStockInfos = Db.Queryable<Dt_StockInfo>()
+                            .Where(x => x.PalletCode == PalletCode && x.Details.Any(v => v.BatchNo == item.BatchNo && v.MaterielCode == item.MaterielCode) && x.LocationCode == item.LocationName)
+                            .Includes(x => x.Details).ToList();
+                        if (stockInfos.Count() == 0 && nowStockInfos.Count() > 0)
+                        {
+                            stockInfos.AddRange(nowStockInfos);
+                        }
+                    }
+                    else
+                    {
+                        //stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterielCode, item.BatchNo, warehouse);
+                        List<Dt_StockInfo> nowStockInfos = Db.Queryable<Dt_StockInfo>()
+                            .Where(x => x.PalletCode == PalletCode && x.Details.Any(v => v.BatchNo == item.BatchNo && v.MaterielCode == item.MaterielCode))
+                            .Includes(x => x.Details).ToList();
+                        if(stockInfos.Count() == 0 && nowStockInfos.Count() > 0)
+                        {
+                            stockInfos.AddRange(nowStockInfos);
+                        }
+                    }
+ 
+                }
+                if(stockInfos.Count() == 0)
+                {
+                    continue;
+                }
+                List<Dt_StockInfo> autoAssignStocks = new List<Dt_StockInfo>();
+                List<IStockInfoService.residueQuantity> newResidueQuantitys = new List<IStockInfoService.residueQuantity>();
+                if (warehouse.Any(x => x.WarehouseCode.Contains("DW")) || warehouse.Any(x => x.WarehouseCode.Contains("YS")))
+                {
+                    autoAssignStocks = _stockService.StockInfoService.DWANDYSGetOutboundStocks(stockInfos,groupDetails, out List<IStockInfoService.residueQuantity> residueQuantitys);
+                    newResidueQuantitys.AddRange(residueQuantitys);
+                    outStocks.AddRange(autoAssignStocks);
+                }
+                foreach(var residueQuantity in newResidueQuantitys)
+                {
+                    foreach (var item in groupDetails)
+                    {
+                        if(residueQuantity.MaterielCode == item.MaterielCode && residueQuantity.BatchNo == item.BatchNo)
+                        {
+                            decimal originalNeedQuantity = item.OrderQuantity;
+
+                            decimal needQuantity = originalNeedQuantity - item.LockQuantity;
+
+                            item.LockQuantity += needQuantity - residueQuantity.NewNeendQuantity;
+
+                            decimal assignQuantity = needQuantity -  residueQuantity.NewNeendQuantity;
+
+                            List<Dt_OutboundOrderDetail> details = outboundOrderDetails.Where(x => !string.IsNullOrEmpty(x.BatchNo) ? x.BatchNo == item.BatchNo : true && x.MaterielCode == item.MaterielCode).ToList();
+
+                            for (int i = 0; i < details.Count; i++)
+                            {
+                                decimal orderQuantity = details[i].OrderQuantity;
+                                for (int j = 0; j < autoAssignStocks.Count; j++)
+                                {
+                                    decimal detailAssignQuantity = outStockLockInfos.Where(x => !string.IsNullOrEmpty(x.BatchNo) ? x.BatchNo == item.BatchNo : true && x.MaterielCode == item.MaterielCode && x.OrderDetailId == details[i].Id).Sum(x => x.AssignQuantity);//鍑哄簱璁㈠崟鏄庣粏宸插垎閰嶆暟閲�
+
+                                    decimal palletAssignQuantity = outStockLockInfos.Where(x => x.BatchNo == item.BatchNo && x.MaterielCode == item.MaterielCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//鍑哄簱璇︽儏宸插垎閰嶆暟閲�
+                                    if (string.IsNullOrEmpty(item.BatchNo))
+                                    {
+                                        palletAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == item.MaterielCode && x.PalletCode == autoAssignStocks[j].PalletCode).Sum(x => x.AssignQuantity);//鍑哄簱璇︽儏宸插垎閰嶆暟閲�
+                                    }
+                                    decimal palletOutboundQuantity = 0;
+                                    if (warehouse.Any(x => x.WarehouseCode.Contains("DW")) || warehouse.Any(x => x.WarehouseCode.Contains("YS")))
+                                    {
+                                        palletOutboundQuantity = autoAssignStocks[j].Details.Where(x => x.BatchNo == item.BatchNo && x.MaterielCode == item.MaterielCode).Sum(x => x.OutboundQuantity);
+
+                                    }
+                                    if (palletAssignQuantity < palletOutboundQuantity)//濡傛灉鍑哄簱璇︽儏宸插垎閰嶆暟閲忓皬浜庢墭鐩樺凡鍒嗛厤鏁伴噺锛屽垯鍙互缁х画娣诲姞璇ユ墭鐩樺嚭搴撲俊鎭�
+                                    {
+                                        decimal orderDetailNeedQuantity = details[i].OrderQuantity - detailAssignQuantity;
+                                        if (orderDetailNeedQuantity > autoAssignStocks[j].Details.Where(x => x.MaterielCode == details[i].MaterielCode && x.BatchNo == details[i].BatchNo).Sum(v => v.OutboundQuantity) - palletAssignQuantity)
+                                        {
+                                            //details[i].LockQuantity += autoAssignStocks[j].Details.Sum(x => x.OutboundQuantity) - palletAssignQuantity;
+                                            Dt_StockInfoDetail dt_StockInfoDetail = new Dt_StockInfoDetail();
+                                            foreach(var autoStockDestail in autoAssignStocks[j].Details)
+                                            {
+                                                if(autoStockDestail.MaterielCode == details[i].MaterielCode && autoStockDestail.BatchNo == details[i].BatchNo)
+                                                {
+                                                    dt_StockInfoDetail = autoStockDestail;
+                                                }
+                                            }
+                                            Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(outboundOrder, details[i], autoAssignStocks[j],dt_StockInfoDetail.OutboundQuantity);
+                                            outStockLockInfos.Add(outStockLockInfo);
+                                            details[i].LockQuantity += outStockLockInfo.AssignQuantity;
+                                            break;
+                                        }
+                                        else
+                                        {
+                                            Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(outboundOrder, details[i], autoAssignStocks[j], details[i].OrderQuantity - details[i].LockQuantity);
+                                            outStockLockInfos.Add(outStockLockInfo);
+                                            details[i].LockQuantity = details[i].OrderQuantity;
+                                            break;
+                                        }
+
+                                    }
+                                }
+                            }
+                            locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(autoAssignStocks.Select(x => x.LocationCode).ToList()));
+                        }
+                     }
+
+                }
+                newResidueQuantitys = new List<IStockInfoService.residueQuantity>();
+            }
+            return (outStocks, outboundOrderDetails, outStockLockInfos, locationInfos);
+        }
+
         private (bool, string) CheckSelectStockDeital(Dt_OutboundOrderDetail outboundOrderDetail, List<StockSelectViewDTO> stockSelectViews)
         {
             if (outboundOrderDetail == null)
diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_StockService/Service/StockInfoService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_StockService/Service/StockInfoService.cs
index 8f4388d..b617a84 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_StockService/Service/StockInfoService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_StockService/Service/StockInfoService.cs
@@ -21,6 +21,7 @@
 using WIDESEA_IStockRepository;
 using WIDESEA_IStockService;
 using WIDESEA_Model.Models;
+using static WIDESEA_IStockService.IStockInfoService;
 
 namespace WIDESEA_StockService
 {
@@ -194,109 +195,132 @@
         }
 
         //浣庢俯銆佽嵂姘村垎閰嶅簱瀛�
-        public List<Dt_StockInfo> DWANDYSGetOutboundStocks(List<Dt_StockInfo> stockInfos, string materielCode,string batchNo ,decimal needQuantity, out decimal residueQuantity)
+        public List<Dt_StockInfo> DWANDYSGetOutboundStocks(List<Dt_StockInfo> stockInfos,List<Dt_OutboundOrderDetail> dt_OutboundOrderDetails, out List<IStockInfoService.residueQuantity> residueQuantitys)
         {
             List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>();
-            decimal stockTotalQuantity = stockInfos.SelectMany(x => x.Details).Where(d => d.BatchNo == batchNo).Sum(v => v.StockQuantity - v.OutboundQuantity);
-            stockInfos = stockInfos.Where(x => x.Details.Any(x => x.BatchNo == batchNo)).OrderBy(x => x.Id).ToList();
-            if (stockTotalQuantity >= needQuantity)//搴撳瓨澶�
+            List<IStockInfoService.residueQuantity> newresidueQantity = new List<IStockInfoService.residueQuantity>();
+            List<Dt_StockInfo> notStocks = new List<Dt_StockInfo>(); ;
+            foreach(var dt_OutboundOrderDetail in dt_OutboundOrderDetails)
             {
-                int index = 0;
-                while (needQuantity > 0)
+                notStocks = stockInfos.Where(x => x.Details.Any(x => x.BatchNo == dt_OutboundOrderDetail.BatchNo && x.MaterielCode == dt_OutboundOrderDetail.MaterielCode)).OrderBy(x => x.Id).ToList();
+                if(notStocks.Count > 0)
                 {
+                    decimal stockTotalQuantity = stockInfos.SelectMany(x => x.Details).Where(d => d.BatchNo == dt_OutboundOrderDetail.BatchNo).Sum(v => v.StockQuantity - v.OutboundQuantity);
+                    decimal needQuantity = dt_OutboundOrderDetail.OrderQuantity - dt_OutboundOrderDetail.LockQuantity;
+                    if (stockTotalQuantity >= needQuantity)//搴撳瓨澶�
+                    {
+                        int index = 0;
+                        while (needQuantity > 0)
+                        {
 
-                    Dt_StockInfo stockInfo = stockInfos[index];
-                    Dt_StockInfoDetail dt_StockInfoDetail = new Dt_StockInfoDetail();
-                    foreach(var detail in stockInfo.Details)
-                    {
-                        if(detail.BatchNo == batchNo && detail.MaterielCode == materielCode)
-                        {
-                            dt_StockInfoDetail = detail;
-                        }
-                    }
-                    decimal useableStockQuantity = dt_StockInfoDetail.StockQuantity - dt_StockInfoDetail.OutboundQuantity;
-                    if (useableStockQuantity < needQuantity)
-                    {
-                        stockInfo.Details.ForEach(x =>
-                        {
-                            if(x.MaterielCode == materielCode && x.BatchNo == batchNo)
+                            Dt_StockInfo stockInfo = stockInfos[index];
+                            Dt_StockInfoDetail dt_StockInfoDetail = new Dt_StockInfoDetail();
+                            foreach (var detail in stockInfo.Details)
                             {
-                                x.OutboundQuantity = x.StockQuantity;
+                                if (detail.BatchNo == dt_OutboundOrderDetail.BatchNo && detail.MaterielCode == dt_OutboundOrderDetail.MaterielCode)
+                                {
+                                    dt_StockInfoDetail = detail;
+                                }
                             }
-                        });
-                        needQuantity -= useableStockQuantity;
+                            decimal useableStockQuantity = dt_StockInfoDetail.StockQuantity - dt_StockInfoDetail.OutboundQuantity;
+                            if (useableStockQuantity < needQuantity)
+                            {
+                                stockInfo.Details.ForEach(x =>
+                                {
+                                    if (x.MaterielCode == dt_OutboundOrderDetail.MaterielCode && x.BatchNo == dt_OutboundOrderDetail.BatchNo)
+                                    {
+                                        x.OutboundQuantity = x.StockQuantity;
+                                    }
+                                });
+                                needQuantity -= useableStockQuantity;
+                            }
+                            else
+                            {
+
+                                stockInfo.Details.ForEach(x =>
+                                {
+                                    if (x.StockQuantity > x.OutboundQuantity && x.MaterielCode == dt_OutboundOrderDetail.MaterielCode && x.BatchNo == dt_OutboundOrderDetail.BatchNo)
+                                    {
+                                        if (x.StockQuantity - x.OutboundQuantity >= needQuantity)
+                                        {
+                                            x.OutboundQuantity += needQuantity;
+                                            needQuantity = 0;
+                                        }
+                                        else
+                                        {
+                                            needQuantity -= (x.StockQuantity - x.OutboundQuantity);
+                                            x.OutboundQuantity = x.StockQuantity;
+                                        }
+                                    }
+                                });
+                            }
+                            outStocks.Add(stockInfo);
+                            index++;
+                        }
                     }
                     else
                     {
-
-                        stockInfo.Details.ForEach(x =>
+                        for (int i = 0; i < stockInfos.Count; i++)
                         {
-                            if (x.StockQuantity > x.OutboundQuantity && x.MaterielCode == materielCode && x.BatchNo == batchNo)
+                            Dt_StockInfo stockInfo = stockInfos[i];
+                            decimal useableStockQuantity = 0;
+                            foreach (var detail in stockInfo.Details)
                             {
-                                if (x.StockQuantity - x.OutboundQuantity >= needQuantity)
+                                if (detail.MaterielCode == dt_OutboundOrderDetail.MaterielCode && detail.BatchNo == dt_OutboundOrderDetail.BatchNo)
                                 {
-                                    x.OutboundQuantity += needQuantity;
-                                    needQuantity = 0;
-                                }
-                                else
-                                {
-                                    needQuantity -= (x.StockQuantity - x.OutboundQuantity);
-                                    x.OutboundQuantity = x.StockQuantity;
+                                    useableStockQuantity = detail.StockQuantity - detail.OutboundQuantity;
                                 }
                             }
-                        });
-                    }
-                    outStocks.Add(stockInfo);
-                    index++;
-                }
-            }
-            else
-            {
-                for (int i = 0; i < stockInfos.Count; i++)
-                {
-                    Dt_StockInfo stockInfo = stockInfos[i];
-                    decimal useableStockQuantity = 0;
-                    foreach (var detail in stockInfo.Details)
-                    {
-                        if(detail.MaterielCode == materielCode && detail.BatchNo == batchNo)
-                        {
-                            useableStockQuantity = detail.StockQuantity - detail.OutboundQuantity;
+
+                            if (useableStockQuantity < needQuantity)
+                            {
+                                stockInfo.Details.ForEach(x => {
+                                    if (x.MaterielCode == dt_OutboundOrderDetail.MaterielCode && x.BatchNo == dt_OutboundOrderDetail.BatchNo)
+                                    {
+                                        x.OutboundQuantity = x.StockQuantity;
+                                    }
+                                });
+                                needQuantity -= useableStockQuantity;
+                            }
+                            else
+                            {
+                                stockInfo.Details.ForEach(x =>
+                                {
+                                    if (x.StockQuantity > x.OutboundQuantity && x.MaterielCode == dt_OutboundOrderDetail.MaterielCode && x.BatchNo == dt_OutboundOrderDetail.BatchNo)
+                                    {
+                                        if (x.StockQuantity - x.OutboundQuantity >= needQuantity)
+                                        {
+                                            x.OutboundQuantity += needQuantity;
+                                            needQuantity = 0;
+                                        }
+                                        else
+                                        {
+                                            needQuantity -= (x.StockQuantity - x.OutboundQuantity);
+                                            x.OutboundQuantity = x.StockQuantity;
+                                        }
+                                    }
+                                });
+                            }
+                            outStocks.Add(stockInfo);
                         }
                     }
-                    
-                    if (useableStockQuantity < needQuantity)
-                    {
-                        stockInfo.Details.ForEach(x => { 
-                            if(x.MaterielCode == materielCode && x.BatchNo == batchNo)
-                            {
-                                x.OutboundQuantity = x.StockQuantity;
-                            }
-                        });
-                        needQuantity -= useableStockQuantity;
-                    }
-                    else
-                    {
-                        stockInfo.Details.ForEach(x =>
-                        {
-                            if (x.StockQuantity > x.OutboundQuantity && x.MaterielCode == materielCode && x.BatchNo == batchNo)
-                            {
-                                if (x.StockQuantity - x.OutboundQuantity >= needQuantity)
-                                {
-                                    x.OutboundQuantity += needQuantity;
-                                    needQuantity = 0;
-                                }
-                                else
-                                {
-                                    needQuantity -= (x.StockQuantity - x.OutboundQuantity);
-                                    x.OutboundQuantity = x.StockQuantity;
-                                }
-                            }
-                        });
-                    }
-                    outStocks.Add(stockInfo);
+                    IStockInfoService.residueQuantity newResidueQuantity = new IStockInfoService.residueQuantity();
+                    newResidueQuantity.MaterielCode = dt_OutboundOrderDetail.MaterielCode;
+                    newResidueQuantity.BatchNo = dt_OutboundOrderDetail.BatchNo;
+                    newResidueQuantity.NewNeendQuantity = needQuantity;
+                    newresidueQantity.Add(newResidueQuantity);
                 }
+                else
+                {
+                    continue;
+                }
+                           
             }
-            residueQuantity = needQuantity;
+            residueQuantitys = newresidueQantity;
+            if(outStocks.Count() > 1)
+            {
+                outStocks.RemoveRange(0, outStocks.Count - 1);
+            }
             return outStocks;
         }
         //瀵煎嚭
diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs
index 99424e0..ea0c35f 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs
@@ -152,7 +152,16 @@
             List<Dt_LocationInfo>? locationInfos = null;
             //if (outboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt())
             {
-                (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.OutboundOrderDetailService.AssignStockOutbound(outboundOrderDetails);
+                Dt_OutboundOrder dt_OutboundOrder = _outboundService.OutboundOrderService.Repository.QueryData(x => x.Id == outboundOrderDetails.First().OrderId).First();
+                (List<Dt_StockInfo>, List<Dt_OutboundOrderDetail>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = new();
+                if (dt_OutboundOrder.OutWareHouse.Contains("DW") || dt_OutboundOrder.OutWareHouse.Contains("YS"))
+                {
+                   result = _outboundService.OutboundOrderDetailService.DWANDYSAssignStockOutbound(outboundOrderDetails);
+                }
+                else
+                {
+                   result = _outboundService.OutboundOrderDetailService.AssignStockOutbound(outboundOrderDetails);
+                }
                 if (result.Item1 != null && result.Item1.Count > 0)
                 {
                     Dt_OutboundOrder outboundOrder = _outboundService.OutboundOrderService.Repository.QueryFirst(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId);
@@ -917,7 +926,7 @@
                 foreach (int key in keys)
                 {
 
-                    (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(keys);
+                   (List<Dt_Task>, List<Dt_StockInfo>?, List<Dt_OutboundOrderDetail>?, List<Dt_OutStockLockInfo>?, List<Dt_LocationInfo>?) result = OutboundTaskDataHandle(keys);
                     if (result.Item2 != null && result.Item2.Count > 0)
                     {
                         stockInfos.AddRange(result.Item2);
@@ -928,17 +937,27 @@
                     }
                     if (result.Item4 != null && result.Item4.Count > 0)
                     {
-                        outStockLockInfos.AddRange(result.Item4);
+                        outStockLockInfos.AddRange(result.Item4); 
                     }
                     if (result.Item5 != null && result.Item5.Count > 0)
                     {
-                        locationInfos.AddRange(result.Item5);
+                        if (locationInfos.First().RoadwayNo.Contains("DW") || locationInfos.First().RoadwayNo.Contains("YS"))
+                        {
+                            locationInfos.AddRange(result.Item5.Distinct());
+                        }
+                        else
+                        {
+                            locationInfos.AddRange(result.Item5);
+                        }
                     }
                     if (result.Item1 != null && result.Item1.Count > 0)
                     {
                         tasks.AddRange(result.Item1);
                     }
-
+                    if(locationInfos.First().RoadwayNo.Contains("DW") || locationInfos.First().RoadwayNo.Contains("YS"))
+                    {
+                        break;
+                    }
 
                 }
 
diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
index ed2bd99..4a091c0 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs
@@ -1004,7 +1004,7 @@
                                 }
                                 if (inboundOrder.OrderStatus == InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt() && inboundOrder.OrderType == 0 && inboundOrder.System.Equals("SMOM"))
                                 {
-
+                                    //SendInboundInfoToWMS(task, inboundOrder, stockInfo);
                                 }
                                 else if (inboundOrder.OrderStatus == InboundStatusEnum.鍏ュ簱瀹屾垚.ObjToInt() && inboundOrder.OrderType == 2 && inboundOrder.System.Equals("SMOM"))
                                 {
@@ -1949,31 +1949,32 @@
 
                         if (inboundOrder == null) return WebResponseContent.Instance.Error("鏈壘鍒板嚭搴撳崟淇℃伅");
 
-                        Dt_OutboundOrderDetail outboundOrderDetail = new Dt_OutboundOrderDetail();
-                        foreach (var detail in stockInfo.Details)
+                        List<Dt_OutboundOrderDetail> outboundOrderDetails = new List<Dt_OutboundOrderDetail>();
+                        foreach(var detail in stockInfo.Details)
                         {
-                            outboundOrderDetail = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrderDetail>()
-                            .Where(x => x.OrderId == inboundOrder.Id && x.BatchNo == detail.BatchNo)
-                            .First();
-                            if (outboundOrderDetail != null) break;
-
+                            Dt_OutboundOrderDetail outboundOrderDetail = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrderDetail>()
+                           .Where(x => x.OrderId == inboundOrder.Id && x.BatchNo == detail.BatchNo).First();
+                            outboundOrderDetails.Add(outboundOrderDetail);
                         }
 
-                        if (outboundOrderDetail.LocationName != null && outboundOrderDetail.LocationName != "")
+                        for(var i = 0; i<outboundOrderDetails.Count; i++)
                         {
-                            foreach (var detail in stockInfo.Details)
+                            if (outboundOrderDetails[i].LocationName != null && outboundOrderDetails[i].LocationName != "")
                             {
-                                outboundOrderDetail = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrderDetail>()
-                                .Where(x => x.OrderId == inboundOrder.Id && x.BatchNo == detail.BatchNo && x.LocationName == stockInfo.LocationCode)
-                                .First();
-                                if (outboundOrderDetail != null) break;
+                                foreach (var detail in stockInfo.Details)
+                                {
+                                    Dt_OutboundOrderDetail newOutboundOrderDetail = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrderDetail>()
+                                   .Where(x => x.OrderId == inboundOrder.Id && x.BatchNo == detail.BatchNo && x.LocationName == stockInfo.LocationCode)
+                                   .First();
+                                    outboundOrderDetails[i] = newOutboundOrderDetail;
+                                }
                             }
                         }
 
-                        if (outboundOrderDetail == null) return WebResponseContent.Instance.Error("鏈壘鍒板嚭搴撳崟淇℃伅");
-                        DWANDYSUpdateOutboundOrderDetails(stockInfo, inboundOrder, ref outboundOrderDetail);
+                        if (outboundOrderDetails == null) return WebResponseContent.Instance.Error("鏈壘鍒板嚭搴撳崟淇℃伅");
+                        DWANDYSUpdateOutboundOrderDetails(stockInfo, inboundOrder, ref outboundOrderDetails);
                         // 3. 鎵ц鏍稿績鍑哄簱閫昏緫
-                        return ExecuteOutboundLogic(task, stockInfo, locationInfo, outboundOrderDetail, inboundOrder);
+                        return DWANDYSExecuteOutboundLogic(task, stockInfo, locationInfo, outboundOrderDetails, inboundOrder);
                     }
                     else
                     {
@@ -2068,15 +2069,10 @@
                 _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails);
 
                 // 鏇存柊搴撳瓨鐘舵�� 鍥炲簱鍗�
-                if (locationInfo.RoadwayNo.Contains("DW") || locationInfo.RoadwayNo.Contains("YS"))
-                {
-                    AddDWANDYSRetrueOrder(stockInfo, inboundOrder);
-                }
-                else
-                {
-                    AddRetrueOrder(stockInfo, inboundOrder);
-                }
 
+                 AddRetrueOrder(stockInfo, inboundOrder);
+     
+                   
                 // 鍖哄垎鍗曟嵁鏁版嵁鏉ユ簮鏇存柊璐т綅鐘舵��
                 if (inboundOrder.System == null)
                 {
@@ -2134,6 +2130,82 @@
                 throw;
             }
         }
+
+        private WebResponseContent DWANDYSExecuteOutboundLogic(Dt_Task task, Dt_StockInfo stockInfo,
+          Dt_LocationInfo locationInfo, List<Dt_OutboundOrderDetail> outboundOrderDetails, Dt_OutboundOrder inboundOrder)
+        {
+            try
+            {
+                _unitOfWorkManage.BeginTran();
+                ///鏇存柊鍑哄簱鍗�
+                _outboundService.OutboundOrderService.Repository.UpdateData(inboundOrder);
+                // 鏇存柊鍑哄簱璁㈠崟璇︽儏
+                _outboundService.OutboundOrderDetailService.Repository.UpdateData(outboundOrderDetails);
+
+                // 鏇存柊搴撳瓨鐘舵�� 鍥炲簱鍗�
+                if (locationInfo.RoadwayNo.Contains("DW") || locationInfo.RoadwayNo.Contains("YS"))
+                {
+                    AddDWANDYSRetrueOrder(stockInfo, inboundOrder);
+                }
+
+                // 鍖哄垎鍗曟嵁鏁版嵁鏉ユ簮鏇存柊璐т綅鐘舵��
+                if (inboundOrder.System == null)
+                {
+                    return WebResponseContent.Instance.Error("鍑哄簱鍗曟暟鎹簮涓虹┖");
+                }
+                if (!inboundOrder.System.Equals("SMOM"))
+                {
+                    UpdateLocationStatus(locationInfo);
+                }
+                // 澶勭悊浠诲姟瀹屾垚
+                CompleteTask(task);
+
+                // 娣诲姞鐘舵�佸彉鏇磋褰�
+                AddStatusChangeRecord(task, stockInfo, locationInfo);
+
+                // 鏍规嵁璁㈠崟绫诲瀷澶勭悊涓嶅悓閫昏緫
+
+                var outboundOrder = _outboundService.OutboundOrderService.Db.Queryable<Dt_OutboundOrder>()
+                    .Where(x => x.OrderNo == inboundOrder.OrderNo).First();
+                foreach(var outboundOrderDetail in outboundOrderDetails)
+                {
+                    var outDetail = _outboundService.OutboundOrderDetailService.Db.Queryable<Dt_OutboundOrderDetail>()
+                   .Where(x => x.OrderId == outboundOrder.Id && x.BatchNo == outboundOrderDetail.BatchNo).First();
+                    string path = "http://fr.mankun.com:8080/webroot/decision/view/report?viewlet=fr-report\\SMOM/Product/Produce/OutBoundDetileReport.cpt&op=write&format=pdf";
+                    string fullPath = AppDomain.CurrentDomain.BaseDirectory;
+                    var url = Path.Combine(fullPath, "wwwroot", "Reports");
+                    string savePath = Path.Combine(url, "鏈鍑哄簱.pdf");
+
+
+                    if (outboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt() && inboundOrder.System.Equals("ERP"))
+                    {
+                        FeedBackOutERP(outboundOrder.OrderNo, outboundOrderDetail.LinId);
+                        DownloadReport(path, savePath, outboundOrderDetail.Id);
+                    }
+                    ///鍗曟嵁瀹屾垚鎺ㄩ�丼MOM绯荤粺
+                    if (outboundOrder.OrderStatus == OutboundStatusEnum.鍑哄簱瀹屾垚.ObjToInt() && inboundOrder.System.Equals("SMOM"))
+                    {
+                        var stockInfoDetail = stockInfo.Details.FirstOrDefault();
+                        ProcessNormalOutbound(task, stockInfo, outboundOrder, outDetail);
+                        //DownloadReport(path, savePath, outboundOrderDetails.Id);
+                        //printTest(savePath);
+                        //SendNormalOutboundToWMS(task, outboundOrder, stockInfoDetail, outDetail);
+                    }
+
+                    if (outboundOrder.OrderType == 240) // 鐩樼偣鍑哄簱
+                    {
+                        // 鐩樼偣鍑哄簱鐗规畩澶勭悊閫昏緫
+                    }
+                }
+                _unitOfWorkManage.CommitTran();
+                return WebResponseContent.Instance.OK();
+            }
+            catch
+            {
+                _unitOfWorkManage.RollbackTran();
+                throw;
+            }
+        }
         private void UpdateOutboundOrderDetails(Dt_StockInfo stockInfo, Dt_OutboundOrder inboundOrder, ref Dt_OutboundOrderDetail inboundOrderDetail)
         {
             int overCount = inboundOrder.Details.Count(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt());
@@ -2163,36 +2235,43 @@
         }
 
         //浣庢俯銆佽嵂姘�
-        private void DWANDYSUpdateOutboundOrderDetails(Dt_StockInfo stockInfo, Dt_OutboundOrder inboundOrder, ref Dt_OutboundOrderDetail inboundOrderDetail)
+        private void DWANDYSUpdateOutboundOrderDetails(Dt_StockInfo stockInfo, Dt_OutboundOrder inboundOrder, ref List<Dt_OutboundOrderDetail> inboundOrderDetails)
         {
-            string BatchNo = inboundOrderDetail.BatchNo;
-            int overCount = inboundOrder.Details.Where(x => x.BatchNo == BatchNo).Count(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt());
-            //inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BatchNo == stockInfo.Details.FirstOrDefault()?.BatchNo&&x.LPNNo==stockInfo.PalletCode);
-
-            foreach (var item in stockInfo.Details)
+            List<Dt_OutboundOrderDetail> newOutboundOrderDetails = inboundOrderDetails;
+            int overCount = inboundOrder.Details.Count(x => x.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt());
+            foreach (var newOutboundOrderDetail in newOutboundOrderDetails)
             {
-                if (inboundOrderDetail == null) continue;
+                string BatchNo = newOutboundOrderDetail.BatchNo;
+                //inboundOrderDetail = inboundOrder.Details.FirstOrDefault(x => x.BatchNo == stockInfo.Details.FirstOrDefault()?.BatchNo&&x.LPNNo==stockInfo.PalletCode);
 
-                if (inboundOrderDetail.BatchNo == item.BatchNo)
+                foreach (var item in stockInfo.Details)
                 {
-                    inboundOrderDetail.OverOutQuantity += item.OutboundQuantity;
+                    if (newOutboundOrderDetail == null) continue;
 
-                    if (inboundOrderDetail.OverOutQuantity == inboundOrderDetail.OrderQuantity)
+                    if (newOutboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.Over.ObjToInt()) continue;
+
+                    if (newOutboundOrderDetail.BatchNo == item.BatchNo)
                     {
-                        inboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt();
-                        overCount++;
-                    }
-                    else if (inboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt())
-                    {
-                        inboundOrderDetail.OrderDetailStatus = OutboundStatusEnum.鍑哄簱涓�.ObjToInt();
-                        inboundOrder.OrderStatus = OutboundStatusEnum.鍑哄簱涓�.ObjToInt();
+                        newOutboundOrderDetail.OverOutQuantity += item.OutboundQuantity;
+
+                        if (newOutboundOrderDetail.OverOutQuantity == newOutboundOrderDetail.OrderQuantity)
+                        {
+                            newOutboundOrderDetail.OrderDetailStatus = OrderDetailStatusEnum.Over.ObjToInt();
+                            overCount++;
+                        }
+                        else if (newOutboundOrderDetail.OrderDetailStatus == OrderDetailStatusEnum.New.ObjToInt())
+                        {
+                            newOutboundOrderDetail.OrderDetailStatus = OutboundStatusEnum.鍑哄簱涓�.ObjToInt();
+                            inboundOrder.OrderStatus = OutboundStatusEnum.鍑哄簱涓�.ObjToInt();
+                        }
                     }
                 }
+                if (inboundOrder.Details.Count() == overCount)
+                {
+                    inboundOrder.OrderStatus = OutboundStatusEnum.鍑哄簱瀹屾垚.ObjToInt();
+                }
             }
-            if (inboundOrder.Details.Count == overCount)
-            {
-                inboundOrder.OrderStatus = OutboundStatusEnum.鍑哄簱瀹屾垚.ObjToInt();
-            }
+  
         }
 
         private void DeleteAndMoveIntoHtStockStatus(Dt_StockInfo stockInfo)
diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Basic/PalletTypeInfoController.cs b/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Basic/PalletTypeInfoController.cs
index 1d80f6f..cd93383 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Basic/PalletTypeInfoController.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Basic/PalletTypeInfoController.cs
@@ -1,5 +1,6 @@
 锘縰sing Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
+using WIDESEA_Core;
 using WIDESEA_Core.BaseController;
 using WIDESEA_IBasicService;
 using WIDESEA_Model.Models;
@@ -13,5 +14,12 @@
         public PalletTypeInfoController(IPalletTypeInfoService service) : base(service)
         {
         }
+
+        [HttpGet,HttpPost, Route("PrintPalletCode"), AllowAnonymous]
+        public WebResponseContent PrintPalletCode(int num, string palletCodeType)
+        {
+            return Service.PrintPalletCode(num, palletCodeType);
+        }
+
     }
 }

--
Gitblit v1.9.3