Пример #1
0
        public bool Save(Cell cell)
        {
            var cellSave  = CellRepository.GetQueryable().FirstOrDefault(c => c.CellCode == cell.CellCode);
            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);

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

            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
        public object GetCellDetails(string type, string id)
        {
            try
            {
                IQueryable <Cell>    cellQuery    = CellRepository.GetQueryable();
                IQueryable <Storage> storageQuery = StorageRepository.GetQueryable();
                var storages = storageQuery;
                var cells    = cellQuery.Where(s => s.MaxPalletQuantity == 0);
                if (type == "ware")
                {
                    cells = cellQuery.Where(c => c.Shelf.Area.Warehouse.WarehouseCode == id && c.MaxPalletQuantity == 0);
                }
                else if (type == "area")
                {
                    cells = cellQuery.Where(c => c.Shelf.Area.AreaCode == id && c.MaxPalletQuantity == 0);
                }
                else if (type == "shelf")
                {
                    cells = cellQuery.Where(c => c.Shelf.ShelfCode == id && c.MaxPalletQuantity == 0);
                }
                else if (type == "cell")
                {
                    cells = cellQuery.Where(c => c.CellCode == id && c.MaxPalletQuantity == 0);
                }
                var sCells = cells.Join(storages, c => c.CellCode, s => s.CellCode, (c, s) => new { cells = c, storages = s }).ToArray();
                if (sCells.Count() > 0)
                {
                    var Cell = sCells.Select(c => new
                    {
                        cellCode      = c.cells.CellCode,
                        cellName      = c.cells.CellName,
                        productCode   = string.IsNullOrEmpty(c.storages.ProductCode) == true ? "" : c.storages.ProductCode,
                        productName   = c.storages.Product == null ? "" : c.storages.Product.ProductName,
                        shelfCode     = c.cells.ShelfCode,
                        unitCode      = c.storages.Product == null ? "" : c.storages.Product.Unit.UnitCode,
                        unitName      = c.storages.Product == null ? "" : c.storages.Product.Unit.UnitName,
                        maxQuantity   = c.cells.MaxQuantity,
                        asdd1         = c.cells.CellCode.Substring(4, 2),  //区
                        asdd2         = c.cells.CellCode.Substring(8, 2),  //货架
                        asdd3         = c.cells.CellCode.Substring(14, 1), //层
                        asdd4         = c.cells.CellCode.Substring(11, 2), //列
                        Quantity      = c.storages.Product == null ? 0 : c.storages.Quantity / c.storages.Product.Unit.Count,
                        EmptyQuantity = c.storages.Product == null ? c.cells.MaxQuantity : c.cells.MaxQuantity - c.storages.Quantity / c.storages.Product.Unit.Count,
                        IsActive      = c.cells.IsActive == "1" ? "可用" : "不可用",
                        UpdateTime    = c.storages.UpdateTime.ToString("yyyy-MM-dd")
                    }).OrderByDescending(c => c.asdd4).OrderByDescending(c => c.asdd3).OrderByDescending(c => c.asdd2).OrderByDescending(c => c.asdd1);

                    return(Cell.ToArray());
                }
                else
                {
                    var s = "".ToArray();
                    return(s);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #4
0
        /// <summary>
        /// 根据参数Code查询货位信息
        /// </summary>
        /// <param name="cellCode">货位Code</param>
        /// <returns></returns>
        public object FindCell(string cellCode)
        {
            IQueryable <Cell> cellQuery = CellRepository.GetQueryable();
            var cell = cellQuery.Where(c => c.CellCode == cellCode).OrderBy(b => b.CellCode).AsEnumerable()
                       .Select(b => new { b.CellCode, b.CellName, b.CellType, b.ShortName, b.Rfid, b.Layer, b.Col, b.ImgX, b.ImgY, b.IsSingle, b.MaxQuantity, b.Description, b.Warehouse.WarehouseName, b.Warehouse.WarehouseCode, b.Area.AreaCode, b.Area.AreaName, b.Shelf.ShelfCode, b.Shelf.ShelfName, DefaultProductCode = b.Product == null ? string.Empty : b.Product.ProductCode, ProductName = b.Product == null ? string.Empty : b.Product.ProductName, IsActive = b.IsActive == "1" ? "可用" : "不可用", UpdateTime = b.UpdateTime.ToString("yyyy-MM-dd hh:mm:ss") });

            return(cell.First(c => c.CellCode == cellCode));
        }
Пример #5
0
        public object GetDetails(int page, int rows, string cellCode)
        {
            IQueryable <Cell> cellQuery = CellRepository.GetQueryable();
            var cell  = cellQuery.OrderBy(b => b.CellCode).AsEnumerable().Select(b => new { b.CellCode, b.CellName, b.CellType, b.ShortName, b.Rfid, b.Layer, b.Col, b.ImgX, b.ImgY, b.IsSingle, b.MaxQuantity, b.Description, b.Warehouse.WarehouseName, b.Warehouse.WarehouseCode, b.Area.AreaCode, b.Area.AreaName, b.Shelf.ShelfCode, b.Shelf.ShelfName, IsActive = b.IsActive == "1" ? "可用" : "不可用", UpdateTime = b.UpdateTime.ToString("yyyy-MM-dd hh:mm:ss") });
            int total = cell.Count();

            cell = cell.Skip((page - 1) * rows).Take(rows);
            return(new { total, rows = cell.ToArray() });
        }
Пример #6
0
        /// <summary>
        /// 修改损益细单
        /// </summary>
        /// <param name="profitLossBillDetail">损益细单</param>
        /// <returns></returns>
        public bool Save(ProfitLossBillDetail profitLossBillDetail, out string strResult)
        {
            strResult = string.Empty;
            bool result = false;

            try
            {
                IQueryable <ProfitLossBillDetail> profitLossBillDetailQuery = ProfitLossBillDetailRepository.GetQueryable();
                var pbd     = profitLossBillDetailQuery.FirstOrDefault(i => i.ID == profitLossBillDetail.ID && i.BillNo == profitLossBillDetail.BillNo);
                var unit    = UnitRepository.GetQueryable().FirstOrDefault(u => u.UnitCode == profitLossBillDetail.UnitCode);
                var cell    = CellRepository.GetQueryable().FirstOrDefault(c => c.CellCode == profitLossBillDetail.CellCode);
                var product = ProductRepository.GetQueryable().FirstOrDefault(p => p.ProductCode == pbd.ProductCode);
                var storage = StorageRepository.GetQueryable().FirstOrDefault(s => s.StorageCode == pbd.StorageCode);
                if (Locker.LockStorage(storage, product) != null)
                {
                    if (IsQuntityRight(profitLossBillDetail.Quantity * unit.Count, storage.InFrozenQuantity - Math.Abs(pbd.Quantity), storage.OutFrozenQuantity - Math.Abs(pbd.Quantity), cell.MaxQuantity * unit.Count, storage.Quantity))
                    {
                        pbd.CellCode    = profitLossBillDetail.CellCode;
                        pbd.StorageCode = profitLossBillDetail.StorageCode;
                        pbd.ProductCode = profitLossBillDetail.ProductCode;
                        pbd.UnitCode    = profitLossBillDetail.UnitCode;
                        pbd.Price       = profitLossBillDetail.Price;
                        //原来的数量撤销
                        if (pbd.Quantity > 0)
                        {
                            storage.InFrozenQuantity -= pbd.Quantity;
                        }
                        else
                        {
                            storage.OutFrozenQuantity -= Math.Abs(pbd.Quantity);
                        }
                        //新的数量生效
                        if (profitLossBillDetail.Quantity > 0)
                        {
                            storage.InFrozenQuantity += profitLossBillDetail.Quantity * unit.Count;
                        }
                        else
                        {
                            storage.OutFrozenQuantity += Math.Abs(profitLossBillDetail.Quantity * unit.Count);
                        }
                        pbd.Quantity    = profitLossBillDetail.Quantity * unit.Count;
                        pbd.Description = profitLossBillDetail.Description;
                        ProfitLossBillDetailRepository.SaveChanges();
                        result = true;
                    }
                }
                strResult = resultStr;
            }
            catch (Exception ex)
            {
                strResult = "修改失败,原因:" + ex.Message;
            }
            return(result);
        }
Пример #7
0
        /// <summary>修改货位</summary>
        public bool SaveCell(string wareCodes, string areaCodes, string shelfCodes, string cellCodes, string defaultProductCode, string editType)
        {
            try
            {
                IQueryable <Cell> cellQuery = CellRepository.GetQueryable();

                if (wareCodes != string.Empty && wareCodes != null)
                {
                    wareCodes = wareCodes.Substring(0, wareCodes.Length - 1);
                }
                else if (areaCodes != string.Empty && areaCodes != null)
                {
                    areaCodes = areaCodes.Substring(0, areaCodes.Length - 1);
                }
                else if (shelfCodes != string.Empty && shelfCodes != null)
                {
                    shelfCodes = shelfCodes.Substring(0, shelfCodes.Length - 1);
                }
                else if (cellCodes != string.Empty && cellCodes != null)
                {
                    cellCodes = cellCodes.Substring(0, cellCodes.Length - 1);
                }

                if (editType == "edit")
                {
                    CellRepository.GetObjectSet()
                    .UpdateEntity(
                        c => c.DefaultProductCode == defaultProductCode,
                        c => new Cell()
                    {
                        DefaultProductCode = null
                    }
                        );
                }
                CellRepository.GetObjectSet()
                .UpdateEntity(
                    c => wareCodes.Contains(c.Warehouse.WarehouseCode) ||
                    areaCodes.Contains(c.Area.AreaCode) ||
                    shelfCodes.Contains(c.ShelfCode) ||
                    cellCodes.Contains(c.CellCode),
                    c => new Cell()
                {
                    DefaultProductCode = defaultProductCode
                }
                    );
                return(true);
            }catch (Exception e)
            {
                return(false);
            }
        }
Пример #8
0
        /// <summary>查找卷烟信息</summary>
        public object GetCellInfo(string productCode)
        {
            IQueryable <Cell> cellQuery = CellRepository.GetQueryable();
            var cellInfo = cellQuery.Where(c1 => c1.Product != null && c1.DefaultProductCode == productCode)
                           .GroupBy(c => c.Product)
                           .Select(c => new
            {
                ProductCode     = c.Key.ProductCode,
                ProductName     = c.Key.ProductName,
                ProductQuantity = c.Count()
            });

            return(cellInfo);
        }
Пример #9
0
        public System.Data.DataTable GetCellPosition(int page, int rows, CellPosition cp)
        {
            IQueryable <CellPosition> cellPositionQuery = CellPositionRepository.GetQueryable();
            IQueryable <Position>     positionQuery     = PositionRepository.GetQueryable();
            IQueryable <Cell>         cellQuery         = CellRepository.GetQueryable();

            var cellPosition = cellPositionQuery.Join(positionQuery,
                                                      c => c.StockInPositionID,
                                                      p1 => p1.ID,
                                                      (c, p1) => new { c.ID, c.CellCode, c.StockInPositionID, c.StockOutPositionID, InName = p1.PositionName })
                               .Join(positionQuery,
                                     c => c.StockOutPositionID,
                                     p2 => p2.ID,
                                     (c, p2) => new { c.ID, c.CellCode, c.StockInPositionID, c.StockOutPositionID, c.InName, OutName = p2.PositionName })
                               .Join(cellQuery,
                                     c => c.CellCode,
                                     cq => cq.CellCode,
                                     (c, cq) => new { c.ID, c.CellCode, c.StockInPositionID, c.StockOutPositionID, CellName = cq.CellName, c.InName, c.OutName }
                                     )
                               .Where(p => p.CellCode.Contains(cp.CellCode))
                               .OrderBy(p => p.ID).AsEnumerable()
                               .Select(p => new
            {
                p.ID,
                p.CellCode,
                p.InName,
                p.OutName,
                p.CellName
            });

            System.Data.DataTable dt = new System.Data.DataTable();
            dt.Columns.Add("货位ID", typeof(string));
            dt.Columns.Add("货位代码", typeof(string));
            dt.Columns.Add("货位名称", typeof(string));
            dt.Columns.Add("入库位置", typeof(string));
            dt.Columns.Add("出库位置", typeof(string));
            foreach (var item in cellPosition)
            {
                dt.Rows.Add
                (
                    item.ID,
                    item.CellCode,
                    item.CellName,
                    item.InName,
                    item.OutName
                );
            }
            return(dt);
        }
Пример #10
0
        /// <summary>加载卷烟信息</summary>
        public object GetCellInfo()
        {
            IQueryable <Cell> cellQuery = CellRepository.GetQueryable();

            var cellInfo = cellQuery.Where(c1 => c1.Product != null)
                           .GroupBy(c2 => c2.Product)
                           .Select(c3 => new
            {
                ProductCode     = c3.Key.ProductCode,
                ProductName     = c3.Key.ProductName,
                ProductQuantity = c3.Count()
            });

            return(cellInfo);
        }
Пример #11
0
        /// <summary>
        /// 新增损益单明细
        /// </summary>
        /// <param name="profitLossBillDetail">损益单细表</param>
        /// <returns></returns>
        public bool Add(ProfitLossBillDetail profitLossBillDetail, out string strResult)
        {
            bool result = false;

            try
            {
                IQueryable <ProfitLossBillDetail> profitLossBillDetailQuery = ProfitLossBillDetailRepository.GetQueryable();
                var unit    = UnitRepository.GetQueryable().FirstOrDefault(u => u.UnitCode == profitLossBillDetail.UnitCode);
                var cell    = CellRepository.GetQueryable().FirstOrDefault(c => c.CellCode == profitLossBillDetail.CellCode);
                var product = ProductRepository.GetQueryable().FirstOrDefault(p => p.ProductCode == profitLossBillDetail.ProductCode);
                var storage = StorageRepository.GetQueryable().FirstOrDefault(s => s.StorageCode == profitLossBillDetail.StorageCode);
                if (Locker.LockStorage(storage, product) != null)
                {
                    if (IsQuntityRight(profitLossBillDetail.Quantity * unit.Count, storage.InFrozenQuantity, storage.OutFrozenQuantity, cell.MaxQuantity * unit.Count, storage.Quantity))
                    {
                        var pbd = new ProfitLossBillDetail();
                        pbd.BillNo      = profitLossBillDetail.BillNo;
                        pbd.CellCode    = profitLossBillDetail.CellCode;
                        pbd.StorageCode = profitLossBillDetail.StorageCode;
                        pbd.ProductCode = profitLossBillDetail.ProductCode;
                        pbd.UnitCode    = profitLossBillDetail.UnitCode;
                        pbd.Price       = profitLossBillDetail.Price;
                        pbd.Quantity    = profitLossBillDetail.Quantity * unit.Count;
                        pbd.Description = profitLossBillDetail.Description;
                        if (profitLossBillDetail.Quantity > 0)
                        {
                            storage.InFrozenQuantity += profitLossBillDetail.Quantity * unit.Count;
                        }
                        else
                        {
                            storage.OutFrozenQuantity += Math.Abs(profitLossBillDetail.Quantity * unit.Count);
                        }

                        ProfitLossBillDetailRepository.Add(pbd);
                        ProfitLossBillDetailRepository.SaveChanges();
                        storage.LockTag = string.Empty;
                        StorageRepository.SaveChanges();
                        result = true;
                    }
                }
                strResult = resultStr == "" ? "该库存的当前库存-出库冻结量小于0或者已经处于编辑状态!" : resultStr;
            }
            catch (Exception ex)
            {
                strResult = "新增失败,原因:" + ex.Message;
            }
            return(result);
        }
Пример #12
0
        /// <summary>
        /// 修改移库细单
        /// </summary>
        /// <param name="moveBillDetail"></param>
        /// <returns></returns>
        public bool Save(MoveBillDetail moveBillDetail, out string strResult)
        {
            bool result = false;
            IQueryable <MoveBillDetail> moveBillDetailQuery = MoveBillDetailRepository.GetQueryable();
            var mbd        = moveBillDetailQuery.FirstOrDefault(i => i.ID == moveBillDetail.ID && i.BillNo == moveBillDetail.BillNo);
            var unit       = UnitRepository.GetQueryable().FirstOrDefault(u => u.UnitCode == moveBillDetail.UnitCode);
            var outStorage = StorageRepository.GetQueryable().FirstOrDefault(s => s.StorageCode == mbd.OutStorageCode);
            var inStorage  = StorageRepository.GetQueryable().FirstOrDefault(s => s.StorageCode == mbd.InStorageCode);
            var product    = ProductRepository.GetQueryable().FirstOrDefault(p => p.ProductCode == mbd.ProductCode);
            var outCell    = CellRepository.GetQueryable().FirstOrDefault(c => c.CellCode == moveBillDetail.OutCellCode);
            var inCell     = CellRepository.GetQueryable().FirstOrDefault(c => c.CellCode == moveBillDetail.InCellCode);
            //判断移出数量是否合理
            bool isOutQuantityRight = IsQuntityRight(moveBillDetail.RealQuantity, outStorage.InFrozenQuantity, outStorage.OutFrozenQuantity - mbd.RealQuantity, outCell.MaxQuantity, outStorage.Quantity, "out");
            //判断移入数量是否合理
            bool isInQuantityRight = IsQuntityRight(moveBillDetail.RealQuantity, inStorage.InFrozenQuantity - mbd.RealQuantity, inStorage.OutFrozenQuantity, inCell.MaxQuantity, inStorage.Quantity, "in");

            if (Locker.LockStorage(outStorage, product) != null)
            {
                if (Locker.LockStorage(inStorage, product) != null)
                {
                    if (isOutQuantityRight && isInQuantityRight)
                    {
                        mbd.ProductCode               = moveBillDetail.ProductCode;
                        mbd.OutCellCode               = moveBillDetail.OutCellCode;
                        mbd.OutStorageCode            = moveBillDetail.OutStorageCode;
                        mbd.InCellCode                = moveBillDetail.InCellCode;
                        mbd.InStorageCode             = moveBillDetail.InStorageCode;
                        mbd.UnitCode                  = moveBillDetail.UnitCode;
                        mbd.RealQuantity              = moveBillDetail.RealQuantity * unit.Count;
                        outStorage.OutFrozenQuantity += moveBillDetail.RealQuantity * unit.Count;
                        inStorage.InFrozenQuantity   += moveBillDetail.RealQuantity * unit.Count;
                        mbd.Status = "0";
                        MoveBillDetailRepository.SaveChanges();
                        result = true;
                    }
                }
                else
                {
                    resultStr = "加锁移入库存失败,当前库存已有人在操作!";
                }
            }
            else
            {
                resultStr = "加锁移出库存失败,当前库存已有人在操作!";
            }
            strResult = resultStr;
            return(result);
        }
Пример #13
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);
        }
Пример #14
0
        public object GetDetail(string type, string id)
        {
            IQueryable <CMD_SHELF> shelfQuery = ShelfRepository.GetQueryable();
            IQueryable <CMD_CELL>  cellQuery  = CellRepository.GetQueryable();
            var shelf = shelfQuery.OrderBy(b => b.SHELF_CODE).AsEnumerable().Select(b => new { b.SHELF_CODE, b.SHELF_NAME, b.ROW_COUNT, b.COLUMN_COUNT, b.WAREHOUSE_CODE, b.AREA_CODE, b.CRANE_NO, b.MEMO, b.STATION_NO });

            if (type == "shelf")
            {
                shelf = shelf.Where(s => s.SHELF_CODE == id);
            }
            else if (type == "cell")
            {
                var shelfCode = cellQuery.Where(c => c.CELL_CODE == id).Select(c => new { c.SHELF_CODE }).ToArray();
                shelf = shelf.Where(s => s.SHELF_CODE == shelfCode[0].SHELF_CODE);
            }
            return(shelf.ToArray());
        }
Пример #15
0
        public object GetDetail(string type, string id)
        {
            IQueryable <Shelf> shelfQuery = ShelfRepository.GetQueryable();
            IQueryable <Cell>  cellQuery  = CellRepository.GetQueryable();
            var shelf = shelfQuery.OrderBy(b => b.ShelfCode).AsEnumerable().Select(b => new { b.ShelfCode, b.ShelfName, b.ShelfType, b.ShortName, b.CellCols, b.CellRows, b.ImgX, b.ImgY, b.Description, b.Area.AreaCode, b.Area.AreaName, b.Warehouse.WarehouseCode, b.Warehouse.WarehouseName, IsActive = b.IsActive == "1" ? "可用" : "不可用", UpdateTime = b.UpdateTime.ToString("yyyy-MM-dd hh:mm:ss") });

            if (type == "shelf")
            {
                shelf = shelf.Where(s => s.ShelfCode == id);
            }
            else if (type == "cell")
            {
                var shelfCode = cellQuery.Where(c => c.CellCode == id).Select(c => new { c.ShelfCode }).ToArray();
                shelf = shelf.Where(s => s.ShelfCode == shelfCode[0].ShelfCode);
            }
            return(shelf.ToArray());
        }
Пример #16
0
        /// <summary>
        /// 查询库区,用于分拣设置货位
        /// </summary>
        /// <param name="areaType">库区类型</param>
        /// <returns></returns>
        public object GetSortCell(string areaType)
        {
            var areas = AreaRepository.GetQueryable().Where(a => a.AreaType == areaType)
                        .OrderBy(a => a.AreaCode).Select(a => a);
            HashSet <Tree> areaSet = new HashSet <Tree>();

            foreach (var area in areas)//库区
            {
                Tree areaTree = new Tree();
                areaTree.id         = area.AreaCode;
                areaTree.text       = "库区:" + area.AreaName;
                areaTree.state      = "open";
                areaTree.attributes = "area";

                var shelfs = ShelfRepository.GetQueryable().Where(s => s.Area.AreaCode == area.AreaCode)
                             .OrderBy(s => s.ShelfCode).Select(s => s);
                HashSet <Tree> shelfSet = new HashSet <Tree>();
                foreach (var shelf in shelfs)//货架
                {
                    Tree shelfTree = new Tree();
                    shelfTree.id         = shelf.ShelfCode;
                    shelfTree.text       = "货架:" + shelf.ShelfName;
                    shelfTree.attributes = "shelf";


                    var cells = CellRepository.GetQueryable().Where(c => c.Shelf.ShelfCode == shelf.ShelfCode)
                                .OrderBy(c => c.CellCode).Select(c => c);
                    HashSet <Tree> cellSet = new HashSet <Tree>();
                    foreach (var cell in cells)//货位
                    {
                        Tree cellTree = new Tree();
                        cellTree.id         = cell.CellCode;
                        cellTree.text       = cell.CellName;
                        cellTree.state      = "open";
                        cellTree.attributes = "cell";
                        cellSet.Add(cellTree);
                    }
                    shelfTree.children = cellSet.ToArray();
                    shelfSet.Add(shelfTree);
                }
                areaTree.children = shelfSet.ToArray();
                areaSet.Add(areaTree);
            }
            return(areaSet.ToArray());
        }
Пример #17
0
        public bool Save(CellPosition cellPosition)
        {
            IQueryable <Cell>     cellQuery     = CellRepository.GetQueryable();
            IQueryable <Position> positionQuery = PositionRepository.GetQueryable();
            var cell = cellQuery.FirstOrDefault(p => p.CellCode == cellPosition.CellCode);
            var c    = CellPositionRepository.GetQueryable().FirstOrDefault(s => s.ID == cellPosition.ID);

            //var position = positionQuery.FirstOrDefault(po => po.ID == cellPosition.ID);
            if (c != null)
            {
                c.ID                 = cellPosition.ID;
                c.CellCode           = cellPosition.CellCode;
                c.StockInPositionID  = cellPosition.StockInPositionID;
                c.StockOutPositionID = cellPosition.StockOutPositionID;
                CellPositionRepository.SaveChanges();
            }

            return(true);
        }
Пример #18
0
        public object GetCell()
        {
            DataTable            dt           = new DataTable();
            IQueryable <Area>    AreaQuery    = AreaRepository.GetQueryable();
            IQueryable <Storage> StorageQuery = StorageRepository.GetQueryable();
            IQueryable <Cell>    CellQuery    = CellRepository.GetQueryable();
            var storageQuantity = StorageQuery.Join(AreaQuery, s => s.Cell.AreaCode, a => a.AreaCode, (s, a) => new { storage = s, area = a });
            var CellInfo        = AreaQuery.Join(CellQuery, s => s.AreaCode, c => c.AreaCode, (s, c) => new { Storage = s, cell = c });
            var CellInfos       = CellInfo.GroupBy(s => s.cell.AreaCode)
                                  .Select(s => new
            {
                areaName  = s.Max(t => t.cell.Area.AreaName),
                enableQty = storageQuantity.AsEnumerable().Where(t => t.area.AreaCode == s.Max(m => m.cell.AreaCode)).Count(t => t.storage.Quantity > 0 || t.storage.InFrozenQuantity > 0 || t.storage.OutFrozenQuantity > 0),
                totalQty  = s.Where(t => t.cell.IsActive == "0" && t.cell.MaxPalletQuantity > 0).Sum(t => t.cell.MaxPalletQuantity) > 0?s.Where(t => t.cell.IsActive == "0" && t.cell.MaxPalletQuantity > 0).Sum(t => t.cell.MaxPalletQuantity):0 + s.Where(t => t.cell.IsActive == "0" && t.cell.MaxPalletQuantity == 0).Count(t => t.cell.IsActive == "0"),
                totalQtys = s.Where(t => t.cell.IsActive == "1" && t.cell.MaxPalletQuantity > 0).Sum(t => t.cell.MaxPalletQuantity) > 0 ? s.Where(t => t.cell.IsActive == "1" && t.cell.MaxPalletQuantity > 0).Sum(t => t.cell.MaxPalletQuantity) : 0 + s.Where(t => t.cell.IsActive == "1" && t.cell.MaxPalletQuantity == 0).Count(t => t.cell.IsActive == "1")
            });

            return(CellInfos);
        }
Пример #19
0
        public object GetDetail(string type, string id)
        {
            IQueryable <Area>  areaQuery  = AreaRepository.GetQueryable();
            IQueryable <Shelf> shelfQuery = ShelfRepository.GetQueryable();
            IQueryable <Cell>  cellQuery  = CellRepository.GetQueryable();
            var area = areaQuery.OrderBy(b => b.AreaCode).AsEnumerable().Select(b => new { b.AreaCode, b.AreaName, b.AreaType, b.ShortName, b.AllotInOrder, b.AllotOutOrder, b.Description, b.Warehouse.WarehouseCode, b.Warehouse.WarehouseName, IsActive = b.IsActive == "1" ? "可用" : "不可用", UpdateTime = b.UpdateTime.ToString("yyyy-MM-dd hh:mm:ss") });

            if (type == "shelf")
            {
                var areaCode = shelfQuery.Where(s => s.ShelfCode == id).Select(s => new{ s.AreaCode }).ToArray();
                area = area.Where(a => a.AreaCode == areaCode[0].AreaCode);
            }
            else if (type == "cell")
            {
                var areaCode = cellQuery.Where(c => c.CellCode == id).Select(c => new { c.AreaCode }).ToArray();
                area = area.Where(a => a.AreaCode == areaCode[0].AreaCode);
            }
            else if (type == "area")
            {
                area = area.Where(a => a.AreaCode == id);
            }
            return(area.ToArray());
        }
Пример #20
0
        /// <summary>
        /// 仓库设置点击货架查询货架的货位信息
        /// </summary>
        /// <param name="shelfCode">货架Code</param>
        /// <returns></returns>
        public object GetCell(string shelfCode)
        {
            HashSet <WareTree> wareSet = new HashSet <WareTree>();
            var cells = CellRepository.GetQueryable().Where(c => c.Shelf.ShelfCode == shelfCode)
                        .OrderBy(c => c.CellCode).Select(c => c);

            foreach (var cell in cells)//货位
            {
                WareTree cellTree = new WareTree();
                cellTree.Code     = cell.CellCode;
                cellTree.Name     = "货位:" + cell.CellName;
                cellTree.CellCode = cell.CellCode;
                cellTree.CellName = cell.CellName;

                cellTree.WarehouseCode = cell.Warehouse.WarehouseCode;
                cellTree.WarehouseName = cell.Warehouse.WarehouseName;

                cellTree.AreaCode = cell.Area.AreaCode;
                cellTree.AreaName = cell.Area.AreaName;

                cellTree.ShelfCode = cell.Shelf.ShelfCode;
                cellTree.ShelfName = cell.Shelf.ShelfName;

                cellTree.Type        = cell.CellType;
                cellTree.Description = cell.Description;
                cellTree.IsActive    = cell.IsActive == "1" ? "可用" : "不可用";
                cellTree.UpdateTime  = cell.UpdateTime.ToString("yyyy-MM-dd hh:mm:ss");
                cellTree.ShortName   = cell.ShortName;
                cellTree.Layer       = cell.Layer;
                cellTree.MaxQuantity = cell.MaxQuantity;
                cellTree.ProductName = cell.Product == null ? string.Empty : cell.Product.ProductName;
                cellTree.attributes  = "cell";

                wareSet.Add(cellTree);
            }
            return(wareSet);
        }
Пример #21
0
        public object GetDetails(int page, int rows, string CellCode, string CellName, string StockInPosition, string StockOutPosition)
        {
            IQueryable <CellPosition> cellPositionQuery = CellPositionRepository.GetQueryable();
            IQueryable <Position>     positionQuery     = PositionRepository.GetQueryable();
            IQueryable <Cell>         cellQuery         = CellRepository.GetQueryable();

            var cellPosition = cellPositionQuery.Join(positionQuery,
                                                      c => c.StockInPositionID,
                                                      p1 => p1.ID,
                                                      (c, p1) => new { c.ID, c.CellCode, c.StockInPositionID, c.StockOutPositionID, InName = p1.PositionName })
                               .Join(positionQuery,
                                     c => c.StockOutPositionID,
                                     p2 => p2.ID,
                                     (c, p2) => new { c.ID, c.CellCode, c.StockInPositionID, c.StockOutPositionID, c.InName, OutName = p2.PositionName })
                               .Join(cellQuery,
                                     c => c.CellCode,
                                     cq => cq.CellCode,
                                     (c, cq) => new { c.ID, c.CellCode, c.StockInPositionID, c.StockOutPositionID, CellName = cq.CellName, c.InName, c.OutName }
                                     )
                               .Where(p => p.CellCode.Contains(CellCode) && p.CellName.Contains(CellName) && p.InName.Contains(StockInPosition) && p.OutName.Contains(StockOutPosition))
                               .OrderBy(p => p.ID).AsEnumerable()
                               .Select(p => new
            {
                p.ID,
                p.CellCode,
                p.StockInPositionID,
                p.InName,
                p.StockOutPositionID,
                p.OutName,
                p.CellName
            });

            int total = cellPosition.Count();

            cellPosition = cellPosition.Skip((page - 1) * rows).Take(rows);
            return(new { total, rows = cellPosition.ToArray() });
        }
Пример #22
0
        public object GetDetail(int page, int rows, string type, string id)
        {
            IQueryable <Warehouse> wareQuery  = WarehouseRepository.GetQueryable();
            IQueryable <Shelf>     shelfQuery = ShelfRepository.GetQueryable();
            IQueryable <Area>      areaQuery  = AreaRepository.GetQueryable();
            IQueryable <Cell>      cellQuery  = CellRepository.GetQueryable();
            var warehouse = wareQuery.OrderBy(b => b.WarehouseCode).AsEnumerable().Select(b => new { b.WarehouseCode, b.WarehouseName, b.WarehouseType, b.Description, b.ShortName, IsActive = b.IsActive == "1" ? "可用" : "不可用", UpdateTime = b.UpdateTime.ToString("yyyy-MM-dd hh:mm:ss") });

            if (type == "ware")
            {
                warehouse = warehouse.Where(w => w.WarehouseCode == id);
            }
            else if (type == "area")
            {
                var WarehouseCode = areaQuery.Where(a => a.AreaCode == id).Select(a => new { a.WarehouseCode }).ToArray();
                warehouse = warehouse.Where(w => w.WarehouseCode == WarehouseCode[0].WarehouseCode);
            }
            else if (type == "shelf")
            {
                var WarehouseCode = shelfQuery.Where(s => s.ShelfCode == id).Select(s => new { s.WarehouseCode }).ToArray();
                warehouse = warehouse.Where(w => w.WarehouseCode == WarehouseCode[0].WarehouseCode);
            }
            else if (type == "cell")
            {
                var WarehouseCode = cellQuery.Where(c => c.CellCode == id).Select(c => new { c.WarehouseCode }).ToArray();
                warehouse = warehouse.Where(w => w.WarehouseCode == WarehouseCode[0].WarehouseCode);
            }
            else
            {
                warehouse = warehouse.Select(w => w);
            }
            int total = warehouse.Count();

            warehouse = warehouse.Skip((page - 1) * rows).Take(rows);
            return(new { total, rows = warehouse.ToArray() });
        }
Пример #23
0
        public object GetCellBy(int page, int rows, string QueryString, string Value)
        {
            string productCode = "", productName = "";

            if (QueryString == "ProductCode")
            {
                productCode = Value;
            }
            else
            {
                productName = Value;
            }
            IQueryable <Cell> cellQuery = CellRepository.GetQueryable();
            var cell = cellQuery.Where(c => c.Product != null && c.DefaultProductCode.Contains(productCode) && c.Product.ProductName.Contains(productName))
                       .GroupBy(c => c.Product)
                       .Select(c => new
            {
                ProductCode     = c.Key.ProductCode,
                ProductName     = c.Key.ProductName,
                ProductQuantity = c.Count()
            });

            return(cell);
        }
Пример #24
0
        /// <summary>
        /// 修改移库细单
        /// </summary>
        /// <param name="moveBillDetail"></param>
        /// <returns></returns>
        public bool Save(MoveBillDetail moveBillDetail, out string strResult)
        {
            bool    result            = false;
            decimal inFrozenQuantity  = 0;
            decimal outFrozenQuantity = 0;

            if (moveBillDetail.OutCellCode == moveBillDetail.InCellCode)
            {
                strResult = "移入和移出货位不能一样!";
                return(false);
            }
            IQueryable <MoveBillDetail> moveBillDetailQuery = MoveBillDetailRepository.GetQueryable();
            var     mbd     = moveBillDetailQuery.FirstOrDefault(i => i.ID == moveBillDetail.ID && i.BillNo == moveBillDetail.BillNo);
            var     unit    = UnitRepository.GetQueryable().FirstOrDefault(u => u.UnitCode == moveBillDetail.UnitCode);
            Product product = null;

            if (mbd.ProductCode == moveBillDetail.ProductCode)//判断用户选择的移库卷烟编码和之前保存的移库卷烟编码是否相等
            {
                product = ProductRepository.GetQueryable().FirstOrDefault(p => p.ProductCode == mbd.ProductCode);
            }
            else
            {
                product = ProductRepository.GetQueryable().FirstOrDefault(p => p.ProductCode == moveBillDetail.ProductCode);
            }
            var     outCell       = CellRepository.GetQueryable().FirstOrDefault(c => c.CellCode == moveBillDetail.OutCellCode);
            var     inCell        = CellRepository.GetQueryable().FirstOrDefault(c => c.CellCode == moveBillDetail.InCellCode);
            Storage outStorage    = null;
            Storage oldOutStorage = null;

            if (mbd.OutStorageCode == moveBillDetail.OutStorageCode)//判断用户选择的移出库存和之前保存的移出库存是否相等
            {
                outStorage        = StorageRepository.GetQueryable().FirstOrDefault(s => s.StorageCode == mbd.OutStorageCode);
                outFrozenQuantity = outStorage.OutFrozenQuantity - mbd.RealQuantity;
            }
            else
            {
                oldOutStorage     = StorageRepository.GetQueryable().FirstOrDefault(s => s.StorageCode == mbd.OutStorageCode);
                outStorage        = StorageRepository.GetQueryable().FirstOrDefault(s => s.StorageCode == moveBillDetail.OutStorageCode);
                outFrozenQuantity = outStorage.OutFrozenQuantity;
            }
            Storage inStorage    = null;
            Storage oldInStorage = null;

            if (mbd.InCellCode == moveBillDetail.InCellCode)//判断用户选择的移入货位和之前保存的移入货位是否相等
            {
                inStorage        = StorageRepository.GetQueryable().FirstOrDefault(s => s.StorageCode == mbd.InStorageCode);
                inFrozenQuantity = inStorage.InFrozenQuantity - mbd.RealQuantity;
            }
            else
            {
                oldInStorage = StorageRepository.GetQueryable().FirstOrDefault(s => s.StorageCode == mbd.InStorageCode);
                inStorage    = Locker.LockStorage(inCell);
                if (inStorage == null)
                {
                    strResult = "移入库存加锁失败!";
                    return(false);
                }
                inFrozenQuantity = inStorage.InFrozenQuantity;
            }
            if (inCell.IsSingle == "1")
            {
                if (inStorage.Product != null && inStorage.Product.ProductCode != moveBillDetail.ProductCode)
                {
                    strResult = "货位:<" + inCell.CellName + ">是非货位管理货位不能移入不同品牌的卷烟!";
                    return(false);
                }
            }
            //判断移出数量是否合理
            bool isOutQuantityRight = IsQuntityRight(moveBillDetail.RealQuantity * unit.Count, outStorage.InFrozenQuantity, outFrozenQuantity, outCell.MaxQuantity * product.Unit.Count, outStorage.Quantity, "out");

            if (Locker.LockStorage(outStorage, product) != null)
            {
                //if (Locker.LockStorage(inStorage, product) != null)
                //{
                //判断移入数量是否合理
                bool isInQuantityRight = IsQuntityRight(moveBillDetail.RealQuantity * unit.Count, inFrozenQuantity, inStorage.OutFrozenQuantity, inCell.MaxQuantity * product.Unit.Count, inStorage.Quantity, "in");
                if (isOutQuantityRight && isInQuantityRight)
                {
                    if (mbd.OutStorageCode == moveBillDetail.OutStorageCode)
                    {
                        outStorage.OutFrozenQuantity -= mbd.RealQuantity;
                        outStorage.OutFrozenQuantity += moveBillDetail.RealQuantity * unit.Count;
                    }
                    else
                    {
                        oldOutStorage.OutFrozenQuantity -= mbd.RealQuantity;
                        outStorage.OutFrozenQuantity    += moveBillDetail.RealQuantity * unit.Count;
                    }
                    if (mbd.InCellCode == moveBillDetail.InCellCode)
                    {
                        inStorage.InFrozenQuantity -= mbd.RealQuantity;
                        inStorage.InFrozenQuantity += moveBillDetail.RealQuantity * unit.Count;
                    }
                    else
                    {
                        oldInStorage.InFrozenQuantity -= mbd.RealQuantity;
                        inStorage.InFrozenQuantity    += moveBillDetail.RealQuantity * unit.Count;
                    }
                    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;
                    mbd.Status            = "0";
                    outStorage.LockTag    = string.Empty;
                    inStorage.LockTag     = string.Empty;
                    inStorage.ProductCode = product.ProductCode;
                    MoveBillDetailRepository.SaveChanges();
                    result = true;
                }
                //}
                //else
                //{
                //    resultStr = "加锁移入库存失败,当前库存已有人在操作!";
                //}
            }
            else
            {
                resultStr = "加锁移出库存失败,当前库存已有人在操作!";
            }
            strResult = resultStr;
            return(result);
        }
Пример #25
0
        /// <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);
        }
Пример #26
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 = ""
                    });
                }
            }
        }
Пример #27
0
        public bool AllotEdit(string billNo, long id, string cellCode, decimal allotQuantity, out string strResult)
        {
            bool result = false;
            var  ibm    = OutBillMasterRepository.GetQueryable().FirstOrDefault(i => i.BillNo == billNo && i.Status == "3");
            var  cell   = CellRepository.GetQueryable().Single(c => c.CellCode == cellCode);

            if (ibm != null)
            {
                if (string.IsNullOrEmpty(ibm.LockTag))
                {
                    var allotDetail = ibm.OutBillAllots.Single(a => a.ID == (int)id);
                    if (string.IsNullOrEmpty(allotDetail.Storage.LockTag))
                    {
                        Storage storage;
                        if (allotDetail.CellCode == cellCode)
                        {
                            storage = allotDetail.Storage;
                            storage.OutFrozenQuantity -= allotDetail.AllotQuantity;
                        }
                        else
                        {
                            storage = Locker.LockNoEmpty(cell, allotDetail.Product);
                            allotDetail.Storage.OutFrozenQuantity -= allotDetail.AllotQuantity;
                        }
                        if (storage != null)
                        {
                            decimal q1 = allotDetail.OutBillDetail.BillQuantity - allotDetail.OutBillDetail.AllotQuantity;
                            decimal q2 = allotQuantity * allotDetail.Unit.Count;
                            decimal q3 = storage.Quantity - storage.OutFrozenQuantity;
                            if (q1 >= q2 && q2 <= q3)
                            {
                                try
                                {
                                    allotDetail.OutBillDetail.AllotQuantity -= allotDetail.AllotQuantity;
                                    allotDetail.OutBillDetail.AllotQuantity += q2;
                                    storage.OutFrozenQuantity += q2;
                                    storage.LockTag            = string.Empty;
                                    allotDetail.CellCode       = storage.Cell.CellCode;
                                    allotDetail.StorageCode    = storage.StorageCode;
                                    allotDetail.AllotQuantity  = q2;
                                    OutBillAllotRepository.SaveChanges();
                                    strResult = "保存修改成功!";
                                    result    = true;
                                }
                                catch (Exception)
                                {
                                    strResult = "保存修改失败,订单或储位其他人正在操作!";
                                }
                            }
                            else
                            {
                                strResult = "分配数量超过订单数量,或者当前储位库存量不足!";
                            }
                        }
                        else
                        {
                            strResult = "当前选择的储位不可用,其他人正在操作或没有库存!";
                        }
                    }
                    else
                    {
                        strResult = "当前储位其他人正在操作,请稍候重试!";
                    }
                }
                else
                {
                    strResult = "当前订单其他人正在操作,请稍候重试!";
                }
            }
            else
            {
                strResult = "当前订单状态不是已分配,或当前订单不存在!";
            }
            return(result);
        }
Пример #28
0
        public bool AllotAdd(string billNo, long id, string cellCode, string productName, out string strResult, out decimal allotQuantity)
        {
            bool    result = false;
            var     ibm    = OutBillMasterRepository.GetQueryable().FirstOrDefault(i => i.BillNo == billNo);
            var     cell   = CellRepository.GetQueryable().Single(c => c.CellCode == cellCode);
            var     obm    = OutBillDetailRepository.GetQueryable().FirstOrDefault(o => o.ID == id);
            var     stor   = StorageRepository.GetQueryable().Single(c => c.CellCode == cellCode);
            decimal q1     = obm.BillQuantity - obm.AllotQuantity;

            allotQuantity = 0;
            if (ibm != null)
            {
                if (string.IsNullOrEmpty(ibm.LockTag))
                {
                    Storage storage = Locker.LockNoEmpty(cell, obm.Product);
                    if (storage != null)
                    {
                        if (stor.Product.ProductName == productName)
                        {
                            if (q1 > 0)
                            {
                                OutBillAllot billAllot = null;
                                decimal      q3        = storage.Quantity - storage.OutFrozenQuantity;
                                if (q1 <= q3)
                                {
                                    try
                                    {
                                        billAllot = new OutBillAllot()
                                        {
                                            BillNo          = billNo,
                                            OutBillDetailId = obm.ID,
                                            ProductCode     = obm.ProductCode,
                                            CellCode        = storage.CellCode,
                                            StorageCode     = storage.StorageCode,
                                            UnitCode        = obm.UnitCode,
                                            AllotQuantity   = q1,
                                            RealQuantity    = 0,
                                            Status          = "0"
                                        };
                                        allotQuantity              = (q3 - q1) / storage.Product.Unit.Count;
                                        obm.AllotQuantity         += q1;
                                        storage.OutFrozenQuantity += q1;
                                        ibm.OutBillAllots.Add(billAllot);
                                        ibm.Status      = "3";
                                        storage.LockTag = string.Empty;
                                        StorageRepository.SaveChanges();
                                        strResult = "保存修改成功!";
                                        result    = true;
                                    }
                                    catch (Exception)
                                    {
                                        strResult = "保存添加失败,订单或储位其他人正在操作!";
                                    }
                                }
                                else
                                {
                                    try
                                    {
                                        billAllot = new OutBillAllot()
                                        {
                                            BillNo          = billNo,
                                            OutBillDetailId = obm.ID,
                                            ProductCode     = obm.ProductCode,
                                            CellCode        = storage.CellCode,
                                            StorageCode     = storage.StorageCode,
                                            UnitCode        = obm.UnitCode,
                                            AllotQuantity   = q3,
                                            RealQuantity    = 0,
                                            Status          = "0"
                                        };
                                        obm.AllotQuantity         += q3;
                                        storage.OutFrozenQuantity += q3;
                                        ibm.OutBillAllots.Add(billAllot);
                                        ibm.Status      = "3";
                                        storage.LockTag = string.Empty;
                                        StorageRepository.SaveChanges();
                                        strResult = "保存修改成功!";
                                        result    = true;
                                    }
                                    catch (Exception)
                                    {
                                        strResult = "保存添加失败,订单或储位其他人正在操作!";
                                    }
                                }
                            }
                            else
                            {
                                strResult = "该产品已无分配任务!";
                            }
                        }
                        else
                        {
                            strResult = "该卷烟没有出库任务!";
                        }
                    }
                    else
                    {
                        strResult = "当前选择的储位不可用,其他人正在操作或没有库存!";
                    }
                }
                else
                {
                    strResult = "当前订单其他人正在操作,请稍候重试!";
                }
            }
            else
            {
                strResult = "当前订单状态不是已分配,或当前订单不存在!";
            }
            return(result);
        }
Пример #29
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 = ""
                    });
                }
            }
        }
Пример #30
0
        /// <summary>
        /// 移库时用的树形结构数据,可根据货架Code查询,根据移出的货位和移入的货位查询-移库单使用
        /// </summary>
        /// <param name="shelfCode">货架Code</param>
        /// <param name="inOrOut">移入还是移出</param>
        /// <param name="productCode">产品代码</param>
        /// <returns></returns>
        public object GetMoveCellDetails(string shelfCode, string inOrOut, string productCode)
        {
            var            warehouses = WarehouseRepository.GetQueryable().AsEnumerable();
            HashSet <Tree> wareSet    = new HashSet <Tree>();

            if (shelfCode == null || shelfCode == string.Empty) //判断是否是加载货位
            {
                foreach (var warehouse in warehouses)           //仓库
                {
                    Tree wareTree = new Tree();
                    wareTree.id         = warehouse.WarehouseCode;
                    wareTree.text       = "仓库:" + warehouse.WarehouseName;
                    wareTree.state      = "open";
                    wareTree.attributes = "ware";

                    var areas = AreaRepository.GetQueryable().Where(a => a.Warehouse.WarehouseCode == warehouse.WarehouseCode)
                                .OrderBy(a => a.AreaCode).Select(a => a);
                    HashSet <Tree> areaSet = new HashSet <Tree>();
                    foreach (var area in areas)//库区
                    {
                        Tree areaTree = new Tree();
                        areaTree.id         = area.AreaCode;
                        areaTree.text       = "库区:" + area.AreaName;
                        areaTree.state      = "open";
                        areaTree.attributes = "area";

                        var shelfs = ShelfRepository.GetQueryable().Where(s => s.Area.AreaCode == area.AreaCode)
                                     .OrderBy(s => s.ShelfCode).Select(s => s);
                        HashSet <Tree> shelfSet = new HashSet <Tree>();
                        foreach (var shelf in shelfs)//货架
                        {
                            Tree shelfTree = new Tree();
                            shelfTree.id         = shelf.ShelfCode;
                            shelfTree.text       = "货架:" + shelf.ShelfName;
                            shelfTree.attributes = "shelf";
                            shelfTree.state      = "closed";
                            shelfSet.Add(shelfTree);
                        }
                        areaTree.children = shelfSet.ToArray();
                        areaSet.Add(areaTree);
                    }
                    wareTree.children = areaSet.ToArray();
                    wareSet.Add(wareTree);
                }
            }
            else
            {
                var cells = CellRepository.GetQueryable().Where(c => c.CellCode == c.CellCode);
                if (inOrOut == "out")// 查询出可以移出卷烟的货位
                {
                    var storages = StorageRepository.GetQueryable().Where(s => (s.Quantity - s.OutFrozenQuantity) > 0 && string.IsNullOrEmpty(s.Cell.LockTag)).Select(s => s.CellCode);
                    cells = cells.Where(c => c.Shelf.ShelfCode == shelfCode && storages.Any(s => s == c.CellCode))
                            .OrderBy(s => s.CellCode);
                }
                else if (inOrOut == "in")//查询出可以移入卷烟的货位
                {
                    var storages = StorageRepository.GetQueryable().Where(s => s.Quantity == 0 ||
                                                                          (s.Cell.IsSingle == "1" && s.ProductCode == productCode && ((s.Cell.MaxQuantity * s.Product.Unit.Count) - s.InFrozenQuantity - s.Quantity) > 0) ||
                                                                          (s.Cell.IsSingle == "0" && string.IsNullOrEmpty(s.Cell.LockTag))).Select(s => s.CellCode);
                    cells = cells.Where(c => c.Shelf.ShelfCode == shelfCode && storages.Any(s => s == c.CellCode))
                            .OrderBy(c => c.CellCode).Select(c => c);
                }
                else if (inOrOut == "stockOut")//查询可以出库的数量 --出库使用
                {
                    var storages = StorageRepository.GetQueryable().Where(s => (s.Quantity - s.OutFrozenQuantity) > 0 &&
                                                                          string.IsNullOrEmpty(s.Cell.LockTag) &&
                                                                          s.ProductCode == productCode)
                                   .Select(s => s.CellCode);
                    cells = cells.Where(c => c.Shelf.ShelfCode == shelfCode && storages.Any(s => s == c.CellCode)).OrderBy(c => c.CellCode);
                }
                foreach (var cell in cells)//货位
                {
                    var  product  = ProductRepository.GetQueryable().FirstOrDefault(p => p.ProductCode == cell.DefaultProductCode);
                    Tree cellTree = new Tree();
                    cellTree.id         = cell.CellCode;
                    cellTree.text       = "货位:" + cell.CellName;
                    cellTree.state      = "open";
                    cellTree.attributes = "cell";
                    wareSet.Add(cellTree);
                }
            }
            return(wareSet.ToArray());
        }