Browse Source

删除冗余方法并修改查询条件和返回信息

删除了多个获取货位信息的方法,包括 `RingGetEmptyCell`、`GetEmptyCell`、`RingGetFullCell`、`GetFullCell` 和 `GetEmptyCell`(带有 `emptyLoc` 参数的版本)。删除了一个执行并发锁的静态方法 `RedisExists`。修改了 `_taskrepository.AsQueryable()` 查询条件,增加了 `&&x.Status< TaskStatus.Finish` 条件。修改了 `res.ResMsg` 的返回信息,增加了 `findBestStackingPosition` 的值。
林豪 左 9 months ago
parent
commit
09a069c5d1
1 changed files with 2 additions and 114 deletions
  1. 2 114
      wms.service/Service/FJService.cs

+ 2 - 114
wms.service/Service/FJService.cs

@@ -4795,12 +4795,12 @@ namespace wms.service.Service
                 if (findBestStackingPosition!=req.EquCode)//当前码垛位不是最近码垛位置
                 {
                     //查看最近码垛位是否存在未结束的码垛任务
-                    var used = _taskrepository.AsQueryable().With(SqlWith.NoLock).Any(x => x.AddrTo==findBestStackingPosition&&x.BusType== FJTaskBusType.环形库出库码垛任务.GetDescription());
+                    var used = _taskrepository.AsQueryable().With(SqlWith.NoLock).Any(x => x.AddrTo==findBestStackingPosition&&x.BusType== FJTaskBusType.环形库出库码垛任务.GetDescription()&&x.Status< TaskStatus.Finish);
                     //无正在执行的任务,报错返回
                     if (!used)
                     {
                         res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
-                        res.ResMsg = "优先最近码垛位执行";
+                        res.ResMsg = $"优先最近码垛位执行-{findBestStackingPosition}";
                         return res;
                     }
                 }
@@ -7170,118 +7170,6 @@ namespace wms.service.Service
             return res;
         }
 
-        /// <summary>
-        ///  获取环形库第一深度为空,第二深度有货的货位信息
-        /// </summary>
-        /// <param name="wareHouseId">仓库信息主键</param>
-        /// <param name="depth">第一深度</param>
-        /// <param name="size"></param>
-        /// <returns></returns>
-        public ISugarQueryable<BaseWarecell, BaseWarecell, BillInvnow> RingGetEmptyCell(long wareHouseId, int depth, long size) => GetEmptyCell(wareHouseId, depth, FjLocationType.RingLibrary, size);
-
-        /// <summary>
-        ///  获取第一深度为空,第二深度有货的货位信息
-        /// </summary>
-        /// <param name="wareHouseId">仓库信息主键</param>
-        /// <param name="depth">第一深度</param>
-        /// <param name="type">仓库类型</param>
-        /// <param name="size">大小货位</param>
-        /// <returns></returns>
-        public ISugarQueryable<BaseWarecell, BaseWarecell, BillInvnow> GetEmptyCell(long wareHouseId, int depth, FjLocationType type, long size)
-        {
-            var nextDepth = depth + 1;
-            return _basewarecellrepository.Context.Queryable<BaseWarecell, BaseWarecell, BillInvnow>((loc1, loc2, inv)
-                    => new object[]
-                    {
-                        JoinType.Inner,loc1.Shelf == loc2.Shelf && loc1.Col == loc2.Col && loc1.Layer == loc2.Layer ,
-                        JoinType.Inner, loc2.ContGrpBarCode == inv.ContGrpBarCode||loc2.ContGrpBarCode == inv.HWBarCode,
-                    })
-                .Where((loc1, loc2, inv) => loc1.WarehouseId == wareHouseId && loc1.TypeNum == type && loc1.Depth == depth && loc1.StateNum == FjLocationState.Empty && loc1.IsStop == 0 && loc1.Size == size)
-                .Where((loc1, loc2, inv) => (loc2.StateNum == FjLocationState.Full || loc2.StateNum == FjLocationState.StockIn) && loc2.Depth == nextDepth && loc2.IsStop == 0 && loc2.Size == size)
-                .Where((loc1, loc2, inv) => inv.InvStateCode == InvState.InvEcecState_In.ToString() || inv.InvStateCode == InvState.InvEcecState_BuildUp.ToString());
-        }
-
-        /// <summary>
-        ///  获取环形库第一深度为空,第二深度有货的货位信息
-        /// </summary>
-        /// <param name="wareHouseId">仓库信息主键</param>
-        /// <param name="depth">第一深度</param>
-        /// <param name="size"></param>
-        /// <returns></returns>
-        public ISugarQueryable<BaseWarecell, BaseWarecell, BillInvnow> RingGetFullCell(long wareHouseId, int depth, long size) => GetEmptyCell(wareHouseId, depth, FjLocationType.RingLibrary, size);
-
-        /// <summary>
-        ///  获取第一深度为空,第二深度有货的货位信息
-        /// </summary>
-        /// <param name="wareHouseId">仓库信息主键</param>
-        /// <param name="depth">第一深度</param>
-        /// <param name="type">仓库类型</param>
-        /// <param name="size">大小货位</param>
-        /// <returns></returns>
-        public ISugarQueryable<BaseWarecell, BaseWarecell, BillInvnow> GetFullCell(long wareHouseId, int depth, FjLocationType type, long size)
-        {
-            var nextDepth = depth + 1;
-            return _basewarecellrepository.Context.Queryable<BaseWarecell, BaseWarecell, BillInvnow>((loc1, loc2, inv)
-                    => new object[]
-                    {
-                        JoinType.Inner,loc1.Shelf == loc2.Shelf && loc1.Col == loc2.Col && loc1.Layer == loc2.Layer ,
-                        JoinType.Inner, loc2.ContGrpBarCode == inv.ContGrpBarCode||loc2.ContGrpBarCode == inv.HWBarCode,
-                    })
-                .Where((loc1, loc2, inv) => loc1.WarehouseId == wareHouseId && loc1.TypeNum == type && loc1.Depth == depth && loc1.StateNum == FjLocationState.Empty && loc1.IsStop == 0 && loc1.Size == size)
-                .Where((loc1, loc2, inv) => (loc2.StateNum == FjLocationState.Full || loc2.StateNum == FjLocationState.StockIn) && loc2.Depth == nextDepth && loc2.IsStop == 0 && loc2.Size == size)
-                .Where((loc1, loc2, inv) => inv.InvStateCode == InvState.InvEcecState_In.ToString() || inv.InvStateCode == InvState.InvEcecState_BuildUp.ToString());
-        }
-
-        /// <summary>
-        ///  获取前置深位为空的货位信息
-        /// </summary>
-        /// <param name="emptyLoc">可用深位集合</param>
-        /// <param name="depth">前置深位</param>
-        /// <returns></returns>
-        public IEnumerable<string> GetEmptyCell(List<BaseWarecell> emptyLoc, int depth)
-        {
-            var nextDepth = depth + 1;
-            return _basewarecellrepository.GetList(p => p.TypeNum == FjLocationType.RingLibrary && p.Depth == depth)
-                   .Join(emptyLoc.Where(p => p.Depth == nextDepth), loc1 => new { loc1.Col, loc1.Layer, loc1.Shelf }, loc2 => new { loc2.Col, loc2.Layer, loc2.Shelf }, (loc1, loc2) => loc2)
-                   .ToList().Select(x => x.Code);
-        }
-
-        /// <summary>
-        ///  执行并发锁
-        ///  指定redis
-        /// </summary>
-        /// <param name="lockKey">并发锁key</param>
-        /// <exception cref="Exception"></exception>
-        public static SRes RedisExists(string lockKey, Action act)
-        {
-            lock (lockInOrOut)
-            {
-                lockKey = "ConcurrentLock:" + lockKey;
-                var res = new SRes()
-                {
-                    ResCode = ResponseStatusCodeEnum.Sucess.GetHashCode(),
-                    ResMsg = ResponseStatusCodeEnum.Sucess.GetDescription(),
-                };
-                try
-                {
-                    if (RedisHelper.Exists(lockKey)) throw new Exception($"调用冲突:{lockKey}");
-                    RedisHelper.Expire(lockKey, 60);
-                    act();
-                }
-                catch (Exception ex)
-                {
-                    res.ResCode = ResponseStatusCodeEnum.Fail.GetHashCode();
-                    res.ResMsg = $"{ex.Message}";
-                }
-                finally
-                {
-                    RedisHelper.Del(lockKey);
-                }
-
-                return res;
-            }
-        }
-
         /// <summary>
         ///  计算最佳码垛位置
         /// </summary>