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 | 277 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 274 insertions(+), 3 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 6f58879..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"
@@ -1,10 +1,13 @@
-锘縰sing SqlSugar;
+锘縰sing Microsoft.Data.SqlClient;
+using Org.BouncyCastle.Bcpg.Sig;
+using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Core;
+using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
using WIDESEA_Core.Enums;
using WIDESEA_Core.Helper;
@@ -20,6 +23,9 @@
{
private readonly IBasicRepository _basicRepository;
public ILocationInfoRepository Repository => BaseDal;
+ private readonly static object _locker = new object();
+
+ public static List<LocationCache> locationCaches = new List<LocationCache>();
public LocationInfoService(ILocationInfoRepository BaseDal, IBasicRepository basicRepository) : base(BaseDal)
{
@@ -47,7 +53,7 @@
List<Dt_LocationInfo> locationInfos = Repository.QueryData(x => keys.Contains(x.Id));
locationInfos.ForEach(x =>
{
- x.EnableStatus = EnableEnum.Enable.ObjToInt();
+ x.EnableStatus = EnableStatusEnum.Normal.ObjToInt();
});
Repository.UpdateData(locationInfos);
@@ -59,7 +65,7 @@
List<Dt_LocationInfo> locationInfos = Repository.QueryData(x => keys.Contains(x.Id));
locationInfos.ForEach(x =>
{
- x.EnableStatus = EnableEnum.Disable.ObjToInt();
+ x.EnableStatus = EnableStatusEnum.Disable.ObjToInt();
});
Repository.UpdateData(locationInfos);
@@ -76,6 +82,205 @@
return LocationDisableStatus(new int[] { key });
}
+
+ //浼犲叆宸烽亾鍙�2 璐ф灦绫诲瀷10
+ /// <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 > 5).ToList();//鏌ヨ娣诲姞闈欐�佸彉閲忚秴杩�10鍒嗛挓鐨勮揣浣�
+ 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 = 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鍒嗛挓鍐呭垎閰嶇殑璐т綅,鏍规嵁灞傘�佸垪銆佹繁搴︺�佽鎺掑簭
+
+
+ for (int i = 0; i < emptyLocations.Count; i++)
+ {
+ if (emptyLocations[i].Depth == 1)//鍒ゆ柇鏄惁1娣辫揣浣�
+ {
+ //鏌ヨ娣卞簱浣�
+ 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 = sencondDepthLocationShen.LocationCode });
+ return sencondDepthLocationShen;//1娣辫揣浣嶅強2娣辫揣浣嶉兘涓虹┖鐨勬儏鍐典笅,浼樺厛鍒嗛厤2娣辫揣浣�
+ }
+ else
+ {
+ 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
+ {
+ //鏌ヨ2娣辫揣浣嶅搴旂殑1娣辫揣浣嶆槸鍚︿负绌�
+ int emprow = emptyLocations[i].Row == 4 ? 3 : 2;
+
+ 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];
+ }
+ }
+ }
+ 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 > 5).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);//鏌ヨ宸烽亾鎵�鏈夎揣浣嶄俊鎭�
+
+
+ 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);//鏌ヨ宸烽亾鎵�鏈夎揣浣嶄俊鎭�
+
+
+ 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)
+ {
+ Dt_LocationInfo locationInfos = BaseDal.QueryFirst(x => x.LocationCode == LocationCode);
+ if(locationInfos !=null)
+ {
+ return locationInfos;
+ }
+ else
+ {
+ return null;
+ }
+ }
public WebResponseContent InitializationLocation(InitializationLocationDTO initializationLocationDTO)
{
try
@@ -136,5 +341,71 @@
return WebResponseContent.Instance.Error(ex.Message);
}
}
+
+ public class LocationCache
+ {
+ public string LocationCode { get; set; }
+
+ public DateTime DateTime { get; set; }
+ }
+
+ /*public WebResponseContent RetrieveStorageLocationInformation()
+ {
+ List<Dt_LocationInfo> dt_Locations = BaseDal.QueryData();
+
+ //鑾峰彇鎴愬搧搴撲綅鏁伴噺(娣�)
+ List<Dt_LocationInfo> Shallowlocation = dt_Locations.Where(x => x.RoadwayNo == "1" && x.LocationStatus == LocationStatusEnum.Free.ObjToInt()&& x.EnableStatus == (int)EnableStatusEnum.Normal && x.Layer <= 9 && x.Depth==1).ToList();
+ List<Dt_LocationInfo> Finishedlocation = dt_Locations.Where(x => x.RoadwayNo == "1" && x.LocationStatus == LocationStatusEnum.Free.ObjToInt()&& x.EnableStatus == (int)EnableStatusEnum.Normal && x.Layer <= 9 && x.Depth == 2).ToList();
+
+ //鑾峰彇14-37鍒楀簱浣嶆暟閲�
+
+ //鑾峰彇绌烘墭搴撲綅鏁伴噺
+
+ //鑾峰彇鍘熸潗鏂欏簱浣嶆暟閲�
+ //鑾峰彇绌烘墭鏁伴噺
+ }*/
+
+ public WebResponseContent RetrieveStorageLocationInformation()
+ {
+ // 1. 鏌ユ壘娣卞簱浣�
+ List<Dt_LocationInfo> dt_Locations = BaseDal.QueryData(
+ x => x.RoadwayNo == "1"
+ && x.EnableStatus == 0
+ && x.LocationStatus == 0
+ && x.Depth == 2
+ && x.Layer <= 9
+ );
+
+ if (dt_Locations == null || !dt_Locations.Any())
+ {
+ return WebResponseContent.Instance.OK(new List<string>().ToJson());
+ }
+
+ // 2. 鏌ヨ鎵�鏈夋祬搴撲綅
+ var allShallow = BaseDal.QueryData(
+ x => x.RoadwayNo == "1" && x.Depth == 1
+ );
+
+ List<string> locationCodes = new List<string>();
+
+ if (allShallow != null)
+ {
+ // 鍦ㄥ唴瀛樹腑杩囨护骞舵彁鍙朙ocationCode
+ locationCodes = allShallow
+ .Where(x =>
+ dt_Locations.Any(deep =>
+ deep.Layer == x.Layer
+ && deep.RoadwayNo == x.RoadwayNo
+ && deep.Column == x.Column
+ && ((deep.Row == 1 && x.Row == 2) || (deep.Row != 1 && x.Row == 3))
+ )
+ && x.LocationStatus != 0
+ )
+ .Select(x => x.LocationCode) // 鍙�夋嫨LocationCode瀛楁
+ .ToList();
+ }
+
+ return WebResponseContent.Instance.OK(locationCodes.ToJson());
+ }
}
}
--
Gitblit v1.9.3