diff --git a/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java b/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java index 48e98818ef..9278897d29 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java +++ b/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java @@ -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 sourceInfo = ChartDataBuild.transTableNormal(xAxis, yAxis, view, data, extStack, desensitizationList); + sourceInfo.put("sourceData", data); + view.setData(sourceInfo); + return view; + } // 同比/环比计算,通过对比类型和数据设置,计算出对应指标的结果,然后替换结果data数组中的对应元素 // 如果因维度变化(如时间字段缺失,时间字段的展示格式变化)导致无法计算结果的,则结果data数组中的对应元素全置为null // 根据不同图表类型,获得需要替换的指标index array diff --git a/core/core-backend/src/main/java/io/dataease/chart/server/ChartDataServer.java b/core/core-backend/src/main/java/io/dataease/chart/server/ChartDataServer.java index 3df134d2d6..9d7e5494b5 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/server/ChartDataServer.java +++ b/core/core-backend/src/main/java/io/dataease/chart/server/ChartDataServer.java @@ -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 excelHeaderKeys = request.getExcelHeaderKeys(); + viewDTO.setResultCount(limit); ChartViewDTO chartViewInfo = getData(viewDTO); - List tableRow = (List) chartViewInfo.getData().get("tableRow"); - List result = new ArrayList<>(); - for (Map detailMap : tableRow) { - List detailObj = new ArrayList<>(); - for (String key : excelHeaderKeys) { - detailObj.add(detailMap.get(key)); - } - result.add(detailObj.toArray()); - } - request.setDetails(result); + List tableRow = (List) chartViewInfo.getData().get("sourceData"); + request.setDetails(tableRow); } catch (Exception e) { throw new RuntimeException(e); }