From b2cc7bb7740e42e57cf50af02a8ca4b535cad484 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期三, 11 三月 2026 17:02:21 +0800
Subject: [PATCH] 优化WMS接口逻辑

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/RGVLocationInfoService.cs |   65 +++++++++++++++++++++++++-------
 1 files changed, 51 insertions(+), 14 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/RGVLocationInfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/RGVLocationInfoService.cs"
index 9156ebf..4562f62 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/RGVLocationInfoService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/RGVLocationInfoService.cs"
@@ -53,22 +53,59 @@
                 foreach (var item in items)
                 {
                     List<Dt_RGVLocationInfo> dt_RGVLocationInfos = BaseDal.QueryData(x => x.RoadwayNo == items.Key);//鏌ユ壘褰撳墠宸烽亾鍙疯揣浣�
-                    rGVLocationInfo = dt_RGVLocationInfos.Where(x => x.Depth < item.Depth && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt()).FirstOrDefault();//鍒ゆ柇娴呮繁搴﹁揣浣嶆槸鍚︽湁璐�
-                    if (rGVLocationInfo != null)//娴呮繁搴﹁揣浣嶆湁璐э紝鎵炬繁娣卞害璐т綅鏄惁鏈夎揣
+                    if (item.LocationType == 1)
                     {
-                        if (item.LocationType == 1) break;//宸烽亾绫诲瀷涓哄崟鍚戯紝鐩存帴璺宠繃
-                        foreach (var locationInfo in rGVLocationInfos.Where(x => x.RoadwayNo == items.Key).OrderBy(x => x.Depth))
-                        {
-                            if (!dt_RGVLocationInfos.Where(x => x.LocationStatus == LocationStatusEnum.InStock.ObjToInt() && x.Depth > locationInfo.Depth).Any()) return locationInfo;
-                        }
-                        //rGVLocationInfo = dt_RGVLocationInfos.Where(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt()).OrderBy(x => x.Depth).FirstOrDefault();//鎵炬祬娣卞害绌鸿揣浣�
-                        //if (rGVLocationInfo != null)
-                        //{
-                        //    if (dt_RGVLocationInfos.Where(x => x.Depth > rGVLocationInfo.Depth && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt()).FirstOrDefault() == null)//鍒ゆ柇娣辨繁搴﹁揣浣嶆槸鍚︽湁璐�
-                        //        return rGVLocationInfo;
-                        //}
+                        rGVLocationInfo = dt_RGVLocationInfos.Where(x => x.Depth < item.Depth && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt()).FirstOrDefault();//鍒ゆ柇娴呮繁搴﹁揣浣嶆槸鍚︽湁璐�
+                        if (rGVLocationInfo != null) break;
+                        return item;
                     }
-                    else return item;
+                    else
+                    {
+                        rGVLocationInfo = dt_RGVLocationInfos.Where(x => x.Depth < item.Depth && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt()).OrderByDescending(x => x.Depth).FirstOrDefault();//鍒ゆ柇娴呮繁搴﹁揣浣嶆槸鍚︽湁璐�
+                        if (rGVLocationInfo != null)
+                        {
+                            rGVLocationInfo = dt_RGVLocationInfos.Where(x => x.Depth > rGVLocationInfo.Depth && x.LocationStatus == LocationStatusEnum.Free.ObjToInt()).OrderBy(x => x.Depth).FirstOrDefault();
+                            if (rGVLocationInfo != null)
+                            {
+                                if (dt_RGVLocationInfos.Where(x => x.Depth > rGVLocationInfo.Depth && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt()).Any()) rGVLocationInfo = null;
+                                else return rGVLocationInfo;
+                            }
+                            //var Depth = 0;
+                            //while (item.Depth - rGVLocationInfo.Depth != 0)
+                            //{
+                            //    if (rGVLocationInfo.Depth < item.Depth) Depth = rGVLocationInfo.Depth - 1;
+                            //    else Depth = rGVLocationInfo.Depth + 1;
+                            //    rGVLocationInfo = dt_RGVLocationInfos.Where(x => x.Depth == Depth).FirstOrDefault();
+                            //    if (rGVLocationInfo != null && rGVLocationInfo.LocationStatus == (int)LocationStatusEnum.Free) return rGVLocationInfo;
+                            //}
+                        }//鍒ゆ柇娴呮繁搴﹁揣浣嶆槸鍚︽湁璐�
+                        else return item;
+                    }
+
+                    //if (rGVLocationInfo != null)//娴呮繁搴﹁揣浣嶆湁璐э紝鎵炬繁娣卞害璐т綅鏄惁鏈夎揣
+                    //{
+                    //    if (item.LocationType == 1) break;//宸烽亾绫诲瀷涓哄崟鍚戯紝鐩存帴璺宠繃
+                    //    foreach (var locationInfo in rGVLocationInfos.Where(x => x.RoadwayNo == items.Key).OrderByDescending(x => x.Depth))
+                    //    {
+                    //        if (!dt_RGVLocationInfos.Where(x => x.LocationStatus == LocationStatusEnum.InStock.ObjToInt() && x.Depth < locationInfo.Depth).Any()) return locationInfo;
+                    //    }
+                    //    //rGVLocationInfo = dt_RGVLocationInfos.Where(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt()).OrderBy(x => x.Depth).FirstOrDefault();//鎵炬祬娣卞害绌鸿揣浣�
+                    //    //if (rGVLocationInfo != null)
+                    //    //{
+                    //    //    if (dt_RGVLocationInfos.Where(x => x.Depth > rGVLocationInfo.Depth && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt()).FirstOrDefault() == null)//鍒ゆ柇娣辨繁搴﹁揣浣嶆槸鍚︽湁璐�
+                    //    //        return rGVLocationInfo;
+                    //    //}
+                    //}
+                    //if (rGVLocationInfo == null)
+                    //{
+                    //    rGVLocationInfo = dt_RGVLocationInfos.Where(x => x.Depth > item.Depth && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt()).FirstOrDefault();//鍒ゆ柇娴呮繁搴﹁揣浣嶆槸鍚︽湁璐�
+                    //    if (item.LocationType == 1) break;//宸烽亾绫诲瀷涓哄崟鍚戯紝鐩存帴璺宠繃
+                    //    foreach (var locationInfo in rGVLocationInfos.Where(x => x.RoadwayNo == items.Key).OrderByDescending(x => x.Depth))
+                    //    {
+                    //        if (!dt_RGVLocationInfos.Where(x => x.LocationStatus == LocationStatusEnum.InStock.ObjToInt() && x.Depth < locationInfo.Depth).Any()) return locationInfo;
+                    //    }
+                    //}
+                    //else return item;
                 }
             }
             #endregion

--
Gitblit v1.9.3