From 9b63799bad0a988ed577384e96d5066b8e614817 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Fri, 21 Jul 2023 10:47:28 +0800 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=E5=8E=BB=E6=8E=89=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/dataset/DataSetTableService.java | 50 ------------------- 1 file changed, 50 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java index 9ec95c5178..8bb823aba2 100644 --- a/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java +++ b/backend/src/main/java/io/dataease/service/dataset/DataSetTableService.java @@ -2425,56 +2425,6 @@ public class DataSetTableService { return excelFileData; } - // public List parseExcel(String filename, InputStream inputStream, boolean isPreview) throws Exception { -// List excelSheetDataList = new ArrayList<>(); -// try { -// String suffix = filename.substring(filename.lastIndexOf(".") + 1); -// if (StringUtils.equalsIgnoreCase(suffix, "xlsx")) { -// -// } -// -// if (StringUtils.equalsIgnoreCase(suffix, "csv")) { -// List fields = new ArrayList<>(); -// BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); -// String s = reader.readLine();// first line -// String[] split = s.split(","); -// for (String s1 : split) { -// TableField tableFiled = new TableField(); -// tableFiled.setName(s1); -// tableFiled.setOriginName(s1); -// tableFiled.setFieldType("TEXT"); -// fields.add(tableFiled); -// } -// List data = csvData(reader, isPreview); -// ExcelSheetData excelSheetData = new ExcelSheetData(); -// String[] fieldArray = fields.stream().map(TableField::getName).toArray(String[]::new); -// excelSheetData.setFields(fields); -// excelSheetData.setData(data); -// excelSheetData.setExcelLabel(filename.substring(0, filename.lastIndexOf('.'))); -// excelSheetDataList.add(excelSheetData); -// } -// inputStream.close(); -// for (ExcelSheetData excelSheetData : excelSheetDataList) { -// List data = excelSheetData.getData(); -// String[] fieldArray = excelSheetData.getFields().stream().map(TableField::getName).toArray(String[]::new); -// -// List> jsonArray = new ArrayList<>(); -// if (data != null) { -// jsonArray = data.stream().map(ele -> { -// Map map = new HashMap<>(); -// for (int i = 0; i < fieldArray.length; i++) { -// map.put(fieldArray[i], i < ele.length ? ele[i] : ""); -// } -// return map; -// }).collect(Collectors.toList()); -// } -// excelSheetData.setJsonArray(jsonArray); -// }; -// } catch (Exception e) { -// DEException.throwException(e); -// } -// return excelSheetDataList; -// } public List excelSheetDataList(InputStream inputStream, boolean isPreview) { List excelSheetDataList = new ArrayList<>(); NoModelDataListener noModelDataListener = new NoModelDataListener(); From 67185652254dfecd0e913fe2cf78cdbe01fa7cff Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Fri, 21 Jul 2023 14:44:31 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20=E7=A6=81=E6=AD=A2=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E6=B5=8F=E8=A7=88=E5=99=A8=E6=B3=A8=E9=94=80token=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/layout/components/Topbar.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/layout/components/Topbar.vue b/frontend/src/layout/components/Topbar.vue index 1888c83b07..34a133efa8 100644 --- a/frontend/src/layout/components/Topbar.vue +++ b/frontend/src/layout/components/Topbar.vue @@ -281,7 +281,7 @@ export default { unloadHandler(e) { this.gap_time = new Date().getTime() - this.beforeUnload_time if (this.gap_time <= 5) { - this.logout().then(res => {}) + // this.logout().then(res => {}) } }, From d9b30bafb753fffe9b35165df1268c7a70c7c947 Mon Sep 17 00:00:00 2001 From: ulleo Date: Fri, 21 Jul 2023 15:38:17 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=E6=8F=92=E4=BB=B6=E8=A7=86?= =?UTF-8?q?=E5=9B=BE=E6=94=AF=E6=8C=81=E5=8F=82=E6=95=B0=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/chart/ChartViewService.java | 18 ++++++++++++------ .../chart/ViewPluginBaseServiceImpl.java | 8 ++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java index 1b7384fd61..abd95116f2 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -448,7 +448,7 @@ public class ChartViewService { fieldMap.put("yAxis", yAxis); fieldMap.put("extStack", extStack); fieldMap.put("extBubble", extBubble); - PluginViewParam pluginViewParam = buildPluginParam(fieldMap, fieldCustomFilter, extFilterList, ds, table, view, rowPermissionsTree); + PluginViewParam pluginViewParam = buildPluginParam(fieldMap, fieldCustomFilter, extFilterList, ds, table, view, rowPermissionsTree, requestList); String sql = pluginViewSql(pluginViewParam, view); if (StringUtils.isBlank(sql)) { return new ArrayList(); @@ -982,7 +982,7 @@ public class ChartViewService { fieldMap.put("extBubble", extBubble); fieldMap.put("xAxis", xAxis); fieldMap.put("yAxis", yAxis); - PluginViewParam pluginViewParam = buildPluginParam(fieldMap, fieldCustomFilter, extFilterList, ds, table, view, rowPermissionsTree); + PluginViewParam pluginViewParam = buildPluginParam(fieldMap, fieldCustomFilter, extFilterList, ds, table, view, rowPermissionsTree, chartExtRequest); String sql = pluginViewSql(pluginViewParam, view); if (StringUtils.isBlank(sql)) { return emptyChartViewDTO(view); @@ -1441,12 +1441,13 @@ public class ChartViewService { return dto; } - private PluginViewParam buildPluginParam(Map> fieldMap, List customFilters, List extFilters, Datasource ds, DatasetTable table, ChartViewDTO view, List rowPermissionsTree) { + private PluginViewParam buildPluginParam(Map> fieldMap, List customFilters, List extFilters, Datasource ds, DatasetTable table, ChartViewDTO view, List rowPermissionsTree, ChartExtRequest chartExtRequest) { PluginViewParam pluginViewParam = new PluginViewParam(); PluginViewSetImpl pluginViewSet = BeanUtils.copyBean(new PluginViewSetImpl(), table); pluginViewSet.setDsType(ds.getType()); pluginViewSet.setTableId(table.getId()); pluginViewSet.setDs(ds); + pluginViewSet.setChartExtRequest(gson.toJson(chartExtRequest)); PluginViewLimit pluginViewLimit = BeanUtils.copyBean(new PluginViewLimit(), view); @@ -1851,8 +1852,8 @@ public class ChartViewService { chartViewMapper.updateByPrimaryKeySelective(chartView); } - private String handleVariable(String sql, ChartExtRequest requestList, QueryProvider qp, DataSetTableDTO table, Datasource ds) throws Exception { - List sqlVariables = new Gson().fromJson(table.getSqlVariableDetails(), new TypeToken>() { + public String preHandleVariable(String sql, ChartExtRequest requestList, QueryProvider qp, DataSetTableDTO table) { + List sqlVariables = gson.fromJson(table.getSqlVariableDetails(), new TypeToken>() { }.getType()); if (requestList != null && CollectionUtils.isNotEmpty(requestList.getFilter())) { for (ChartExtFilterRequest chartExtFilterRequest : requestList.getFilter()) { @@ -1863,7 +1864,7 @@ public class ChartViewService { continue; } - Boolean isEndParam = false; + boolean isEndParam = false; for (String parameter : chartExtFilterRequest.getParameters()) { if (parameter.contains("|DE|")) { String[] parameterArray = parameter.split("\\|DE\\|"); @@ -1902,6 +1903,11 @@ public class ChartViewService { } } } + return sql; + } + + private String handleVariable(String sql, ChartExtRequest requestList, QueryProvider qp, DataSetTableDTO table, Datasource ds) throws Exception { + sql = preHandleVariable(sql, requestList, qp, table); sql = dataSetTableService.handleVariableDefaultValue(sql, null, ds.getType(), false); return sql; } diff --git a/backend/src/main/java/io/dataease/service/chart/ViewPluginBaseServiceImpl.java b/backend/src/main/java/io/dataease/service/chart/ViewPluginBaseServiceImpl.java index a8707f05fd..97b44fe33f 100644 --- a/backend/src/main/java/io/dataease/service/chart/ViewPluginBaseServiceImpl.java +++ b/backend/src/main/java/io/dataease/service/chart/ViewPluginBaseServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.util.ReflectUtil; import com.google.gson.Gson; import io.dataease.commons.model.PluginViewSetImpl; import io.dataease.commons.utils.TableUtils; +import io.dataease.controller.request.chart.ChartExtRequest; import io.dataease.dto.dataset.DataSetTableUnionDTO; import io.dataease.dto.dataset.DataTableInfoDTO; import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs; @@ -47,6 +48,9 @@ public class ViewPluginBaseServiceImpl implements ViewPluginBaseService { @Resource private DataSetTableService dataSetTableService; + @Resource + private ChartViewService chartViewService; + @Override public PluginSingleField buildField(String dsType, PluginViewField pluginViewField, PluginViewSQL tableObj, int index) { @@ -122,6 +126,10 @@ public class ViewPluginBaseServiceImpl implements ViewPluginBaseService { break; case SQL: String sql = dataTableInfoDTO.isBase64Encryption() ? new String(java.util.Base64.getDecoder().decode(dataTableInfoDTO.getSql())) : dataTableInfoDTO.getSql(); + if (StringUtils.isNotBlank(pluginViewSet.getChartExtRequest())) { + ChartExtRequest chartExtRequest = gson.fromJson(pluginViewSet.getChartExtRequest(), ChartExtRequest.class); + sql = chartViewService.preHandleVariable(sql, chartExtRequest, ProviderFactory.getQueryProvider(pluginViewSet.getDsType()), dataSetTableService.getWithPermission(pluginViewSet.getTableId(), chartExtRequest.getUser())); + } tableName = dataSetTableService.handleVariableDefaultValue(sql, null, pluginViewSet.getDsType(), false); tableName = "(" + sqlFix(tableName) + ")"; break;