forked from github/dataease
commit
c48d0773ef
@ -448,7 +448,7 @@ public class ChartViewService {
|
|||||||
fieldMap.put("yAxis", yAxis);
|
fieldMap.put("yAxis", yAxis);
|
||||||
fieldMap.put("extStack", extStack);
|
fieldMap.put("extStack", extStack);
|
||||||
fieldMap.put("extBubble", extBubble);
|
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);
|
String sql = pluginViewSql(pluginViewParam, view);
|
||||||
if (StringUtils.isBlank(sql)) {
|
if (StringUtils.isBlank(sql)) {
|
||||||
return new ArrayList<String[]>();
|
return new ArrayList<String[]>();
|
||||||
@ -982,7 +982,7 @@ public class ChartViewService {
|
|||||||
fieldMap.put("extBubble", extBubble);
|
fieldMap.put("extBubble", extBubble);
|
||||||
fieldMap.put("xAxis", xAxis);
|
fieldMap.put("xAxis", xAxis);
|
||||||
fieldMap.put("yAxis", yAxis);
|
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);
|
String sql = pluginViewSql(pluginViewParam, view);
|
||||||
if (StringUtils.isBlank(sql)) {
|
if (StringUtils.isBlank(sql)) {
|
||||||
return emptyChartViewDTO(view);
|
return emptyChartViewDTO(view);
|
||||||
@ -1441,12 +1441,13 @@ public class ChartViewService {
|
|||||||
return dto;
|
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();
|
PluginViewParam pluginViewParam = new PluginViewParam();
|
||||||
PluginViewSetImpl pluginViewSet = BeanUtils.copyBean(new PluginViewSetImpl(), table);
|
PluginViewSetImpl pluginViewSet = BeanUtils.copyBean(new PluginViewSetImpl(), table);
|
||||||
pluginViewSet.setDsType(ds.getType());
|
pluginViewSet.setDsType(ds.getType());
|
||||||
pluginViewSet.setTableId(table.getId());
|
pluginViewSet.setTableId(table.getId());
|
||||||
pluginViewSet.setDs(ds);
|
pluginViewSet.setDs(ds);
|
||||||
|
pluginViewSet.setChartExtRequest(gson.toJson(chartExtRequest));
|
||||||
PluginViewLimit pluginViewLimit = BeanUtils.copyBean(new PluginViewLimit(), view);
|
PluginViewLimit pluginViewLimit = BeanUtils.copyBean(new PluginViewLimit(), view);
|
||||||
|
|
||||||
|
|
||||||
@ -1851,8 +1852,8 @@ public class ChartViewService {
|
|||||||
chartViewMapper.updateByPrimaryKeySelective(chartView);
|
chartViewMapper.updateByPrimaryKeySelective(chartView);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String handleVariable(String sql, ChartExtRequest requestList, QueryProvider qp, DataSetTableDTO table, Datasource ds) throws Exception {
|
public String preHandleVariable(String sql, ChartExtRequest requestList, QueryProvider qp, DataSetTableDTO table) {
|
||||||
List<SqlVariableDetails> sqlVariables = new Gson().fromJson(table.getSqlVariableDetails(), new TypeToken<List<SqlVariableDetails>>() {
|
List<SqlVariableDetails> sqlVariables = gson.fromJson(table.getSqlVariableDetails(), new TypeToken<List<SqlVariableDetails>>() {
|
||||||
}.getType());
|
}.getType());
|
||||||
if (requestList != null && CollectionUtils.isNotEmpty(requestList.getFilter())) {
|
if (requestList != null && CollectionUtils.isNotEmpty(requestList.getFilter())) {
|
||||||
for (ChartExtFilterRequest chartExtFilterRequest : requestList.getFilter()) {
|
for (ChartExtFilterRequest chartExtFilterRequest : requestList.getFilter()) {
|
||||||
@ -1863,7 +1864,7 @@ public class ChartViewService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolean isEndParam = false;
|
boolean isEndParam = false;
|
||||||
for (String parameter : chartExtFilterRequest.getParameters()) {
|
for (String parameter : chartExtFilterRequest.getParameters()) {
|
||||||
if (parameter.contains("|DE|")) {
|
if (parameter.contains("|DE|")) {
|
||||||
String[] parameterArray = parameter.split("\\|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);
|
sql = dataSetTableService.handleVariableDefaultValue(sql, null, ds.getType(), false);
|
||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import cn.hutool.core.util.ReflectUtil;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import io.dataease.commons.model.PluginViewSetImpl;
|
import io.dataease.commons.model.PluginViewSetImpl;
|
||||||
import io.dataease.commons.utils.TableUtils;
|
import io.dataease.commons.utils.TableUtils;
|
||||||
|
import io.dataease.controller.request.chart.ChartExtRequest;
|
||||||
import io.dataease.dto.dataset.DataSetTableUnionDTO;
|
import io.dataease.dto.dataset.DataSetTableUnionDTO;
|
||||||
import io.dataease.dto.dataset.DataTableInfoDTO;
|
import io.dataease.dto.dataset.DataTableInfoDTO;
|
||||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||||
@ -47,6 +48,9 @@ public class ViewPluginBaseServiceImpl implements ViewPluginBaseService {
|
|||||||
@Resource
|
@Resource
|
||||||
private DataSetTableService dataSetTableService;
|
private DataSetTableService dataSetTableService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ChartViewService chartViewService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PluginSingleField buildField(String dsType, PluginViewField pluginViewField, PluginViewSQL tableObj, int index) {
|
public PluginSingleField buildField(String dsType, PluginViewField pluginViewField, PluginViewSQL tableObj, int index) {
|
||||||
@ -122,6 +126,10 @@ public class ViewPluginBaseServiceImpl implements ViewPluginBaseService {
|
|||||||
break;
|
break;
|
||||||
case SQL:
|
case SQL:
|
||||||
String sql = dataTableInfoDTO.isBase64Encryption() ? new String(java.util.Base64.getDecoder().decode(dataTableInfoDTO.getSql())) : dataTableInfoDTO.getSql();
|
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 = dataSetTableService.handleVariableDefaultValue(sql, null, pluginViewSet.getDsType(), false);
|
||||||
tableName = "(" + sqlFix(tableName) + ")";
|
tableName = "(" + sqlFix(tableName) + ")";
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user