|
|
@@ -55,6 +55,114 @@ namespace CallCenterApi.Interface.Controllers
|
|
55
|
55
|
return Error("加载失败");
|
|
56
|
56
|
|
|
57
|
57
|
}
|
|
|
58
|
+ public ActionResult GetZTreeNew()
|
|
|
59
|
+ {
|
|
|
60
|
+ DataTable dt = new DataTable();
|
|
|
61
|
+ string pid = HttpUtility.UrlDecode(RequestString.GetQueryString("pid"));
|
|
|
62
|
+ string sql = " and F_State=0 ";
|
|
|
63
|
+ if (pid.Trim() != "")
|
|
|
64
|
+ {
|
|
|
65
|
+ sql += " and F_PrentId=" + pid.Trim();
|
|
|
66
|
+ }
|
|
|
67
|
+ else
|
|
|
68
|
+ {
|
|
|
69
|
+ pid = "0";
|
|
|
70
|
+ sql += " and F_PrentId=0 ";
|
|
|
71
|
+ }
|
|
|
72
|
+ if (pid=="38")
|
|
|
73
|
+ {
|
|
|
74
|
+ string rjson = RedisHelper.StringGet("ztree_38new")?.ToString() ?? "";
|
|
|
75
|
+ if (!string.IsNullOrEmpty(rjson))
|
|
|
76
|
+ {
|
|
|
77
|
+ return Success("加载成功", rjson.ToObject<DataTable>());
|
|
|
78
|
+ }
|
|
|
79
|
+ }
|
|
|
80
|
+
|
|
|
81
|
+
|
|
|
82
|
+ dt = new BLL.T_Sys_DictionaryValue().GetList(" 1=1 " + sql).Tables[0];
|
|
|
83
|
+ string sqltest = " with cte(F_ValueId ,F_Value,F_PrentId,F_Layer,F_IsLeaf,F_State,F_ItemId) as(select F_ValueId ,F_Value,F_PrentId,F_Layer,F_IsLeaf,F_State,F_ItemId from T_Sys_DictionaryValue where F_PrentId = " + pid + " UNION all select t.F_ValueId, t.F_Value,t .F_PrentId,t.F_Layer,t.F_IsLeaf,t.F_State,t.F_ItemId from T_Sys_DictionaryValue as t inner join cte as c on c.F_ValueId = t.F_PrentId )select * from cte ";
|
|
|
84
|
+
|
|
|
85
|
+
|
|
|
86
|
+ var tab2 = DbHelperSQL.Query(sqltest).Tables[0];
|
|
|
87
|
+
|
|
|
88
|
+ List<TreeModelNew> modelList = BindTreeNew(dt, "0", tab2);
|
|
|
89
|
+ if (pid == "38")
|
|
|
90
|
+ {
|
|
|
91
|
+ RedisHelper.StringSet("ztree_38", modelList.ToJson());
|
|
|
92
|
+ }
|
|
|
93
|
+ if (modelList.Count > 0)
|
|
|
94
|
+ {
|
|
|
95
|
+ return Success("加载成功", modelList);
|
|
|
96
|
+ }
|
|
|
97
|
+ else
|
|
|
98
|
+ return Error("加载失败");
|
|
|
99
|
+
|
|
|
100
|
+ }
|
|
|
101
|
+ public class TreeModelNew
|
|
|
102
|
+ {
|
|
|
103
|
+ private string _id;
|
|
|
104
|
+ /// <summary>
|
|
|
105
|
+ /// Id
|
|
|
106
|
+ /// </summary>
|
|
|
107
|
+ public string id
|
|
|
108
|
+ {
|
|
|
109
|
+ set { _id = value; }
|
|
|
110
|
+ get { return _id; }
|
|
|
111
|
+ }
|
|
|
112
|
+
|
|
|
113
|
+
|
|
|
114
|
+ private string _title;
|
|
|
115
|
+ /// <summary>
|
|
|
116
|
+ /// 树节点显示文本
|
|
|
117
|
+ /// </summary>
|
|
|
118
|
+ public string title
|
|
|
119
|
+ {
|
|
|
120
|
+ set { _title = value; }
|
|
|
121
|
+ get { return _title; }
|
|
|
122
|
+ }
|
|
|
123
|
+ private List<TreeModelNew> _child;
|
|
|
124
|
+ public List<TreeModelNew> child
|
|
|
125
|
+ {
|
|
|
126
|
+ set { _child = value; }
|
|
|
127
|
+ get { return _child; }
|
|
|
128
|
+ }
|
|
|
129
|
+ }
|
|
|
130
|
+ private List<TreeModelNew> BindTreeNew(DataTable tab, string parentid, DataTable tabtwo)
|
|
|
131
|
+ {
|
|
|
132
|
+ // DataTable tab2 = new DataTable();
|
|
|
133
|
+
|
|
|
134
|
+ if (tab != null && tab.Rows.Count > 0)
|
|
|
135
|
+ {
|
|
|
136
|
+ List<Model.T_Sys_DictionaryValue> categorylist = new BLL.T_Sys_DictionaryValue().DataTableToList(tab);
|
|
|
137
|
+ List<TreeModelNew> modelList = new List<TreeModelNew>(categorylist.Count);
|
|
|
138
|
+ for (int i = 0; i < categorylist.Count; i++)
|
|
|
139
|
+ {
|
|
|
140
|
+ TreeModelNew model = new TreeModelNew();
|
|
|
141
|
+ string currentID = categorylist[i].F_ValueId.ToString();//当前功能ID
|
|
|
142
|
+ model.id = currentID;
|
|
|
143
|
+ model.title = categorylist[i].F_Value;
|
|
|
144
|
+ DataTable newdt = new DataTable();
|
|
|
145
|
+ newdt = tabtwo.Clone();
|
|
|
146
|
+ DataRow[] dr = tabtwo.Select(" F_PrentId=" + currentID + " and F_State=0 ");
|
|
|
147
|
+ for (int j = 0; j < dr.Length; j++)
|
|
|
148
|
+ {
|
|
|
149
|
+ newdt.ImportRow((DataRow)dr[j]);
|
|
|
150
|
+ }
|
|
|
151
|
+ if (newdt != null && newdt.Rows.Count > 0)
|
|
|
152
|
+ {
|
|
|
153
|
+ model.child = BindTreeNew(newdt, currentID, tabtwo);
|
|
|
154
|
+ }
|
|
|
155
|
+ modelList.Add(model);
|
|
|
156
|
+ }
|
|
|
157
|
+ return modelList;
|
|
|
158
|
+
|
|
|
159
|
+ }
|
|
|
160
|
+ else
|
|
|
161
|
+ {
|
|
|
162
|
+ return null;
|
|
|
163
|
+ }
|
|
|
164
|
+
|
|
|
165
|
+ }
|
|
58
|
166
|
|
|
59
|
167
|
//tree 树形知识库分类
|
|
60
|
168
|
private List<Model.TreeModel> BindTree(DataTable tab, string parentid, DataTable tabtwo)
|