From f49fa4b5027cfdc27b429985d023e8002abcca2e Mon Sep 17 00:00:00 2001
From: huanghongfeng <huanghongfeng@hnkhzn.com>
Date: 星期三, 05 十一月 2025 23:54:12 +0800
Subject: [PATCH] 1
---
代码管理/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Base/LocationInfoService.cs | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 114 insertions(+), 5 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 6fad4e6..936f130 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"
@@ -82,11 +82,13 @@
return LocationDisableStatus(new int[] { key });
}
+
+ //浼犲叆宸烽亾鍙�2 璐ф灦绫诲瀷10
public Dt_LocationInfo? GetLocation(string roadway,int Locationtype)
{
lock (_locker)
{
- List<LocationCache> removeItems = locationCaches.Where(x => (DateTime.Now - x.DateTime).TotalMinutes > 5).ToList();//鏌ヨ娣诲姞闈欐�佸彉閲忚秴杩�5鍒嗛挓鐨勮揣浣�
+ List<LocationCache> removeItems = locationCaches.Where(x => (DateTime.Now - x.DateTime).TotalMinutes > 20).ToList();//鏌ヨ娣诲姞闈欐�佸彉閲忚秴杩�20鍒嗛挓鐨勮揣浣�
int count = removeItems.Count;
for (int i = 0; i < count; i++)
{
@@ -95,10 +97,10 @@
List<string> lockLocations = locationCaches.Select(x => x.LocationCode).ToList();
- List<Dt_LocationInfo> locationInfos = BaseDal.QueryData(x => x.RoadwayNo == roadway && x.LocationType == Locationtype);//鏌ヨ宸烽亾鎵�鏈夎揣浣嶄俊鎭�
+ 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> 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鍒嗛挓鍐呭垎閰嶇殑璐т綅,鏍规嵁灞傘�佸垪銆佹繁搴︺�佽鎺掑簭
+ 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鍒嗛挓鍐呭垎閰嶇殑璐т綅,鏍规嵁灞傘�佸垪銆佹繁搴︺�佽鎺掑簭
for (int i = 0; i < emptyLocations.Count; i++)
@@ -120,6 +122,7 @@
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 });
@@ -136,7 +139,7 @@
{
lock (_locker)
{
- List<LocationCache> removeItems = locationCaches.Where(x => (DateTime.Now - x.DateTime).TotalMinutes > 5).ToList();//鏌ヨ娣诲姞闈欐�佸彉閲忚秴杩�5鍒嗛挓鐨勮揣浣�
+ List<LocationCache> removeItems = locationCaches.Where(x => (DateTime.Now - x.DateTime).TotalMinutes > 20).ToList();//鏌ヨ娣诲姞闈欐�佸彉閲忚秴杩�5鍒嗛挓鐨勮揣浣�
int count = removeItems.Count;
for (int i = 0; i < count; i++)
{
@@ -145,7 +148,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);//鏌ヨ宸烽亾鎵�鏈夎揣浣嶄俊鎭�
+ 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鍒嗛挓鍐呭垎閰嶇殑璐т綅,鏍规嵁灞傘�佸垪銆佹繁搴︺�佽鎺掑簭
@@ -181,6 +184,112 @@
}
}
+ //浼犲叆宸烽亾鍙�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鍒嗛挓鐨勮揣浣�
+ 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.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();//鏌ヨ绌鸿揣浣嶄俊鎭苟鎺掗櫎20鍒嗛挓鍐呭垎閰嶇殑璐т綅,鏍规嵁灞傘�佸垪銆佹繁搴︺�佽鎺掑簭
+
+
+ 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
+ {
+ if (sencondDepthLocation != null && sencondDepthLocation.LocationStatus != LocationStatusEnum.Lock.ObjToInt()) //鍒ゆ柇浜屾繁鏃犱换鍔�
+ {
+ 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;
+ }
+ }
+
+
+ public Dt_LocationInfo? GetLocation4(string roadway, int Locationtype, int Startingcolumn, int Terminationcolumn)
+ {
+ lock (_locker)
+ {
+ List<LocationCache> removeItems = locationCaches.Where(x => (DateTime.Now - x.DateTime).TotalMinutes > 20).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
+ {
+ if (sencondDepthLocation != null && sencondDepthLocation.LocationStatus != LocationStatusEnum.Lock.ObjToInt())
+ {
+ 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;
+ }
+ }
public Dt_LocationInfo? GetLocationplatform(string LocationCode)
{
--
Gitblit v1.9.3