wangxinhui
4 天以前 9ec715d2deb18a269dd49c48da91a36632d08c81
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/Service/AssignLocation/LocationInfoService_CSJ.cs
@@ -57,6 +57,8 @@
                List<string> lockLocationCodes = locationCaches_CSJ.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);
                if (locationInfos == null || locationInfos.Count == 0)
                {
                    throw new Exception($"未找到该巷道的货位信息,巷道号:{roadwayNo}");
@@ -101,6 +103,57 @@
                        Dt_LocationInfo? locationInfo = GetUsableLocation_CSJ(locationInfos, undefinedTypeEmptyLocation, palletType);
                        if (locationInfo != null)
                        {
                            if (locationInfo.Depth < locationInfoDepth.Max(x => x.Depth))
                            {
                                Dt_LocationInfo? locationInfoExist = null;
                                int Column = locationInfo.Column;
                                if (locationInfo.Row < locationInfoDepth.Max(x => x.Depth))
                                {
                                    locationInfoExist = locationInfoDepth.FirstOrDefault(x => x.Row == (palletTypeInfo.LocaitonCount==2 ? (locationInfo.Row - 2): (locationInfo.Row - 1)) && x.Column == Column && x.Layer == locationInfo.Layer);
                                }
                                else
                                {
                                    locationInfoExist = locationInfoDepth.FirstOrDefault(x => x.Row == (palletTypeInfo.LocaitonCount == 2 ? (locationInfo.Row + 2) : (locationInfo.Row + 1)) && x.Column == Column && x.Layer == locationInfo.Layer);
                                }
                                //获取深位货位类型
                                if (locationInfoExist == null)
                                {
                                    continue;
                                }
                                Dt_PalletTypeInfo palletTypeInfoDepth = _basicRepository.PalletTypeInfoRepository.QueryFirst(x => x.WarehouseId == locationInfoExist.WarehouseId && x.PalletType == locationInfoExist.LocationType);
                                if (palletTypeInfoDepth != null && palletTypeInfoDepth.LocaitonCount != palletTypeInfo.LocaitonCount)
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                Dt_LocationInfo? locationInfoExist = null;
                                int Column = locationInfo.Column;
                                if (locationInfo.Row % locationInfoDepth.Max(x => x.Depth)==0)
                                {
                                    locationInfoExist = locationInfoDepth.FirstOrDefault(x => x.Row == (palletTypeInfo.LocaitonCount == 2 ? (locationInfo.Row - 2) : (locationInfo.Row - 1)) && x.Column == Column && x.Layer == locationInfo.Layer);
                                }
                                else
                                {
                                    locationInfoExist = locationInfoDepth.FirstOrDefault(x => x.Row == (palletTypeInfo.LocaitonCount == 2 ? (locationInfo.Row + 2) : (locationInfo.Row + 1)) && x.Column == Column && x.Layer == locationInfo.Layer);
                                }
                                //获取深位货位类型
                                if (locationInfoExist == null)
                                {
                                    continue;
                                }
                                Dt_PalletTypeInfo palletTypeInfoDepth = _basicRepository.PalletTypeInfoRepository.QueryFirst(x => x.WarehouseId == locationInfoExist.WarehouseId && x.PalletType == locationInfoExist.LocationType);
                                if (palletTypeInfoDepth != null && palletTypeInfoDepth.LocaitonCount != palletTypeInfo.LocaitonCount)
                                {
                                    continue;
                                }
                                if (locationInfoExist.LocationStatus != LocationStatusEnum.Free.ObjToInt() || locationInfoExist.EnableStatus != EnableStatusEnum.Normal.ObjToInt())
                                {
                                    continue;
                                }
                            }
                            locationCaches_CSJ.Add(new LocationCache { LocationCode = locationInfo.LocationCode, DateTime = DateTime.Now });
                            return locationInfo;
                        }
@@ -114,6 +167,56 @@
                        Dt_LocationInfo? locationInfo = GetUsableLocation_CSJ(locationInfos, definedTypeEmptyLocation, palletType);
                        if (locationInfo != null)
                        {
                            if (locationInfo.Depth < locationInfoDepth.Max(x => x.Depth))
                            {
                                Dt_LocationInfo? locationInfoExist = null;
                                int Column = locationInfo.Column;
                                if (locationInfo.Row < locationInfoDepth.Max(x => x.Depth))
                                {
                                    locationInfoExist = locationInfoDepth.FirstOrDefault(x => x.Row == (palletTypeInfo.LocaitonCount == 2 ? (locationInfo.Row - 2) : (locationInfo.Row - 1)) && x.Column == Column && x.Layer == locationInfo.Layer);
                                }
                                else
                                {
                                    locationInfoExist = locationInfoDepth.FirstOrDefault(x => x.Row == (palletTypeInfo.LocaitonCount == 2 ? (locationInfo.Row + 2) : (locationInfo.Row + 1)) && x.Column == Column && x.Layer == locationInfo.Layer);
                                }
                                //获取深位货位类型
                                if (locationInfoExist == null)
                                {
                                    continue;
                                }
                                Dt_PalletTypeInfo palletTypeInfoDepth = _basicRepository.PalletTypeInfoRepository.QueryFirst(x => x.WarehouseId == locationInfoExist.WarehouseId && x.PalletType == locationInfoExist.LocationType);
                                if (palletTypeInfoDepth != null && palletTypeInfoDepth.LocaitonCount != palletTypeInfo.LocaitonCount)
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                Dt_LocationInfo? locationInfoExist = null;
                                int Column = locationInfo.Column;
                                if (locationInfo.Row % locationInfoDepth.Max(x => x.Depth) == 0)
                                {
                                    locationInfoExist = locationInfoDepth.FirstOrDefault(x => x.Row == (palletTypeInfo.LocaitonCount == 2 ? (locationInfo.Row - 2) : (locationInfo.Row - 1)) && x.Column == Column && x.Layer == locationInfo.Layer);
                                }
                                else
                                {
                                    locationInfoExist = locationInfoDepth.FirstOrDefault(x => x.Row == (palletTypeInfo.LocaitonCount == 2 ? (locationInfo.Row + 2) : (locationInfo.Row + 1)) && x.Column == Column && x.Layer == locationInfo.Layer);
                                }
                                //获取深位货位类型
                                if (locationInfoExist == null)
                                {
                                    continue;
                                }
                                Dt_PalletTypeInfo palletTypeInfoDepth = _basicRepository.PalletTypeInfoRepository.QueryFirst(x => x.WarehouseId == locationInfoExist.WarehouseId && x.PalletType == locationInfoExist.LocationType);
                                if (palletTypeInfoDepth != null && palletTypeInfoDepth.LocaitonCount != palletTypeInfo.LocaitonCount)
                                {
                                    continue;
                                }
                                if (locationInfoExist.LocationStatus != LocationStatusEnum.Free.ObjToInt() || locationInfoExist.EnableStatus != EnableStatusEnum.Normal.ObjToInt())
                                {
                                    continue;
                                }
                            }
                            locationCaches_CSJ.Add(new LocationCache { LocationCode = locationInfo.LocationCode, DateTime = DateTime.Now });
                            return locationInfo;
                        }
@@ -190,21 +293,60 @@
                case 3:
                case 4:
                    {
                        List<Dt_LocationInfo> moreDepth = locations.Where(x => x.Depth > emptyLocation.Depth).ToList();
                        moreDepthFlag = moreDepth.FirstOrDefault(x => x.LocationStatus != LocationStatusEnum.InStock.ObjToInt() && x.LocationStatus != LocationStatusEnum.PalletLock.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt())) == null;//查询大于当前货位深度的集合里是否有状态不为有货的货位,如果是true,则表示深货位有未被使用的情况
                        List<Dt_LocationInfo> littleDepth = locations.Where(x => x.Depth <= emptyLocation.Depth).ToList();
                        littleDepthFlag = littleDepth.FirstOrDefault(x => x.LocationStatus != LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt())) == null; //查询小于当前货位深度的集合里是否有状态不为空,且禁用状态不为禁用以及只入的货位,如果是true,则表示浅货位被使用或者被禁用的情况
                        if (emptyLocation.LocationType == 0)
                        {
                            List<Dt_LocationInfo> moreDepth = locations.Where(x => x.Depth > emptyLocation.Depth).ToList();
                            moreDepthFlag = moreDepth.FirstOrDefault(x => x.LocationStatus != LocationStatusEnum.InStock.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.LocationType != 0) == null;//查询大于当前货位深度的集合里是否有状态不为有货的货位,如果是true,则表示深货位有未被使用的情况
                            List<Dt_LocationInfo> littleDepth = locations.Where(x => x.Depth <= emptyLocation.Depth).ToList();
                            littleDepthFlag = littleDepth.FirstOrDefault(x => x.LocationStatus != LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.LocationType != 0) == null; //查询小于当前货位深度的集合里是否有状态不为空,且禁用状态不为禁用以及只入的货位,如果是true,则表示浅货位被使用或者被禁用的情况
                        }
                        else
                        {
                            List<Dt_LocationInfo> moreDepth = locations.Where(x => x.Depth > emptyLocation.Depth).ToList();
                            moreDepthFlag = moreDepth.FirstOrDefault(x => x.LocationStatus != LocationStatusEnum.InStock.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.LocationType != emptyLocation.LocationType) == null;//查询大于当前货位深度的集合里是否有状态不为有货的货位,如果是true,则表示深货位有未被使用的情况
                            List<Dt_LocationInfo> littleDepth = locations.Where(x => x.Depth <= emptyLocation.Depth).ToList();
                            littleDepthFlag = littleDepth.FirstOrDefault(x => x.LocationStatus != LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.LocationType != emptyLocation.LocationType) == null; //查询小于当前货位深度的集合里是否有状态不为空,且禁用状态不为禁用以及只入的货位,如果是true,则表示浅货位被使用或者被禁用的情况
                        }
                        //if (moreDepthFlag && littleDepthFlag)
                        //{
                        //    return emptyLocation;
                        //}
                        //List<Dt_LocationInfo> moreDepth = locations.Where(x => x.Depth > emptyLocation.Depth).ToList();
                        //moreDepthFlag = moreDepth.FirstOrDefault(x => x.LocationStatus != LocationStatusEnum.InStock.ObjToInt() && x.LocationStatus != LocationStatusEnum.PalletLock.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt())) == null;//查询大于当前货位深度的集合里是否有状态不为有货的货位,如果是true,则表示深货位有未被使用的情况
                        //List<Dt_LocationInfo> littleDepth = locations.Where(x => x.Depth <= emptyLocation.Depth).ToList();
                        //littleDepthFlag = littleDepth.FirstOrDefault(x => x.LocationStatus != LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt())) == null; //查询小于当前货位深度的集合里是否有状态不为空,且禁用状态不为禁用以及只入的货位,如果是true,则表示浅货位被使用或者被禁用的情况
                    }
                    break;
                case 1:
                case 2:
                    {
                        List<Dt_LocationInfo> moreDepth = locations.Where(x => x.Depth > emptyLocation.Depth).ToList();
                        moreDepthFlag = moreDepth.FirstOrDefault(x => x.LocationStatus != LocationStatusEnum.InStock.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt())) == null;//查询大于当前货位深度的集合里是否有状态不为有货的货位,如果是true,则表示深货位有未被使用的情况
                        if (emptyLocation.LocationType == 0)
                        {
                            List<Dt_LocationInfo> moreDepth = locations.Where(x => x.Depth > emptyLocation.Depth).ToList();
                            moreDepthFlag = moreDepth.FirstOrDefault(x => x.LocationStatus != LocationStatusEnum.InStock.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.LocationType != 0) == null;//查询大于当前货位深度的集合里是否有状态不为有货的货位,如果是true,则表示深货位有未被使用的情况
                        List<Dt_LocationInfo> littleDepth = locations.Where(x => x.Depth <= emptyLocation.Depth).ToList();
                        littleDepthFlag = littleDepth.FirstOrDefault(x => x.LocationStatus != LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt())) == null; //查询小于当前货位深度的集合里是否有状态不为空,且禁用状态不为禁用以及只入的货位,如果是true,则表示浅货位被使用或者被禁用的情况
                            List<Dt_LocationInfo> littleDepth = locations.Where(x => x.Depth <= emptyLocation.Depth).ToList();
                            littleDepthFlag = littleDepth.FirstOrDefault(x => x.LocationStatus != LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.LocationType != 0) == null; //查询小于当前货位深度的集合里是否有状态不为空,且禁用状态不为禁用以及只入的货位,如果是true,则表示浅货位被使用或者被禁用的情况
                        }
                        else
                        {
                            List<Dt_LocationInfo> moreDepth = locations.Where(x => x.Depth > emptyLocation.Depth).ToList();
                            moreDepthFlag = moreDepth.FirstOrDefault(x => x.LocationStatus != LocationStatusEnum.InStock.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.LocationType != emptyLocation.LocationType) == null;//查询大于当前货位深度的集合里是否有状态不为有货的货位,如果是true,则表示深货位有未被使用的情况
                            List<Dt_LocationInfo> littleDepth = locations.Where(x => x.Depth <= emptyLocation.Depth).ToList();
                            littleDepthFlag = littleDepth.FirstOrDefault(x => x.LocationStatus != LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt()) && x.LocationType != emptyLocation.LocationType) == null; //查询小于当前货位深度的集合里是否有状态不为空,且禁用状态不为禁用以及只入的货位,如果是true,则表示浅货位被使用或者被禁用的情况
                        }
                        //List<Dt_LocationInfo> moreDepth = locations.Where(x => x.Depth > emptyLocation.Depth).ToList();
                        //moreDepthFlag = moreDepth.FirstOrDefault(x => x.LocationStatus != LocationStatusEnum.InStock.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt())) == null;//查询大于当前货位深度的集合里是否有状态不为有货的货位,如果是true,则表示深货位有未被使用的情况
                        //List<Dt_LocationInfo> littleDepth = locations.Where(x => x.Depth <= emptyLocation.Depth).ToList();
                        //littleDepthFlag = littleDepth.FirstOrDefault(x => x.LocationStatus != LocationStatusEnum.Free.ObjToInt() && (x.EnableStatus == EnableStatusEnum.OnlyIn.ObjToInt() || x.EnableStatus == EnableStatusEnum.Normal.ObjToInt())) == null; //查询小于当前货位深度的集合里是否有状态不为空,且禁用状态不为禁用以及只入的货位,如果是true,则表示浅货位被使用或者被禁用的情况
                    }
                    break;