コード例 #1
0
 public static AscmAllocateRuleService GetInstance()
 {
     if (service == null)
     {
         service = new AscmAllocateRuleService();
     }
     return(service);
 }
コード例 #2
0
 public static AscmAllocateRuleService GetInstance()
 {
     if (service == null)
         service = new AscmAllocateRuleService();
     return service;
 }
コード例 #3
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);
        }