...
Markdown |
---|
## 数据模型取数
- <strong>接口调用</strong>
方式1
## <strong>后端接口方式</strong>
支持 SDK 通过 rmi 的方式调用
```java
import smartbi.net.sf.json.JSONObject;
import smartbi.sdk.ClientConnector;
import smartbi.sdk.InvokeResult;
public class DataModelDemo {
public static void main(String[] args) {
// 用户名
String user = "admin";
// 密码
String password = "admin";
// Smartbi链接http://10.10.35.85:18080/smartbi
String smartbiURL = "http://localhost:8080/smartbi";
// 创建Smartbi链接对象
ClientConnector conn = new ClientConnector(smartbiURL);
// 建立此连接时,就对smartbi进行了登录
boolean ret = conn.open(user, password);
String pid = "I8a8a9fb601831840184096ba01831acd3de00554"; // 父节点id
String str = "同上面post的内容";
JSONObject obj = JSONObject.fromString(str);
// 创建模型
InvokeResult res = conn.remoteInvoke("AugmentedDataSetForVModule", "create", new Object[]{pid, obj});
// 更新模型
// InvokeResult res = conn.remoteInvoke("AugmentedDataSetForVModule", "update", new Object[]{obj});
// 查询模型
// InvokeResult res = conn.remoteInvoke("AugmentedDataSetForVModule", "getData", new Object[]{obj});
conn.close();
}
}
```
方式2
http://host:port/smartbi/smartbix/api/augmentedQuery/data/
- <strong>接口请求类型</strong>
POST
- <strong>返回值</strong>
<strong>DataIterator 数据结果</strong>
| <strong>属性</strong> | <strong>类型</strong> | <strong>说明</strong> |
| --------------------- | ------------------------ | -------------------------------- |
| columnLabels | List<String> | 数据迭代器对应的列表标题列表占位 |
| iterator | Iterator<List<CellData>> | 结果(二维数组) |
| totalRowCount | Int | 总行数,目前不支持,返回-1 |
<strong>CellData 单元格数据</strong>
| <strong>属性</strong> | <strong>类型</strong> | <strong>说明</strong> |
| --------------------- | --------------------- | --------------------- |
| type | ValueType | 数据类型 |
| displayValue | String | 显示值 |
| value | Object | 真实值 |
### 示例-普通二维查询
普通二维查询,维度放行区、度量放列区
```json
{
"dataSetId": "I8a8aa3d4018220a120a154fd018220c691c50013",
"rows": [
"product_name"
],
"columns": [
"store_sales_m"
]
}
```

### 示例-交叉表查询
交叉表查询的情况,度量放行区
```json
{
"dataSetId": "I8a8aa3d4018220a120a154fd018220c691c50013",
"rows": [
"product_name","store_sales_m"
]
}
```
### 示例-过滤
```json
{
"dataSetId": "I8a8aa3d4018220a120a154fd018220c691c50013",
"rows": [
"product_name"
],
"columns": [
"store_sales_m"
],
"filters": [
{
"name": "product_name",
"operation":"EQUALS",
"values":["型号1"]
}
]
}
```
### 示例-快速度量、排序

### 示例-分类汇总、提示

### 私有计算度量、私有分组字段
```json
{
"dataSetId": "I8a8aa3d4018220a120a154fd018220c691c50013",
"rows": ["sales_region2", "customGroup"],
"columns": ["store_sales_m", "custom1"],
"custom": {
"items": [
{
"name": "custom1",
"expression": "[Measures].[store_sales_m] + 1",
"valueType": "BIGDECIMAL",
"type": "CALC_MEASURE"
}, {
"name": "customGroup",
"expression": "{\"calcField\":{\"type\":\"CALC_GROUP\",\"define\":{\"expression\":{\"groupType\":\"ENUM\",\"valueList\":[{\"enumData\":[[\"中型卖场\",\"中型卖场\"],[\"大型超市\",\"大型超市\"],[\"小型卖场\",\"小型卖场\"]],\"id\":1,\"name\":\"卖场\"}],\"otherName\":\"其他\",\"mergeIntoOneItem\":\"merge\",\"valueType\":\"STRING\"},\"ref\":\"AUGMENTED_DATASET_FIELD.I8a8aa3d4018220a120a154fd018220c691c50013.Field-FoodmartCN_datamodel-null-null-store-store_type\"}}}",
"valueType": "STRING",
"type": "CALC_GROUP"
}
]
}
}
```

- <strong>接口参数及其说明</strong>
##### <strong>DataModelQueryVO 模型查询</strong><strong>VO</strong>
| <strong>属性</strong> | <strong>类型</strong> | <strong>说明</strong> |
| --------------------- | -------------------------- | -------------------------------------------------------------------------------------------------------------- |
| dataSetId | Stirng | 模型 id |
| rows | List<String> | 行区字段名称列表 |
| columns | List<String> | 列区字段名称列表 |
| nameLabelMap | Map<String, String> | 汇总别名设置 |
| filters | List<DataModelFilterVO> | 筛选区列表 |
| quickCalculations | List<DataModelQuickCalcVO> | 快速计算定义列表 |
| custom | DataModelCustomVO | 多维元素私有定义 |
| orderBys | List<DataModelOrderByVO> | 排序设置列表 |
| subtotals | List<DataModelSubtotalVO> | 分类汇总设置列表 |
| tooltips | List<DataModelTooltipVO> | 提示字段设置列表 |
| paramValues | Map<String, Object> | 参数值映射:参数名 <-> 参数值 |
| rowPageNum | int | 第几页(行区),默认是 1 |
| rowsPerPage | int | 每页几行(行区),默认是 20 |
| queryType | QueryType | 查询方式:LIST_QUERY、MONDRIAN_QUERY,分别代表:清单查询、多维查询;清单查询时只能查维度、层次;默认是多维查询 |
##### <strong>DataModelFilterVO 筛选区</strong><strong>VO</strong>
| <strong>属性</strong> | <strong>类型</strong> | <strong>说明</strong> |
| --------------------- | --------------------- | --------------------- |
| name | Stirng | 字段名称 |
| operation | FilterOperationType | 运算符类型 |
| values | List<Object> | 过滤器的值 |
##### <strong>DataModelQuickCalcVO 快速计算设置</strong><strong>VO</strong>
| <strong>属性</strong> | <strong>类型</strong> | <strong>说明</strong> |
| --------------------- | --------------------- | ---------------------------------------------------------------------------------- |
| name | Stirng | 快速计算命名 |
| fieldName | String | 需要快速计算的字段名称 |
| calcType | CalculationType | 计算类型 |
| timeType | FieldTreeNodeType | 时间层次类型:LEVEL_TIME_YEAR、LEVEL_TIME_QUARTER、LEVEL_TIME_MONTH、LEVEL_TIME_DAY |
| timeHierId | String | 时间层次 Id (可不填,当行、列区有多个不同日期层次的时候才填) |
##### <strong>DataModelCustomVO 模型私有定义</strong><strong>VO</strong>
| <strong>属性</strong> | <strong>类型</strong> | <strong>说明</strong> |
| --------------------- | --------------------------- | --------------------- |
| items | List<DataModelCustomItemVO> | 模型私有定义列表 |
##### <strong>DataModelCustomItemVO 模型查询</strong><strong>VO</strong>
| <strong>属性</strong> | <strong>类型</strong> | <strong>说明</strong> |
| --------------------- | --------------------- | ------------------------------------------------------------------------- |
| name | 名称 | 模型私有定义列表 |
| expression | String | mdx 表达式 |
| type | FieldTreeNodeType | CALC_MEASURE、CALC_MEMBER、NAMEDSET,分别代表:计算度量、计算成员、命名集 |
| dataFormat | String | 数据格式 |
| valueType | ValueType | 数据类型 |
##### <strong>DataModelOrderByVO 排序设置 VO</strong>
| <strong>属性</strong> | <strong>类型</strong> | <strong>说明</strong> |
| --------------------- | --------------------- | -------------------------------------------------------------------------------- |
| fieldName | Stirng | 字段名称 |
| type | OrderByType | 排序类型:ASC、DESC、BASC、BDESC、NONE,分别代表:升序、降序、全局升序、全局降序 |
| orderPriority | int | 优先级 |
##### <strong>DataModelSubtotalVO 分类汇总 VO</strong>
| <strong>属性</strong> | <strong>类型</strong> | <strong>说明</strong> |
| --------------------- | --------------------- | --------------------------------------------- |
| name | Stirng | 字段名称 |
| subtotal | Subtotal | 字段是否汇总,SHOW、SHOW 分别代表:显示、隐藏 |
##### <strong>DataModelTooltipVO 提示设置 VO</strong>
| <strong>属性</strong> | <strong>类型</strong> | <strong>说明</strong> |
| --------------------- | --------------------- | --------------------- |
| name | Stirng | 字段名称 |
|
...