forked from github/dataease
Merge pull request #8599 from dataease/pr@dev-v2@refactor_details
refactor(图表): 图表明细支持大数据量导出
This commit is contained in:
commit
cd53482acd
@ -82,10 +82,9 @@ public class ChartDataManage {
|
||||
DEException.throwException(ResultCode.DATA_IS_WRONG.code(), Translator.get("i18n_chart_delete"));
|
||||
}
|
||||
|
||||
//如果是excel导出 则最多导出20万条; 如果是从仪表板获取图表数据,则仪表板的查询模式,查询结果的数量,覆盖图表对应的属性
|
||||
//如果是excel导出 如果是从仪表板获取图表数据,则仪表板的查询模式,查询结果的数量,覆盖图表对应的属性
|
||||
if (view.getIsExcelExport()) {
|
||||
view.setResultMode(ChartConstants.VIEW_RESULT_MODE.CUSTOM);
|
||||
view.setResultCount(200000);
|
||||
} else if (ChartConstants.VIEW_RESULT_MODE.CUSTOM.equals(chartExtRequest.getResultMode())) {
|
||||
view.setResultMode(chartExtRequest.getResultMode());
|
||||
view.setResultCount(chartExtRequest.getResultCount());
|
||||
@ -572,6 +571,13 @@ public class ChartDataManage {
|
||||
} else {
|
||||
data = resultCustomSort(xAxis, data);
|
||||
}
|
||||
// 如果是表格导出查询 则在此处直接就可以返回
|
||||
if (chartExtRequest.getExcelExportFlag()) {
|
||||
Map<String, Object> sourceInfo = ChartDataBuild.transTableNormal(xAxis, yAxis, view, data, extStack, desensitizationList);
|
||||
sourceInfo.put("sourceData", data);
|
||||
view.setData(sourceInfo);
|
||||
return view;
|
||||
}
|
||||
// 同比/环比计算,通过对比类型和数据设置,计算出对应指标的结果,然后替换结果data数组中的对应元素
|
||||
// 如果因维度变化(如时间字段缺失,时间字段的展示格式变化)导致无法计算结果的,则结果data数组中的对应元素全置为null
|
||||
// 根据不同图表类型,获得需要替换的指标index array
|
||||
|
@ -19,6 +19,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@ -41,6 +42,9 @@ public class ChartDataServer implements ChartDataApi {
|
||||
@Resource
|
||||
private VisualizationTemplateExtendDataManage extendDataManage;
|
||||
|
||||
@Value("${export.views.limit:500000}")
|
||||
private Integer limit;
|
||||
|
||||
@Override
|
||||
public ChartViewDTO getData(ChartViewDTO chartViewDTO) throws Exception {
|
||||
try {
|
||||
@ -60,18 +64,10 @@ public class ChartDataServer implements ChartDataApi {
|
||||
try {
|
||||
ChartViewDTO viewDTO = request.getViewInfo();
|
||||
viewDTO.setIsExcelExport(true);
|
||||
List<String> excelHeaderKeys = request.getExcelHeaderKeys();
|
||||
viewDTO.setResultCount(limit);
|
||||
ChartViewDTO chartViewInfo = getData(viewDTO);
|
||||
List<Map> tableRow = (List) chartViewInfo.getData().get("tableRow");
|
||||
List<Object[]> result = new ArrayList<>();
|
||||
for (Map detailMap : tableRow) {
|
||||
List<Object> detailObj = new ArrayList<>();
|
||||
for (String key : excelHeaderKeys) {
|
||||
detailObj.add(detailMap.get(key));
|
||||
}
|
||||
result.add(detailObj.toArray());
|
||||
}
|
||||
request.setDetails(result);
|
||||
List<Object[]> tableRow = (List) chartViewInfo.getData().get("sourceData");
|
||||
request.setDetails(tableRow);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user