1. 业务指标

1.1. 资源说明

1.1.1. 业务指标的定义

数据工程师面对分析师的需求,需要将业务数据库的数据集、字段整理创建成业务指标,供分析师以业务指标为基本单位进行数据下载和分析。

业务指标结构说明

Metric

业务指标的基础结构和数据集指标结构相同

下面是业务指标特有的结构说明

字段 类型 描述
createdBy LONG 创建者的userId
createdAt DATE 创建时间
updatedBy LONG 更新者的userId
updatedAt DATE 更新时间
where HE 数组 限定条件
dimensions JSONOBJECT 数组 定义分析维度
pathAttr METRIC 数组 路径归因
implication STRING 业务含义
category STRING 类别,默认值为"measure"
MetricDto
字段 类型 描述
creator OBJECT 创建者信息
updater OBJECT 更新者信息
action STRING 权限描述, admin-read-write是管理者权限,read-write是编辑者权限,read是查看者权限

1.2. 接口说明

1.2.1. 1、新增业务指标

请求URL

POST /api/apps/{appId}/datasets/{datasetId}/measures

请求参数

request body 请求体

业务指标结构说明

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
data OBJECT 业务指标共同结构见业务指标结构说明

接口示例

  1. 请求

POST /api/apps/119287/datasets/7/measures

{
  "label": "988test",
  "implication": "",
  "action": "write",
  "appId": 119287,
  "datasetId": 7,
  "dimensions": [
    {
      "datasetId": 7,
      "fieldName": "省/自治区",
      "label": "省/自治区"
    },
    {
      "datasetId": 7,
      "fieldName": "城市",
      "label": "城市"
    }
  ],
  "expr": {
    "kind": "formula",
    "op": "SUM({销售额})"
  },
  "pathAttr": [
  ]
}
  1. 响应结果
{
  "version": "4.3-SNAPSHOT@0883acb#cff8b38",
  "code": 0,
  "msg": "success",
  "data": {
    "datasetId": 7,
    "fieldName": "c1",
    "appId": 119287,
    "tags": {
    },
    "createdBy": 11549,
    "createdAt": "2023-02-10 11:04:12",
    "updatedBy": 11549,
    "updatedAt": "2023-02-10 11:04:12",
    "dimensions": [
      {
        "fieldName": "省/自治区",
        "datasetId": 7,
        "label": "省/自治区"
      },
      {
        "fieldName": "城市",
        "datasetId": 7,
        "label": "城市"
      }
    ],
    "pathAttr": [
    ],
    "implication": "",
    "category": "measure",
    "label": "988test",
    "expr": {
      "kind": "formula",
      "op": "SUM({销售额})",
      "type": "number",
      "value": "SUM({销售额})",
      "isAggregate": true,
      "isConstant": false,
      "allFieldsFromBaseDataset": true
    },
    "type": "number",
    "config": {
    }
  }
}

1.2.2. 2、复制业务指标

请求URL

POST /api/apps/{appId}/datasets/{datasetId}/measures/{fieldName}/duplicate

请求参数

request body 请求体
字段 类型 是否必须 说明
label STRING 别名

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
data OBJECT 业务指标共同结构见业务指标结构说明

接口示例

  1. 请求

POST /api/apps/119287/datasets/7/measures/c1/duplicate

{
  "label": "988test1"
}
  1. 响应结果
{
  "version": "4.3-SNAPSHOT@0883acb#cff8b38",
  "code": 0,
  "msg": "success",
  "data": {
    "datasetId": 7,
    "fieldName": "c2",
    "appId": 119287,
    "tags": {
    },
    "createdBy": 11549,
    "createdAt": "2023-02-10 11:08:42",
    "updatedBy": 11549,
    "updatedAt": "2023-02-10 11:08:42",
    "dimensions": [
      {
        "fieldName": "省/自治区",
        "datasetId": 7,
        "label": "省/自治区"
      },
      {
        "fieldName": "城市",
        "datasetId": 7,
        "label": "城市"
      }
    ],
    "pathAttr": [
    ],
    "implication": "",
    "category": "measure",
    "label": "988test1",
    "expr": {
      "kind": "formula",
      "op": "SUM({销售额})",
      "type": "number",
      "value": "SUM({销售额})",
      "isAggregate": true,
      "isConstant": false,
      "allFieldsFromBaseDataset": true
    },
    "type": "number",
    "config": {
    }
  }
}

1.2.3. 3、更新业务指标

请求URL

PUT /api/apps/{appId}/datasets/{datasetId}/measures/{fieldName}

请求参数

request body 请求体

业务指标结构说明

URL 参数
字段 类型 是否必须 说明
force BOOLEAN 是否强制更新数据集

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
data OBJECT 业务指标共同结构见业务指标结构说明

接口示例

  1. 请求

PUT /api/apps/119287/datasets/7/measures/c1

{
  "datasetId": 7,
  "fieldName": "c1",
  "appId": 119287,
  "tags": {
  },
  "dimensions": [
    {
      "fieldName": "省/自治区",
      "datasetId": 7,
      "label": "省/自治区"
    },
    {
      "fieldName": "城市",
      "datasetId": 7,
      "label": "城市"
    }
  ],
  "pathAttr": [
  ],
  "implication": "",
  "category": "measure",
  "label": "988test",
  "expr": {
    "kind": "formula",
    "op": "SUM({销售额})",
    "type": "number",
    "isAggregate": true,
    "isConstant": false,
    "allFieldsFromBaseDataset": true
  },
  "type": "number",
  "action": "admin|read|write||",
  "config": {
  }
}
  1. 响应结果
{
  "version": "4.3-SNAPSHOT@0883acb#cff8b38",
  "code": 0,
  "msg": "success",
  "data": {
    "datasetId": 7,
    "fieldName": "c1",
    "appId": 119287,
    "tags": {
    },
    "updatedBy": 11549,
    "updatedAt": "2023-02-10 11:16:53",
    "dimensions": [
      {
        "fieldName": "省/自治区",
        "datasetId": 7,
        "label": "省/自治区"
      },
      {
        "fieldName": "城市",
        "datasetId": 7,
        "label": "城市"
      }
    ],
    "pathAttr": [
    ],
    "implication": "",
    "category": "measure",
    "label": "988test",
    "expr": {
      "kind": "formula",
      "op": "SUM({销售额})",
      "type": "number",
      "value": "SUM({销售额})",
      "isAggregate": true,
      "isConstant": false,
      "allFieldsFromBaseDataset": true
    },
    "type": "number",
    "config": {
    }
  }
}

1.2.4. 4、分页查询业务指标

请求URL

GET /api/apps/{appId}/datasets/{datasetId}/measures

请求参数

URL 参数
字段 类型 是否必须 说明
orderBy STRING 排序字段
orderType STRING 排序类型
kanbanId LONG 看板Id
queryDimensionType BOOLEAN 是否查询分析维度字段类型
q STRING 搜索条件
limit INTEGER 分页获取个数,默认是1000
offst INTEGER 分页偏移量,默认是0

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
data OBJECT 数组 业务指标共同结构见业务指标结构说明

接口示例

  1. 请求

GET /api/apps/0/datasets/0/measures?orderBy=updatedAt&orderType=desc&limit=1000&offset=0&q=988

  1. 响应结果
{
  "version": "4.3-SNAPSHOT@ed95d9d#cff8b38",
  "code": 0,
  "msg": "success",
  "data": [
    {
      "datasetId": 7,
      "fieldName": "c1",
      "appId": 119287,
      "tags": {
      },
      "createdBy": 11549,
      "createdAt": "2023-02-10 11:04:12",
      "updatedBy": 11549,
      "updatedAt": "2023-02-10 11:16:53",
      "dimensions": [
        {
          "fieldName": "省/自治区",
          "datasetId": 7,
          "label": "省/自治区",
          "type": "string"
        },
        {
          "fieldName": "城市",
          "datasetId": 7,
          "label": "城市",
          "type": "string"
        }
      ],
      "pathAttr": [
      ],
      "implication": "",
      "category": "measure",
      "label": "988test",
      "expr": {
        "kind": "formula",
        "op": "SUM({销售额})",
        "type": "number",
        "value": "SUM({销售额})",
        "isAggregate": true,
        "isConstant": false,
        "allFieldsFromBaseDataset": true
      },
      "type": "number",
      "creator": {
        "id": 11549,
        "name": "陈静",
        "email": "111@qq.com",
        "avatar": "",
        "loginName": "chenjing"
      },
      "updater": {
        "id": 11549,
        "name": "陈静",
        "email": "111@qq.com",
        "avatar": "",
        "loginName": "chenjing"
      },
      "action": "|admin|read|write|",
      "accessCount": 4,
      "lastAccessedAt": "2023-02-10 11:16:47",
      "config": {
      }
    },
    {
      "datasetId": 7,
      "fieldName": "c2",
      "appId": 119287,
      "tags": {
      },
      "createdBy": 11549,
      "createdAt": "2023-02-10 11:08:42",
      "updatedBy": 11549,
      "updatedAt": "2023-02-10 11:08:42",
      "dimensions": [
        {
          "fieldName": "省/自治区",
          "datasetId": 7,
          "label": "省/自治区",
          "type": "string"
        },
        {
          "fieldName": "城市",
          "datasetId": 7,
          "label": "城市",
          "type": "string"
        }
      ],
      "pathAttr": [
      ],
      "implication": "",
      "category": "measure",
      "label": "988test1",
      "expr": {
        "kind": "formula",
        "op": "SUM({销售额})",
        "type": "number",
        "value": "SUM({销售额})",
        "isAggregate": true,
        "isConstant": false,
        "allFieldsFromBaseDataset": true
      },
      "type": "number",
      "creator": {
        "id": 11549,
        "name": "陈静",
        "email": "111@qq.com",
        "avatar": "",
        "loginName": "chenjing"
      },
      "updater": {
        "id": 11549,
        "name": "陈静",
        "email": "111@qq.com",
        "avatar": "",
        "loginName": "chenjing"
      },
      "action": "|admin|read|write|",
      "accessCount": 4,
      "lastAccessedAt": "2023-02-10 11:16:47",
      "config": {
      }
    }
  ],
  "totalHits": 2,
  "offset": 0
}

1.2.5. 5、根据ID查询业务指标

请求URL

GET /api/apps/{appId}/datasets/{datasetId}/measures/{fieldName}

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
data OBJECT 业务指标共同结构见业务指标结构说明

接口示例

  1. 请求

GET /api/apps/119287/datasets/7/measures/c1

  1. 响应结果
{
  "version": "4.3-SNAPSHOT@ed95d9d#cff8b38",
  "code": 0,
  "msg": "success",
  "data": {
    "datasetId": 7,
    "fieldName": "c1",
    "appId": 119287,
    "tags": {
    },
    "dimensions": [
      {
        "fieldName": "省/自治区",
        "datasetId": 7,
        "label": "省/自治区"
      },
      {
        "fieldName": "城市",
        "datasetId": 7,
        "label": "城市"
      }
    ],
    "pathAttr": [
    ],
    "implication": "",
    "category": "measure",
    "label": "988test",
    "expr": {
      "kind": "formula",
      "op": "SUM({销售额})",
      "type": "number",
      "value": "SUM({销售额})",
      "isAggregate": true,
      "isConstant": false,
      "allFieldsFromBaseDataset": true
    },
    "type": "number",
    "action": "admin|read|write||",
    "config": {
    }
  }
}

1.2.6. 6、重写业务指标表达式

请求URL

POST /api/apps/{appId}/datasets/{datasetId}/measures/rewrite-formula

请求参数

request body 请求体

HE 表达式,详情参照HE 的数据集函数

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
data OBJECT 业务指标共同结构见业务指标结构说明

接口示例

  1. 请求

POST /api/apps/125615/datasets/3/measures/rewrite-formula

{
  "kind": "formula",
  "op": "COUNT({{12}}.{客户类型}) FILTER (WHERE TRUNC_MONTH({发货日期}) < {{%v_month}} AND in({c10}, {{%多值动态地区}}))",
  "type": "number",
  "value": "COUNT({{客户}}.{客户类型}) FILTER (WHERE TRUNC_MONTH({发货日期}) < {{%v_month}} AND in({caseWhen}, {{%多值动态地区}}))",
  "isAggregate": true,
  "isConstant": false,
  "allFieldsFromBaseDataset": false
}
  1. 响应结果
{
  "version": "4.3-SNAPSHOT@ed95d9d#0e77c76",
  "code": 0,
  "msg": "success",
  "data": {
    "kind": "formula",
    "op": "COUNT({{12}}.{客户类型}) FILTER (WHERE TRUNC_MONTH({发货日期}) < {{%v_month}} AND in({c10}, {{%多值动态地区}}))",
    "value": "COUNT({{客户}}.{客户类型}) FILTER (WHERE TRUNC_MONTH({发货日期}) < {{%v_month}} AND in({caseWhen}, {{%多值动态地区}}))",
    "isAggregate": true
  }
}

1.2.7. 7、根据ID删除业务指标

请求URL

DELETE /api/apps/{appId}/datasets/{datasetId}/measures/{fieldName}

请求参数

URL 参数
字段 类型 是否必须 说明
force BOOLEAN 是否强制更新数据集

返回对象的格式说明

字段 类型 说明
version STRING 当前系统版本哈希值
msg STRING 成功返回 success

接口示例

  1. 请求

DELETE /api/apps/119287/datasets/7/measures/c2

  1. 响应结果
{
  "version": "4.3-SNAPSHOT@ed95d9d#0e77c76",
  "code": 0,
  "msg": "success"
}

results matching ""

    No results matching ""

    数据填报 系统操作记录