大数据量导出接口使用方法

1.先调用 大数据量导出接口 /api/dash/report/asyncExportExcel,传参形式如下:

{
    "token":"17369934192653998e9cd87e7fe220310054f",
    "reportId": 144, //报告id
    "componentId": "c-1-144-124-m5yot95o", //组件id
    "exportType": "xlsx", //导出类型,值为csvxlsx
    "excelSplitLimit": 1000000
}

返回值如下:

{
    "code": 200,
    "result": 15, //返回导出任务id,可以通过「获取导出状态接口」轮询导出状态
    "apiCost": 96,
    "logPath": "/operation/log/74iybCQveSUL1EumkVgZan"
}

2.将上一步的result 返回的id值传到 获取导出状态接口/api/dash/exportExcelTask/get 中,传参如下:

{
    "token":"17369934192653998e9cd87e7fe220310054f",
    "id":"15"  //上面接口返回的result
}

返回结果如下:

{
    "code": 200,
    "result": {
        "id": 15,
        "status": "success",
        "message": {
            "transId": "74iybCQveSUL1EumkVgZan"
        },
        "setting": {
            "downloadHost": "http://10.219.36.84",
            "domainId": 1,
            "domainName": "private",
            "instanceApproveInfo": {
                "enable": false,
                "exportMode": "export",
                "flowTemplateType": "reportExport"
            },
            "extraFlowInfo": {
                "extraData": {
                    "ip": "10.0.0.2",
                    "headers": {
                        "host": "10.219.36.84",
                        "x-forwarded-host": "10.219.36.84",
                        "x-forwarded-for": "10.0.0.2",
                        "connection": "close",
                        "content-length": "183",
                        "user-agent": "Apifox/1.0.0 (https://apifox.com)",
                        "content-type": "application/json",
                        "accept": "*/*",
                        "accept-encoding": "gzip, deflate, br"
                    },
                    "exportFileName": "超市_20250116:12"
                },
                "extraParameters": {}
            }
        },
        "type": "component",
        "componentId": "c-1-144-124-m5yot95o",
        "dashboardId": 124,
        "reportId": 144,
        "projectId": 7,
        "componentName": "id、title、create_time",
        "reportName": "超市",
        "downloadKey": "excel-1736993559877-74iybCQveSUL1EumkVgZan.xlsx",
        "createTime": "2025-01-16T02:12:39.000Z",
        "creatorId": 1,
        "modifyTime": "2025-01-16T02:12:39.000Z",
        "modifierId": null,
        "componentType": "table",
        "msgTag": null,
        "fileName": null,
        "webhookList": null,
        "exportType": "excel",
        "exportWay": "async",
        "flowInstanceId": null
    },
    "apiCost": 2,
    "logPath": "/operation/log/nU8ZWodAH9ZtqPvVoSmXLa"
}

3.将获取到的setting 里的 downloadHost 参数和downloadKey 参数拼成如下链接,浏览器访问即可下载导出文件

http://10.219.36.84/api/dash/util/download?key=excel-1736993559877-74iybCQveSUL1EumkVgZan.xlsx