fix: 抽取模式插件视图不可用

This commit is contained in:
fit2cloud-chenyw 2022-03-28 15:17:41 +08:00
parent 28d567447e
commit 8137acfd50
2 changed files with 29 additions and 22 deletions

View File

@ -784,6 +784,7 @@ public class ChartViewService {
PluginViewParam pluginViewParam = new PluginViewParam(); PluginViewParam pluginViewParam = new PluginViewParam();
PluginViewSet pluginViewSet = BeanUtils.copyBean(new PluginViewSet(), table); PluginViewSet pluginViewSet = BeanUtils.copyBean(new PluginViewSet(), table);
pluginViewSet.setDsType(ds.getType()); pluginViewSet.setDsType(ds.getType());
pluginViewSet.setTabelId(table.getId());
PluginViewLimit pluginViewLimit = BeanUtils.copyBean(new PluginViewLimit(), view); PluginViewLimit pluginViewLimit = BeanUtils.copyBean(new PluginViewLimit(), view);

View File

@ -93,6 +93,11 @@ public class ViewPluginBaseServiceImpl implements ViewPluginBaseService {
public PluginViewSQL getTableObj(PluginViewSet pluginViewSet) { public PluginViewSQL getTableObj(PluginViewSet pluginViewSet) {
String tableName = null; String tableName = null;
DataTableInfoDTO dataTableInfoDTO = new Gson().fromJson(pluginViewSet.getInfo(), DataTableInfoDTO.class); DataTableInfoDTO dataTableInfoDTO = new Gson().fromJson(pluginViewSet.getInfo(), DataTableInfoDTO.class);
if (ObjectUtils.isNotEmpty(pluginViewSet.getMode()) && 1 == pluginViewSet.getMode()) {
tableName = "ds_" + pluginViewSet.getTabelId().replaceAll("-", "_");
}else {
switch (pluginViewSet.getType()) { switch (pluginViewSet.getType()) {
case "db": case "db":
tableName = dataTableInfoDTO.getTable(); tableName = dataTableInfoDTO.getTable();
@ -113,9 +118,10 @@ public class ViewPluginBaseServiceImpl implements ViewPluginBaseService {
tableName = (String) sqlMap.get("sql"); tableName = (String) sqlMap.get("sql");
break; break;
default: default:
tableName = dataTableInfoDTO.getTable();
break; break;
} }
}
String keyword = ConstantsUtil.constantsValue(pluginViewSet.getDsType(), "KEYWORD_TABLE"); String keyword = ConstantsUtil.constantsValue(pluginViewSet.getDsType(), "KEYWORD_TABLE");
String tabelName = (tableName.startsWith("(") && tableName.endsWith(")")) ? tableName : String.format(keyword, tableName); String tabelName = (tableName.startsWith("(") && tableName.endsWith(")")) ? tableName : String.format(keyword, tableName);
String tabelAlias = String.format(TABLE_ALIAS_PREFIX, 0); String tabelAlias = String.format(TABLE_ALIAS_PREFIX, 0);