首页 > 其他分享 >FlowPortal-BPM——获取树状结构的物料分类

FlowPortal-BPM——获取树状结构的物料分类

时间:2022-11-25 10:56:20浏览次数:46  
标签:leaf 树状 BPM FlowPortal ToString new Leafchildren tb pk

   /// <summary>
    /// 获取物料分类-树形结构
    /// </summary>
    /// <returns></returns> 
    public JObject getMaterialBasicClass(HttpContext context)
    {
        string sql = "select pk_marbasclass, code, name, pk_parent from V_NCC_MaterialBasicClass where name not like '%停用%' and code not in('T','Z') order by pk_marbasclass";
        SqlConnection con = new SqlConnection();
        con.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["BLDB"].ConnectionString;
        SqlDataAdapter ada = new SqlDataAdapter();
        SqlCommandBuilder sb = new SqlCommandBuilder(ada);
        ada.SelectCommand = new SqlCommand(sql, con);
        DataSet ds = new DataSet();
        ada.Fill(ds);
        DataTable tb = ds.Tables[0];

        string key, MID, text, leaf, searchType = "11";

        //↓↓↓一级分类
        List<object> Leafchildren_1 = new List<object>();
        for (int i = 0; i < tb.Rows.Count; i++)
        {

            if (tb.Rows[i]["pk_parent"].ToString() == "~")
            {
                //↓↓↓二级分类
                List<object> Leafchildren_2 = new List<object>();
                for (int j = 0; j < tb.Rows.Count; j++)
                {
                    if (tb.Rows[j]["pk_parent"].ToString() == tb.Rows[i]["pk_marbasclass"].ToString())
                    {
                        //↓↓↓三级分类
                        List<object> Leafchildren_3 = new List<object>();
                        for (int k = 0; k < tb.Rows.Count; k++)
                        {
                            if (tb.Rows[k]["pk_parent"].ToString() == tb.Rows[j]["pk_marbasclass"].ToString())
                            {
                                //↓↓↓四级分类
                                List<object> Leafchildren_4 = new List<object>();
                                for (int l = 0; l < tb.Rows.Count; l++)
                                {
                                    if (tb.Rows[l]["pk_parent"].ToString() == tb.Rows[k]["pk_marbasclass"].ToString())
                                    {
                                        DataRow item_4 = tb.Rows[l];
                                        key = item_4["pk_marbasclass"].ToString();
                                        MID = item_4["code"].ToString();
                                        text = item_4["name"].ToString();
                                        leaf = "true";

                                        Leafchildren_4.Add(new { key, MID, leaf, text, searchType });
                                    }
                                }
                                //↑↑↑四级分类

                                DataRow item_3 = tb.Rows[k];
                                key = item_3["pk_marbasclass"].ToString();
                                MID = item_3["code"].ToString();
                                text = item_3["name"].ToString();

                                if (Leafchildren_4.Count > 0)
                                {
                                    leaf = "false";
                                    Leafchildren_3.Add(new { key, MID, leaf, text, searchType, Leafchildren_4 });
                                }
                                else
                                {
                                    leaf = "true";
                                    Leafchildren_3.Add(new { key, MID, leaf, text, searchType });
                                }
                            }
                        }
                        //↑↑↑三级分类

                        DataRow item_2 = tb.Rows[j];
                        key = item_2["pk_marbasclass"].ToString();
                        MID = item_2["code"].ToString();
                        text = item_2["name"].ToString();

                        if (Leafchildren_3.Count > 0)
                        {
                            leaf = "false";
                            Leafchildren_2.Add(new { key, MID, leaf, text, searchType, Leafchildren_3 });
                        }
                        else
                        {
                            leaf = "true";
                            Leafchildren_2.Add(new { key, MID, leaf, text, searchType });
                        }
                    }
                }
                //↑↑↑二级分类

                DataRow item_1 = tb.Rows[i];
                key = item_1["pk_marbasclass"].ToString();
                MID = item_1["code"].ToString();
                text = item_1["name"].ToString();

                if (Leafchildren_2.Count > 0)
                {
                    leaf = "false";
                    Leafchildren_1.Add(new { key, MID, leaf, text, searchType, Leafchildren_2 });
                }
                else
                {
                    leaf = "true";
                    Leafchildren_1.Add(new { key, MID, leaf, text, searchType });
                }
            }
        }
        //↑↑↑一级分类

        //↓↓↓根目录
        List<object> GchildrenG = new List<object>();

        bool expanded = true;
        text = "产品分类";
        key = "All";
        string pk_marbasclass = "%";
        string success = "True";

        if (Leafchildren_1.Count > 0)
        {
            leaf = "false";
            GchildrenG.Add(new { pk_marbasclass, key, expanded, leaf, text, searchType, Leafchildren_1 });
        }
        else
        {
            leaf = "true";
            GchildrenG.Add(new { pk_marbasclass, key, expanded, leaf, text, searchType });
        }
        //↑↑↑根目录

        //标签名替换
        return JObject.Parse(JsonConvert.SerializeObject(new { GchildrenG, success }).Replace("GchildrenG", "children").Replace("Leafchildren_1", "children").Replace("Leafchildren_2", "children").Replace("Leafchildren_3", "children").Replace("Leafchildren_4", "children"));
   }

 

标签:leaf,树状,BPM,FlowPortal,ToString,new,Leafchildren,tb,pk
From: https://www.cnblogs.com/qq450867541/p/16924435.html

相关文章

  • 树状数组
    了解树状数组    树状数组(BinaryIndexedTree(B.I.T),FenwickTree)是一个查询和修改复杂度都为log(n)的数据结构。主要用于查询任意两位之间的所有元素之和,但是......
  • bpmnjs的基本使用(vue)
    bpmn-js在vue中的基本使用效果:下载依赖包npmibpmn-jsbpmn-js-properties-panelcamunda-bpmn-moddle"bpmn-js":"^10.3.0","bpmn-js-properties-panel":"^1.1......
  • jbpm 常用代码及 jbpm IdentityService 扩展
    一、流程定义1.部署流程定义ProcessEngineprocessEngine=newConfiguration().buildProcessEngine();RepositoryServicerepositoryService=......
  • 基础树状数组
    树状数组:利用数组下标的二进制关系,构造一种类似于树形的结构,有点像一个变成树形的前缀和可以实现单点修改、区间修改、区间查询等操作2的整数n次幂的位置就是表示该位置......
  • 数组数据转为树状结构
    代码letarr=[{id:3,parent:2},{id:1,parent:null},{id:2,parent:1},]letroot=arr.map(i=>{ letchildren=arr.filte......
  • BPMN
    目录说明图标常用图标BPMN本质XMLBPMN小细节连线乱码导出图片说明BPMN就是使用各种图标,外加连线,实现可视化定义流程,并给流程各个节点设置负责人......
  • 流程图bpmn
    bpmn流程图官网//引入流程图及汉化方案importModelerfrom'bpmn-js/lib/Modeler'//引入节点属性面板importpropertiesPanelModulefrom'bpmn-js-properties-pane......
  • bpmn给userTask分配用户
    项目中整合bpmn.js做流程设计器,如果流程设计器是专业人员使用,哪ok,没问题;如果客户要求也能使用流程设计器做一些常用流程,这里就会有问题,如图这里是角色编码,对于客户而......
  • L - Fenwick Tree Gym - 103861L(打表,树状数组)
    题意:一开始数组的每个数都是零对于每次操作:可以对一个数加上一个实数在加上实数的同时,对应的i+lowbit(i)一直到<=n都会加上这个实数不同操作可以加上不同的实......
  • pmdk -- libpmemlog 介绍
    文章目录​​1.libpmemlog应用背景​​​​2.libpmemlog使用方式​​​​2.1基本接口​​​​2.2接口使用​​​​3.Libpmemlog性能​​​​3.1writesyscall性......