/// <summary>
        /// 新增移库细单
        /// </summary>
        /// <param name="moveBillDetail"></param>
        /// <returns></returns>
        public bool Add(MoveBillDetail moveBillDetail, out string strResult)
        {
            bool result = false;

            try
            {
                IQueryable <MoveBillDetail> moveBillDetailQuery = MoveBillDetailRepository.GetQueryable();
                var     product    = ProductRepository.GetQueryable().FirstOrDefault(p => p.ProductCode == moveBillDetail.ProductCode);
                var     unit       = UnitRepository.GetQueryable().FirstOrDefault(u => u.UnitCode == moveBillDetail.UnitCode);
                var     storage    = StorageRepository.GetQueryable().FirstOrDefault(s => s.StorageCode == moveBillDetail.InStorageCode);
                var     outStorage = StorageRepository.GetQueryable().FirstOrDefault(s => s.StorageCode == moveBillDetail.OutStorageCode);
                var     outCell    = CellRepository.GetQueryable().FirstOrDefault(c => c.CellCode == moveBillDetail.OutCellCode);
                var     inCell     = CellRepository.GetQueryable().FirstOrDefault(c => c.CellCode == moveBillDetail.InCellCode);
                Storage inStorage  = null;
                if (storage != null)
                {
                    inStorage = Locker.LockStorage(storage, product);
                }
                else
                {
                    inStorage = Locker.LockStorage(inCell);
                }
                //判断移出数量是否合理
                bool isOutQuantityRight = IsQuntityRight(moveBillDetail.RealQuantity * unit.Count, outStorage.InFrozenQuantity, outStorage.OutFrozenQuantity, outCell.MaxQuantity * product.Unit.Count, outStorage.Quantity, "out");
                if (Locker.LockStorage(outStorage, product) != null)
                {
                    if (inStorage != null)
                    {
                        //判断移入数量是否合理
                        bool isInQuantityRight = IsQuntityRight(moveBillDetail.RealQuantity * unit.Count, inStorage.InFrozenQuantity, inStorage.OutFrozenQuantity, inCell.MaxQuantity * product.Unit.Count, inStorage.Quantity, "in");
                        if (isInQuantityRight && isOutQuantityRight)
                        {
                            var mbd = new MoveBillDetail();
                            mbd.BillNo                    = moveBillDetail.BillNo;
                            mbd.ProductCode               = moveBillDetail.ProductCode;
                            mbd.OutCellCode               = moveBillDetail.OutCellCode;
                            mbd.OutStorageCode            = moveBillDetail.OutStorageCode;
                            mbd.InCellCode                = moveBillDetail.InCellCode;
                            mbd.InStorageCode             = inStorage.StorageCode;
                            mbd.UnitCode                  = moveBillDetail.UnitCode;
                            mbd.RealQuantity              = moveBillDetail.RealQuantity * unit.Count;
                            outStorage.OutFrozenQuantity += moveBillDetail.RealQuantity * unit.Count;
                            inStorage.ProductCode         = moveBillDetail.ProductCode;
                            inStorage.InFrozenQuantity   += moveBillDetail.RealQuantity * unit.Count;
                            mbd.Status                    = "0";
                            inStorage.LockTag             = string.Empty;
                            outStorage.LockTag            = string.Empty;
                            MoveBillDetailRepository.Add(mbd);
                            MoveBillDetailRepository.SaveChanges();
                            result = true;
                        }
                        else
                        {
                            result = false;
                        }
                    }
                    else
                    {
                        resultStr = "移入库存加锁失败";
                    }
                }
                else
                {
                    resultStr = "移出库存加锁失败";
                }
            }
            catch (Exception ex)
            {
                resultStr = ex.ToString();
            }
            strResult = resultStr;
            return(result);
        }