Exemplo n.º 1
0
        private void UpdateLists()
        {
            var inLoaded = Repository.Logistics.RouteListRepository.AllGoodsLoaded(UoW, Entity);
            var goods    = Repository.Logistics.RouteListRepository.GetGoodsAndEquipsInRL(UoW, Entity);
            List <RouteListControlNotLoadedNode> notLoadedNomenclatures = new List <RouteListControlNotLoadedNode>();

            foreach (var good in goods)
            {
                var     loaded       = inLoaded.FirstOrDefault(x => x.NomenclatureId == good.NomenclatureId);
                decimal loadedAmount = 0;
                if (loaded != null)
                {
                    loadedAmount = loaded.Amount;
                }
                if (loadedAmount < good.Amount)
                {
                    notLoadedNomenclatures.Add(new RouteListControlNotLoadedNode()
                    {
                        NomenclatureId = good.NomenclatureId,
                        Count          = (int)(good.Amount - loadedAmount)
                    });
                }
            }
            DomainHelper.FillPropertyByEntity <RouteListControlNotLoadedNode, Nomenclature>
                (UoW,
                notLoadedNomenclatures,
                x => x.NomenclatureId,
                (node, obj) => { node.Nomenclature = obj; });
            ObservableNotLoadedList = new GenericObservableList <RouteListControlNotLoadedNode>(notLoadedNomenclatures);


            var notAttachedNomenclatures = UoW.Session.QueryOver <Nomenclature>()
                                           .WhereRestrictionOn(x => x.Warehouse).IsNull
                                           .WhereRestrictionOn(x => x.Id).IsIn(goods.Select(x => x.NomenclatureId).ToList())
                                           .List();

            ObservableNotAttachedList            = new GenericObservableList <Nomenclature>(notAttachedNomenclatures);
            ytreeviewNotLoaded.ItemsDataSource   = ObservableNotLoadedList;
            ytreeviewNotAttached.ItemsDataSource = ObservableNotAttachedList;
        }
Exemplo n.º 2
0
        public List <ReturnsNode> GetReturnsToWarehouse(IUnitOfWork uow, int routeListId, NomenclatureCategory[] categories = null, int[] excludeNomenclatureIds = null)
        {
            Nomenclature               nomenclatureAlias      = null;
            ReturnsNode                resultAlias            = null;
            CarUnloadDocumentItem      carUnloadItemsAlias    = null;
            WarehouseMovementOperation movementOperationAlias = null;

            var returnableQuery = uow.Session.QueryOver <CarUnloadDocument>().Where(doc => doc.RouteList.Id == routeListId)
                                  .JoinAlias(doc => doc.Items, () => carUnloadItemsAlias)
                                  .JoinAlias(() => carUnloadItemsAlias.WarehouseMovementOperation, () => movementOperationAlias)
                                  .Where(Restrictions.IsNotNull(Projections.Property(() => movementOperationAlias.IncomingWarehouse)))
                                  .JoinAlias(() => movementOperationAlias.Nomenclature, () => nomenclatureAlias)
                                  .Where(() => !nomenclatureAlias.IsSerial);

            if (categories != null)
            {
                returnableQuery.Where(() => nomenclatureAlias.Category.IsIn(categories));
            }

            if (excludeNomenclatureIds != null)
            {
                returnableQuery.Where(() => !nomenclatureAlias.Id.IsIn(excludeNomenclatureIds));
            }

            var result = returnableQuery.SelectList(list => list
                                                    .SelectGroup(() => nomenclatureAlias.Id).WithAlias(() => resultAlias.NomenclatureId)
                                                    .Select(() => nomenclatureAlias.Name).WithAlias(() => resultAlias.Name)
                                                    .Select(() => false).WithAlias(() => resultAlias.Trackable)
                                                    .Select(() => nomenclatureAlias.Category).WithAlias(() => resultAlias.NomenclatureCategory)
                                                    .SelectSum(() => movementOperationAlias.Amount).WithAlias(() => resultAlias.Amount))
                         .TransformUsing(Transformers.AliasToBean <ReturnsNode>())
                         .List <ReturnsNode>();

            DomainHelper.FillPropertyByEntity <ReturnsNode, Nomenclature>(uow, result, x => x.NomenclatureId, (node, nom) => node.Nomenclature = nom);
            return(result.ToList());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Возвращает список товаров возвращенного на склад по номенклатурам
        /// </summary>
        public List <ReturnsNode> GetReturnsToWarehouse(IUnitOfWork uow, int routeListId, params int[] nomenclatureIds)
        {
            List <ReturnsNode>         result                 = new List <ReturnsNode>();
            Nomenclature               nomenclatureAlias      = null;
            ReturnsNode                resultAlias            = null;
            Equipment                  equipmentAlias         = null;
            CarUnloadDocument          carUnloadAlias         = null;
            CarUnloadDocumentItem      carUnloadItemsAlias    = null;
            WarehouseMovementOperation movementOperationAlias = null;

            var returnableQuery = QueryOver.Of <CarUnloadDocument>(() => carUnloadAlias)
                                  .JoinAlias(() => carUnloadAlias.Items, () => carUnloadItemsAlias)
                                  .JoinAlias(() => carUnloadItemsAlias.WarehouseMovementOperation, () => movementOperationAlias)
                                  .JoinAlias(() => movementOperationAlias.Nomenclature, () => nomenclatureAlias)
                                  .Where(Restrictions.IsNotNull(Projections.Property(() => movementOperationAlias.IncomingWarehouse)))
                                  .Where(() => !nomenclatureAlias.IsSerial)
                                  .Where(() => carUnloadAlias.RouteList.Id == routeListId)
                                  .Where(() => nomenclatureAlias.Id.IsIn(nomenclatureIds))
                                  .GetExecutableQueryOver(uow.Session);

            var returnableItems = returnableQuery.SelectList
                                  (
                list => list.SelectGroup(() => nomenclatureAlias.Id).WithAlias(() => resultAlias.NomenclatureId)
                .Select(() => nomenclatureAlias.Name).WithAlias(() => resultAlias.Name)
                .Select(() => false).WithAlias(() => resultAlias.Trackable)
                .Select(() => nomenclatureAlias.Category).WithAlias(() => resultAlias.NomenclatureCategory)
                .Select(() => carUnloadItemsAlias.DefectSource).WithAlias(() => resultAlias.DefectSource)
                .SelectSum(() => movementOperationAlias.Amount).WithAlias(() => resultAlias.Amount)
                                  )
                                  .TransformUsing(Transformers.AliasToBean <ReturnsNode>())
                                  .List <ReturnsNode>();

            var returnableQueryEquipment = uow.Session.QueryOver <CarUnloadDocument>(() => carUnloadAlias)
                                           .JoinAlias(() => carUnloadAlias.Items, () => carUnloadItemsAlias)
                                           .JoinAlias(() => carUnloadItemsAlias.WarehouseMovementOperation, () => movementOperationAlias)
                                           .JoinAlias(() => movementOperationAlias.Equipment, () => equipmentAlias)
                                           .JoinAlias(() => equipmentAlias.Nomenclature, () => nomenclatureAlias)
                                           .Where(Restrictions.IsNotNull(Projections.Property(() => movementOperationAlias.IncomingWarehouse)))
                                           .Where(() => carUnloadAlias.RouteList.Id == routeListId)
                                           .Where(() => nomenclatureAlias.Id.IsIn(nomenclatureIds))
            ;


            var returnableEquipment =
                returnableQueryEquipment.SelectList(list => list
                                                    .Select(() => equipmentAlias.Id).WithAlias(() => resultAlias.Id)
                                                    .SelectGroup(() => nomenclatureAlias.Id).WithAlias(() => resultAlias.NomenclatureId)
                                                    .Select(() => nomenclatureAlias.Name).WithAlias(() => resultAlias.Name)
                                                    .Select(() => nomenclatureAlias.IsSerial).WithAlias(() => resultAlias.Trackable)
                                                    .Select(() => nomenclatureAlias.Category).WithAlias(() => resultAlias.NomenclatureCategory)
                                                    .SelectSum(() => movementOperationAlias.Amount).WithAlias(() => resultAlias.Amount)
                                                    .Select(() => nomenclatureAlias.Type).WithAlias(() => resultAlias.EquipmentType)
                                                    .Select(() => carUnloadItemsAlias.DefectSource).WithAlias(() => resultAlias.DefectSource)
                                                    )
                .TransformUsing(Transformers.AliasToBean <ReturnsNode>())
                .List <ReturnsNode>();

            result.AddRange(returnableItems);
            result.AddRange(returnableEquipment);
            DomainHelper.FillPropertyByEntity <ReturnsNode, Nomenclature>(uow, result, x => x.NomenclatureId, (node, nom) => node.Nomenclature = nom);
            return(result);
        }