1
wangxinhui
2025-06-12 e7be74e711076896e7e841b54691daa95067c567
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_GM.cs
@@ -43,6 +43,8 @@
                List<string> lockLocationCodes = locationCaches_GM.Select(x => x.LocationCode).ToList();
                List<Dt_LocationInfo> locationInfos = Repository.QueryData(x => x.RoadwayNo == roadwayNo);
                //获取所有二深位货位数据
                List<Dt_LocationInfo> locationInfoDepth = Repository.QueryData(x => x.RoadwayNo == roadwayNo && x.Depth== locationInfos.Max(v=>v.Depth));
                if (locationInfos == null || locationInfos.Count == 0)
                {
                    throw new Exception($"未找到该巷道的货位信息,巷道号:{roadwayNo}");
@@ -60,10 +62,18 @@
                    if (mathCurrentRow <= maxDepth)
                    {
                        locationInfos = locationInfos.Where(x => x.Row - Convert.ToInt32(Math.Ceiling(x.Row / maxDepth / 2.0)) * maxDepth * 2 <= maxDepth).ToList();
                        if (beRelocation.Row> maxDepth)
                        {
                            locationInfos = locationInfos.Where(x=>x.Row>maxDepth).ToList();
                        }
                    }
                    else
                    {
                        locationInfos = locationInfos.Where(x => x.Row - Convert.ToInt32(Math.Ceiling(x.Row / maxDepth / 2.0)) * maxDepth * 2 > maxDepth).ToList();
                        if (beRelocation.Row <= maxDepth)
                        {
                            locationInfos = locationInfos.Where(x => x.Row <= maxDepth).ToList();
                        }
                    }
                }
@@ -83,6 +93,37 @@
                        Dt_LocationInfo? locationInfo = GetUsableLocation_GM(locationInfos, definedTypeEmptyLocation, palletType, palletTypeInfo);
                        if (locationInfo != null)
                        {
                            if (locationInfo.Depth<locationInfoDepth.Max(x=>x.Depth) && palletTypeInfo.LocaitonCount<2)
                            {
                                Dt_LocationInfo? locationInfoExist = null;
                                int Column = locationInfo.Column;
                                if (Column % 2 == 0)
                                {
                                    Column -= 1;
                                }
                                if (locationInfo.Row - locationInfo.Depth == locationInfo.Depth)
                                {
                                    locationInfoExist = locationInfoDepth.FirstOrDefault(x => x.Row == (locationInfo.Row-1) && x.Column== Column && x.Layer==locationInfo.Layer && x.LocationStatus==LocationStatusEnum.InStock.ObjToInt());
                                }
                                else
                                {
                                    locationInfoExist = locationInfoDepth.FirstOrDefault(x => x.Row == (locationInfo.Row + 1) && x.Column == Column && x.Layer == locationInfo.Layer && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt());
                                }
                                //获取深位货位类型
                                if (locationInfoExist==null)
                                {
                                    continue;
                                }
                                Dt_PalletTypeInfo palletTypeInfoDepth = _basicRepository.PalletTypeInfoRepository.QueryFirst(x => x.WarehouseId == locationInfoExist.WarehouseId && x.PalletType == locationInfoExist.LocationType);
                                if (palletTypeInfoDepth == null)
                                {
                                    continue;
                                }
                                if (palletTypeInfoDepth.LocaitonCount==2 && palletTypeInfo.LocaitonCount==1)
                                {
                                    continue;
                                }
                            }
                            locationCaches_GM.Add(new LocationCache { LocationCode = locationInfo.LocationCode, DateTime = DateTime.Now });
                            return locationInfo;
                        }
@@ -103,16 +144,47 @@
                        Dt_LocationInfo? locationInfo = GetUsableLocation_GM(locationInfos, undefinedTypeEmptyLocation, palletType, palletTypeInfo);
                        if (locationInfo != null)
                        {
                            if (locationInfo.Depth < locationInfoDepth.Max(x => x.Depth) && palletTypeInfo.LocaitonCount < 2)
                            {
                                Dt_LocationInfo? locationInfoExist = null;
                                int Column = locationInfo.Column;
                                if (Column % 2 == 0)
                                {
                                    Column -= 1;
                                }
                                if (locationInfo.Row - locationInfo.Depth == locationInfo.Depth)
                                {
                                    locationInfoExist = locationInfoDepth.FirstOrDefault(x => x.Row == (locationInfo.Row - 1) && x.Column == Column && x.Layer == locationInfo.Layer && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt());
                                }
                                else
                                {
                                    locationInfoExist = locationInfoDepth.FirstOrDefault(x => x.Row == (locationInfo.Row + 1) && x.Column == Column && x.Layer == locationInfo.Layer && x.LocationStatus == LocationStatusEnum.InStock.ObjToInt());
                                }
                                //获取深位货位类型
                                if (locationInfoExist == null)
                                {
                                    continue;
                                }
                                Dt_PalletTypeInfo palletTypeInfoDepth = _basicRepository.PalletTypeInfoRepository.QueryFirst(x => x.WarehouseId == locationInfoExist.WarehouseId && x.PalletType == locationInfoExist.LocationType);
                                if (palletTypeInfoDepth == null)
                                {
                                    continue;
                                }
                                if (palletTypeInfoDepth.LocaitonCount == 2)
                                {
                                    continue;
                                }
                            }
                            locationCaches_GM.Add(new LocationCache { LocationCode = locationInfo.LocationCode, DateTime = DateTime.Now });
                            return locationInfo;
                        }
                    }
                }
                //判断如果已定义货位类型的货位和未定义类型的空货位都为空释放满足条件的货位
                if (!definedTypeEmptyLocations.Any() && !undefinedTypeEmptyLocations.Any())
                {
                ////判断如果已定义货位类型的货位和未定义类型的空货位都为空释放满足条件的货位
                //if (!definedTypeEmptyLocations.Any() && !undefinedTypeEmptyLocations.Any())
                //{
                }
                //}
                return null;
            }
        }