From 7a70c16d9fb28646a0f22e9f699746df6c651e8c Mon Sep 17 00:00:00 2001
From: Admin <Admin@ADMIN>
Date: 星期一, 15 十二月 2025 20:14:04 +0800
Subject: [PATCH] 最新

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs |  102 ++++++++++++++++++++-------------------------------
 1 files changed, 40 insertions(+), 62 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs"
index 275ecf1..8684e22 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs"
@@ -84,11 +84,19 @@
 
 
         //浼犲叆宸烽亾鍙�2   璐ф灦绫诲瀷10
-        public Dt_LocationInfo? GetLocation(string roadway,int Locationtype)
+        /// <summary>
+        /// 璐т綅鏌ユ壘
+        /// </summary>
+        /// <param name="roadway">宸烽亾鍙�</param>
+        /// <param name="Locationtype">璐т綅绫诲瀷</param>
+        /// <param name="Startingcolumn">璧峰鍒�</param>
+        /// <param name="Terminationcolumn">缁堟鍒�</param>
+        /// <returns></returns>
+        public Dt_LocationInfo? GetLocation(string roadway,int Locationtype, int Startingcolumn, int Terminationcolumn)
         {
             lock (_locker)
             {
-                List<LocationCache> removeItems = locationCaches.Where(x => (DateTime.Now - x.DateTime).TotalMinutes > 20).ToList();//鏌ヨ娣诲姞闈欐�佸彉閲忚秴杩�20鍒嗛挓鐨勮揣浣�
+                List<LocationCache> removeItems = locationCaches.Where(x => (DateTime.Now - x.DateTime).TotalMinutes > 5).ToList();//鏌ヨ娣诲姞闈欐�佸彉閲忚秴杩�10鍒嗛挓鐨勮揣浣�
                 int count = removeItems.Count;
                 for (int i = 0; i < count; i++)
                 {
@@ -97,7 +105,15 @@
 
                 List<string> lockLocations = locationCaches.Select(x => x.LocationCode).ToList();
 
-                List<Dt_LocationInfo> locationInfos = BaseDal.QueryData(x => x.RoadwayNo == roadway  && x.LocationType == Locationtype && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && !lockLocations.Contains(x.LocationCode));//鏌ヨ宸烽亾鎵�鏈夎揣浣嶄俊鎭�
+                List<Dt_LocationInfo> locationInfos = null;
+                if (Startingcolumn !=0 && Terminationcolumn != 0)
+                {
+                    locationInfos=BaseDal.QueryData(x => x.RoadwayNo == roadway && x.LocationType == Locationtype && x.Column >= Startingcolumn && x.Column <= Terminationcolumn && x.EnableStatus == (int)EnableStatusEnum.Normal);
+                }
+                else
+                {
+                    locationInfos=BaseDal.QueryData(x => x.RoadwayNo == roadway && x.LocationType == Locationtype && x.EnableStatus == (int)EnableStatusEnum.Normal);
+                }
 
                 
                 List<Dt_LocationInfo> emptyLocations = locationInfos.Where(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt()  && !lockLocations.Contains(x.LocationCode)).OrderBy(x => x.Layer).ThenBy(x => x.Column).ThenByDescending(x => x.Depth).ThenBy(x => x.Row).ToList();//鏌ヨ绌鸿揣浣嶄俊鎭苟鎺掗櫎20鍒嗛挓鍐呭垎閰嶇殑璐т綅,鏍规嵁灞傘�佸垪銆佹繁搴︺�佽鎺掑簭
@@ -107,23 +123,32 @@
                 {
                     if (emptyLocations[i].Depth == 1)//鍒ゆ柇鏄惁1娣辫揣浣�
                     {
-                        Dt_LocationInfo? sencondDepthLocation = locationInfos.FirstOrDefault(x => Math.Abs(x.Row - emptyLocations[i].Row) == 1 && x.Layer == emptyLocations[i].Layer && x.Column == emptyLocations[i].Column);//鏌ヨ2娣辫揣浣嶅搴旂殑1娣辫揣浣嶆槸鍚︿负绌�,闃叉鍑虹幇鍒嗛厤1娣辫揣浣嶈��2娣辫揣浣嶄负绌虹殑鎯呭喌
-                        if (sencondDepthLocation != null && sencondDepthLocation.LocationStatus == LocationStatusEnum.Free.ObjToInt())
+                        //鏌ヨ娣卞簱浣�
+                        int emprow = emptyLocations[i].Row==2?1:4;
+
+                        Dt_LocationInfo? sencondDepthLocationShen = emptyLocations.FirstOrDefault(x => x.Row== emprow && x.Layer == emptyLocations[i].Layer && x.Column == emptyLocations[i].Column);
+                        if (sencondDepthLocationShen != null && sencondDepthLocationShen.LocationStatus == LocationStatusEnum.Free.ObjToInt())
                         {
-                            locationCaches.Add(new LocationCache { DateTime = DateTime.Now, LocationCode = sencondDepthLocation.LocationCode });
-                            return sencondDepthLocation;//1娣辫揣浣嶅強2娣辫揣浣嶉兘涓虹┖鐨勬儏鍐典笅,浼樺厛鍒嗛厤2娣辫揣浣�
+                            locationCaches.Add(new LocationCache { DateTime = DateTime.Now, LocationCode = sencondDepthLocationShen.LocationCode });
+                            return sencondDepthLocationShen;//1娣辫揣浣嶅強2娣辫揣浣嶉兘涓虹┖鐨勬儏鍐典笅,浼樺厛鍒嗛厤2娣辫揣浣�
                         }
                         else
                         {
-                            locationCaches.Add(new LocationCache { DateTime = DateTime.Now, LocationCode = emptyLocations[i].LocationCode });
-                            return emptyLocations[i];
+                            Dt_LocationInfo? sencondDepthLo = locationInfos.FirstOrDefault(x => x.Row == emprow && x.Layer == emptyLocations[i].Layer && x.Column == emptyLocations[i].Column);
+                            if (sencondDepthLo != null && sencondDepthLo.LocationStatus != LocationStatusEnum.Lock.ObjToInt() && sencondDepthLo.LocationStatus == LocationStatusEnum.InStock.ObjToInt() && !lockLocations.Contains(sencondDepthLo.LocationCode))
+                            {
+                                locationCaches.Add(new LocationCache { DateTime = DateTime.Now, LocationCode = emptyLocations[i].LocationCode });
+                                return emptyLocations[i];
+                            }
                         }
                     }
                     else
                     {
-                        Dt_LocationInfo? sencondDepthLocation = locationInfos.FirstOrDefault(x => Math.Abs(x.Row - emptyLocations[i].Row) == 1 && x.Layer == emptyLocations[i].Layer && x.Column == emptyLocations[i].Column);//鏌ヨ2娣辫揣浣嶅搴旂殑1娣辫揣浣嶆槸鍚︿负绌�
+                        //鏌ヨ2娣辫揣浣嶅搴旂殑1娣辫揣浣嶆槸鍚︿负绌�
+                        int emprow = emptyLocations[i].Row == 4 ? 3 : 2;
 
-                        if (sencondDepthLocation != null && sencondDepthLocation.LocationStatus == LocationStatusEnum.Free.ObjToInt())
+                        Dt_LocationInfo? sencondDepthLocationQian = emptyLocations.FirstOrDefault(x => x.Row== emprow && x.Layer == emptyLocations[i].Layer && x.Column == emptyLocations[i].Column);
+                        if (sencondDepthLocationQian != null && sencondDepthLocationQian.LocationStatus == LocationStatusEnum.Free.ObjToInt())
                         {
                             locationCaches.Add(new LocationCache { DateTime = DateTime.Now, LocationCode = emptyLocations[i].LocationCode });
                             return emptyLocations[i];
@@ -135,61 +160,14 @@
         }
 
 
-        public Dt_LocationInfo? GetLocation2(string roadway, int Locationtype,int Startingcolumn,int Terminationcolumn)
-        {
-            lock (_locker)
-            {
-                List<LocationCache> removeItems = locationCaches.Where(x => (DateTime.Now - x.DateTime).TotalMinutes > 3).ToList();//鏌ヨ娣诲姞闈欐�佸彉閲忚秴杩�5鍒嗛挓鐨勮揣浣�
-                int count = removeItems.Count;
-                for (int i = 0; i < count; i++)
-                {
-                    locationCaches.Remove(removeItems[i]);//绉婚櫎鏌ヨ娣诲姞闈欐�佸彉閲忚秴杩�5鍒嗛挓鐨勮揣浣�
-                }
-
-                List<string> lockLocations = locationCaches.Select(x => x.LocationCode).ToList();
-
-                List<Dt_LocationInfo> locationInfos = BaseDal.QueryData(x => x.RoadwayNo == roadway && x.LocationType == Locationtype && x.Column> Startingcolumn && x.Column< Terminationcolumn && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && !lockLocations.Contains(x.LocationCode));//鏌ヨ宸烽亾鎵�鏈夎揣浣嶄俊鎭�
-
-
-                List<Dt_LocationInfo> emptyLocations = locationInfos.Where(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && !lockLocations.Contains(x.LocationCode)).OrderBy(x => x.Layer).ThenBy(x => x.Column).ThenByDescending(x => x.Depth).ThenBy(x => x.Row).ToList();//鏌ヨ绌鸿揣浣嶄俊鎭苟鎺掗櫎5鍒嗛挓鍐呭垎閰嶇殑璐т綅,鏍规嵁灞傘�佸垪銆佹繁搴︺�佽鎺掑簭
-
-
-                for (int i = 0; i < emptyLocations.Count; i++)
-                {
-                    if (emptyLocations[i].Depth == 1)//鍒ゆ柇鏄惁1娣辫揣浣�
-                    {
-                        Dt_LocationInfo? sencondDepthLocation = locationInfos.FirstOrDefault(x => Math.Abs(x.Row - emptyLocations[i].Row) == 1 && x.Layer == emptyLocations[i].Layer && x.Column == emptyLocations[i].Column);//鏌ヨ2娣辫揣浣嶅搴旂殑1娣辫揣浣嶆槸鍚︿负绌�,闃叉鍑虹幇鍒嗛厤1娣辫揣浣嶈��2娣辫揣浣嶄负绌虹殑鎯呭喌
-                        if (sencondDepthLocation != null && sencondDepthLocation.LocationStatus == LocationStatusEnum.Free.ObjToInt())
-                        {
-                            locationCaches.Add(new LocationCache { DateTime = DateTime.Now, LocationCode = sencondDepthLocation.LocationCode });
-                            return sencondDepthLocation;//1娣辫揣浣嶅強2娣辫揣浣嶉兘涓虹┖鐨勬儏鍐典笅,浼樺厛鍒嗛厤2娣辫揣浣�
-                        }
-                        else
-                        {
-                            locationCaches.Add(new LocationCache { DateTime = DateTime.Now, LocationCode = emptyLocations[i].LocationCode });
-                            return emptyLocations[i];
-                        }
-                    }
-                    else
-                    {
-                        Dt_LocationInfo? sencondDepthLocation = locationInfos.FirstOrDefault(x => Math.Abs(x.Row - emptyLocations[i].Row) == 1 && x.Layer == emptyLocations[i].Layer && x.Column == emptyLocations[i].Column);//鏌ヨ2娣辫揣浣嶅搴旂殑1娣辫揣浣嶆槸鍚︿负绌�
-                        if (sencondDepthLocation != null && sencondDepthLocation.LocationStatus == LocationStatusEnum.Free.ObjToInt())
-                        {
-                            locationCaches.Add(new LocationCache { DateTime = DateTime.Now, LocationCode = emptyLocations[i].LocationCode });
-                            return emptyLocations[i];
-                        }
-                    }
-                }
-                return null;
-            }
-        }
+        
 
         //浼犲叆宸烽亾鍙�2   璐ф灦绫诲瀷10
         public Dt_LocationInfo? GetLocation3(string roadway, int Locationtype)
         {
             lock (_locker)
             {
-                List<LocationCache> removeItems = locationCaches.Where(x => (DateTime.Now - x.DateTime).TotalMinutes > 20).ToList();//鏌ヨ娣诲姞闈欐�佸彉閲忚秴杩�20鍒嗛挓鐨勮揣浣�
+                List<LocationCache> removeItems = locationCaches.Where(x => (DateTime.Now - x.DateTime).TotalMinutes > 5).ToList();//鏌ヨ娣诲姞闈欐�佸彉閲忚秴杩�20鍒嗛挓鐨勮揣浣�
                 int count = removeItems.Count;
                 for (int i = 0; i < count; i++)
                 {
@@ -198,7 +176,7 @@
 
                 List<string> lockLocations = locationCaches.Select(x => x.LocationCode).ToList();
 
-                List<Dt_LocationInfo> locationInfos = BaseDal.QueryData(x => x.RoadwayNo == roadway && x.LocationType == Locationtype && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && !lockLocations.Contains(x.LocationCode));//鏌ヨ宸烽亾鎵�鏈夎揣浣嶄俊鎭�
+                List<Dt_LocationInfo> locationInfos = BaseDal.QueryData(x => x.RoadwayNo == roadway && x.LocationType == Locationtype);//鏌ヨ宸烽亾鎵�鏈夎揣浣嶄俊鎭�
 
 
                 List<Dt_LocationInfo> emptyLocations = locationInfos.Where(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && !lockLocations.Contains(x.LocationCode)).OrderBy(x => x.Layer).ThenBy(x => x.Column).ThenByDescending(x => x.Depth).ThenBy(x => x.Row).ToList();//鏌ヨ绌鸿揣浣嶄俊鎭苟鎺掗櫎20鍒嗛挓鍐呭垎閰嶇殑璐т綅,鏍规嵁灞傘�佸垪銆佹繁搴︺�佽鎺掑簭
@@ -252,7 +230,7 @@
 
                 List<string> lockLocations = locationCaches.Select(x => x.LocationCode).ToList();
 
-                List<Dt_LocationInfo> locationInfos = BaseDal.QueryData(x => x.RoadwayNo == roadway && x.LocationType == Locationtype && x.Column > Startingcolumn && x.Column < Terminationcolumn && x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && !lockLocations.Contains(x.LocationCode));//鏌ヨ宸烽亾鎵�鏈夎揣浣嶄俊鎭�
+                List<Dt_LocationInfo> locationInfos = BaseDal.QueryData(x => x.RoadwayNo == roadway && x.LocationType == Locationtype && x.Column > Startingcolumn && x.Column < Terminationcolumn);//鏌ヨ宸烽亾鎵�鏈夎揣浣嶄俊鎭�
 
 
                 List<Dt_LocationInfo> emptyLocations = locationInfos.Where(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt() && !lockLocations.Contains(x.LocationCode)).OrderBy(x => x.Layer).ThenBy(x => x.Column).ThenByDescending(x => x.Depth).ThenBy(x => x.Row).ToList();//鏌ヨ绌鸿揣浣嶄俊鎭苟鎺掗櫎5鍒嗛挓鍐呭垎閰嶇殑璐т綅,鏍规嵁灞傘�佸垪銆佹繁搴︺�佽鎺掑簭

--
Gitblit v1.9.3