From ffb5bb3a68ae74ed3a1765baf946336cead3bb0d Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期一, 23 六月 2025 09:00:37 +0800
Subject: [PATCH] 货位同侧移库,干膜货位大小托分配优化,WCS任务接收优化等

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs                        |    3 
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/LocationInfoService_Common.cs             |    4 +
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_ZH.cs  |   34 +++++++++-
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_CSJ.cs |    9 +-
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_GM.cs  |   28 +++++----
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesTaskService.cs                              |    2 
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Common/LocationEnum/LocationStatusEnum.cs                      |    2 
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/MesOutboundOrderService.cs                     |   10 +-
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs                               |   31 ----------
 9 files changed, 63 insertions(+), 60 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_CSJ.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_CSJ.cs"
index 700950d..4fa7a1d 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_CSJ.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_CSJ.cs"
@@ -72,14 +72,13 @@
                         throw new Exception($"鏈壘鍒拌揣浣嶄俊鎭�");
                     }
                     int maxDepth = locationInfos.Max(x => x.Depth);
-                    int mathCurrentRow = beRelocation.Row - Convert.ToInt32(Math.Ceiling(beRelocation.Row / maxDepth / 2.0)) * maxDepth * 2;
-                    if (mathCurrentRow <= maxDepth)
+                    if (beRelocation.Row <= maxDepth)
                     {
-                        locationInfos = locationInfos.Where(x => x.Row - Convert.ToInt32(Math.Ceiling(x.Row / maxDepth / 2.0)) * maxDepth * 2 <= maxDepth).ToList();
+                        locationInfos = locationInfos.Where(x => x.Row <= maxDepth).ToList();
                     }
-                    else
+                    else if (beRelocation.Row > maxDepth)
                     {
-                        locationInfos = locationInfos.Where(x => x.Row - Convert.ToInt32(Math.Ceiling(x.Row / maxDepth / 2.0)) * maxDepth * 2 > maxDepth).ToList();
+                        locationInfos = locationInfos.Where(x => x.Row > maxDepth).ToList();
                     }
                 }
 
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_GM.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_GM.cs"
index 7a17157..2fc79e7 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_GM.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_GM.cs"
@@ -58,22 +58,24 @@
                         throw new Exception($"鏈壘鍒拌揣浣嶄俊鎭�");
                     }
                     int maxDepth = locationInfos.Max(x => x.Depth);
-                    int mathCurrentRow = beRelocation.Row - Convert.ToInt32(Math.Ceiling(beRelocation.Row / maxDepth / 2.0)) * maxDepth * 2;
-                    if (mathCurrentRow <= maxDepth)
+                    //int mathCurrentRow = beRelocation.Row - Convert.ToInt32(Math.Ceiling(beRelocation.Row / maxDepth / 2.0)) * maxDepth * 2;
+                    //if (mathCurrentRow <= maxDepth)
+                    //{
+                    //    locationInfos = locationInfos.Where(x => x.Row - Convert.ToInt32(Math.Ceiling(x.Row / maxDepth / 2.0)) * maxDepth * 2 <= maxDepth).ToList();
+                        
+                    //}
+                    //else
+                    //{
+                    //    locationInfos = locationInfos.Where(x => x.Row - Convert.ToInt32(Math.Ceiling(x.Row / maxDepth / 2.0)) * maxDepth * 2 > maxDepth).ToList();
+                        
+                    //}
+                    if (beRelocation.Row <= maxDepth)
                     {
-                        locationInfos = locationInfos.Where(x => x.Row - Convert.ToInt32(Math.Ceiling(x.Row / maxDepth / 2.0)) * maxDepth * 2 <= maxDepth).ToList();
-                        if (beRelocation.Row <= maxDepth)
-                        {
-                            locationInfos = locationInfos.Where(x=>x.Row <= maxDepth).ToList();
-                        }
+                        locationInfos = locationInfos.Where(x => x.Row <= maxDepth).ToList();
                     }
-                    else
+                    else if (beRelocation.Row > maxDepth)
                     {
-                        locationInfos = locationInfos.Where(x => x.Row - Convert.ToInt32(Math.Ceiling(x.Row / maxDepth / 2.0)) * maxDepth * 2 > maxDepth).ToList();
-                        if (beRelocation.Row > maxDepth)
-                        {
-                            locationInfos = locationInfos.Where(x => x.Row > maxDepth).ToList();
-                        }
+                        locationInfos = locationInfos.Where(x => x.Row > maxDepth).ToList();
                     }
                 }
 
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_ZH.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_ZH.cs"
index 2d3addd..788d1de 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_ZH.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_ZH.cs"
@@ -58,14 +58,22 @@
                         throw new Exception($"鏈壘鍒拌揣浣嶄俊鎭�");
                     }
                     int maxDepth = locationInfos.Max(x => x.Depth);
-                    int mathCurrentRow = beRelocation.Row - Convert.ToInt32(Math.Ceiling(beRelocation.Row / maxDepth / 2.0)) * maxDepth * 2;
-                    if (mathCurrentRow <= maxDepth)
+                    //int mathCurrentRow = beRelocation.Row - Convert.ToInt32(Math.Ceiling(beRelocation.Row / maxDepth / 2.0)) * maxDepth * 2;
+                    //if (mathCurrentRow <= maxDepth)
+                    //{
+                    //    locationInfos = locationInfos.Where(x => x.Row - Convert.ToInt32(Math.Ceiling(x.Row / maxDepth / 2.0)) * maxDepth * 2 <= maxDepth).ToList();
+                    //}
+                    //else
+                    //{
+                    //    locationInfos = locationInfos.Where(x => x.Row - Convert.ToInt32(Math.Ceiling(x.Row / maxDepth / 2.0)) * maxDepth * 2 > maxDepth).ToList();
+                    //}
+                    if (beRelocation.Row <= maxDepth)
                     {
-                        locationInfos = locationInfos.Where(x => x.Row - Convert.ToInt32(Math.Ceiling(x.Row / maxDepth / 2.0)) * maxDepth * 2 <= maxDepth).ToList();
+                        locationInfos = locationInfos.Where(x => x.Row <= maxDepth).ToList();
                     }
-                    else
+                    else if (beRelocation.Row > maxDepth)
                     {
-                        locationInfos = locationInfos.Where(x => x.Row - Convert.ToInt32(Math.Ceiling(x.Row / maxDepth / 2.0)) * maxDepth * 2 > maxDepth).ToList();
+                        locationInfos = locationInfos.Where(x => x.Row > maxDepth).ToList();
                     }
                 }
 
@@ -139,6 +147,14 @@
                                     continue;
                                 }
                             }
+                            if (palletTypeInfo.IsOdd)
+                            {
+                                Dt_LocationInfo? locationInfoExist = locationInfoDepth.FirstOrDefault(x => x.Row == locationInfo.Row  && x.Column == (locationInfo.Column-1) && x.Layer == locationInfo.Layer);
+                                if (locationInfoExist!=null && locationInfoExist.LocationStatus!= LocationStatusEnum.Free.ObjToInt() && locationInfoExist.LocationStatus != LocationStatusEnum.FreeLock.ObjToInt())
+                                {
+                                    continue;
+                                }
+                            }
                             locationCaches_ZH.Add(new LocationCache { LocationCode = locationInfo.LocationCode, DateTime = DateTime.Now });
                             return locationInfo;
                         }
@@ -203,6 +219,14 @@
                                     continue;
                                 }
                             }
+                            if (palletTypeInfo.IsOdd)
+                            {
+                                Dt_LocationInfo? locationInfoExist = locationInfoDepth.FirstOrDefault(x => x.Row == locationInfo.Row && x.Column == (locationInfo.Column - 1) && x.Layer == locationInfo.Layer);
+                                if (locationInfoExist != null && locationInfoExist.LocationStatus != LocationStatusEnum.Free.ObjToInt() && locationInfoExist.LocationStatus != LocationStatusEnum.FreeLock.ObjToInt())
+                                {
+                                    continue;
+                                }
+                            }
                             locationCaches_ZH.Add(new LocationCache { LocationCode = locationInfo.LocationCode, DateTime = DateTime.Now });
                             return locationInfo;
                         }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/LocationInfoService_Common.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/LocationInfoService_Common.cs"
index c4fcbbc..82ca087 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/LocationInfoService_Common.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/LocationInfoService_Common.cs"
@@ -508,6 +508,10 @@
             for (int j = location.Depth - 1; j >= 1; j--)
             {
                 Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.Depth == j && x.Column == location.Column && x.Layer == location.Layer && (x.Row == row + 1 || x.Row == row - 1));
+                if (j == 1 && location.RoadwayNo.Contains("CSJ") && (row==1 || row==6))
+                {
+                    locationInfo = locationInfos.FirstOrDefault(x => x.Depth == j && x.Column == location.Column && x.Layer == location.Layer && (x.Row == row + 2 || x.Row == row - 2));
+                }
                 if (locationInfo != null)
                 {
                     groupLocations.Add(locationInfo);
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Common/LocationEnum/LocationStatusEnum.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Common/LocationEnum/LocationStatusEnum.cs"
index 87a5df4..a134a94 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Common/LocationEnum/LocationStatusEnum.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Common/LocationEnum/LocationStatusEnum.cs"
@@ -30,7 +30,7 @@
         InStockLock = 10,
 
         /// <summary>
-        /// 鏈夎揣閿佸畾
+        /// 绌洪棽閿佸畾
         /// </summary>
         [Description("绌洪棽閿佸畾")]
         FreeLock = 20,
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/MesOutboundOrderService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/MesOutboundOrderService.cs"
index 2f7bfe9..42aba4b 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/MesOutboundOrderService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_OutboundService/MesOutboundOrderService.cs"
@@ -60,19 +60,19 @@
             float originalNeedQuantity = mesOutboundOrder.OrderQuantity;
 
             float needQuantity = originalNeedQuantity;
-
+            //鑾峰彇搴撳瓨
             List<Dt_StockInfo> stockInfos = _stockService.StockInfoService.GetUseableStocks(mesOutboundOrder.MaterialCode, "", mesOutboundOrder.WarehouseId);
             if (!stockInfos.Any())
             {
                 throw new Exception($"鏈壘鍒板彲鍒嗛厤搴撳瓨");
             }
             List<Dt_StockInfo> autoAssignStocks = _stockService.StockInfoService.GetOutboundStocks(stockInfos, mesOutboundOrder.MaterialCode, needQuantity, out float residueQuantity);
-            mesOutboundOrder.LockQuantity += needQuantity - residueQuantity;
+            if (residueQuantity>0)
+            {
+                throw new Exception($"搴撳瓨涓嶈冻");
+            }
             autoAssignStocks.OrderBy(x => x.Details.FirstOrDefault()?.StockQuantity).ToList();
             outStocks.AddRange(autoAssignStocks);
-            float assignQuantity = needQuantity - residueQuantity;
-
-            float orderQuantity = mesOutboundOrder.OrderQuantity;
             for (int j = 0; j < autoAssignStocks.Count; j++)
             {
                 float detailAssignQuantity = outStockLockInfos.Where(x => x.MaterielCode == mesOutboundOrder.MaterialCode).Sum(x => x.AssignQuantity);//鍑哄簱璁㈠崟鏄庣粏宸插垎閰嶆暟閲�
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs"
index e6e6e09..1d75b62 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs"
@@ -267,36 +267,7 @@
             }
             else
             {
-                for (int i = 0; i < stockInfos.Count; i++)
-                {
-                    Dt_StockInfo stockInfo = stockInfos[i];
-                    float useableStockQuantity = stockInfo.Details.Where(x => x.MaterielCode == materielCode).Sum(x => x.StockQuantity - x.OutboundQuantity);
-                    if (useableStockQuantity < needQuantity)
-                    {
-                        stockInfo.Details.ForEach(x => x.OutboundQuantity = x.StockQuantity);
-                        needQuantity -= useableStockQuantity;
-                    }
-                    else
-                    {
-                        stockInfo.Details.ForEach(x =>
-                        {
-                            if (x.StockQuantity > x.OutboundQuantity && x.MaterielCode == materielCode)
-                            {
-                                if (x.StockQuantity - x.OutboundQuantity >= needQuantity)
-                                {
-                                    x.OutboundQuantity += needQuantity;
-                                    needQuantity = 0;
-                                }
-                                else
-                                {
-                                    needQuantity -= (x.StockQuantity - x.OutboundQuantity);
-                                    x.OutboundQuantity = x.StockQuantity;
-                                }
-                            }
-                        });
-                    }
-                    outStocks.Add(stockInfo);
-                }
+                throw new Exception("搴撳瓨涓嶈冻");
             }
             residueQuantity = needQuantity;
             return outStocks;
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesTaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesTaskService.cs"
index a74fb82..f864815 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesTaskService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/MesTaskService.cs"
@@ -531,9 +531,11 @@
                 List<Dt_OutStockLockInfo>? outStockLockInfos = null;
                 List<Dt_LocationInfo>? locationInfos = null;
                 {
+                    //鍒嗛厤搴撳瓨
                     (List<Dt_StockInfo>, Dt_MesOutboundOrder, List<Dt_OutStockLockInfo>, List<Dt_LocationInfo>) result = _outboundService.MesOutboundOrderService.AssignStockOutbound(mesOutboundOrder);
                     if (result.Item1 != null && result.Item1.Count > 0)
                     {
+                        //鍒涘缓浠诲姟
                         tasks = GetTasks(result.Item1, TaskTypeEnum.MesOutbound);
                         result.Item2.OrderStatus = OrderDetailStatusEnum.Outbound.ObjToInt();
                         result.Item3.ForEach(x =>
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
index 87bf3af..cc2786f 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService_Outbound.cs"
@@ -601,13 +601,14 @@
         public List<Dt_Task> GetTasks(List<Dt_StockInfo> stockInfos, TaskTypeEnum taskType)
         {
             List<Dt_Task> tasks = new List<Dt_Task>();
+            List<Dt_LocationInfo> locationInfos = _basicService.LocationInfoService.Repository.QueryData(x => stockInfos.Select(x=>x.LocationCode).Contains(x.LocationCode));
             for (int i = 0; i < stockInfos.Count; i++)
             {
                 Dt_StockInfo stockInfo = stockInfos[i];
 
                 if (stockInfo != null)
                 {
-                    Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == stockInfo.LocationCode);
+                    Dt_LocationInfo? locationInfo = locationInfos.FirstOrDefault(x => x.LocationCode == stockInfo.LocationCode);
                     if (!tasks.Exists(x => x.PalletCode == stockInfo.PalletCode))
                     {
                         Dt_Task task = new()

--
Gitblit v1.9.3