| | |
| | | using System; |
| | | using SqlSugar; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEAWCS_Common.LocationEnum; |
| | | using WIDESEAWCS_Core.BaseRepository; |
| | | using WIDESEAWCS_Core.BaseServices; |
| | | using WIDESEAWCS_Core.Helper; |
| | | using WIDESEAWCS_IBasicInfoService; |
| | | using WIDESEAWCS_Model.Models; |
| | | |
| | |
| | | public RGVLocationInfoService(IRepository<Dt_RGVLocationInfo> BaseDal) : base(BaseDal) |
| | | { |
| | | } |
| | | |
| | | private Dictionary<string, OrderByType> _emptyAssignOrderBy = new Dictionary<string, OrderByType>() |
| | | { |
| | | { nameof(Dt_RGVLocationInfo.Row), OrderByType.Asc }, |
| | | { nameof(Dt_RGVLocationInfo.Depth), OrderByType.Desc }, |
| | | { nameof(Dt_RGVLocationInfo.Layer), OrderByType.Asc }, |
| | | //{ nameof(Dt_RGVLocationInfo.Column), OrderByType.Asc }, |
| | | }; |
| | | private Dictionary<string, OrderByType> _DepthAscOrderBy = new Dictionary<string, OrderByType>() |
| | | { |
| | | { nameof(Dt_RGVLocationInfo.Depth), OrderByType.Asc }, |
| | | }; |
| | | public IRepository<Dt_RGVLocationInfo> Repository => BaseDal; |
| | | |
| | | public List<Dt_RGVLocationInfo> GetFreeLocationInfos() |
| | | { |
| | | return BaseDal.QueryData(x => x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt(), _emptyAssignOrderBy); |
| | | } |
| | | /// <summary> |
| | | /// æ¥æ¾å
¥åºå¯ç¨è´§ä½ |
| | | /// </summary> |
| | | /// <param name="AreaCode"></param> |
| | | /// <returns></returns> |
| | | public Dt_RGVLocationInfo? GetInFreeLocationInfo(string AreaCode) |
| | | { |
| | | Dt_RGVLocationInfo? rGVLocationInfo = null; |
| | | Dt_RGVLocationInfo? FreerGVLocationInfo = null; |
| | | List<Dt_RGVLocationInfo> rGVLocationInfos = BaseDal.QueryData(x => x.WarehouseId.ToString() == AreaCode && x.EnableStatus == EnableStatusEnum.Normal.ObjToInt() && x.LocationStatus == LocationStatusEnum.Free.ObjToInt(), _emptyAssignOrderBy);//æ¥æ¾ææç©ºè´§ä½ |
| | | if (rGVLocationInfos == null || rGVLocationInfos.Count < 1) return rGVLocationInfo; |
| | | #region å¤æå··éæ¯å¦æè´§ |
| | | List<string> LocationCodes = new List<string>(); |
| | | foreach (var items in rGVLocationInfos.GroupBy(x => x.RoadwayNo))//æ ¹æ®å··éå·åç» |
| | | { |
| | | foreach (var item in items) |
| | | { |
| | | List<Dt_RGVLocationInfo> dt_RGVLocationInfos = BaseDal.QueryData(x => x.RoadwayNo == items.Key);//æ¥æ¾å½åå··éå·è´§ä½ |
| | | if (item.LocationType == 1) |
| | | { |
| | | rGVLocationInfo = dt_RGVLocationInfos.Where(x => x.Depth < item.Depth && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt()).FirstOrDefault();//夿æµ
æ·±åº¦è´§ä½æ¯å¦æè´§ |
| | | if (rGVLocationInfo != null) break; |
| | | 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 |
| | | return FreerGVLocationInfo; |
| | | } |
| | | } |
| | | } |