rsbi hace 4 años
padre
commit
7a60763227

+ 18 - 14
src/main/java/com/ruisitech/bi/service/model/CubeService.java

@@ -283,28 +283,32 @@ public class CubeService {
 		}
 	}
 	
-	public Object treeCube(Integer cubeId){
+	public List<Map<String, Object>> treeCube(Integer cubeId){
 		Map<String, Object> curGroup = null; //当前分组对象.
+		//默认所有节点都打开
+		Map<String, Object> state = new HashMap<String, Object>();
+		state.put("opened", true);
 		List<Map<String, Object>> ls = mapper.listDs(String.valueOf(cubeId));
 		for(int i=0; i<ls.size(); i++){
-			Map<String, Object> m = (Map<String, Object>)ls.get(i);
-			m.put("iconCls", "icon-cube");
+			Map<String, Object> m = ls.get(i);
+			m.put("icon", "fa fa-cubes");
+			m.put("state", state);
 			//给数据集节点添加维度、指标节点
 			List<Map<String, Object>> cubeChild = new ArrayList<Map<String, Object>>();
 			m.put("children", cubeChild);
 			Map<String, Object> wdnode = new HashMap<String, Object>();
 			wdnode.put("id", "wd");
 			wdnode.put("text", "维度");
-			wdnode.put("state", "open");
-			wdnode.put("iconCls", "icon-dim2");
+			wdnode.put("state", state);
+			wdnode.put("icon", "fa fa-gears");
 			List<Map<String, Object>> wdnodeChild = new ArrayList<Map<String, Object>>();
 			wdnode.put("children", wdnodeChild);
 			cubeChild.add(wdnode);
 			Map<String, Object> zbnode = new HashMap<String, Object>();
 			zbnode.put("id", "zb");
 			zbnode.put("text", "度量");
-			zbnode.put("state", "open");
-			zbnode.put("iconCls", "icon-kpigroup");
+			zbnode.put("state", state);
+			zbnode.put("icon", "glyphicon glyphicon-signal");
 			List<Map<String, Object>> zbnodeChild = new ArrayList<Map<String, Object>>();
 			zbnode.put("children", zbnodeChild);
 			cubeChild.add(zbnode);
@@ -326,12 +330,12 @@ public class CubeService {
 						Map<String, Object> fz = new HashMap<String, Object>();
 						fz.put("id", grouptype);
 						fz.put("text", groupname);
-						fz.put("state", "open");
-						fz.put("iconCls", "icon-dim");
+						fz.put("state", state);
+						fz.put("icon", " glyphicon glyphicon-stop icon_dim");
 						fz.put("children", new ArrayList());
 						//给分组添加attributes (把分组的第一个节点信息传递给他,拖拽分组时就当拖拽第一个节点)
 						Map<String, Object> attr = new HashMap<String, Object>();
-						fz.put("attributes", attr);
+						fz.put("li_attr", attr);
 						attr.put("col_type", col_type);
 						attr.put("col_id", child.get("col_id"));
 						attr.put("col_name", child.get("col_name"));
@@ -362,7 +366,7 @@ public class CubeService {
 					curGroup = null;
 				}
 				Map<String, Object> attr = new HashMap<String, Object>();
-				child.put("attributes", attr);
+				child.put("li_attr", attr);
 				//添加立方体所使用的数据源到Tree
 				attr.put("col_type", col_type);
 				attr.put("col_id", child.get("col_id"));
@@ -395,12 +399,12 @@ public class CubeService {
 				//设置节点图标
 				if(col_type == 1){
 					if(grouptype == null || grouptype.length() == 0){
-						child.put("iconCls", "icon-dim");
+						child.put("icon", "glyphicon glyphicon-stop icon_dim");
 					}else{
-						child.put("iconCls", "icon-dimlevel");
+						child.put("icon", "fa fa-th-large icon_dim");
 					}
 				}else{
-					child.put("iconCls", "icon-kpi");
+					child.put("icon", "glyphicon glyphicon-stop icon_kpi");
 				}
 				if(col_type == 1){
 					if(curGroup == null){

+ 6 - 1
src/main/java/com/ruisitech/bi/web/model/CubeController.java

@@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.ResponseBody;
 
 import java.util.List;
+import java.util.Map;
 
 @Controller
 @RequestMapping(value = "/model")
@@ -70,6 +71,10 @@ public class CubeController extends BaseController {
 	@RequestMapping(value="/treeCube.action")
 	public @ResponseBody
     Object tree(Integer cubeId){
-		return super.buildSucces(service.treeCube(cubeId));
+		List<Map<String, Object>> ret = service.treeCube(cubeId);
+		if(ret.size() == 0){
+			return super.buildError("无数据");
+		}
+		return ret;
 	}
 }

+ 3 - 3
src/main/resources/mybatis/cubeMapper.xml

@@ -93,7 +93,7 @@
 	
 	<select id="listCubeMeta" resultType="java.util.HashMap" parameterType="java.lang.Integer">
 		select  a.rid as "id", a.cube_id as "cubeId", c.dset as "dsetId", f.ds_id as "dsid", a.tname "tname", a.col_type as "col_type", a.col_id as "col_id", a.col_name as "col_name", b.dim_desc as "dim_name", 
-		b.dim_desc "text", 'open' as "state", 'icon-dim' as "iconCls", alias "alias", '' as "fmt", '' as "aggre", dim_type as "dim_type", 
+		b.dim_desc "text",alias "alias", '' as "fmt", '' as "aggre", dim_type as "dim_type",
 		cas_parent as "iscas", b.col_table_name as "tableName", b.col_key as "tableColKey", b.col_name as "tableColName", a.ord as "ord", b.ordcol as "ordcol", 1 as "ord2", 
 		 dim_ord "dimord", 1 as "rate", '' as "unit", b.group_type as "grouptype",  d.group_name as "groupname", 0 as "calc_kpi",  a.calc as "calc", 
 		 b.key_val_type "valType", b.dateformat as "dateformat"
@@ -103,7 +103,7 @@
 		left join olap_dim_group d on b.group_type = d.group_id
 		where a.cube_Id = #{cubeId} and a.col_type = 1 
 		 UNION all 
-		 select a.rid id, a.cube_id, d.dset, f.ds_id as "dsid", a.tname,a.col_type, a.col_id, a.col_name, '' as dim_name, c.kpi_name text, 'open' as state, 'icon-kpi' as iconCls, alias, 
+		 select a.rid id, a.cube_id, d.dset, f.ds_id as "dsid", a.tname,a.col_type, a.col_id, a.col_name, '' as dim_name, c.kpi_name text, alias,
 		 fmt, aggre, '' as dim_type,  '' as iscas, '' as tableName, '' as tableColKey, '' as tableColName, ord, '' as ordcol, 2 as ord2, '' as dimord, rate, unit, 
 		 '' as grouptype, '' as groupname, calc_kpi,  a.calc,'' as valType, '' as dateformat
 		from olap_cube_col_meta a, olap_kpi_list c, olap_cube_meta d,   etl_dataset f
@@ -113,7 +113,7 @@
 	</select>
 	
 	<select id="listDs" resultType="java.util.HashMap" parameterType="java.lang.String">
-         select a.cube_id "cubeId", 'noname' as "tname", a.cube_name "text", 'open' as "state", 'icon-cube' as "iconCls"
+         select a.cube_id "cubeId", 'noname' as "tname", a.cube_name "text"
 		from olap_cube_meta a
          where cube_id in (${selectDsIds}) order by cube_id
 	</select>