From 58a1b8b7db72225e0c2acca4f76399899f1bda4f Mon Sep 17 00:00:00 2001
From: wankeda <Administrator@DESKTOP-HAU3ST3>
Date: 星期五, 09 一月 2026 15:14:41 +0800
Subject: [PATCH] 1

---
 WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/NewPartialTaskService_Outbound.cs |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 55 insertions(+), 4 deletions(-)

diff --git a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/NewPartialTaskService_Outbound.cs b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/NewPartialTaskService_Outbound.cs
index 0f9506a..1542a16 100644
--- a/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/NewPartialTaskService_Outbound.cs
+++ b/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/NewPartialTaskService_Outbound.cs
@@ -20,7 +20,7 @@
                 List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
                 List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
 
-                List<Dt_NewOutboundOrderDetail> outboundOrderDetails = _outboundService.NewOutboundOrderDetailService.Repository.QueryData(x => keys.Contains(x.OrderId));
+                List<Dt_NewOutboundOrderDetail> outboundOrderDetails = _outboundService.NewOutboundOrderDetailService.Repository.QueryData(x => keys.Contains(x.Id));
                 if (outboundOrderDetails == null || outboundOrderDetails.Count == 0)
                 {
                     throw new Exception("鏈壘鍒板嚭搴撳崟鏄庣粏淇℃伅");
@@ -29,9 +29,13 @@
                 {
                     throw new Exception("鎵�閫夊嚭搴撳崟鏄庣粏瀛樺湪鍑哄簱涓垨宸插畬鎴�");
                 }
-                List<Dt_NewOutboundOrder> outboundOrders = _outboundService.NewOutboundOrderService.Repository.QueryData(x => keys.Contains(x.Id));
+                List<Dt_NewOutboundOrder> outboundOrders = _outboundService.NewOutboundOrderService.Repository.QueryData(x => x.Id == outboundOrderDetails.FirstOrDefault().OrderId);
                 List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.Repository.QueryData(x => outboundOrderDetails.Select(s => s.LPNNo).Contains(x.PalletCode));
                 if (outboundOrderDetails == null || outboundOrderDetails.Count == 0)
+                {
+                    throw new Exception("鏈壘鍒板簱瀛樹俊鎭�");
+                }
+                if (stockInfos == null || stockInfos.Count == 0)
                 {
                     throw new Exception("鏈壘鍒板簱瀛樹俊鎭�");
                 }
@@ -46,10 +50,11 @@
                     stockInfoDetail.OutboundQuantity += item.OrderQuantity;
                     item.LockQuantity += item.OrderQuantity;
                     var outboundOrder = outboundOrders.FirstOrDefault(x => x.Id == item.OrderId);
-                    Dt_OutStockLockInfo outStockLockInfo = _outboundService.OutboundStockLockInfoService.GetOutStockLockInfo(outboundOrder, item, stockInfo, item.OrderQuantity);
+                    Dt_OutStockLockInfo outStockLockInfo = _outboundService.OutboundStockLockInfoService.GetOutStockLockInfo(outboundOrder, item, stockInfo, stockInfoDetail, item.OrderQuantity);
                     outStockLockInfo.Status = OutStockStatus.鍑哄簱涓�.ObjToInt();
                     item.OrderDetailStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
                     outboundOrder.OrderStatus = OutboundStatusEnum.鍑哄簱涓�.ObjToInt();
+                    stockInfo.StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
                     var task = Newtasks.FirstOrDefault(x => x.PalletCode == item.LPNNo);
                     task.OrderNo = outboundOrder.OrderNo;
                     tasks.Add(task);
@@ -71,7 +76,53 @@
 
                 _unitOfWorkManage.CommitTran();
                 //灏嗕换鍔℃帹閫佸埌WCS
-                return PushTasksToWCS(tasks);
+                return PushTasksWCS(tasks);
+            }
+            catch (Exception ex)
+            {
+                _unitOfWorkManage.RollbackTran();
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
+        }
+
+        //鍚堟墭鍑哄簱
+        public WebResponseContent WMSGenerateSTOutboundTask(int[] keys)
+        {
+            try
+            {
+                List<Dt_Task> tasks = new List<Dt_Task>();
+                List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
+                List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
+
+                List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.Repository.QueryData(x => keys.Contains(x.Id) && x.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt());
+                if (stockInfos == null || stockInfos.Count == 0)
+                {
+                    throw new Exception("鏈壘鍒板簱瀛樹俊鎭�,鎴栧簱瀛樼姸鎬佷笉涓哄叆搴撳畬鎴�");
+                }
+                var Newtasks = GetTasks(stockInfos, TaskTypeEnum.OutSyncretism);
+                List<Dt_StockInfoDetail> stockInfoDetails = _stockService.StockInfoDetailService.Repository.QueryData(x => stockInfos.Select(x => x.Id).Contains(x.StockId));
+                foreach (var item in stockInfos)
+                {
+                    Dt_StockInfo? stockInfo = stockInfos.FirstOrDefault(x => x.PalletCode == item.PalletCode);
+                    if (stockInfo == null) continue;
+
+                    stockInfo.StockStatus = StockStatusEmun.鍑哄簱閿佸畾.ObjToInt();
+                    var task = Newtasks.FirstOrDefault(x => x.PalletCode == item.PalletCode);
+                    tasks.Add(task);
+                }
+                locationInfos.AddRange(_basicService.LocationInfoService.Repository.GetLocationInfos(stockInfos.Select(x => x.LocationCode).ToList()));
+
+                _unitOfWorkManage.BeginTran();
+
+                BaseDal.AddData(tasks);
+                _stockService.StockInfoService.Repository.UpdateData(stockInfos);
+                _stockService.StockInfoDetailService.Repository.UpdateData(stockInfoDetails);
+                _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfos, LocationStatusEnum.Lock.ObjToInt(), StockChangeType.Outbound.ObjToInt(), "", tasks?.Select(x => x.TaskNum).ToList());
+                _basicService.LocationInfoService.Repository.UpdateLocationStatus(locationInfos, LocationStatusEnum.Lock);
+
+                _unitOfWorkManage.CommitTran();
+                //灏嗕换鍔℃帹閫佸埌WCS
+                return PushTasksWCS(tasks);
             }
             catch (Exception ex)
             {

--
Gitblit v1.9.3