forked from github/dataease
perf(定时报告): 根据视图数据范围导出不同数据
This commit is contained in:
parent
84a22b5dec
commit
bed3413747
@ -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`;
|
||||
|
||||
|
||||
|
||||
|
@ -82,8 +82,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.4.0-0",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.18.6",
|
||||
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.18.6",
|
||||
"@babel/register": "7.0.0",
|
||||
"@vue/cli-plugin-babel": "3.6.0",
|
||||
"@vue/cli-plugin-eslint": "^5.0.4",
|
||||
|
@ -2484,18 +2484,19 @@ export default {
|
||||
exec_time: 'Execute time',
|
||||
start_time: 'Start time',
|
||||
end_time: 'End time',
|
||||
|
||||
chart_data: 'View data',
|
||||
preview: 'Preview',
|
||||
emial_preview: 'Emial preview',
|
||||
|
||||
chart_data_range: 'View data range',
|
||||
simple_repeat: 'Simple repeat',
|
||||
once_a_day: 'Once a day',
|
||||
once_a_week: 'Once a week',
|
||||
once_a_month: 'Once a month',
|
||||
complex_repeat: 'Complex repeat',
|
||||
pixel_tip: 'Please code custom pixel(such as 2560 * 1600) or select',
|
||||
task_type: 'Task type'
|
||||
|
||||
task_type: 'Task type',
|
||||
range_view: 'Displayed data',
|
||||
range_all: 'All data'
|
||||
},
|
||||
dynamic_time: {
|
||||
set_default: 'Set Default',
|
||||
|
@ -2485,18 +2485,19 @@ export default {
|
||||
exec_time: '執行時間',
|
||||
start_time: '開始時間',
|
||||
end_time: '結束時間',
|
||||
|
||||
chart_data: '視圖數據',
|
||||
preview: '預覽',
|
||||
emial_preview: '郵件預覽',
|
||||
|
||||
chart_data_range: '視圖數據範圍',
|
||||
simple_repeat: '簡單重複',
|
||||
once_a_day: '每天一次',
|
||||
once_a_week: '每周一次',
|
||||
once_a_month: '每月一次',
|
||||
complex_repeat: '複雜重複',
|
||||
pixel_tip: '可直接輸入分辨率(例如:2560 * 1600)或者選擇',
|
||||
task_type: '任務類型'
|
||||
|
||||
task_type: '任務類型',
|
||||
range_view: '展示數據',
|
||||
range_all: '全部數據'
|
||||
},
|
||||
dynamic_time: {
|
||||
set_default: '設置默認值',
|
||||
|
Loading…
Reference in New Issue
Block a user