Esempio n. 1
0
        public List <AscmDiscreteJobs> GetList(YnPage ynPage, string sortName, string sortOrder, string queryWord, string queryStartTime, string queryEndTime, string queryType, string queryRanker, string userName)
        {
            List <AscmDiscreteJobs> list = null;

            try
            {
                string sort = "", whereQueryWord = "", where = "", where_Param = "";
                string userRole          = AscmUserInfoService.GetInstance().GetUserRoleName(userName);
                string userLogisticsName = AscmUserInfoService.GetInstance().GetUserLogisticsName(userName, userRole);

                string hql        = "from AscmDiscreteJobs";
                string hql_ParamZ = "select zRankerName from AscmAllocateRule";
                string hql_ParamD = "select dRankerName from AscmAllocateRule";

                string sql = "select * from ASCM_DISCRETE_JOBS";

                if (userRole == "领料员")
                {
                    whereQueryWord = "workerName = '" + userName + "'";
                    where_Param    = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where_Param, whereQueryWord);
                }
                else if (userRole == "总装排产员" || userRole == "电装排产员")
                {
                    whereQueryWord = "workerId = '" + userName + "'";
                    where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                }
                else
                {
                    if (!string.IsNullOrEmpty(userLogisticsName))
                    {
                        IList <AscmLogisticsClassInfo> ilistAscmLogisticsClassInfo = AscmLogisticsClassInfoService.GetInstance().GetList("from AscmLogisticsClassInfo where logisticsClass in (" + userLogisticsName + ")", false, false);
                        string ids = string.Empty;
                        if (ilistAscmLogisticsClassInfo != null && ilistAscmLogisticsClassInfo.Count > 0)
                        {
                            foreach (AscmLogisticsClassInfo ascmlogisticsClassInfo in ilistAscmLogisticsClassInfo)
                            {
                                if (!string.IsNullOrEmpty(ids))
                                {
                                    ids += ",";
                                }
                                ids += ascmlogisticsClassInfo.id;
                            }
                        }

                        whereQueryWord = AscmCommonHelperService.GetInstance().IsJudgeListCount(ids, "logisticsClassId");
                        where_Param    = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where_Param, whereQueryWord);
                    }
                }

                if (!string.IsNullOrEmpty(where_Param))
                {
                    string newCondition = string.Empty;
                    hql_ParamZ  += " where " + where_Param;
                    hql_ParamZ   = "workerId in (" + hql_ParamZ + ")";
                    newCondition = YnBaseClass2.Helper.StringHelper.SqlWhereOrAdd(newCondition, hql_ParamZ);

                    hql_ParamD  += " where " + where_Param;
                    hql_ParamD   = "workerId in (" + hql_ParamD + ")";
                    newCondition = YnBaseClass2.Helper.StringHelper.SqlWhereOrAdd(newCondition, hql_ParamD);
                    where       += "(" + newCondition + ")";
                }

                if (!string.IsNullOrEmpty(queryType))
                {
                    whereQueryWord = "identificationId = " + queryType;
                    where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                }

                if (!string.IsNullOrEmpty(queryStartTime) && !string.IsNullOrEmpty(queryEndTime))
                {
                    queryStartTime = queryStartTime + " 00:00:00";
                    queryEndTime   = queryEndTime + " 23:59:59";

                    whereQueryWord = "createTime > '" + queryStartTime + "'";
                    where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);

                    whereQueryWord = "createTime <= '" + queryEndTime + "'";
                    where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                }
                else if (!string.IsNullOrEmpty(queryStartTime) && string.IsNullOrEmpty(queryEndTime))
                {
                    whereQueryWord = "createTime like '" + queryStartTime + "%'";
                    where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                }
                else if (string.IsNullOrEmpty(queryStartTime) && !string.IsNullOrEmpty(queryEndTime))
                {
                    whereQueryWord = "createTime like '" + queryEndTime + "%'";
                    where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                }

                if (!string.IsNullOrEmpty(queryRanker))
                {
                    whereQueryWord = "workerId = '" + queryRanker + "'";
                    where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                }

                if (!string.IsNullOrEmpty(where))
                {
                    hql += " where " + where;
                    sql += " where " + where;
                }

                sql = sql.Replace("AscmAllocateRule", "ASCM_ALLOCATE_RULE");

                object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObjectBySQL("select count(*) from (" + sql + ")");
                int    count   = 0;
                int.TryParse(object1.ToString(), out count);
                IList <AscmDiscreteJobs> ilist = YnDaoHelper.GetInstance().nHibernateHelper.Find <AscmDiscreteJobs>(hql, count, ynPage);
                if (ilist != null && ilist.Count > 0)
                {
                    list = YnBaseClass2.Helper.ConvertHelper.ConvertIListToList <AscmDiscreteJobs>(ilist);
                    SetRanker(list);
                    list = list.OrderBy(e => e.workerId).OrderBy(e => e.productLine).OrderBy(e => e.sequence).OrderBy(e => e.identificationId).OrderBy(e => e.id).ToList();
                }
            }
            catch (Exception ex)
            {
                YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Find AscmDiscreteJobs)", ex);
                throw ex;
            }

            return(list);
        }
Esempio n. 2
0
        //public List<AscmDiscreteJobs> GetList(YnPage ynPage, string sortName, string sortOrder, string queryWord)
        //{
        //    List<AscmDiscreteJobs> list = null;
        //    try
        //    {
        //        string sort = "";
        //        if (!string.IsNullOrEmpty(sortName))
        //        {
        //            sort = "order by " + sortName.Trim() + " " ;
        //            if (!string.IsNullOrEmpty(sortOrder))
        //                sort += sortOrder.Trim();
        //        }

        //        string sql = "from AscmDiscreteJobs";
        //        IList<AscmDiscreteJobs> ilist = YnDaoHelper.GetInstance().nHibernateHelper.Find<AscmDiscreteJobs>(sql + sort, sql, ynPage);
        //        if (ilist != null)
        //        {
        //            list = YnBaseClass2.Helper.ConvertHelper.ConvertIListToList<AscmDiscreteJobs>(ilist);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Find AscmDiscreteJobs)", ex);
        //        throw ex;
        //    }
        //    return list;
        //}

        public List <AscmDiscreteJobs> GetList(YnPage ynpage, string sortName, string sortOrder, string queryWord, string queryDate, string queryType, string queryRanker, string userLogistisClass, string userRole, string userName)
        {
            List <AscmDiscreteJobs> list = null;

            try
            {
                string sort = "", whereQueryWord = "", where = "";
                string sql = "from AscmDiscreteJobs";
                if (!string.IsNullOrEmpty(sortName))
                {
                    sort = "order by " + sortName.Trim() + " ";
                    if (!string.IsNullOrEmpty(sortOrder))
                    {
                        sort += sortOrder.Trim();
                    }
                }

                if (!string.IsNullOrEmpty(queryDate))
                {
                    whereQueryWord = "createTime like '%" + queryDate + "%'";
                    where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                }

                if (!string.IsNullOrEmpty(queryType))
                {
                    whereQueryWord = "identificationId = " + queryType;
                    where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                }

                if (!string.IsNullOrEmpty(userLogistisClass))
                {
                    IList <AscmLogisticsClassInfo> ilistAscmLogisticsClassInfo = AscmLogisticsClassInfoService.GetInstance().GetList("from AscmLogisticsClassInfo where logisticsClass in (" + userLogistisClass + ")", false, false);
                    string ids = string.Empty;
                    if (ilistAscmLogisticsClassInfo != null && ilistAscmLogisticsClassInfo.Count > 0)
                    {
                        foreach (AscmLogisticsClassInfo ascmlogisticsClassInfo in ilistAscmLogisticsClassInfo)
                        {
                            if (!string.IsNullOrEmpty(ids))
                            {
                                ids += ",";
                            }
                            ids += ascmlogisticsClassInfo.id;
                        }
                    }

                    string newCondition = AscmCommonHelperService.GetInstance().IsJudgeListCount(ids, "logisticsClassId");
                    if (!string.IsNullOrEmpty(newCondition))
                    {
                        string newsql = "from AscmAllocateRule where " + newCondition;
                        IList <AscmAllocateRule> ilistAscmAllocateRule = AscmAllocateRuleService.GetInstance().GetList(newsql, false, false, false);
                        ids = "";
                        if (ilistAscmAllocateRule != null && ilistAscmAllocateRule.Count > 0)
                        {
                            foreach (AscmAllocateRule ascmAllocateRule in ilistAscmAllocateRule)
                            {
                                if (!string.IsNullOrEmpty(ids) && (!string.IsNullOrEmpty(ascmAllocateRule.zRankerName) || !string.IsNullOrEmpty(ascmAllocateRule.dRankerName)))
                                {
                                    ids += ",";
                                }
                                if (!string.IsNullOrEmpty(ascmAllocateRule.zRankerName))
                                {
                                    ids += "'" + ascmAllocateRule.zRankerName + "'";
                                }
                                if (!string.IsNullOrEmpty(ids) && !string.IsNullOrEmpty(ascmAllocateRule.dRankerName))
                                {
                                    ids += ",";
                                }
                                if (!string.IsNullOrEmpty(ascmAllocateRule.dRankerName))
                                {
                                    ids += "'" + ascmAllocateRule.dRankerName + "'";
                                }
                            }
                        }

                        if (string.IsNullOrEmpty(queryRanker))
                        {
                            whereQueryWord = AscmCommonHelperService.GetInstance().IsJudgeListCount(ids, "workerId");
                            where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                        }
                        else
                        {
                            if (ids.IndexOf(queryRanker) > -1)
                            {
                                whereQueryWord = "workerId like '%" + queryRanker + "%'";
                                where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                            }
                            else
                            {
                                whereQueryWord = AscmCommonHelperService.GetInstance().IsJudgeListCount(ids, "workerId");
                                where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                            }
                        }
                    }
                }
                else
                {
                    if (userRole == "总装排产员" || userRole == "电装排产员")
                    {
                        whereQueryWord = "workerId = '" + userName + "'";
                        where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                    }
                    else if (userRole == "领料员")
                    {
                        string newsql = "from AscmAllocateRule where workerName = '" + userName + "'";
                        string ids    = string.Empty;
                        IList <AscmAllocateRule> ilistAscmAllocateRule = AscmAllocateRuleService.GetInstance().GetList(newsql, false, false, false);
                        if (ilistAscmAllocateRule != null && ilistAscmAllocateRule.Count > 0)
                        {
                            foreach (AscmAllocateRule ascmAllocateRule in ilistAscmAllocateRule)
                            {
                                if (!string.IsNullOrEmpty(ids))
                                {
                                    ids += ",";
                                }
                                if (!string.IsNullOrEmpty(ascmAllocateRule.zRankerName))
                                {
                                    ids += "'" + ascmAllocateRule.zRankerName + "'";
                                }
                                if (!string.IsNullOrEmpty(ascmAllocateRule.dRankerName))
                                {
                                    ids += "'" + ascmAllocateRule.dRankerName + "'";
                                }
                            }
                        }

                        whereQueryWord = AscmCommonHelperService.GetInstance().IsJudgeListCount(ids, "workerId");
                        where          = YnBaseClass2.Helper.StringHelper.SqlWhereAndAdd(where, whereQueryWord);
                    }
                }

                if (!string.IsNullOrEmpty(where))
                {
                    sql += " where " + where + " order by workerId,workerId,productLine,sequence,id";
                    IList <AscmDiscreteJobs> ilist = YnDaoHelper.GetInstance().nHibernateHelper.Find <AscmDiscreteJobs>(sql, sql, ynpage);
                    if (ilist != null && ilist.Count > 0)
                    {
                        list = YnBaseClass2.Helper.ConvertHelper.ConvertIListToList <AscmDiscreteJobs>(ilist);
                        SetRanker(list);
                    }
                }
            }
            catch (Exception ex)
            {
                YnBaseClass2.Helper.LogHelper.GetLog().Error("查询失败(Find AscmDiscreteJobs)", ex);
                throw ex;
            }

            return(list);
        }