Exemple #1
0
        public ActionResult List()
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(User));

            criteria.CreateAlias("Orders", "o");
            criteria.SetProjection(
                Projections.ProjectionList()
                .Add(Projections.Count("Orders").As("Quantity"))
                .Add(Projections.GroupProperty("Id").As("UserId")));
            criteria.SetResultTransformer(Transformers.AliasToBean(typeof(UserOrdersReportRow)));
            IList <UserOrdersReportRow> userOrders    = daoTemplate.FindByCriteria <UserOrdersReportRow>(criteria);
            DetachedCriteria            usersCriteria = DetachedCriteria.For(typeof(User)).SetFetchMode("Orders", FetchMode.Select);
            IList <User> users = daoTemplate.FindByCriteria <User>(usersCriteria);
            IList <UserListItemViewModel> viewModels = new List <UserListItemViewModel>(users.Count);

            foreach (User user in users)
            {
                UserOrdersReportRow row = userOrders.SingleOrDefault(x => x.UserId == user.Id);
                int quantity            = row == null ? 0 : row.Quantity;
                viewModels.Add(new UserListItemViewModel()
                {
                    Quantity = quantity,
                    User     = user,
                    Profit   = user.Profit(),
                    Summ     = user.Orders.Sum(x => x.SummWithDiscount)
                });
            }
            return(View(viewModels));
        }
Exemple #2
0
        private IList <LocationTransaction> GetLocationTransaction(int mark)
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(LocationTransaction));

            criteria.Add(Expression.Eq("IsSubcontract", false));
            criteria.Add(Expression.In("TransactionType", new string[] {
                BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_WO,
                BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_WO,
                BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_ISS_WO_BF
            }));
            criteria.Add(Expression.Gt("Id", mark));

            criteria.SetProjection(Projections.ProjectionList()
                                   .Add(Projections.Max("Id").As("Id"))
                                   .Add(Projections.GroupProperty("OrderNo").As("OrderNo"))
                                   .Add(Projections.GroupProperty("OrderDetailId").As("OrderDetailId"))
                                   .Add(Projections.GroupProperty("OrderLocationTransactionId").As("OrderLocationTransactionId"))
                                   .Add(Projections.GroupProperty("TransactionType").As("TransactionType"))
                                   .Add(Projections.GroupProperty("Item").As("Item"))
                                   .Add(Projections.GroupProperty("Location").As("Location"))
                                   .Add(Projections.Sum("Qty").As("Qty"))
                                   .Add(Projections.GroupProperty("EffectiveDate").As("EffectiveDate"))
                                   .Add(Projections.GroupProperty("PartyFrom").As("PartyFrom"))
                                   .Add(Projections.GroupProperty("PartyTo").As("PartyTo"))
                                   .Add(Projections.GroupProperty("RefLocation").As("RefLocation")));

            criteria.SetResultTransformer(Transformers.AliasToBean(typeof(LocationTransaction)));
            return(criteriaMgr.FindAll <LocationTransaction>(criteria));
        }
        private List <LeanEngine.Entity.InvBalance> GetInspectInvBalance()
        {
            //报验库存
            DetachedCriteria criteria = DetachedCriteria.For(typeof(InspectOrderDetail));

            criteria.CreateAlias("InspectOrder", "io");
            criteria.CreateAlias("LocationLotDetail", "lld");
            criteria.Add(Expression.Eq("io.Status", BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE));
            criteria.Add(Expression.Eq("io.IsSeperated", false));

            criteria.SetProjection(Projections.ProjectionList()
                                   .Add(Projections.Sum("InspectQty").As("InspectQty"))
                                   .Add(Projections.Sum("QualifiedQty").As("QualifiedQty"))
                                   .Add(Projections.Sum("RejectedQty").As("RejectedQty"))
                                   .Add(Projections.GroupProperty("LocationFrom.Code").As("LocationFromCode"))
                                   .Add(Projections.GroupProperty("lld.Item.Code").As("ItemCode")));

            criteria.SetResultTransformer(Transformers.AliasToBean(typeof(InspectOrderDetail)));
            IList <InspectOrderDetail> inspectOrderDetailList = CriteriaMgr.FindAll <InspectOrderDetail>(criteria);
            var query = from i in inspectOrderDetailList
                        select new LeanEngine.Entity.InvBalance
            {
                Loc     = i.LocationFromCode,
                Item    = i.ItemCode,
                Qty     = i.InspectedQty,
                InvType = Enumerators.InvType.Inspect
            };

            return(query.Where(q => q.Qty != 0).ToList());
        }
        protected static IList <T> LoadAll <T>()
        {
            DetachedCriteria criteria = DetachedCriteria.For <T>();

            criteria.SetResultTransformer(new DistinctRootEntityResultTransformer());
            return(criteria.GetExecutableCriteria(UnitOfWork.CurrentSession).List <T>());
        }
        public IList <InProcessLocationDetail> GetInProcessLocationDetailOut(IList <string> itemList, IList <string> locList)
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(InProcessLocationDetail));

            criteria.CreateAlias("InProcessLocation", "ip");
            criteria.Add(Expression.Eq("ip.Status", BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE));
            criteria.Add(Expression.Eq("ip.Type", BusinessConstants.CODE_MASTER_INPROCESS_LOCATION_TYPE_VALUE_NORMAL));
            criteria.CreateAlias("OrderLocationTransaction", "olt");
            if (itemList.Count == 1)
            {
                criteria.Add(Expression.Eq("olt.Item.Code", itemList[0]));
            }
            else
            {
                criteria.Add(Expression.InG <string>("olt.Item.Code", itemList));
            }
            if (locList.Count == 1)
            {
                criteria.Add(Expression.Eq("olt.Location.Code", locList[0]));
            }
            else
            {
                criteria.Add(Expression.InG <string>("olt.Location.Code", locList));
            }

            criteria.SetProjection(Projections.ProjectionList()
                                   .Add(Projections.GroupProperty("olt.Location.Code").As("LocationCode"))
                                   .Add(Projections.GroupProperty("olt.Item.Code").As("ItemCode"))
                                   .Add(Projections.Sum("Qty").As("Qty")));

            criteria.SetResultTransformer(Transformers.AliasToBean(typeof(InProcessLocationDetail)));
            return(this.criteriaMgr.FindAll <InProcessLocationDetail>(criteria));
        }
Exemple #6
0
    protected override void SetCriteria()
    {
        DetachedCriteria criteria = DetachedCriteria.For(typeof(CycleCountResult));

        criteria.CreateAlias("CycleCount", "cc");
        criteria.CreateAlias("cc.Location", "l");

        #region Customize
        SecurityHelper.SetRegionSearchCriteria(criteria, "l.Region.Code", this.CurrentUser.Code); //区域权限
        OrderHelper.SetActiveOrderStatusCriteria(criteria, "cc.Status");                          //状态
        #endregion

        #region Select Parameters
        CriteriaHelper.SetPartyCriteria(criteria, "l.Region.Code", this._criteriaParam);
        CriteriaHelper.SetLocationCriteria(criteria, "cc.Location.Code", this._criteriaParam);
        CriteriaHelper.SetStartDateCriteria(criteria, "cc.EffectiveDate", this._criteriaParam);
        CriteriaHelper.SetEndDateCriteria(criteria, "cc.EffectiveDate", this._criteriaParam);
        CriteriaHelper.SetStorageBinCriteria(criteria, "StorageBin.Code", this._criteriaParam);
        CriteriaHelper.SetItemCriteria(criteria, "Item.Code", this._criteriaParam);
        CriteriaHelper.SetOrderNoCriteria(criteria, "CycleCount.Code", this._criteriaParam, MatchMode.Start);
        #endregion

        #region Projections
        ProjectionList projectionList = Projections.ProjectionList()
                                        .Add(Projections.Max("Id").As("Id"))
                                        .Add(Projections.Sum("Qty").As("Qty"))
                                        .Add(Projections.Sum("InvQty").As("InvQty"))
                                        .Add(Projections.Sum("DiffQty").As("DiffQty"))
                                        .Add(Projections.Count("HuId").As("Cartons"))
                                        .Add(Projections.GroupProperty("Item").As("Item"));

        if (!this._criteriaParam.ClassifiedOrderNo)
        {
            projectionList.Add(Projections.GroupProperty("CycleCount").As("CycleCount"));
        }
        if (!this._criteriaParam.ClassifiedLocation)
        {
            projectionList.Add(Projections.GroupProperty("cc.Location").As("Location"));
        }
        if (!this._criteriaParam.ClassifiedBin)
        {
            projectionList.Add(Projections.GroupProperty("StorageBin").As("StorageBin"));//库格
        }
        if (!this._criteriaParam.ClassifiedHuId)
        {
            projectionList.Add(Projections.GroupProperty("HuId").As("HuId"));                           //条码
            projectionList.Add(Projections.GroupProperty("LotNo").As("LotNo"));                         //批号
            projectionList.Add(Projections.GroupProperty("ReferenceLocation").As("ReferenceLocation")); //参考库位
            projectionList.Add(Projections.GroupProperty("DiffReason").As("DiffReason"));               //差异原因
        }

        criteria.SetProjection(projectionList);
        criteria.SetResultTransformer(Transformers.AliasToBean(typeof(CycleCountResult)));
        #endregion

        DetachedCriteria selectCountCriteria = CloneHelper.DeepClone <DetachedCriteria>(criteria);
        selectCountCriteria.SetProjection(Projections.Count("Id"));
        SetSearchCriteria(criteria, selectCountCriteria);
    }
Exemple #7
0
        private static DetachedCriteria TransformToRowCount(DetachedCriteria criteria)
        {
            DetachedCriteria cloned = CriteriaTransformer.Clone(criteria);

            cloned.ClearOrders();
            cloned.SetResultTransformer(null).SetFirstResult(0).SetMaxResults(RowSelection.NoValue).SetProjection(
                Projections.RowCountInt64());
            return(cloned);
        }
Exemple #8
0
    protected override void SetCriteria()
    {
        DetachedCriteria criteria = DetachedCriteria.For(typeof(OrderDetailView));

        #region Customize
        criteria.Add(Expression.Eq("Type", BusinessConstants.CODE_MASTER_ORDER_TYPE_VALUE_PRODUCTION));
        SecurityHelper.SetRegionSearchCriteria(criteria, "PartyTo.Code", this.CurrentUser.Code); //区域权限
        OrderHelper.SetActiveOrderStatusCriteria(criteria, "Status");                            //订单状态
        #endregion

        #region Select Parameters
        CriteriaHelper.SetFlowCriteria(criteria, "Flow", this._criteriaParam);
        CriteriaHelper.SetPartyCriteria(criteria, "PartyTo.Code", this._criteriaParam);
        CriteriaHelper.SetStartDateCriteria(criteria, "EffDate", this._criteriaParam);
        CriteriaHelper.SetEndDateCriteria(criteria, "EffDate", this._criteriaParam);
        CriteriaHelper.SetShiftCriteria(criteria, "Shift.Code", this._criteriaParam);
        CriteriaHelper.SetItemCriteria(criteria, "Item.Code", this._criteriaParam);
        #endregion

        #region Projections
        ProjectionList projectionList = Projections.ProjectionList()
                                        .Add(Projections.Max("Id").As("Id"))
                                        .Add(Projections.Sum("OrderedQty").As("OrderedQty"))
                                        .Add(Projections.Sum("ReceivedQty").As("ReceivedQty"))
                                        .Add(Projections.Sum("RejectedQty").As("RejectedQty"))
                                        .Add(Projections.Sum("ScrapQty").As("ScrapQty"))
                                        .Add(Projections.GroupProperty("Item").As("Item"))
                                        .Add(Projections.GroupProperty("Uom").As("Uom"));

        if (!this._criteriaParam.ClassifiedFlow)
        {
            projectionList.Add(Projections.GroupProperty("Flow").As("Flow"));
            projectionList.Add(Projections.GroupProperty("Description").As("Description"));
        }
        if (!this._criteriaParam.ClassifiedParty)
        {
            projectionList.Add(Projections.GroupProperty("PartyTo").As("PartyTo"));
        }
        if (!this._criteriaParam.ClassifiedShift)
        {
            projectionList.Add(Projections.GroupProperty("Shift").As("Shift"));
        }
        if (!this._criteriaParam.ClassifiedDate)
        {
            projectionList.Add(Projections.GroupProperty("EffDate").As("EffDate"));
        }

        criteria.SetProjection(projectionList);
        criteria.SetResultTransformer(Transformers.AliasToBean(typeof(OrderDetailView)));
        #endregion

        DetachedCriteria selectCountCriteria = CloneHelper.DeepClone <DetachedCriteria>(criteria);
        selectCountCriteria.SetProjection(Projections.Count("Id"));
        SetSearchCriteria(criteria, selectCountCriteria);
    }
 internal int GetCount(ISession session, bool isDistinctResult)
 {
     if (isDistinctResult)
     {
         return(queryCount.SetResultTransformer(new DistinctRootEntityResultTransformer()).GetExecutableCriteria(session).SetProjection(Projections.RowCount()).SetMaxResults(1).UniqueResult <int>());
     }
     else
     {
         return(queryCount.GetExecutableCriteria(session).SetProjection(Projections.RowCount()).SetMaxResults(1).UniqueResult <int>());
     }
 }
        public IList<SubjectList> GetAllSubject()
        {
            DetachedCriteria criteria = DetachedCriteria.For<SubjectList>();
            ProjectionList list = Projections.ProjectionList().Create();
            list.Add(Projections.Distinct(Projections.Property("SubjectCode")));
            list.Add(Projections.GroupProperty("SubjectCode"), "SubjectCode");
            list.Add(Projections.GroupProperty("SubjectName"), "SubjectName");
            criteria.SetProjection(list);
            criteria.SetResultTransformer(new NHibernate.Transform.AliasToBeanResultTransformer(typeof(SubjectList)));

            return criteriaMgr.FindAll<SubjectList>(criteria);
        }
        /// <summary>
        /// 获取应用权限类型的应用
        /// </summary>
        /// <returns></returns>
        public static IList <SysApplication> GetApplications()
        {
            // Type为1,ID为Data的权限
            DetachedCriteria crits = DetachedCriteria.For <SysAuth>();

            crits.Add(Expression.IsNotNull("Data"));
            crits.Add(Expression.IsNull("ModuleID"));
            crits.Add(Expression.Eq("Type", 1));
            crits.SetResultTransformer(new DistinctRootEntityResultTransformer());
            IList <SysAuth> auths = SysAuth.FindAll(crits);

            return(SysAuthRule.RetrieveAllApplicationFromAuthList(auths));
        }
        internal List<EntityType> FindList(ISession session,bool isDistinctResult)
        {
            IList<EntityType> results;

            if (isDistinctResult)
                results = query.SetResultTransformer(new DistinctRootEntityResultTransformer()).GetExecutableCriteria(session).List<EntityType>();
            else
                results = query.GetExecutableCriteria(session).List<EntityType>();

            if (results == null)
                return null;

            return new List<EntityType>(results);
        }
        public IList <InProcessLocationDetail> GetInProcessLocationDetailIn(IList <string> itemList, IList <string> locList)
        {
            DetachedCriteria subCriteria = DetachedCriteria.For(typeof(OrderLocationTransaction));

            subCriteria.CreateAlias("OrderDetail", "od");
            subCriteria.CreateAlias("od.OrderHead", "oh");
            OrderHelper.SetOpenOrderStatusCriteria(subCriteria, "oh.Status");
            subCriteria.Add(Expression.Eq("IOType", BusinessConstants.IO_TYPE_IN));
            if (itemList != null && itemList.Count > 0)
            {
                if (itemList.Count == 1)
                {
                    subCriteria.Add(Expression.Eq("Item.Code", itemList[0]));
                }
                else
                {
                    subCriteria.Add(Expression.InG <string>("Item.Code", itemList));
                }
            }
            if (locList != null && locList.Count > 0)
            {
                if (locList.Count == 1)
                {
                    subCriteria.Add(Expression.Eq("Location.Code", locList[0]));
                }
                else
                {
                    subCriteria.Add(Expression.InG <string>("Location.Code", locList));
                }
            }
            subCriteria.SetProjection(Projections.ProjectionList().Add(Projections.GroupProperty("OrderDetail.Id")));

            DetachedCriteria criteria = DetachedCriteria.For(typeof(InProcessLocationDetail));

            criteria.CreateAlias("InProcessLocation", "ip");
            criteria.Add(Expression.Eq("ip.Status", BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE));
            criteria.Add(Expression.Eq("ip.Type", BusinessConstants.CODE_MASTER_INPROCESS_LOCATION_TYPE_VALUE_NORMAL));
            criteria.CreateAlias("OrderLocationTransaction", "olt");
            criteria.Add(Subqueries.PropertyIn("olt.OrderDetail.Id", subCriteria));

            criteria.SetProjection(Projections.ProjectionList()
                                   .Add(Projections.GroupProperty("olt.Location.Code").As("LocationCode"))
                                   .Add(Projections.GroupProperty("olt.Item.Code").As("ItemCode"))
                                   .Add(Projections.Sum("Qty").As("Qty")));

            criteria.SetResultTransformer(Transformers.AliasToBean(typeof(InProcessLocationDetail)));
            return(this.criteriaMgr.FindAll <InProcessLocationDetail>(criteria));
        }
        /// <summary>
        /// To use multi criteria to eagerly load multiple child collection, if the first detached criteria has child collection to query,
        /// then must use .SetResultTransformer(new DistinctRootEntityResultTransformer() for the first detached criteria
        /// </summary>
        /// <param name="multiCriteria">The multi criteria.</param>
        /// <param name="detachedCriteria">The detached criteria.</param>
        /// <param name="orders">The orders.</param>
        /// <param name="returnDistinctRoot">If set to <c>true</c> [return distinct root].</param>
        /// <returns>A <see cref="IMultiCriteria"/></returns>
        public static IMultiCriteria AddDetachedCriteria(
            this IMultiCriteria multiCriteria, DetachedCriteria detachedCriteria, IEnumerable <Order> orders = null, bool returnDistinctRoot = false)
        {
            if (orders != null && orders.Count() > 0)
            {
                detachedCriteria.AddOrders(orders);
            }

            if (returnDistinctRoot)
            {
                detachedCriteria = detachedCriteria.SetResultTransformer(new DistinctRootEntityResultTransformer());
            }

            multiCriteria.Add(detachedCriteria);
            return(multiCriteria);
        }
        private IList <LocationTransaction> GetIssTr(List <int> orderDetIdList)
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(OrderLocationTransaction));

            criteria.CreateAlias("OrderDetail", "od");
            criteria.CreateAlias("od.OrderHead", "oh");
            CriteriaHelper.SetInCriteria <int>(criteria, "od.Id", orderDetIdList);
            criteria.Add(Expression.Eq("IOType", BusinessConstants.IO_TYPE_OUT));

            criteria.SetProjection(Projections.Distinct(Projections.ProjectionList()
                                                        .Add(Projections.Property("od.Id").As("OrderDetailId"))
                                                        .Add(Projections.Property("Location.Code").As("Location"))
                                                        .Add(Projections.Property("oh.PartyFrom.Code").As("PartyFrom"))));

            criteria.SetResultTransformer(Transformers.AliasToBean(typeof(LocationTransaction)));
            return(criteriaMgr.FindAll <LocationTransaction>(criteria));
        }
        public List <StudentPlacedDto> getNonPlacedStudentsBySearchKey(string searchKey)
        {
            Utility.logFile(Constant.METHOD_ENTER + Utility.getCurrentMethodName(1) + "(StudentPlacedManagerImpl)", null, Constant.LOGTYPE_INFO);
            DetachedCriteria mainCriteria = DetachedCriteria.For <Entity_Student>("student");

            mainCriteria.Add(Restrictions.Eq("student.myConfigObj.currentBatch", Common.loggedUser.myConfigObj.currentBatch));
            mainCriteria.Add(Restrictions.Eq("student.myConfigObj.currentDegree", Common.loggedUser.myConfigObj.currentDegree));

            DetachedCriteria subCriteria = DetachedCriteria.For <Entity_PlacementDetails>("placedObj");

            subCriteria.Add(Restrictions.EqProperty("placedObj.studentId", "student.studentId"));
            subCriteria.SetProjection(Projections.Distinct(Projections.Property("placedObj.studentId")));
            mainCriteria.Add(Subqueries.NotExists(subCriteria));

            Disjunction disjunction = Restrictions.Disjunction();

            disjunction.Add(Restrictions.InsensitiveLike("student.collegeId", searchKey, MatchMode.Exact));

            mainCriteria.Add(disjunction);

            ProjectionList projectionsList = Projections.ProjectionList();

            projectionsList.Add(Projections.Property("student.collegeId"), "collegeId");
            projectionsList.Add(Projections.Property("student.studentName"), "name");
            projectionsList.Add(Projections.Property("student.gender"), "gender");
            projectionsList.Add(Projections.Property("student.branch"), "branch");
            projectionsList.Add(Projections.Property("student.myConfigObj.currentDegree"), "degree");
            projectionsList.Add(Projections.Property("student.phone"), "contact");

            mainCriteria.SetProjection(projectionsList);
            mainCriteria.AddOrder(Order.Asc("student.collegeId"));

            mainCriteria.SetResultTransformer(new AliasToBeanResultTransformer(typeof(StudentPlacedDto)));

            IList list = persistence.findByCriteria(mainCriteria);

            if (list != null && list.Count > 0)
            {
                return(list.Cast <StudentPlacedDto>().ToList());
            }
            else
            {
                return(null);
            }
        }
Exemple #17
0
    private DetachedCriteria SetCriteria()
    {
        DetachedCriteria criteria = DetachedCriteria.For(typeof(WoReceiptView));

        ProjectionList projectionList = Projections.ProjectionList()
                                        .Add(Projections.Sum("RecQty").As("RecQty"))
                                        .Add(Projections.GroupProperty("Flow").As("Flow"))
                                        .Add(Projections.GroupProperty("Item").As("Item"))
                                        .Add(Projections.GroupProperty("ItemDesc").As("ItemDesc"))
                                        .Add(Projections.Max("Id").As("Id"))
                                        .Add(Projections.Count("Id").As("BoxCount"));

        #region Customize
        SecurityHelper.SetRegionSearchCriteria(criteria, "PartyFrom", this.CurrentUser.Code); //区域权限
        #endregion

        #region Select Parameters
        if (this.tbPartyFrom.Text.Trim() != string.Empty)
        {
            criteria.Add(Expression.Eq("PartyFrom", this.tbPartyFrom.Text.Trim()));
        }
        if (this.tbOrderNo.Text.Trim() != string.Empty)
        {
            criteria.Add(Expression.Eq("OrderNo", this.tbOrderNo.Text.Trim()));
        }
        if (this.tbItem.Text.Trim() != string.Empty)
        {
            criteria.Add(Expression.Eq("Item", this.tbItem.Text.Trim()));
        }

        if (this.tbStartTime.Text.Trim() != string.Empty)
        {
            criteria.Add(Expression.Ge("CreateDate", DateTime.Parse(this.tbStartTime.Text.Trim())));
        }
        if (this.tbEndTime.Text.Trim() != string.Empty)
        {
            criteria.Add(Expression.Le("CreateDate", DateTime.Parse(this.tbEndTime.Text.Trim())));
        }
        #endregion

        criteria.SetProjection(projectionList);
        criteria.SetResultTransformer(Transformers.AliasToBean(typeof(WoReceiptView)));
        return(criteria);
    }
        public IList <LocationTransaction> GetProjectionLocationTransaction(IList <string> itemList, IList <string> locList, DateTime?endDate)
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(LocationTransaction));

            if (itemList != null && itemList.Count > 0)
            {
                if (itemList.Count == 1)
                {
                    criteria.Add(Expression.Eq("Item", itemList[0]));
                }
                else
                {
                    criteria.Add(Expression.InG <string>("Item", itemList));
                }
            }
            if (locList != null && locList.Count > 0)
            {
                if (locList.Count == 1)
                {
                    criteria.Add(Expression.Eq("Location", locList[0]));
                }
                else
                {
                    criteria.Add(Expression.InG <string>("Location", locList));
                }
            }
            if (endDate.HasValue)
            {
                criteria.Add(Expression.Gt("EffectiveDate", endDate.Value));
            }

            #region Projections
            ProjectionList projectionList = Projections.ProjectionList()
                                            .Add(Projections.Max("Id").As("Id"))
                                            .Add(Projections.Sum("Qty").As("Qty"))
                                            .Add(Projections.GroupProperty("Item").As("Item"))
                                            .Add(Projections.GroupProperty("Location").As("Location"));

            criteria.SetProjection(projectionList);
            criteria.SetResultTransformer(Transformers.AliasToBean(typeof(LocationTransaction)));
            #endregion

            return(criteriaMgr.FindAll <LocationTransaction>(criteria));
        }
        public IList <OrderLocationTransaction> GetOpenOrderLocationTransaction(IList <string> itemList, IList <string> locList)
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(OrderLocationTransaction));

            criteria.CreateAlias("OrderDetail", "od");
            criteria.CreateAlias("od.OrderHead", "oh");
            OrderHelper.SetOpenOrderStatusCriteria(criteria, "oh.Status");
            if (itemList != null && itemList.Count > 0)
            {
                if (itemList.Count == 1)
                {
                    criteria.Add(Expression.Eq("Item.Code", itemList[0]));
                }
                else
                {
                    criteria.Add(Expression.InG <string>("Item.Code", itemList));
                }
            }
            if (locList != null && locList.Count > 0)
            {
                if (locList.Count == 1)
                {
                    criteria.Add(Expression.Eq("Location.Code", locList[0]));
                }
                else
                {
                    criteria.Add(Expression.InG <string>("Location.Code", locList));
                }
            }
            #region Projections
            ProjectionList projectionList = Projections.ProjectionList()
                                            .Add(Projections.Max("Id").As("Id"))
                                            .Add(Projections.Sum("OrderedQty").As("OrderedQty"))
                                            .Add(Projections.Sum("AccumulateQty").As("AccumulateQty"))
                                            .Add(Projections.GroupProperty("IOType").As("IOType"))
                                            .Add(Projections.GroupProperty("Item").As("Item"))
                                            .Add(Projections.GroupProperty("Location").As("Location"));

            criteria.SetProjection(projectionList);
            criteria.SetResultTransformer(Transformers.AliasToBean(typeof(OrderLocationTransaction)));
            #endregion

            return(criteriaMgr.FindAll <OrderLocationTransaction>(criteria));
        }
Exemple #20
0
        public DetachedCriteria GetDetachedCriteriaWithoutOrder <T>()
        {
            DetachedCriteria criteria            = DetachedCriteria.For(typeof(T));
            HqlJunctionSearchCriterionItem item2 = new HqlJunctionSearchCriterionItem(base.Searches)
            {
                FtCritBuilder = this._ftCritBuilder
            };
            ICriterion criterion = item2.GetCriterion();

            if (criterion != null)
            {
                criteria.Add(criterion);
            }
            if (this.IsDistinct)
            {
                criteria.SetResultTransformer(new DistinctRootEntityResultTransformer());
            }
            return(criteria);
        }
        public IList<SubjectList> GetCostCenter(string subjectCode)
        {
            if (subjectCode == null || subjectCode == string.Empty)
            {
                return null;
            }
            else
            {
                DetachedCriteria criteria = DetachedCriteria.For<SubjectList>();
                criteria.Add(Expression.Eq("SubjectCode", subjectCode));
                ProjectionList list = Projections.ProjectionList().Create();
                list.Add(Projections.Distinct(Projections.Property("CostCenterCode")));
                list.Add(Projections.GroupProperty("CostCenterCode"), "CostCenterCode");
                list.Add(Projections.GroupProperty("CostCenterName"), "CostCenterName");
                criteria.SetProjection(list);
                criteria.SetResultTransformer(new NHibernate.Transform.AliasToBeanResultTransformer(typeof(SubjectList)));

                return criteriaMgr.FindAll<SubjectList>(criteria);
            }
        }
        public List <StudentPlacedDto> getPlacedStudents()
        {
            Utility.logFile(Constant.METHOD_ENTER + Utility.getCurrentMethodName(1) + "(StudentPlacedManagerImpl)", null, Constant.LOGTYPE_INFO);
            DetachedCriteria criteria = DetachedCriteria.For <Entity_PlacementDetails>();

            criteria.CreateAlias("stuObj", "student");
            criteria.CreateAlias("compDetailsObj", "compDetails");
            criteria.CreateAlias("compDetails.companyObj", "company");

            ProjectionList projectionsList = Projections.ProjectionList();

            projectionsList.Add(Projections.Property("detailsId"), "detailsId");
            projectionsList.Add(Projections.Property("student.collegeId"), "collegeId");
            projectionsList.Add(Projections.Property("student.studentName"), "name");
            projectionsList.Add(Projections.Property("student.gender"), "gender");
            projectionsList.Add(Projections.Property("student.branch"), "branch");
            projectionsList.Add(Projections.Property("student.myConfigObj.currentDegree"), "degree");
            projectionsList.Add(Projections.Property("student.phone"), "contact");
            projectionsList.Add(Projections.Property("company.companyName"), "company");
            projectionsList.Add(Projections.Property("compDetails.type"), "companyType");
            projectionsList.Add(Projections.Property("DOR"), "dor");

            criteria.SetProjection(projectionsList);
            criteria.Add(Restrictions.Eq("compDetails.myConfigObj.currentBatch", Common.loggedUser.myConfigObj.currentBatch));
            criteria.Add(Restrictions.Eq("compDetails.myConfigObj.currentDegree", Common.loggedUser.myConfigObj.currentDegree));
            criteria.Add(Restrictions.Eq("student.myConfigObj.currentBatch", Common.loggedUser.myConfigObj.currentBatch));
            criteria.Add(Restrictions.Eq("student.myConfigObj.currentDegree", Common.loggedUser.myConfigObj.currentDegree));

            criteria.AddOrder(Order.Asc("DOR"));
            criteria.SetResultTransformer(new AliasToBeanResultTransformer(typeof(StudentPlacedDto)));
            IList list = persistence.findByCriteria(criteria);

            if (list != null && list.Count > 0)
            {
                return(list.Cast <StudentPlacedDto>().ToList());
            }
            else
            {
                return(null);
            }
        }
Exemple #23
0
    protected override void SetCriteria()
    {
        DetachedCriteria criteria = DetachedCriteria.For(typeof(LocationDetail));

        criteria.CreateAlias("Location", "l");

        #region Customize
        criteria.Add(Expression.Not(Expression.Eq("Qty", new decimal(0))));
        SecurityHelper.SetRegionSearchCriteria(criteria, "l.Region.Code", this.CurrentUser.Code); //区域权限
        #endregion

        #region Select Parameters
        CriteriaHelper.SetPartyCriteria(criteria, "l.Region.Code", this._criteriaParam);
        CriteriaHelper.SetLocationCriteria(criteria, "Location.Code", this._criteriaParam);
        CriteriaHelper.SetItemCriteria(criteria, "Item.Code", this._criteriaParam);
        #endregion

        #region Projections
        ProjectionList projectionList = Projections.ProjectionList()
                                        .Add(Projections.Max("Id").As("Id"))
                                        .Add(Projections.Sum("Qty").As("Qty"))
                                        .Add(Projections.GroupProperty("Item").As("Item"));

        if (this._criteriaParam.ClassifiedParty)
        {
            projectionList.Add(Projections.GroupProperty("l.Region").As("Region"));
        }
        if (this._criteriaParam.ClassifiedLocation)
        {
            projectionList.Add(Projections.GroupProperty("Location").As("Location"));
        }

        criteria.SetProjection(projectionList);
        criteria.SetResultTransformer(Transformers.AliasToBean(typeof(LocationDetail)));
        #endregion

        DetachedCriteria selectCountCriteria = CloneHelper.DeepClone <DetachedCriteria>(criteria);
        selectCountCriteria.SetProjection(Projections.Count("Id"));
        SetSearchCriteria(criteria, selectCountCriteria);
    }
        private IList <DssExportHistory> GetRctTrLocationTransaction(int mark, string tranType)
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(LocationTransaction));

            criteria.Add(Expression.Gt("Id", mark));
            criteria.Add(Expression.Eq("TransactionType", tranType)); //BusinessConstants.CODE_MASTER_LOCATION_TRANSACTION_TYPE_VALUE_RCT_TR
            criteria.Add(Expression.IsNotNull("OrderNo"));            //todo,过滤投料
            if (tranType != "ISS-UNP")
            {
                criteria.SetProjection(Projections.ProjectionList()
                                       .Add(Projections.Max("Id").As("OriginalId"))
                                       .Add(Projections.GroupProperty("OrderNo").As("OrderNo"))
                                       .Add(Projections.GroupProperty("OrderDetailId").As("OrderDetailId"))
                                       //.Add(Projections.GroupProperty("ReceiptNo"))
                                       .Add(Projections.GroupProperty("Item").As("Item"))
                                       .Add(Projections.GroupProperty("Location").As("Location"))
                                       .Add(Projections.Sum("Qty").As("Qty"))
                                       .Add(Projections.GroupProperty("EffectiveDate").As("EffectiveDate"))
                                       //.Add(Projections.GroupProperty("PartyFrom").As("PartyFrom"))
                                       .Add(Projections.GroupProperty("PartyTo").As("PartyTo")));
            }
            else
            {
                criteria.SetProjection(Projections.ProjectionList()
                                       .Add(Projections.Max("Id").As("OriginalId"))
                                       .Add(Projections.GroupProperty("OrderNo").As("OrderNo"))
                                       //.Add(Projections.GroupProperty("OrderDetailId").As("OrderDetailId"))
                                       //.Add(Projections.GroupProperty("ReceiptNo"))
                                       .Add(Projections.GroupProperty("Item").As("Item"))
                                       .Add(Projections.GroupProperty("Location").As("Location"))
                                       .Add(Projections.Sum("Qty").As("Qty"))
                                       .Add(Projections.GroupProperty("EffectiveDate").As("EffectiveDate"))
                                       .Add(Projections.GroupProperty("PartyFrom").As("PartyFrom"))
                                       .Add(Projections.GroupProperty("PartyTo").As("PartyTo")));
                //.Add(Projections.GroupProperty("RefLocation").As("ReferenceLocation")));
            }
            criteria.SetResultTransformer(Transformers.AliasToBean(typeof(DssExportHistory)));
            return(criteriaMgr.FindAll <DssExportHistory>(criteria));
        }
 public ICriteria SetResultTransformer(IResultTransformer resultTransformer)
 {
     return(detachedCriteria.SetResultTransformer(resultTransformer).Adapt(session));
 }
        /// <summary>
        ///     Builds a <see cref="DetachedCriteria" /> from the given <see cref="IMorphableFlowQuery" /> query.
        /// </summary>
        /// <param name="query">
        ///     The query from which to build a <see cref="ICriteria" />.
        /// </param>
        /// <typeparam name="TSource">
        ///     The <see cref="System.Type" /> of the underlying entity for the given query.
        /// </typeparam>
        /// <returns>
        ///     The built <see cref="DetachedCriteria" />.
        /// </returns>
        public virtual DetachedCriteria Build <TSource>(IMorphableFlowQuery query)
        {
            if (query == null)
            {
                throw new ArgumentNullException("query");
            }

            DetachedCriteria criteria = DetachedCriteria.For <TSource>(query.Alias);

            foreach (Join join in query.Joins)
            {
                criteria.CreateAlias(join.Property, join.Alias, join.JoinType, join.WithClause);
            }

            foreach (ICriterion criterion in query.Criterions)
            {
                criteria.Add(criterion);
            }

            foreach (Lock queryLock in query.Locks)
            {
                if (queryLock.Alias == null)
                {
                    criteria.SetLockMode(queryLock.LockMode);
                }
                else
                {
                    criteria.SetLockMode(queryLock.Alias, queryLock.LockMode);
                }
            }

            bool skips = query.ResultsToSkip.HasValue && query.ResultsToSkip.Value > 0;

            if (skips)
            {
                criteria.SetFirstResult(query.ResultsToSkip.Value);
            }

            bool takes = query.ResultsToTake.HasValue && query.ResultsToTake.Value > 0;

            if (takes)
            {
                criteria.SetMaxResults(query.ResultsToTake.Value);
            }

            if (query.IsCacheable)
            {
                criteria.SetCacheable(true);

                if (query.CacheMode.HasValue)
                {
                    criteria.SetCacheMode(query.CacheMode.Value);
                }

                if (!string.IsNullOrEmpty(query.CacheRegion))
                {
                    criteria.SetCacheRegion(query.CacheRegion);
                }
            }

            criteria
            .SetProjection
            (
                GetProjection(query)
            );

            if (query.ResultTransformer != null)
            {
                criteria.SetResultTransformer(query.ResultTransformer);
            }

            if (query.Orders.Count > 0 && (skips || takes))
            {
                foreach (OrderByStatement statement in query.Orders)
                {
                    if (statement.IsBasedOnSource)
                    {
                        criteria.AddOrder(statement.Order);
                    }
                }
            }

            return(criteria);
        }
Exemple #27
0
    protected override void SetCriteria()
    {
        DetachedCriteria selectCriteria = DetachedCriteria.For(typeof(LocationTransactionView));

        #region Select Parameters
        CriteriaHelper.SetStartDateCriteria(selectCriteria, "EffDate", this._criteriaParam);
        CriteriaHelper.SetEndDateCriteria(selectCriteria, "EffDate", this._criteriaParam);
        CriteriaHelper.SetLocationCriteria(selectCriteria, "Loc", this._criteriaParam);
        //目标库位 djin 2012-08-02
        if (_criteriaParam.RefLoc != null)
        {
            CriteriaHelper.SetRefLocationCriteria(selectCriteria, "RefLoc", this._criteriaParam);
        }
        //end
        //CriteriaHelper.SetLocationCriteria(selectCriteria, "Location.Code", this._criteriaParam);
        CriteriaHelper.SetItemCriteria(selectCriteria, "Item", this._criteriaParam);
        CriteriaHelper.SetTransactionTypeCriteria(selectCriteria, "TransType", this._criteriaParam);
        #endregion

        //Party权限
        SecurityHelper.SetPartySearchCriteria(selectCriteria, "PartyFrom", this.CurrentUser.Code);
        SecurityHelper.SetPartySearchCriteria(selectCriteria, "PartyTo", this.CurrentUser.Code);

        #region Projections 默认按item,uom和location来group
        ProjectionList projectionList = Projections.ProjectionList()
                                        .Add(Projections.Sum("Qty").As("Qty"))
                                        .Add(Projections.GroupProperty("Id").As("Id"))
                                        .Add(Projections.GroupProperty("Item").As("Item"))
                                        .Add(Projections.GroupProperty("Uom").As("Uom"))
                                        //.Add(Projections.GroupProperty("RefOrderNo").As("RefOrderNo"))
                                        //.Add(Projections.GroupProperty("PartyFromName").As("PartyFromName"))
                                        //.Add(Projections.GroupProperty("PartyToName").As("PartyToName"))
                                        .Add(Projections.GroupProperty("Loc").As("Loc"))
                                        .Add(Projections.GroupProperty("LocName").As("LocName"))
                                        .Add(Projections.GroupProperty("ItemDescription").As("ItemDescription"))
                                        .Add(Projections.GroupProperty("TransType").As("TransType"))
                                        .Add(Projections.GroupProperty("OrderNo").As("OrderNo"))
                                        .Add(Projections.GroupProperty("IpNo").As("IpNo"))
                                        .Add(Projections.GroupProperty("RecNo").As("RecNo"))
                                        .Add(Projections.GroupProperty("LotNo").As("LotNo"));
        //.Add(Projections.GroupProperty("CreateUser").As("CreateUser"));
        if (_criteriaParam.RefLoc != null)
        {
            projectionList.Add(Projections.GroupProperty("RefLoc").As("RefLoc"));
        }
        //if (!this._criteriaParam.ClassifiedTransType)
        //{
        //    projectionList.Add(Projections.GroupProperty("TransType").As("TransType"));
        //}
        if (!this._criteriaParam.ClassifiedDate)
        {
            projectionList.Add(Projections.GroupProperty("EffDate").As("EffDate"));
        }
        if (!this._criteriaParam.ClassifiedUser)
        {
            projectionList.Add(Projections.GroupProperty("CreateUser").As("CreateUser"));
        }
        if (!this._criteriaParam.ClassifiedUser && !this._criteriaParam.ClassifiedDate)
        {
            projectionList.Add(Projections.GroupProperty("RefOrderNo").As("RefOrderNo"));
            projectionList.Add(Projections.GroupProperty("PartyFromName").As("PartyFromName"));
            projectionList.Add(Projections.GroupProperty("PartyToName").As("PartyToName"));
        }

        selectCriteria.SetProjection(projectionList);
        selectCriteria.SetResultTransformer(Transformers.AliasToBean(typeof(LocationTransactionView)));
        #endregion



        DetachedCriteria selectCountCriteria = CloneHelper.DeepClone <DetachedCriteria>(selectCriteria);

        selectCriteria.AddOrder(Order.Desc("Id"));
        selectCountCriteria.SetProjection(Projections.RowCount());
        SetSearchCriteria(selectCriteria, selectCountCriteria);
    }
Exemple #28
0
    private object CollectResultParam(string pickListNo, string orderNo, string status, string startDate, string endDate, string itemCode, string hu)
    {
        DetachedCriteria criteria = DetachedCriteria.For <PickListResult>();

        criteria.CreateAlias("LocationLotDetail", "lld");
        criteria.CreateAlias("lld.Location", "l");
        criteria.CreateAlias("lld.Item", "i");
        criteria.CreateAlias("lld.Hu", "hu");
        criteria.CreateAlias("PickListDetail", "pld");
        criteria.CreateAlias("pld.Uom", "u");
        criteria.CreateAlias("pld.PickList", "pl");
        criteria.CreateAlias("pld.OrderLocationTransaction", "olt");
        criteria.CreateAlias("olt.OrderDetail", "od");
        criteria.CreateAlias("od.OrderHead", "oh");

        #region partyFrom
        SecurityHelper.SetPartySearchCriteria(criteria, "pl.PartyFrom", this.CurrentUser.Code);
        #endregion

        if (pickListNo != null && pickListNo != string.Empty)
        {
            criteria.Add(Expression.Like("pl.PickListNo", pickListNo, MatchMode.Start));
        }
        if (orderNo != null && orderNo != string.Empty)
        {
            criteria.Add(Expression.Like("oh.OrderNo", orderNo, MatchMode.Start));
        }
        if (itemCode != string.Empty)
        {
            criteria.Add(Expression.Eq("i.Code", itemCode));
        }
        if (hu != string.Empty)
        {
            criteria.Add(Expression.Eq("hu.HuId", hu));
        }
        if (status != string.Empty)
        {
            criteria.Add(Expression.Eq("pl.Status", status));
        }
        if (startDate != string.Empty)
        {
            criteria.Add(Expression.Ge("pl.CreateDate", DateTime.Parse(startDate)));
        }
        if (endDate != string.Empty)
        {
            criteria.Add(Expression.Lt("pl.CreateDate", DateTime.Parse(endDate).AddDays(1)));
        }
        criteria.SetProjection(Projections.ProjectionList()
                               .Add(Projections.GroupProperty("l.Code").As("LocationCode"))
                               .Add(Projections.GroupProperty("i.Code").As("ItemCode"))
                               .Add(Projections.GroupProperty("i.Desc1").As("ItemDescription"))
                               .Add(Projections.GroupProperty("u.Code").As("UomCode"))
                               .Add(Projections.GroupProperty("pld.UnitCount").As("UnitCount"))
                               .Add(Projections.GroupProperty("pld.StorageBin.Code").As("StorageBinCode"))
                               .Add(Projections.GroupProperty("pld.LotNo").As("LotNo"))
                               .Add(Projections.GroupProperty("pl.Status").As("Status"))
                               .Add(Projections.GroupProperty("pl.PickListNo").As("PickListNo"))
                               .Add(Projections.GroupProperty("hu.HuId").As("HuId"))
                               .Add(Projections.GroupProperty("oh.OrderNo").As("OrderNo"))
                               .Add(Projections.Sum("Qty").As("Qty")));
        criteria.SetResultTransformer(Transformers.AliasToBean(typeof(PickListResult)));

        DetachedCriteria selectCountCriteria = CloneHelper.DeepClone <DetachedCriteria>(criteria);
        //DetachedCriteria selectCountCriteria = DetachedCriteria.For<PickListResult>();
        //CloneHelper.CopyProperty(criteria, selectCountCriteria);
        selectCountCriteria.SetProjection(Projections.Count("Id"));
        return(new object[] { 2, criteria, selectCountCriteria, IsExport });
    }
Exemple #29
0
        public IList <PickListResult> GetPickListResult(string[] locationCodes, string[] itemCodes, decimal?unitCount, string uomCode, string[] status, bool isGroup)
        {
            DetachedCriteria criteria = DetachedCriteria.For <PickListResult>();

            criteria.CreateAlias("LocationLotDetail", "lld");
            criteria.CreateAlias("PickListDetail", "pld");

            if (locationCodes != null && locationCodes.Length > 0)
            {
                criteria.CreateAlias("lld.Location", "l");
                if (locationCodes.Length == 1)
                {
                    criteria.Add(Expression.Eq("l.Code", locationCodes[0]));
                }
                else
                {
                    criteria.Add(Expression.In("l.Code", locationCodes));
                }
            }

            if (itemCodes != null && itemCodes.Length > 0)
            {
                criteria.CreateAlias("lld.Item", "i");
                if (itemCodes.Length == 1)
                {
                    criteria.Add(Expression.Eq("i.Code", itemCodes[0]));
                }
                else
                {
                    criteria.Add(Expression.In("i.Code", itemCodes));
                }
            }

            if (uomCode != null && uomCode.Trim() != string.Empty)
            {
                criteria.CreateAlias("pld.Uom", "u");
                criteria.Add(Expression.Eq("u.Code", uomCode));
            }

            if (unitCount.HasValue)
            {
                criteria.Add(Expression.Eq("pld.UnitCount", unitCount));
            }

            if (status != null && status.Length > 0)
            {
                criteria.CreateAlias("pld.PickList", "pl");
                if (status.Length == 1)
                {
                    criteria.Add(Expression.Eq("pl.Status", status[0]));
                }
                else
                {
                    criteria.Add(Expression.In("pl.Status", status));
                }
            }
            if (isGroup)
            {
                criteria.SetProjection(Projections.ProjectionList()
                                       .Add(Projections.GroupProperty("lld.Location.Code").As("LocationCode"))
                                       .Add(Projections.GroupProperty("lld.Item.Code").As("ItemCode"))
                                       .Add(Projections.GroupProperty("pld.Uom.Code").As("UomCode"))
                                       .Add(Projections.GroupProperty("pld.UnitCount").As("UnitCount"))
                                       .Add(Projections.GroupProperty("pl.Status").As("Status"))
                                       .Add(Projections.Sum("Qty").As("Qty")));
                criteria.SetResultTransformer(Transformers.AliasToBean(typeof(PickListResult)));
            }
            return(this.criteriaMgr.FindAll <PickListResult>(criteria));
        }