dengjunjie
2026-03-11 b2cc7bb7740e42e57cf50af02a8ca4b535cad484
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_BasicInfoService/RGVLocationInfoService.cs
@@ -53,23 +53,60 @@
                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)//浅深度货位有货,找深深度货位是否有货
                    {
                        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;
                        if (rGVLocationInfo != null) break;
                        return item;
                        }
                        //rGVLocationInfo = dt_RGVLocationInfos.Where(x => x.LocationStatus == LocationStatusEnum.Free.ObjToInt()).OrderBy(x => x.Depth).FirstOrDefault();//找浅深度空货位
                        //if (rGVLocationInfo != null)
                    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 (dt_RGVLocationInfos.Where(x => x.Depth > rGVLocationInfo.Depth && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt()).FirstOrDefault() == null)//判断深深度货位是否有货
                        //        return rGVLocationInfo;
                            //    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;