From fe256a7afaa132910875d3dc73783d9ab2d7ace5 Mon Sep 17 00:00:00 2001
From: liulijun <liulijun@hnkhzn.com>
Date: 星期四, 12 三月 2026 18:57:44 +0800
Subject: [PATCH] 老厂排程单页面增加用纸顺序号和是否缺料

---
 项目代码/WMS/WMSServices/WIDESEA_OutboundService/OutMESOrderService.cs |  115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 112 insertions(+), 3 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_OutboundService/OutMESOrderService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_OutboundService/OutMESOrderService.cs"
index c420a2a..3bae542 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_OutboundService/OutMESOrderService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_OutboundService/OutMESOrderService.cs"
@@ -6,6 +6,8 @@
 using System.Threading.Tasks;
 using WIDESEA_Common.LocationEnum;
 using WIDESEA_Common.MaterielEnum;
+using WIDESEA_Common.OrderEnum;
+using WIDESEA_Common.WareHouseEnum;
 using WIDESEA_Core;
 using WIDESEA_Core.BaseServices;
 using WIDESEA_Core.Helper;
@@ -107,7 +109,7 @@
         }
 
         /// <summary>
-        /// 鍑哄簱搴撳瓨鍒嗛厤鍚庯紝鏇存柊鏁版嵁搴撴暟鎹�
+        /// 鍑哄簱搴撳瓨鍒嗛厤鍚庯紝鏇存柊鏁版嵁搴撴暟鎹�(鍘熸枡)
         /// </summary>
         public WebResponseContent LockOutboundStockDataUpdate(List<Dt_StockInfo> stockInfos, List<Dt_OutMESOrder> outboundOrderDetails, List<Dt_OutStockLockInfo> outStockLockInfos, List<Dt_LocationInfo> locationInfos, LocationStatusEnum locationStatus = LocationStatusEnum.Lock, List<Dt_Task>? tasks = null)
         {
@@ -146,7 +148,46 @@
             }
         }
         /// <summary>
-        /// 鍒嗛厤搴撳瓨
+        /// 鍑哄簱搴撳瓨鍒嗛厤鍚庯紝鏇存柊鏁版嵁搴撴暟鎹�(鎴愬搧)
+        /// </summary>
+        public WebResponseContent LockOutboundStockDataUpdate(List<Dt_ProStockInfo> stockInfos, List<Dt_OutMESOrder> outboundOrderDetails, List<Dt_OutStockLockInfo> outStockLockInfos, List<Dt_LocationInfo> locationInfos, LocationStatusEnum locationStatus = LocationStatusEnum.Lock, List<Dt_Task>? tasks = null)
+        {
+            try
+            {
+                _stockService.ProStockInfoService.Repository.UpdateData(stockInfos);
+                BaseDal.UpdateData(outboundOrderDetails);
+
+                List<Dt_OutStockLockInfo> addOutStockLockInfos = outStockLockInfos.Where(x => x.Id == 0).ToList();
+                if (addOutStockLockInfos != null && addOutStockLockInfos.Any())
+                {
+                    if (tasks != null)
+                    {
+                        addOutStockLockInfos.ForEach(x =>
+                        {
+                            x.TaskNum = tasks.FirstOrDefault(v => v.PalletCode == x.PalletCode)?.TaskNum;
+                        });
+                    }
+
+                    _outStockLockInfoService.Repository.AddData(addOutStockLockInfos);
+                }
+                List<Dt_OutStockLockInfo> updateOutStockLockInfos = outStockLockInfos.Where(x => x.Id > 0).ToList();
+                if (updateOutStockLockInfos != null && updateOutStockLockInfos.Any())
+                {
+                    _outStockLockInfoService.Repository.UpdateData(updateOutStockLockInfos);
+                }
+                //娣诲姞璐т綅鐘舵��
+                _locationStatusChangeRecordService.AddLocationStatusChangeRecord(locationInfos, locationStatus, LocationChangeType.OutboundAssignLocation, "", tasks?.Select(x => x.TaskNum).ToList());
+                //鎵归噺鏇存柊璐т綅鐘舵��
+                _basicService.LocationInfoService.Repository.UpdateLocationStatus(locationInfos, locationStatus);
+                return WebResponseContent.Instance.OK();
+            }
+            catch (Exception ex)
+            {
+                return WebResponseContent.Instance.Error(ex.Message);
+            }
+        }
+        /// <summary>
+        /// 鍒嗛厤搴撳瓨(鍘熸枡)
         /// </summary>
         public (List<Dt_StockInfo>, List<Dt_OutMESOrder>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignStockOutbound(List<Dt_OutMESOrder> outboundOrders)
         {
@@ -169,7 +210,7 @@
                 List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(item.MaterialCode, item.WarehouseId).Where(x => !outStocks.Select(x => x.PalletCode).Contains(x.PalletCode)).ToList();
                 if (!stockInfos.Any())
                 {
-                    throw new Exception($"鏈壘鍒板彲鍒嗛厤搴撳瓨");
+                    continue;
                 }
                 //鍒嗛厤瀹為檯搴撳瓨
                 List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, needQuantity).OrderBy(x => x.StockLength).ToList();
@@ -206,7 +247,75 @@
                         assignStop = false;
                     }
                 }
+                //淇敼鐘舵��
+                item.OutMESOrderStatus = OutOrderStatusEnum.鍑哄簱涓�.ObjToInt();
+                locationInfos.AddRange(_basicRepository.LocationInfoRepository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList()));
+            }
 
+            return (outStocks, outboundOrders, outStockLockInfos, locationInfos);
+        }
+        /// <summary>
+        /// 鍒嗛厤搴撳瓨(鎴愬搧)
+        /// </summary>
+        public (List<Dt_ProStockInfo>, List<Dt_OutMESOrder>, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) AssignProStockOutbound(List<Dt_OutMESOrder> outboundOrders)
+        {
+            if (!outboundOrders.Any())
+            {
+                throw new Exception($"鏈壘鍒板嚭搴撳崟鏄庣粏淇℃伅");
+            }
+
+            List<Dt_ProStockInfo> outStocks = new List<Dt_ProStockInfo>();
+
+            //鍑哄簱璇︽儏
+            List<Dt_OutStockLockInfo> outStockLockInfos = new List<Dt_OutStockLockInfo>();
+            //璐т綅瀛樺偍
+            List<Dt_LocationInfo> locationInfos = new List<Dt_LocationInfo>();
+
+            foreach (var item in outboundOrders)
+            {
+                decimal needQuantity = item.ReqQuantity;
+                //鑾峰彇鍙敤搴撳瓨
+                List<Dt_ProStockInfo> stockInfos = _stockService.ProStockInfoService.GetUseableStocks(item.MaterialCode, WarehouseEnum.LLDCP.ObjToInt()).Where(x => !outStocks.Select(x => x.PalletCode).Contains(x.PalletCode)).ToList();
+                if (!stockInfos.Any())
+                {
+                    continue;
+                }
+                //鍒嗛厤瀹為檯搴撳瓨
+                List<Dt_ProStockInfo> autoAssignStocks = _stockService.ProStockInfoService.GetOutboundStocks(stockInfos, needQuantity);
+                //娣诲姞搴撳瓨鍒嗛厤
+                outStocks.AddRange(autoAssignStocks);
+                //璁㈠崟鏁伴噺
+                decimal orderQuantity = item.ReqQuantity;
+                bool assignStop = true;
+                while (assignStop)
+                {
+                    //鍑哄簱璁㈠崟鏄庣粏宸插垎閰嶆暟閲�
+                    decimal detailAssignQuantity = outStockLockInfos.Where(x => x.OrderDetailId == item.OutDetailId).Sum(x => x.AssignQuantity);
+
+                    decimal orderDetailNeedQuantity = item.ReqQuantity - detailAssignQuantity;
+
+                    decimal useStockLength = autoAssignStocks[0].proStockInfoDetails
+                        .Sum(x => x.StockQty);
+                    if (orderDetailNeedQuantity > useStockLength)
+                    {
+
+                        //鐢熸垚璇︽儏
+                        Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(item, autoAssignStocks[0], useStockLength);
+                        outStockLockInfos.Add(outStockLockInfo);
+                        item.AssignTotalUsage += useStockLength;
+                        autoAssignStocks.Remove(autoAssignStocks[0]);
+                    }
+                    else
+                    {
+                        //鐢熸垚璇︽儏
+                        Dt_OutStockLockInfo outStockLockInfo = _outStockLockInfoService.GetOutStockLockInfo(item, autoAssignStocks[0], orderDetailNeedQuantity);
+                        outStockLockInfos.Add(outStockLockInfo);
+                        item.AssignTotalUsage = orderQuantity;
+                        autoAssignStocks.Remove(autoAssignStocks[0]);
+                        assignStop = false;
+                    }
+                }
+                item.OutMESOrderStatus = OutOrderStatusEnum.鍑哄簱涓�.ObjToInt();
                 locationInfos.AddRange(_basicRepository.LocationInfoRepository.GetLocationInfos(outStocks.Select(x => x.LocationCode).ToList()));
             }
 

--
Gitblit v1.9.3