public IEnumerable <GoodsInRouteListResult> AllGoodsDelivered(IUnitOfWork uow, RouteList routeList) { if (routeList == null) { throw new ArgumentNullException(nameof(routeList)); } IList <GoodsInRouteListResult> result = new List <GoodsInRouteListResult>(); if (!routeList.Addresses.Any()) { return(result); } DeliveryDocument docAlias = null; DeliveryDocumentItem docItemsAlias = null; GoodsInRouteListResult resultNodeAlias = null; result = uow.Session.QueryOver <DeliveryDocument>(() => docAlias) .Inner.JoinAlias(d => d.Items, () => docItemsAlias) .WhereRestrictionOn(d => d.RouteListItem.Id).IsIn(routeList.Addresses.Select(x => x.Id).ToArray()) .And(() => docItemsAlias.Direction == DeliveryDirection.ToClient) .SelectList(list => list .SelectGroup(() => docItemsAlias.Nomenclature.Id).WithAlias(() => resultNodeAlias.NomenclatureId) .SelectSum(() => docItemsAlias.Amount).WithAlias(() => resultNodeAlias.Amount) ).TransformUsing(Transformers.AliasToBean <GoodsInRouteListResult>()) .List <GoodsInRouteListResult>(); return(result); }
public IList <GoodsInRouteListResult> GetEquipmentsInRL(IUnitOfWork uow, RouteList routeList) { GoodsInRouteListResult resultAlias = null; Vodovoz.Domain.Orders.Order orderAlias = null; OrderEquipment orderEquipmentAlias = null; Nomenclature OrderEquipmentNomenclatureAlias = null; //Выбирается список Id заказов находящихся в МЛ var ordersQuery = QueryOver.Of <Vodovoz.Domain.Orders.Order>(() => orderAlias); var routeListItemsSubQuery = QueryOver.Of <RouteListItem>() .Where(r => r.RouteList.Id == routeList.Id) .Where(r => !r.WasTransfered || (r.WasTransfered && r.NeedToReload)) .Select(r => r.Order.Id); ordersQuery.WithSubquery.WhereProperty(o => o.Id).In(routeListItemsSubQuery).Select(o => o.Id); var orderEquipmentsQuery = uow.Session.QueryOver <OrderEquipment>(() => orderEquipmentAlias) .WithSubquery.WhereProperty(i => i.Order.Id).In(ordersQuery) .Where(() => orderEquipmentAlias.Direction == Direction.Deliver) .JoinAlias(() => orderEquipmentAlias.Nomenclature, () => OrderEquipmentNomenclatureAlias); return(orderEquipmentsQuery .SelectList(list => list .SelectGroup(() => OrderEquipmentNomenclatureAlias.Id).WithAlias(() => resultAlias.NomenclatureId) .Select(Projections.Sum( Projections.Cast(NHibernateUtil.Decimal, Projections.Property(() => orderEquipmentAlias.Count)))).WithAlias(() => resultAlias.Amount) ) .TransformUsing(Transformers.AliasToBean <GoodsInRouteListResult>()) .List <GoodsInRouteListResult>()); }
public IList <GoodsInRouteListResult> GetGoodsInRLWithoutEquipments(IUnitOfWork uow, RouteList routeList) { GoodsInRouteListResult resultAlias = null; Vodovoz.Domain.Orders.Order orderAlias = null; OrderItem orderItemsAlias = null; Nomenclature OrderItemNomenclatureAlias = null; var ordersQuery = QueryOver.Of(() => orderAlias); var routeListItemsSubQuery = QueryOver.Of <RouteListItem>() .Where(r => r.RouteList.Id == routeList.Id) .Where(r => !r.WasTransfered || (r.WasTransfered && r.NeedToReload)) .Select(r => r.Order.Id); ordersQuery.WithSubquery.WhereProperty(o => o.Id).In(routeListItemsSubQuery).Select(o => o.Id); var orderitemsQuery = uow.Session.QueryOver <OrderItem>(() => orderItemsAlias) .WithSubquery.WhereProperty(i => i.Order.Id).In(ordersQuery) .JoinAlias(() => orderItemsAlias.Nomenclature, () => OrderItemNomenclatureAlias) .Where(() => OrderItemNomenclatureAlias.Category.IsIn(Nomenclature.GetCategoriesForShipment())); return(orderitemsQuery.SelectList(list => list .SelectGroup(() => OrderItemNomenclatureAlias.Id).WithAlias(() => resultAlias.NomenclatureId) .SelectSum(() => orderItemsAlias.Count).WithAlias(() => resultAlias.Amount)) .TransformUsing(Transformers.AliasToBean <GoodsInRouteListResult>()) .List <GoodsInRouteListResult>()); }
public IEnumerable <GoodsInRouteListResult> AllGoodsTransferredTo(IUnitOfWork uow, RouteList routeList) { if (routeList == null) { throw new ArgumentNullException(nameof(routeList)); } AddressTransferDocument transferDocAlias = null; AddressTransferDocumentItem transferDocItemAlias = null; DriverNomenclatureTransferItem driverTransferDocItemAlias = null; GoodsInRouteListResult resultNodeAlias = null; var result = uow.Session.QueryOver <AddressTransferDocument>(() => transferDocAlias) .Inner.JoinAlias(() => transferDocAlias.AddressTransferDocumentItems, () => transferDocItemAlias) .Inner.JoinAlias(() => transferDocItemAlias.DriverNomenclatureTransferDocumentItems, () => driverTransferDocItemAlias) .Where(() => transferDocAlias.RouteListTo.Id == routeList.Id) .SelectList(list => list .SelectGroup(() => driverTransferDocItemAlias.Nomenclature.Id).WithAlias(() => resultNodeAlias.NomenclatureId) .SelectSum(() => driverTransferDocItemAlias.Amount).WithAlias(() => resultNodeAlias.Amount) ).TransformUsing(Transformers.AliasToBean <GoodsInRouteListResult>()) .List <GoodsInRouteListResult>(); return(result); }
public IList <GoodsInRouteListResult> AllGoodsLoaded(IUnitOfWork uow, RouteList routeList, CarLoadDocument excludeDoc = null) { CarLoadDocument docAlias = null; CarLoadDocumentItem docItemsAlias = null; GoodsInRouteListResult inCarLoads = null; var loadedQuery = uow.Session.QueryOver <CarLoadDocument>(() => docAlias) .Where(d => d.RouteList.Id == routeList.Id); if (excludeDoc != null) { loadedQuery.Where(d => d.Id != excludeDoc.Id); } var loadedlist = loadedQuery .JoinAlias(d => d.Items, () => docItemsAlias) .SelectList(list => list .SelectGroup(() => docItemsAlias.Nomenclature.Id).WithAlias(() => inCarLoads.NomenclatureId) .SelectSum(() => docItemsAlias.Amount).WithAlias(() => inCarLoads.Amount) ).TransformUsing(Transformers.AliasToBean <GoodsInRouteListResult>()) .List <GoodsInRouteListResult>(); return(loadedlist); }