コード例 #1
0
        public new bool Add(Cell cell)
        {
            var cellAdd   = new Cell();
            var warehouse = WarehouseRepository.GetQueryable().FirstOrDefault(w => w.WarehouseCode == cell.WarehouseCode);
            var area      = AreaRepository.GetQueryable().FirstOrDefault(a => a.AreaCode == cell.AreaCode);
            var shelf     = ShelfRepository.GetQueryable().FirstOrDefault(s => s.ShelfCode == cell.ShelfCode);
            var product   = ProductRepository.GetQueryable().FirstOrDefault(p => p.ProductCode == cell.DefaultProductCode);

            cellAdd.CellCode    = cell.CellCode;
            cellAdd.CellName    = cell.CellName;
            cellAdd.ShortName   = cell.ShortName;
            cellAdd.CellType    = cell.CellType;
            cellAdd.Layer       = cell.Layer;
            cellAdd.Col         = cell.Col;
            cellAdd.ImgX        = cell.ImgX;
            cellAdd.ImgY        = cell.ImgY;
            cellAdd.Rfid        = cell.Rfid;
            cellAdd.Warehouse   = warehouse;
            cellAdd.Area        = area;
            cellAdd.Shelf       = shelf;
            cellAdd.Product     = product;
            cellAdd.MaxQuantity = cell.MaxQuantity;
            cellAdd.IsSingle    = cell.IsSingle;
            cellAdd.Description = cell.Description;
            cellAdd.IsActive    = cell.IsActive;
            cellAdd.UpdateTime  = DateTime.Now;

            CellRepository.Add(cellAdd);
            CellRepository.SaveChanges();
            return(true);
        }
コード例 #2
0
        public bool UpdateTree(string type, string id, bool isCheck, string proCode2)
        {
            bool result = false;

            if (type == "cell")
            {
                IQueryable <Cell> queryCell = CellRepository.GetQueryable();
                var cell = queryCell.FirstOrDefault(i => i.CellCode == id);
                if (isCheck == true)
                {
                    cell.DefaultProductCode = proCode2;
                }
                else
                {
                    cell.DefaultProductCode = null;
                }
                CellRepository.SaveChanges();
                result = true;
            }
            else
            {
                return(false);
            }
            return(result);
        }
コード例 #3
0
ファイル: StorageLocker.cs プロジェクト: radtek/HNXC_WMS
 public void UnLock(Cell[] cells)
 {
     try
     {
         cells.AsParallel().ForAll(c => c.LockTag = string.Empty);
         CellRepository.SaveChanges();
     }
     catch (Exception)
     {
         return;
     }
 }
コード例 #4
0
ファイル: StorageLocker.cs プロジェクト: radtek/HNXC_WMS
 private void UnLock(Cell cell)
 {
     try
     {
         cell.LockTag = string.Empty;
         CellRepository.SaveChanges();
     }
     catch (Exception)
     {
         CellRepository.Detach(cell);
     }
 }
コード例 #5
0
        public bool Delete(string cellCode)
        {
            var cell = CellRepository.GetQueryable()
                       .FirstOrDefault(c => c.CellCode == cellCode);

            if (cell != null)
            {
                CellRepository.Delete(cell);
                CellRepository.SaveChanges();
            }
            else
            {
                return(false);
            }
            return(true);
        }
コード例 #6
0
ファイル: StorageLocker.cs プロジェクト: radtek/HNXC_WMS
 private bool Lock(Cell cell)
 {
     try
     {
         if (string.IsNullOrEmpty(cell.LockTag))
         {
             cell.LockTag = this.LockKey;
             CellRepository.SaveChanges();
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception)
     {
         CellRepository.Detach(cell);
         return(false);
     }
 }
コード例 #7
0
        public void Allot(string connectionId, ProgressState ps, CancellationToken cancellationToken, string billNo, string[] areaCodes)
        {
            Locker.LockKey = billNo;
            ConnectionId   = connectionId;
            ps.State       = StateType.Start;
            ps.Messages.Add("开始分配!");
            NotifyConnection(ps.Clone());
            IQueryable <THOK.Authority.DbModel.SystemParameter> systemParQuery = SystemParameterRepository.GetQueryable();
            IQueryable <InBillMaster> inBillMasterQuery = InBillMasterRepository.GetQueryable();
            IQueryable <Cell>         cellQuery         = CellRepository.GetQueryable();

            InBillMaster billMaster = inBillMasterQuery.Single(b => b.BillNo == billNo);

            if (!CheckAndLock(billMaster, ps))
            {
                return;
            }

            var isDefaultProduct  = systemParQuery.FirstOrDefault(s => s.ParameterName == "IsDefaultProduct");  //查询预设的卷烟其他卷烟是否可入 0 否 1是
            var InMantissaIsPiece = systemParQuery.FirstOrDefault(s => s.ParameterName == "InMantissaIsPiece"); //查询入库的尾数是否放入件烟区  0 否 1是

            //选择未分配的细单数组;
            var billDetails = billMaster.InBillDetails
                              .Where(b => (b.BillQuantity - b.AllotQuantity) > 0)
                              .ToArray();


            //选择当前订单操作目标仓库;
            var cells = cellQuery.Where(c => c.WarehouseCode == billMaster.WarehouseCode &&
                                        c.Warehouse.IsActive == "1" &&
                                        c.Area.IsActive == "1" &&
                                        c.IsActive == "1" &&
                                        (areaCodes.Any(a => a == c.AreaCode) ||
                                         (!areaCodes.Any() && c.Area.AllotInOrder > 0)))
                        .ToArray();

            //1:主库区;2:件烟区;
            //3;条烟区;4:暂存区;
            //5:备货区;6:残烟区;
            //7:罚烟区;8:虚拟区;
            //9:其他区;

            //排除 件烟区,条烟区 货位是单一存储的空货位;
            string [] areaTypes = new string [] { "2", "3" };
            var       cells1    = cells.Where(c => areaTypes.All(a => a != c.Area.AreaType) &&
                                              c.IsSingle == "1" &&
                                              (c.Storages.Count == 0 ||
                                               c.Storages.Any(s => string.IsNullOrEmpty(s.LockTag) &&
                                                              s.Quantity == 0 &&
                                                              s.InFrozenQuantity == 0)))
                                  .ToArray();

            //条烟区 货位是单一存储的货位(不必是空货位,因为条烟会多次存储到同一个货位);
            areaTypes = new string[] { "3" };
            var cell2 = cells.Where(c => areaTypes.Any(a => a == c.Area.AreaType) &&
                                    c.IsSingle == "1")
                        .ToArray();

            //件烟区 货位是单一存储的空货位;
            areaTypes = new string[] { "2", "4" };
            var cell3 = cells.Where(c => areaTypes.Any(a => a == c.Area.AreaType) &&
                                    c.IsSingle == "1" &&
                                    c.Storages.Any(s => string.IsNullOrEmpty(s.LockTag) &&
                                                   s.Product != null &&
                                                   (s.Quantity > 0 || s.InFrozenQuantity > 0) &&
                                                   c.MaxQuantity * s.Product.Unit.Count > s.Quantity - s.InFrozenQuantity))
                        .ToArray();

            //件烟区 货位是单一存储的空货位;
            areaTypes = new string[] { "2" };
            var cell4 = cells.Where(c => areaTypes.Any(a => a == c.Area.AreaType) &&
                                    c.IsSingle == "1" &&
                                    (c.Storages.Count == 0 ||
                                     c.Storages.Any(s => string.IsNullOrEmpty(s.LockTag) &&
                                                    s.Quantity == 0 &&
                                                    s.InFrozenQuantity == 0
                                                    )
                                    )
                                    )
                        .ToArray();

            //非货位管理区
            var cell5 = cells.Where(c => c.IsSingle == "0")
                        .ToArray();


            //排除 件烟区,条烟区
            var cellQueryFromList1 = cells1.Where(c => c.Storages.Count == 0 ||
                                                  c.Storages.Any(s => string.IsNullOrEmpty(s.LockTag) &&
                                                                 s.Quantity == 0 &&
                                                                 s.InFrozenQuantity == 0))
                                     .OrderBy(c => c.Area.AllotInOrder);
            //条烟区
            var cellQueryFromList2 = cell2.OrderBy(c => c.Area.AllotInOrder);

            //件烟区 --入库尾数可以放入件烟区
            var cellQueryFromList3 = cell3.OrderBy(c => c.Area.AllotInOrder);

            if (InMantissaIsPiece.ParameterValue != "0")
            {
                cellQueryFromList3 = cell3.Where(c => c.Storages.Any(s => c.MaxQuantity * s.Product.Unit.Count > s.Quantity - s.InFrozenQuantity))
                                     .OrderBy(c => c.Area.AllotInOrder);
            }
            //件烟区 --入库尾数不放入件烟区
            var cellQueryFromList4 = cell4.Where(c => c.Storages.Count == 0 ||
                                                 c.Storages.Any(s => string.IsNullOrEmpty(s.LockTag) &&
                                                                s.Quantity == 0 &&
                                                                s.InFrozenQuantity == 0))
                                     .OrderBy(c => c.Area.AllotInOrder);

            //非货位管理区
            var cellQueryFromList5 = cell5.OrderBy(c => c.Area.AllotInOrder % 10000);

            foreach (var billDetail in billDetails)
            {
                //分配预设当前卷烟的货位;
                var cs = cellQueryFromList1.Where(c => c.DefaultProductCode == billDetail.ProductCode);
                AllotPallet(billMaster, billDetail, cs, cancellationToken, ps);
                //分配没预设卷烟的货位;
                cs = cellQueryFromList1.Where(c => string.IsNullOrEmpty(c.DefaultProductCode));
                AllotPallet(billMaster, billDetail, cs, cancellationToken, ps);

                if (isDefaultProduct.ParameterValue != "0")//判断预设卷烟后不能放入其他烟
                {
                    //分配预设其他卷烟的货位;
                    cs = cellQueryFromList1.Where(c => c.DefaultProductCode != billDetail.ProductCode &&
                                                  !string.IsNullOrEmpty(c.DefaultProductCode));
                    AllotPallet(billMaster, billDetail, cs, cancellationToken, ps);
                }

                //分配条烟到条烟区;
                cs = cellQueryFromList2.Where(c => c.DefaultProductCode == billDetail.ProductCode ||
                                              (c.Storages.Count == 1 &&
                                               c.Storages.First().ProductCode == billDetail.ProductCode)
                                              );
                AllotBar(billMaster, billDetail, cs, cancellationToken, ps);
                //分配条烟到条烟区;
                if (!cs.Any())
                {
                    cs = cellQueryFromList2.Where(c => (isDefaultProduct.ParameterValue == "0" ? string.IsNullOrEmpty(c.DefaultProductCode) : c.WarehouseCode == c.WarehouseCode));
                    AllotBar(billMaster, billDetail, cs, cancellationToken, ps);
                }

                //分配未满一托盘的卷烟到件烟区;
                cs = cellQueryFromList3.Where(c => (isDefaultProduct.ParameterValue == "0" ? string.IsNullOrEmpty(c.DefaultProductCode) : c.WarehouseCode == c.WarehouseCode) || c.DefaultProductCode == billDetail.ProductCode);
                if (cellQueryFromList2.Any())
                {
                    if (InMantissaIsPiece.ParameterValue != "0")
                    {
                        AllotPiece(billMaster, billDetail, cs, cancellationToken, ps);
                    }
                    cs = cellQueryFromList4.Where(c => (isDefaultProduct.ParameterValue == "0" ? string.IsNullOrEmpty(c.DefaultProductCode) : c.WarehouseCode == c.WarehouseCode));
                    AllotPiece(billMaster, billDetail, cs, cancellationToken, ps);
                }
                else
                {
                    if (InMantissaIsPiece.ParameterValue != "0")
                    {
                        AllotPieceAndBar(billMaster, billDetail, cs, cancellationToken, ps);
                    }
                    cs = cellQueryFromList4.Where(c => (isDefaultProduct.ParameterValue == "0" ? string.IsNullOrEmpty(c.DefaultProductCode) : c.WarehouseCode == c.WarehouseCode));
                    AllotPieceAndBar(billMaster, billDetail, cs, cancellationToken, ps);
                }

                //分配未满一托盘的卷烟到下层货架;
                cs = cellQueryFromList1.Where(c => c.Layer == 1 && (isDefaultProduct.ParameterValue == "0" ? string.IsNullOrEmpty(c.DefaultProductCode) : c.WarehouseCode == c.WarehouseCode));
                if (cellQueryFromList2.Count() > 0)
                {
                    AllotPiece(billMaster, billDetail, cs, cancellationToken, ps);
                }
                else
                {
                    AllotPieceAndBar(billMaster, billDetail, cs, cancellationToken, ps);
                }

                //分配未分配卷烟到其他库区;
                cs = cellQueryFromList1.Where(c => (isDefaultProduct.ParameterValue == "0" ? string.IsNullOrEmpty(c.DefaultProductCode) : c.WarehouseCode == c.WarehouseCode));
                AllotPiece(billMaster, billDetail, cs, cancellationToken, ps);

                //分配未分配卷烟到其他非货位管理货位;
                while (!cancellationToken.IsCancellationRequested && (billDetail.BillQuantity - billDetail.AllotQuantity) > 0)
                {
                    var c = cellQueryFromList5.Where(i => !i.Storages.Any() ||
                                                     i.Storages.Count() < i.MaxPalletQuantity ||
                                                     i.Storages.Any(s => string.IsNullOrEmpty(s.LockTag) &&
                                                                    s.Quantity == 0 &&
                                                                    s.InFrozenQuantity == 0))
                            .FirstOrDefault();

                    if (c != null)
                    {
                        lock (c)
                        {
                            decimal allotQuantity = c.MaxQuantity * billDetail.Product.Unit.Count;
                            decimal billQuantity  = billDetail.BillQuantity - billDetail.AllotQuantity;
                            allotQuantity = allotQuantity < billQuantity ? allotQuantity : billQuantity;
                            var targetStorage = Locker.LockStorage(c);
                            if (targetStorage != null &&
                                targetStorage.Quantity == 0 &&
                                targetStorage.InFrozenQuantity == 0)
                            {
                                Allot(billMaster, billDetail, c, targetStorage, allotQuantity, ps);
                                Locker.UnLockStorage(targetStorage);
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }

            string billno = billMaster.BillNo;

            if (billMaster.InBillDetails.Any(i => i.BillQuantity - i.AllotQuantity > 0))
            {
                ps.State = StateType.Warning;
                ps.Errors.Add("分配未全部完成,没有储位可分配!");
                NotifyConnection(ps.Clone());

                InBillMasterRepository.GetObjectSet()
                .UpdateEntity(i => i.BillNo == billno,
                              i => new InBillMaster()
                {
                    LockTag = ""
                });
            }
            else
            {
                ps.State = StateType.Info;
                ps.Messages.Add("分配完成,开始保存请稍候!");
                NotifyConnection(ps.Clone());

                billMaster.Status = "3";
                try
                {
                    if (!cancellationToken.IsCancellationRequested)
                    {
                        billMaster.LockTag = string.Empty;
                        CellRepository.SaveChanges();
                        ps.State = StateType.Info;
                        ps.Messages.Clear();
                        ps.Messages.Add("分配成功!");
                        NotifyConnection(ps.Clone());
                    }
                }
                catch (Exception e)
                {
                    ps.State = StateType.Error;
                    ps.Messages.Add("保存失败,详情:" + e.Message);
                    NotifyConnection(ps.Clone());
                }
                finally
                {
                    InBillMasterRepository.GetObjectSet()
                    .UpdateEntity(i => i.BillNo == billno,
                                  i => new InBillMaster()
                    {
                        LockTag = ""
                    });
                }
            }
        }
コード例 #8
0
        public void Allot(string connectionId, Model.ProgressState ps, System.Threading.CancellationToken cancellationToken, string billNo, string[] areaCodes)
        {
            Locker.LockKey = billNo;
            ConnectionId   = connectionId;
            ps.State       = StateType.Start;
            NotifyConnection(ps.Clone());

            IQueryable <OutBillMaster> outBillMasterQuery = OutBillMasterRepository.GetQueryable();
            IQueryable <Cell>          cellQuery          = CellRepository.GetQueryable();
            IQueryable <Storage>       storageQuery       = StorageRepository.GetQueryable();

            OutBillMaster billMaster = outBillMasterQuery.Single(b => b.BillNo == billNo);

            if (!CheckAndLock(billMaster, ps))
            {
                return;
            }

            //选择未分配的细单;
            var billDetails = billMaster.OutBillDetails.Where(b => (b.BillQuantity - b.AllotQuantity) > 0).ToArray();
            //选择当前订单操作目标仓库;
            var storages = storageQuery.Where(s => s.Cell.WarehouseCode == billMaster.WarehouseCode);

            if (areaCodes.Length > 0)
            {
                //选择指定库区;
                storages = storages.Where(s => areaCodes.Any(a => a == s.Cell.AreaCode));
            }
            else
            {
                storages = storages.Where(s => s.Cell.Area.AllotOutOrder > 0);
            }
            storages = storages.Where(s => string.IsNullOrEmpty(s.LockTag) && s.Cell.IsActive == "1" &&
                                      s.Quantity - s.OutFrozenQuantity > 0);

            foreach (var billDetail in billDetails)
            {
                //1:主库区 1;2:件烟区 2;
                //3;条烟区 3;4:暂存区 4;
                //5:备货区 0;6:残烟区 0;
                //7:罚烟区 0;8:虚拟区 0;
                //9:其他区 0;

                //分配整盘;排除 件烟区 条烟区
                string[] areaTypes = new string[] { "2", "3", "5" };
                var      ss        = storages.Where(s => areaTypes.All(a => a != s.Cell.Area.AreaType) &&
                                                    s.ProductCode == billDetail.ProductCode)
                                     .OrderBy(s => new { s.Cell.Area.AllotOutOrder, s.StorageTime });
                AllotPallet(billMaster, billDetail, ss, cancellationToken, ps);

                //分配件烟;件烟区
                areaTypes = new string[] { "2" };
                ss        = storages.Where(s => areaTypes.Any(a => a == s.Cell.Area.AreaType) &&
                                           s.ProductCode == billDetail.ProductCode)
                            .OrderBy(s => new { s.Cell.Area.AllotOutOrder, s.StorageTime });
                AllotPiece(billMaster, billDetail, ss, cancellationToken, ps);

                //分配件烟 (下层储位);排除 件烟区 条烟区
                areaTypes = new string[] { "2", "3", "5" };
                ss        = storages.Where(s => areaTypes.All(a => a != s.Cell.Area.AreaType) &&
                                           s.ProductCode == billDetail.ProductCode &&
                                           s.Cell.Layer == 1)
                            .OrderBy(s => new { s.Cell.Area.AllotOutOrder, s.StorageTime });
                AllotPiece(billMaster, billDetail, ss, cancellationToken, ps);

                //分配件烟 (非下层储位);排除 件烟区 条烟区
                areaTypes = new string[] { "2", "3", "5" };
                ss        = storages.Where(s => areaTypes.All(a => a != s.Cell.Area.AreaType) &&
                                           s.ProductCode == billDetail.ProductCode &&
                                           s.Cell.Layer != 1)
                            .OrderBy(s => new { s.Cell.Area.AllotOutOrder, s.StorageTime });
                AllotPiece(billMaster, billDetail, ss, cancellationToken, ps);

                //分配条烟;条烟区
                areaTypes = new string[] { "3" };
                ss        = storages.Where(s => areaTypes.Any(a => a == s.Cell.Area.AreaType) &&
                                           s.ProductCode == billDetail.ProductCode)
                            .OrderBy(s => new { s.Cell.Area.AllotOutOrder, s.StorageTime });
                AllotBar(billMaster, billDetail, ss, cancellationToken, ps);

                //分配条烟;件烟区
                areaTypes = new string[] { "2" };
                ss        = storages.Where(s => areaTypes.Any(a => a == s.Cell.Area.AreaType) &&
                                           s.ProductCode == billDetail.ProductCode)
                            .OrderBy(s => new { s.Cell.Area.AllotOutOrder, s.StorageTime });
                AllotBar(billMaster, billDetail, ss, cancellationToken, ps);

                //分配条烟 (主库区下层);
                areaTypes = new string[] { "1" };
                ss        = storages.Where(s => areaTypes.All(a => a == s.Cell.Area.AreaType) &&
                                           s.ProductCode == billDetail.ProductCode &&
                                           s.Cell.Layer == 1)
                            .OrderBy(s => new { s.Cell.Area.AllotOutOrder, s.StorageTime });
                AllotBar(billMaster, billDetail, ss, cancellationToken, ps);

                //分配条烟 (主库区)
                areaTypes = new string[] { "1" };
                ss        = storages.Where(s => areaTypes.All(a => a == s.Cell.Area.AreaType) &&
                                           s.ProductCode == billDetail.ProductCode &&
                                           s.Cell.Layer != 1)
                            .OrderBy(s => new { s.Cell.Area.AllotOutOrder, s.StorageTime });
                AllotBar(billMaster, billDetail, ss, cancellationToken, ps);

                //分配条烟 (暂存区)
                areaTypes = new string[] { "4" };
                ss        = storages.Where(s => areaTypes.All(a => a == s.Cell.Area.AreaType) &&
                                           s.ProductCode == billDetail.ProductCode)
                            .OrderBy(s => s.StorageTime)
                            .OrderBy(s => s.Cell.Area.AllotOutOrder);
                AllotBar(billMaster, billDetail, ss, cancellationToken, ps);

                if (billDetail.BillQuantity > billDetail.AllotQuantity)
                {
                    ps.State = StateType.Warning;
                    ps.Errors.Add(billDetail.ProductCode + " " + billDetail.Product.ProductName + ",库存不足!" + "订单量:" + billDetail.BillQuantity / billDetail.Product.Unit.Count + "(件)," + "未分配量:" + (billDetail.BillQuantity - billDetail.RealQuantity) / billDetail.Product.Unit.Count + "(件)");
                }
            }

            string billno = billMaster.BillNo;

            if (billMaster.OutBillDetails.Any(i => i.BillQuantity - i.AllotQuantity > 0))
            {
                ps.State = StateType.Warning;
                ps.Errors.Add("分配未全部完成,没有储位可分配!");
                NotifyConnection(ps.Clone());

                OutBillMasterRepository.GetObjectSet()
                .UpdateEntity(i => i.BillNo == billno,
                              i => new OutBillMaster()
                {
                    LockTag = ""
                });
            }
            else
            {
                ps.State = StateType.Info;
                ps.Messages.Add("分配完成,开始保存请稍候!");
                NotifyConnection(ps.Clone());

                billMaster.Status = "3";
                try
                {
                    if (!cancellationToken.IsCancellationRequested)
                    {
                        billMaster.LockTag = string.Empty;
                        CellRepository.SaveChanges();
                        ps.State = StateType.Info;
                        ps.Messages.Clear();
                        ps.Messages.Add("分配成功!");
                        NotifyConnection(ps.Clone());
                    }
                }
                catch (Exception e)
                {
                    ps.State = StateType.Error;
                    ps.Messages.Add("保存失败,详情:" + e.Message);
                    NotifyConnection(ps.Clone());
                }
                finally
                {
                    OutBillMasterRepository.GetObjectSet()
                    .UpdateEntity(i => i.BillNo == billno,
                                  i => new OutBillMaster()
                    {
                        LockTag = ""
                    });
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// 库存加锁
        /// </summary>
        /// <param name="billNo">订单号</param>
        /// <param name="cell">货位</param>
        /// <returns></returns>
        private Storage LockStorage(string billNo, Cell cell)
        {
            try
            {
                cell.LockTag = billNo;
                CellRepository.SaveChanges();
            }
            catch (Exception)
            {
                CellRepository.Detach(cell);
                return(null);
            }

            Storage storage = null;

            try
            {
                if (cell.IsSingle == "1")
                {
                    if (cell.Storages.Count == 0)
                    {
                        storage = new Storage()
                        {
                            StorageCode = Guid.NewGuid().ToString(),
                            CellCode    = cell.CellCode,
                            IsLock      = "0",
                            LockTag     = billNo,
                            IsActive    = "0",
                            StorageTime = DateTime.Now,
                            UpdateTime  = DateTime.Now
                        };
                        cell.Storages.Add(storage);
                    }
                    else if (cell.Storages.Count == 1)
                    {
                        storage         = cell.Storages.Single();
                        storage.LockTag = billNo;
                    }
                }
                else
                {
                    storage = cell.Storages.Where(s => s.LockTag == null || s.LockTag == string.Empty &&
                                                  s.Quantity == 0 &&
                                                  s.InFrozenQuantity == 0)
                              .FirstOrDefault();
                    if (storage != null)
                    {
                        storage.LockTag = billNo;
                    }
                    else
                    {
                        storage = new Storage()
                        {
                            StorageCode = Guid.NewGuid().ToString(),
                            CellCode    = cell.CellCode,
                            IsLock      = "0",
                            LockTag     = billNo,
                            IsActive    = "0",
                            StorageTime = DateTime.Now,
                            UpdateTime  = DateTime.Now
                        };
                        cell.Storages.Add(storage);
                    }
                }
                StorageRepository.SaveChanges();
            }
            catch (Exception)
            {
                StorageRepository.Detach(storage);
                cell.Storages.Remove(storage);
                storage = null;
            }

            cell.LockTag = string.Empty;
            CellRepository.SaveChanges();

            return(storage);
        }