package mysmartbi; import java.util.List; import smartbi.net.sf.json.JSONObject; import smartbi.sdk.ClientConnector; import smartbi.sdk.InvokeResult; import smartbi.sdk.service.businessview.BusinessViewService; import smartbi.sdk.service.businessview.ViewMetaData; public class Testmain { public static void main(String[] args) { ClientConnector conn = new ClientConnector("http://10.10.202.10:17300/smartbi"); conn.open("admin", "admin"); // 以管理员身份登录 //打开透视分析获取透视分析数据 /* InvokeResult insight = conn.remoteInvoke("InsightService","openQuery",new Object[]{"I4028818a0161df27df27b9b30161e034e4124d7f",""}); JSONObject result = JSONObject.fromObject(insight.getResult()); String clientId = result.getString("clientId"); System.out.println(clientId); Integer pageNo = new Integer(0); InvokeResult result2 = conn.remoteInvoke("InsightService", "getCellData", new Object[]{clientId,pageNo}); // 用户名 System.out.println(result2.getResult()); */ //获取数据集数据 BusinessViewService bs = new BusinessViewService(conn); String bizViewId = "I4028826a015ec2b0c2b0d173015ec2b6d19d008d";//数据集id //给数据集传参,多个参数之间以逗号分隔,json数组格式参数-转字符串传递 Object pobj = new Object(); pobj="[{'id':'OutputParameter.I4028826a015ec2b0c2b0d173015ec2b6d19d008d.销售区域','value':'华南'},{ 'id' :'OutputParameter.I4028826a015ec2b0c2b0d173015ec2b6d19d008d.销售城市' ,'value':'海口'}]"; String paramsJsonArrStr=pobj.toString(); //示例:[{"id":"OutputParameter.I2c90909013e1b3f80113e1c195870038.地区名称参数","value":"华南"},{ "id" :"OutputParameter.I2c90909013e1b3f80113e1c195870038.与地区关联的城市" ,"value":"深圳,厦门"}] int rowsPerPage = 20; //加载数据时每页返回的行数 boolean getTotalRows = true; //是否获取总行数 ViewMetaData vd = bs.openLoadDataView(bizViewId, paramsJsonArrStr, rowsPerPage, getTotalRows); String cId = vd.getClientId(); //获取打开查询后的客户端标识 int totalRows = vd.getTotalRowCount(); //获取总行数 int pageNum = 0; //页码(第1页的页码为0,第2页的页码为1,如此类推) List> list = bs.loadViewData(cId, pageNum); System.out.println(list.toString()); conn.close(); } }