mirror of
https://github.com/dataease/dataease.git
synced 2026-05-24 06:18:10 +08:00
perf(定时报告): 根据视图数据范围导出不同数据
This commit is contained in:
@@ -113,7 +113,7 @@ public abstract class FilterBuildTemplate {
|
||||
return condition;
|
||||
}
|
||||
|
||||
private static Map<String, List<ChartExtFilterRequest>> buildEmpty(List<Map<String, Object>> components) {
|
||||
public static Map<String, List<ChartExtFilterRequest>> buildEmpty(List<Map<String, Object>> components) {
|
||||
Map<String, List<ChartExtFilterRequest>> result = new HashMap<>();
|
||||
components.forEach(element -> {
|
||||
if (StringUtils.equals(element.get("type").toString(), "view")) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.dataease.service.chart;
|
||||
|
||||
import com.google.gson.internal.LinkedTreeMap;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -32,10 +33,10 @@ import com.google.gson.reflect.TypeToken;
|
||||
public class ViewExportExcel {
|
||||
|
||||
private final static Gson gson = new Gson();
|
||||
private Type tokenType = new TypeToken<List<Map<String, Object>>>() {
|
||||
private final Type tokenType = new TypeToken<List<Map<String, Object>>>() {
|
||||
}.getType();
|
||||
|
||||
private Type fieldTokenType = new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
private final Type fieldTokenType = new TypeToken<List<ChartViewFieldDTO>>() {
|
||||
}.getType();
|
||||
|
||||
@DePermissionProxy(paramIndex = 2)
|
||||
@@ -46,41 +47,39 @@ public class ViewExportExcel {
|
||||
PanelGroupService panelGroupService = SpringContextUtil.getBean(PanelGroupService.class);
|
||||
|
||||
PanelGroupDTO panelDto = panelGroupService.findOne(panelId);
|
||||
String componentsJson = panelDto.getPanelData();
|
||||
List<Map<String, Object>> components = gson.fromJson(componentsJson, tokenType);
|
||||
|
||||
ChartExtRequest chartExtRequest = new ChartExtRequest();
|
||||
chartExtRequest.setQueryFrom("panel");
|
||||
chartExtRequest.setFilter(new ArrayList<>());
|
||||
|
||||
|
||||
Map<String, ChartExtRequest> stringChartExtRequestMap = buildViewRequest(components);
|
||||
Map<String, ChartExtRequest> stringChartExtRequestMap = buildViewRequest(panelDto, justView);
|
||||
List<File> results = new ArrayList<>();
|
||||
List<ExcelSheetModel> sheets = viewIds.stream().map(viewId -> viewFiles(viewId, justView ? stringChartExtRequestMap.get(viewId) : chartExtRequest)).collect(Collectors.toList());
|
||||
List<ExcelSheetModel> sheets = viewIds.stream().map(viewId -> viewFiles(viewId, stringChartExtRequestMap.get(viewId))).collect(Collectors.toList());
|
||||
File excelFile = ExcelUtils.exportExcel(sheets, panelDto.getName());
|
||||
results.add(excelFile);
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
private Map<String, ChartExtRequest> buildViewRequest(List<Map<String, Object>> component) {
|
||||
private Map<String, ChartExtRequest> buildViewRequest(PanelGroupDTO panelDto, Boolean justView) {
|
||||
String componentsJson = panelDto.getPanelData();
|
||||
List<Map<String, Object>> components = gson.fromJson(componentsJson, tokenType);
|
||||
String panelStyle = panelDto.getPanelStyle();
|
||||
Map map = gson.fromJson(panelStyle, Map.class);
|
||||
Map panelMap = (LinkedTreeMap)map.get("panel");
|
||||
double resultCount = Double.parseDouble(panelMap.get("resultCount").toString());
|
||||
String resultMode = panelMap.get("resultMode").toString();
|
||||
|
||||
Map<String, ChartExtRequest> result = new HashMap<>();
|
||||
Map<String, List<ChartExtFilterRequest>> panelFilters = FilterBuildTemplate.buildFilters(component);
|
||||
Map<String, List<ChartExtFilterRequest>> panelFilters = justView ? FilterBuildTemplate.buildFilters(components) : FilterBuildTemplate.buildEmpty(components);
|
||||
for (Map.Entry<String, List<ChartExtFilterRequest>> entry : panelFilters.entrySet()) {
|
||||
List<ChartExtFilterRequest> chartExtFilterRequests = entry.getValue();
|
||||
ChartExtRequest chartExtRequest = new ChartExtRequest();
|
||||
chartExtRequest.setQueryFrom("panel");
|
||||
chartExtRequest.setFilter(chartExtFilterRequests);
|
||||
chartExtRequest.setResultCount((int)resultCount);
|
||||
chartExtRequest.setResultMode(resultMode);
|
||||
result.put(entry.getKey(), chartExtRequest);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<ChartExtFilterRequest> initFilters(List<Map<String, Object>> components) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private ExcelSheetModel viewFiles(String viewId, ChartExtRequest request) {
|
||||
ExcelSheetModel result = new ExcelSheetModel();
|
||||
ChartViewDTO chartViewDTO = null;
|
||||
|
||||
@@ -10,5 +10,7 @@ UPDATE `sys_menu` set `component` = REPLACE(`component`, 'form', 'Form') where (
|
||||
|
||||
ALTER TABLE `dataset_table_field` ADD COLUMN `date_format` VARCHAR(255) NULL AFTER `accuracy`;
|
||||
|
||||
ALTER TABLE `sys_task_email` ADD COLUMN `view_data_range` VARCHAR(255) NULL DEFAULT 'view' AFTER `reci_users`;
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user