Merge branch 'dev' into pr@dev_st_fix

This commit is contained in:
dataeaseShu 2023-07-22 08:55:05 +08:00
commit 6de62d5087
4 changed files with 21 additions and 57 deletions

View File

@ -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<String[]>();
@ -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<String, List<ChartViewFieldDTO>> fieldMap, List<ChartFieldCustomFilterDTO> customFilters, List<ChartExtFilterRequest> extFilters, Datasource ds, DatasetTable table, ChartViewDTO view, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree) {
private PluginViewParam buildPluginParam(Map<String, List<ChartViewFieldDTO>> fieldMap, List<ChartFieldCustomFilterDTO> customFilters, List<ChartExtFilterRequest> extFilters, Datasource ds, DatasetTable table, ChartViewDTO view, List<DataSetRowPermissionsTreeDTO> 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<SqlVariableDetails> sqlVariables = new Gson().fromJson(table.getSqlVariableDetails(), new TypeToken<List<SqlVariableDetails>>() {
public String preHandleVariable(String sql, ChartExtRequest requestList, QueryProvider qp, DataSetTableDTO table) {
List<SqlVariableDetails> sqlVariables = gson.fromJson(table.getSqlVariableDetails(), new TypeToken<List<SqlVariableDetails>>() {
}.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;
}

View File

@ -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;

View File

@ -2425,56 +2425,6 @@ public class DataSetTableService {
return excelFileData;
}
// public List<ExcelSheetData> parseExcel(String filename, InputStream inputStream, boolean isPreview) throws Exception {
// List<ExcelSheetData> excelSheetDataList = new ArrayList<>();
// try {
// String suffix = filename.substring(filename.lastIndexOf(".") + 1);
// if (StringUtils.equalsIgnoreCase(suffix, "xlsx")) {
//
// }
//
// if (StringUtils.equalsIgnoreCase(suffix, "csv")) {
// List<TableField> 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<String[]> 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<String[]> data = excelSheetData.getData();
// String[] fieldArray = excelSheetData.getFields().stream().map(TableField::getName).toArray(String[]::new);
//
// List<Map<String, Object>> jsonArray = new ArrayList<>();
// if (data != null) {
// jsonArray = data.stream().map(ele -> {
// Map<String, Object> 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<ExcelSheetData> excelSheetDataList(InputStream inputStream, boolean isPreview) {
List<ExcelSheetData> excelSheetDataList = new ArrayList<>();
NoModelDataListener noModelDataListener = new NoModelDataListener();

View File

@ -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 => {})
}
},