Exemple #1
0
        /// <summary>
        /// 根据库区编码获取生成的货架编码
        /// </summary>
        /// <param name="areaCode">库区编码</param>
        /// <returns></returns>
        public object GetShelfCode(string areaCode)
        {
            string shelfCodeStr = "";
            IQueryable <CMD_SHELF> shelfQuery = ShelfRepository.GetQueryable();
            var shelfCode = shelfQuery.Where(s => s.AREA_CODE == areaCode).Max(s => s.SHELF_CODE);

            if (shelfCode == string.Empty || shelfCode == null)
            {
                shelfCodeStr = areaCode + "-001";
            }
            else
            {
                int i = Convert.ToInt32(shelfCode.ToString().Substring(areaCode.Length + 1, 3));
                i++;
                string newcode = i.ToString();
                if (newcode.Length <= 3)
                {
                    for (int j = 0; j < 3 - i.ToString().Length; j++)
                    {
                        newcode = "0" + newcode;
                    }
                    shelfCodeStr = areaCode + "-" + newcode;
                }
            }
            return(shelfCodeStr);
        }
Exemple #2
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);
        }
Exemple #3
0
        /// <summary>
        /// 根据参数Code查询货架信息
        /// </summary>
        /// <param name="shelfCode">货架Code</param>
        /// <returns></returns>
        public object FindShelf(string shelfCode)
        {
            IQueryable <Shelf> shelfQuery = ShelfRepository.GetQueryable();
            var shelf = shelfQuery.Where(s => s.ShelfCode == shelfCode).OrderBy(b => b.ShelfCode).AsEnumerable()
                        .Select(b => new { b.ShelfCode, b.ShelfName, b.ShelfType, b.CellCols, b.CellRows, b.ImgX, b.ImgY, b.ShortName, 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") });

            return(shelf.First(s => s.ShelfCode == shelfCode));
        }
Exemple #4
0
        /// <summary>
        /// 根据参数Code查询货架信息
        /// </summary>
        /// <param name="shelfCode">货架Code</param>
        /// <returns></returns>
        public object FindShelf(string shelfCode)
        {
            IQueryable <CMD_SHELF> shelfQuery = ShelfRepository.GetQueryable();
            var shelf = shelfQuery.Where(s => s.SHELF_CODE == shelfCode).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 });

            return(shelf.First(s => s.SHELF_CODE == shelfCode));
        }
Exemple #5
0
        public bool Delete(string shelfCode)
        {
            var shelf = ShelfRepository.GetQueryable()
                        .FirstOrDefault(s => s.SHELF_CODE == shelfCode);

            if (shelf != null)
            {
                //Del(CellRepository, shelf.Cells);
                ShelfRepository.Delete(shelf);
                ShelfRepository.SaveChanges();
            }
            else
            {
                return(false);
            }
            return(true);
        }
Exemple #6
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());
        }
Exemple #7
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());
        }
Exemple #8
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());
        }
Exemple #9
0
        public bool Save(CMD_SHELF shelf)
        {
            var shelfSave = ShelfRepository.GetQueryable().FirstOrDefault(s => s.SHELF_CODE == shelf.SHELF_CODE);
            var warehouse = WarehouseRepository.GetQueryable().FirstOrDefault(w => w.WAREHOUSE_CODE == shelf.WAREHOUSE_CODE);
            var area      = AreaRepository.GetQueryable().FirstOrDefault(a => a.AREA_CODE == shelf.AREA_CODE);

            shelfSave.SHELF_CODE     = shelf.SHELF_CODE;
            shelfSave.SHELF_NAME     = shelf.SHELF_NAME;
            shelfSave.STATION_NO     = shelf.STATION_NO;
            shelfSave.CRANE_NO       = shelf.CRANE_NO;
            shelfSave.ROW_COUNT      = shelf.ROW_COUNT;
            shelfSave.COLUMN_COUNT   = shelf.COLUMN_COUNT;
            shelfSave.WAREHOUSE_CODE = warehouse.WAREHOUSE_CODE;
            shelfSave.AREA_CODE      = area.AREA_CODE;
            shelfSave.MEMO           = shelf.MEMO;

            ShelfRepository.SaveChanges();
            return(true);
        }
Exemple #10
0
        public object GetDetails(string warehouseCode, string areaCode, string shelfCode)
        {
            IQueryable <Shelf> shelfQuery = ShelfRepository.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 (warehouseCode != null && warehouseCode != string.Empty)
            {
                shelf = shelf.Where(s => s.WarehouseCode == warehouseCode).OrderBy(s => s.ShelfCode).Select(s => s);
            }
            if (areaCode != null && areaCode != string.Empty)
            {
                shelf = shelf.Where(s => s.AreaCode == areaCode).OrderBy(s => s.ShelfCode).Select(s => s);
            }
            if (shelfCode != null && shelfCode != string.Empty)
            {
                shelf = shelf.Where(s => s.ShelfCode == shelfCode).OrderBy(s => s.ShelfCode).Select(s => s);
            }
            return(shelf.ToArray());
        }
Exemple #11
0
        public object GetDetails(string warehouseCode, string areaCode, string shelfCode)
        {
            IQueryable <CMD_SHELF> shelfQuery = ShelfRepository.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 (warehouseCode != null && warehouseCode != string.Empty)
            {
                shelf = shelf.Where(s => s.WAREHOUSE_CODE == warehouseCode).OrderBy(s => s.SHELF_CODE).Select(s => s);
            }
            if (areaCode != null && areaCode != string.Empty)
            {
                shelf = shelf.Where(s => s.AREA_CODE == areaCode).OrderBy(s => s.SHELF_CODE).Select(s => s);
            }
            if (shelfCode != null && shelfCode != string.Empty)
            {
                shelf = shelf.Where(s => s.SHELF_CODE == shelfCode).OrderBy(s => s.SHELF_CODE).Select(s => s);
            }
            return(shelf.ToArray());
        }
Exemple #12
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());
        }
Exemple #13
0
        public bool Save(Shelf shelf)
        {
            var shelfSave = ShelfRepository.GetQueryable().FirstOrDefault(s => s.ShelfCode == shelf.ShelfCode);
            var warehouse = WarehouseRepository.GetQueryable().FirstOrDefault(w => w.WarehouseCode == shelf.WarehouseCode);
            var area      = AreaRepository.GetQueryable().FirstOrDefault(a => a.AreaCode == shelf.AreaCode);

            shelfSave.ShelfCode   = shelfSave.ShelfCode;
            shelfSave.ShelfName   = shelf.ShelfName;
            shelfSave.ShortName   = shelf.ShortName;
            shelfSave.ShelfType   = shelf.ShelfType;
            shelfSave.CellCols    = shelf.CellCols;
            shelfSave.CellRows    = shelf.CellRows;
            shelfSave.ImgX        = shelf.ImgX;
            shelfSave.ImgY        = shelf.ImgY;
            shelfSave.Warehouse   = warehouse;
            shelfSave.Area        = area;
            shelfSave.Description = shelf.Description;
            shelfSave.IsActive    = shelf.IsActive;
            shelfSave.UpdateTime  = DateTime.Now;

            ShelfRepository.SaveChanges();
            return(true);
        }
Exemple #14
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() });
        }
Exemple #15
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());
        }
Exemple #16
0
        /// <summary>
        /// 盘点时用的树形结构数据,可根据货架Code查询
        /// </summary>
        /// <param name="shelfCode">货架Code</param>
        /// <returns></returns>
        public object GetWareCheck(string shelfCode)
        {
            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.Shelf.ShelfCode == shelfCode)
                            .OrderBy(c => c.CellCode).Select(c => c);
                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());
        }
Exemple #17
0
        /// <summary>
        /// 仓库设置时用的TreeGrid的树形结构,可根据仓库Code查询
        /// </summary>
        /// <param name="wareCode">仓库Code</param>
        /// <returns></returns>
        public object GetSearch(string wareCode)
        {
            var warehouses = WarehouseRepository.GetQueryable().AsEnumerable();

            if (wareCode != null && wareCode != string.Empty)
            {
                warehouses = warehouses.Where(w => w.WarehouseCode == wareCode);
            }

            HashSet <WareTree> wareSet = new HashSet <WareTree>();

            foreach (var warehouse in warehouses)//仓库
            {
                WareTree wareTree = new WareTree();
                wareTree.Code          = warehouse.WarehouseCode;
                wareTree.Name          = "仓库:" + warehouse.WarehouseName;
                wareTree.WarehouseCode = warehouse.WarehouseCode;
                wareTree.WarehouseName = warehouse.WarehouseName;
                wareTree.Type          = warehouse.WarehouseType;
                wareTree.Description   = warehouse.Description;
                wareTree.IsActive      = warehouse.IsActive == "1" ? "可用" : "不可用";
                wareTree.UpdateTime    = warehouse.UpdateTime.ToString("yyyy-MM-dd hh:mm:ss");
                wareTree.ShortName     = warehouse.ShortName;
                wareTree.attributes    = "ware";
                var areas = AreaRepository.GetQueryable().Where(a => a.Warehouse.WarehouseCode == warehouse.WarehouseCode)
                            .OrderBy(a => a.AreaCode).Select(a => a);
                HashSet <WareTree> areaSet = new HashSet <WareTree>();
                foreach (var area in areas)//库区
                {
                    WareTree areaTree = new WareTree();
                    areaTree.Code          = area.AreaCode;
                    areaTree.Name          = "库区:" + area.AreaName;
                    areaTree.AreaCode      = area.AreaCode;
                    areaTree.AreaName      = area.AreaName;
                    areaTree.WarehouseCode = area.Warehouse.WarehouseCode;
                    areaTree.WarehouseName = area.Warehouse.WarehouseName;
                    areaTree.Type          = area.AreaType;
                    areaTree.Description   = area.Description;
                    areaTree.IsActive      = area.IsActive == "1" ? "可用" : "不可用";
                    areaTree.UpdateTime    = area.UpdateTime.ToString("yyyy-MM-dd hh:mm:ss");
                    areaTree.ShortName     = area.ShortName;
                    areaTree.AllotInOrder  = area.AllotInOrder;
                    areaTree.AllotOutOrder = area.AllotOutOrder;
                    areaTree.attributes    = "area";
                    var shelfs = ShelfRepository.GetQueryable().Where(s => s.Area.AreaCode == area.AreaCode)
                                 .OrderBy(s => s.ShelfCode).Select(s => s);
                    HashSet <WareTree> shelfSet = new HashSet <WareTree>();
                    foreach (var shelf in shelfs)//货架
                    {
                        WareTree shelfTree = new WareTree();
                        shelfTree.Code      = shelf.ShelfCode;
                        shelfTree.Name      = "货架:" + shelf.ShelfName;
                        shelfTree.ShelfCode = shelf.ShelfCode;
                        shelfTree.ShelfName = shelf.ShelfName;

                        shelfTree.WarehouseCode = shelf.Warehouse.WarehouseCode;
                        shelfTree.WarehouseName = shelf.Warehouse.WarehouseName;
                        shelfTree.AreaCode      = shelf.Area.AreaCode;
                        shelfTree.AreaName      = shelf.Area.AreaName;

                        shelfTree.Type        = shelf.ShelfType;
                        shelfTree.Description = shelf.Description;
                        shelfTree.IsActive    = shelf.IsActive == "1" ? "可用" : "不可用";
                        shelfTree.UpdateTime  = shelf.UpdateTime.ToString("yyyy-MM-dd hh:mm:ss");
                        shelfTree.ShortName   = shelf.ShortName;
                        shelfTree.attributes  = "shelf";
                        shelfSet.Add(shelfTree);
                    }
                    areaTree.children = shelfSet.ToArray();
                    areaSet.Add(areaTree);
                }
                wareTree.children = areaSet.ToArray();
                wareSet.Add(wareTree);
            }
            return(wareSet.ToArray());
        }