Ejemplo n.º 1
0
        /// <summary>
        /// 插入规则 并且返回主键ID
        /// </summary>
        /// <param name="RuleInfo"></param>
        /// <returns></returns>
        public string AddRuleToSort(SWfsSortRule ruleInfo)
        {
            string result = "0";

            //int i = DapperUtil.Insert<SWfsSortRule>(ruleInfo, true);
            result = DapperUtil.Query <string>("ComBeziWfs_SWfsSortRule_AddSortRule", ruleInfo).FirstOrDefault().ToString();
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 查找产品对应的最小的规则表
        /// </summary>
        /// <param name="list"></param>
        /// <param name="Product"></param>
        /// <returns></returns>
        public SWfsSortRule GetSmallRuleFromListByProduct(List <SWfsSortRule> list, SortProduct Product)
        {
            SWfsSortRule result        = new SWfsSortRule();
            SWfsSortRule resultBese    = new SWfsSortRule();
            SWfsSortRule resultChriden = new SWfsSortRule();

            foreach (SWfsSortRule item in list)
            {
                switch (item.RuleType)
                {
                case 1:    //分类
                    if (Product.CategoryNo == item.RuleObjectNo)
                    {
                        if (item.ParentId == 0)
                        {
                            resultBese = item;
                        }
                        else
                        {
                            resultChriden = item;
                        }
                    }
                    break;

                case 2:    //品牌
                    if (Product.BrandNo == item.RuleObjectNo)
                    {
                        if (item.ParentId == 0)
                        {
                            resultBese = item;
                        }
                        else
                        {
                            resultChriden = item;
                        }
                    }
                    break;

                case 3:    //色系
                    if (Product.ProductPrimaryColorNO == item.RuleObjectNo)
                    {
                        if (item.ParentId == 0)
                        {
                            resultBese = item;
                        }
                        else
                        {
                            resultChriden = item;
                        }
                    }
                    break;

                case 4:    //价格
                    if (Product.PriceNo + "" == item.RuleObjectNo)
                    {
                        if (item.ParentId == 0)
                        {
                            resultBese = item;
                        }
                        else
                        {
                            resultChriden = item;
                        }
                    }
                    break;

                case 6:    //其他
                    foreach (SWfsSortRule itemOther in list)
                    {
                        if (itemOther.ParentId == item.RuleId)
                        {
                            switch (itemOther.RuleType)
                            {
                            case 1:        //分类
                                if (Product.CategoryNo == itemOther.RuleObjectNo)
                                {
                                    resultChriden = itemOther;
                                }
                                break;

                            case 2:        //品牌
                                if (Product.BrandNo == itemOther.RuleObjectNo)
                                {
                                    resultChriden = itemOther;
                                }
                                break;

                            case 3:        //色系
                                if (Product.ProductPrimaryColorNO == itemOther.RuleObjectNo)
                                {
                                    resultChriden = itemOther;
                                }
                                break;

                            case 4:        //价格
                                if (Product.PriceNo + "" == itemOther.RuleObjectNo)
                                {
                                    resultChriden = itemOther;
                                }
                                break;

                            default:
                                resultChriden = item;
                                break;
                            }
                        }
                    }
                    if (resultBese.RuleId < 1 && resultChriden.RuleId < 1)
                    {
                        resultChriden = item;
                    }
                    break;
                }
            }
            if (resultChriden.RuleObjectNo != "")
            {
                result = resultChriden;
            }
            else if (resultBese.RuleObjectNo != "")
            {
                result = resultBese;
            }
            else
            {
                result = null;
            }

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 产品加入排序池的运算方法
        /// </summary>
        /// <param name="OcsCategoryNo">OCS分类编号</param>
        /// <param name="ProductNo">产品编号</param>
        /// <returns>0为失败,1为成功</returns>
        public int AddProductToSort(string OcsCategoryNo, string OcsCategoryName, string CateGoryType, SortProduct Product)
        {
            int result = 0;

            if (IsExitProduct(OcsCategoryNo, Product.ProductNo))  //判断产品是否存在
            {
                #region
                SWfsSortOcsCategory CateDtos = IsRuleCategory(OcsCategoryNo);
                //该系列没有加入排序
                if (CateDtos == null)
                {
                    //添加ocs分类
                    SWfsSortOcsCategory SDto = new SWfsSortOcsCategory
                    {
                        IsApplyRule  = false,
                        CategoryName = OcsCategoryName,
                        CategoryNo   = OcsCategoryNo,
                        AutoLastFlag = 0,
                        DateUpdate   = Convert.ToDateTime("1900-01-01"),
                        DateCreate   = DateTime.Now,
                        CategoryType = Convert.ToInt16(CateGoryType)
                    };
                    AddOcsCategory(SDto);
                    SWfsSortProduct pDto = new SWfsSortProduct()
                    {
                        OcsCategoryNo = OcsCategoryNo,
                        ProductNo     = Product.ProductNo,
                        Sort          = 1,
                        RuleId        = 0,
                        DateCreate    = DateTime.Now
                    };
                    AddProductToSortSingle(pDto);
                    result = 1;
                }
                //该分类已经加入排序
                else
                {
                    //已经执行规则
                    if (CateDtos.IsApplyRule)
                    {
                        List <SWfsSortRule> NDto        = GetRuleByCategoryNo(OcsCategoryNo);           //查找分类下的规则
                        SWfsSortRule        RuleDto     = GetSmallRuleFromListByProduct(NDto, Product); //查找分类最小规则
                        SWfsSortProduct     NproductDto = new SWfsSortProduct();
                        int RuleId = 0;

                        if (RuleDto == null || RuleDto.RuleId + "" == "")
                        {
                            NproductDto = GetMinProductByCategory(OcsCategoryNo);//查询未匹配上的最小产品
                            RuleId      = -1;
                        }
                        else
                        {
                            NproductDto = GetRuleMinProduct(RuleDto.RuleId + "", OcsCategoryNo);//根据最小规则查找最小产品
                            RuleId      = RuleDto.RuleId;
                        }

                        int             SortId = NproductDto.Sort;
                        SWfsSortProduct pDto   = new SWfsSortProduct()
                        {
                            OcsCategoryNo = OcsCategoryNo,
                            ProductNo     = Product.ProductNo,
                            Sort          = SortId,
                            RuleId        = RuleId,
                            DateCreate    = DateTime.Now
                        };
                        AddProductToSortSingle(pDto);
                    }
                    //未执行规则
                    else
                    {
                        SWfsSortProduct NDto   = GetCategoryMaxProduct(OcsCategoryNo);
                        int             sortId = NDto.Sort + 1;
                        SWfsSortProduct pDto   = new SWfsSortProduct()
                        {
                            OcsCategoryNo = OcsCategoryNo,
                            ProductNo     = Product.ProductNo,
                            Sort          = sortId,
                            RuleId        = 0,
                            DateCreate    = DateTime.Now
                        };
                        AddProductToSortSingle(pDto);
                    }
                    result = 1;
                }
                #endregion
            }
            return(result);
        }
Ejemplo n.º 4
0
        public string SaveProductSort(PageDateInfo PageDateList)
        {
            PageDateList.CategoryNo = PageDateList.CategoryNo;
            ProductRulesService PsortService = new ProductRulesService();
            string result = "0";
            //没有执行规则
            int sortInt = 0;

            if (PageDateList.ProductList != null)
            {
                sortInt = sortInt + PageDateList.ProductList.Count();
            }
            if (PageDateList.RuleList != null)
            {
                for (int i = 0; i < PageDateList.RuleList.Count(); i++)
                {
                    if (PageDateList.RuleList[i].ProductList != null)
                    {
                        sortInt = sortInt + PageDateList.RuleList[i].ProductList.Count();
                    }
                    if (PageDateList.RuleList[i].RuleList != null)
                    {
                        for (int k = 0; k < PageDateList.RuleList[i].RuleList.Count(); k++)
                        {
                            if (PageDateList.RuleList[i].RuleList[k].ProductList != null)
                            {
                                sortInt = sortInt + PageDateList.RuleList[i].RuleList[k].ProductList.Count();
                            }
                        }
                    }
                }
            }

            if (PageDateList.IsRule == "0")
            {
                PsortService.DelSortRuleByCategoryNo(PageDateList.CategoryNo);
                PsortService.DelProductByCategoryNo(PageDateList.CategoryNo);
                PsortService.UpdateCateogryTime(PageDateList.CategoryNo, PageDateList.IsLast);
                if (PageDateList.ProductList != null)
                {
                    for (int i = 0; i < PageDateList.ProductList.Count(); i++)
                    {
                        SWfsSortProduct pdto = new SWfsSortProduct();
                        pdto.Sort          = sortInt;
                        pdto.RuleId        = -1;
                        pdto.ProductNo     = PageDateList.ProductList[i].ProductNo;
                        pdto.DateCreate    = DateTime.Now;
                        pdto.OcsCategoryNo = PageDateList.CategoryNo;// PageDateList.productlist[i].ocscategoryno;
                        PsortService.AddProductToSortSingle(pdto);
                        sortInt = sortInt - 1;
                    }
                }
            }
            else
            {
                PsortService.DelSortRuleByCategoryNo(PageDateList.CategoryNo);
                PsortService.DelProductByCategoryNo(PageDateList.CategoryNo);
                PsortService.UpdateCateogryTime(PageDateList.CategoryNo, PageDateList.IsLast);
                string parentid = "0";
                if (PageDateList.RuleList != null)
                {
                    for (int i = 0; i < PageDateList.RuleList.Count(); i++)
                    {
                        SWfsSortRule pruledto = new SWfsSortRule();
                        pruledto.OcsCategoryNo  = PageDateList.CategoryNo;
                        pruledto.ParentId       = 0;
                        pruledto.RuleObjectName = PageDateList.RuleList[i].RuleName;
                        pruledto.RuleObjectNo   = PageDateList.RuleList[i].RuleNo;
                        pruledto.RuleType       = Convert.ToInt16(PageDateList.RuleList[i].RuleType);
                        pruledto.Sort           = PageDateList.RuleList.Count() - i;
                        parentid = PsortService.AddRuleToSort(pruledto);
                        if (PageDateList.RuleList[i].RuleList != null)
                        {
                            for (int j = 0; j < PageDateList.RuleList[i].RuleList.Count(); j++)
                            {
                                SWfsSortRule ruledto = new SWfsSortRule();
                                ruledto.OcsCategoryNo  = PageDateList.CategoryNo;// PageDateList.categoryno;
                                ruledto.ParentId       = Convert.ToInt32(parentid);
                                ruledto.RuleObjectName = PageDateList.RuleList[i].RuleList[j].RuleName;
                                ruledto.RuleObjectNo   = PageDateList.RuleList[i].RuleList[j].RuleNo;
                                ruledto.RuleType       = Convert.ToInt16(PageDateList.RuleList[i].RuleList[j].RuleType);
                                ruledto.Sort           = PageDateList.RuleList[i].RuleList.Count() - j;
                                string ruleid = PsortService.AddRuleToSort(ruledto);

                                if (PageDateList.RuleList[i].RuleList[j].ProductList != null)
                                {
                                    for (int k = 0; k < PageDateList.RuleList[i].RuleList[j].ProductList.Count(); k++)
                                    {
                                        SWfsSortProduct ptdto = new SWfsSortProduct();
                                        ptdto.Sort          = sortInt;
                                        ptdto.RuleId        = Convert.ToInt32(ruleid);
                                        ptdto.ProductNo     = PageDateList.RuleList[i].RuleList[j].ProductList[k].ProductNo;
                                        ptdto.DateCreate    = DateTime.Now;
                                        ptdto.OcsCategoryNo = PageDateList.CategoryNo;// PageDateList.rulelist[i].rulelist[k].productlist[k].ocscategoryno;
                                        PsortService.AddProductToSortSingle(ptdto);
                                        sortInt = sortInt - 1;
                                    }
                                }
                            }
                        }
                        if (PageDateList.RuleList[i].ProductList != null)
                        {
                            for (int l = 0; l < PageDateList.RuleList[i].ProductList.Count(); l++)
                            {
                                SWfsSortProduct podto = new SWfsSortProduct();
                                podto.Sort          = sortInt;
                                podto.RuleId        = Convert.ToInt32(parentid);
                                podto.ProductNo     = PageDateList.RuleList[i].ProductList[l].ProductNo;
                                podto.OcsCategoryNo = PageDateList.CategoryNo;// PageDateList.rulelist[i].productlist[l].ocscategoryno;
                                podto.DateCreate    = DateTime.Now;
                                PsortService.AddProductToSortSingle(podto);
                                sortInt = sortInt - 1;
                            }
                        }
                        if (PageDateList.ProductList != null)
                        {
                            for (int m = 0; m < PageDateList.ProductList.Count(); m++)
                            {
                                SWfsSortProduct dto = new SWfsSortProduct();
                                dto.Sort          = sortInt;
                                dto.RuleId        = 0;
                                dto.ProductNo     = PageDateList.ProductList[m].ProductNo;
                                dto.OcsCategoryNo = PageDateList.CategoryNo;// PageDateList.productlist[m].ocscategoryno;
                                dto.DateCreate    = DateTime.Now;
                                PsortService.AddProductToSortSingle(dto);
                                sortInt = sortInt - 1;
                            }
                        }
                    }
                }
            }
            return(result);
        }