Merge pull request #6999 from dataease/pr@dev@feat_calc
feat: 计算字段支持二次引用 #5996
This commit is contained in:
commit
eac2be019b
@ -1,6 +1,8 @@
|
||||
package io.dataease.provider.engine.doris;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||
@ -197,7 +199,7 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
if (StringUtils.isNotBlank(keyword)) {
|
||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
||||
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||
wheres.add(keyWhere);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
@ -1418,27 +1420,54 @@ public class DorisQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
try {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String buildCalcField(String originField, SQLObj tableObj, int i) throws Exception {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return originField;
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
if (StringUtils.containsIgnoreCase(originField, ele.getId() + "")) {
|
||||
// 计算字段允许二次引用,这里递归查询完整引用链
|
||||
if (Objects.equals(ele.getExtField(), 0)) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(DorisConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getDataeaseName()));
|
||||
} else {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]", ele.getOriginName());
|
||||
originField = buildCalcField(originField, tableObj, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(DorisConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getDataeaseName()));
|
||||
}
|
||||
return originField;
|
||||
return null;
|
||||
}
|
||||
|
||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package io.dataease.provider.engine.mysql;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||
@ -167,7 +169,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
if (StringUtils.isNotBlank(keyword)) {
|
||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
||||
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||
wheres.add(keyWhere);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
@ -1366,27 +1368,54 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
try {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String buildCalcField(String originField, SQLObj tableObj, int i) throws Exception {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return originField;
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
if (StringUtils.containsIgnoreCase(originField, ele.getId() + "")) {
|
||||
// 计算字段允许二次引用,这里递归查询完整引用链
|
||||
if (Objects.equals(ele.getExtField(), 0)) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(MysqlConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getDataeaseName()));
|
||||
} else {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]", ele.getOriginName());
|
||||
originField = buildCalcField(originField, tableObj, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(MysqlConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getDataeaseName()));
|
||||
}
|
||||
return originField;
|
||||
return null;
|
||||
}
|
||||
|
||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
package io.dataease.provider.query.ck;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.commons.utils.BeanUtils;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||
@ -196,7 +198,7 @@ public class CKQueryProvider extends QueryProvider {
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
if (StringUtils.isNotBlank(keyword)) {
|
||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
||||
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||
wheres.add(keyWhere);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
@ -1416,27 +1418,54 @@ public class CKQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
try {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String buildCalcField(String originField, SQLObj tableObj, int i) throws Exception {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return originField;
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
if (StringUtils.containsIgnoreCase(originField, ele.getId() + "")) {
|
||||
// 计算字段允许二次引用,这里递归查询完整引用链
|
||||
if (Objects.equals(ele.getExtField(), 0)) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
} else {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]", ele.getOriginName());
|
||||
originField = buildCalcField(originField, tableObj, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
}
|
||||
return originField;
|
||||
return null;
|
||||
}
|
||||
|
||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||
|
||||
@ -2,7 +2,9 @@ package io.dataease.provider.query.db2;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.dto.datasource.Db2Configuration;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||
@ -172,7 +174,7 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
if (StringUtils.isNotBlank(keyword)) {
|
||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
||||
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||
wheres.add(keyWhere);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
@ -1404,27 +1406,54 @@ public class Db2QueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
try {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String buildCalcField(String originField, SQLObj tableObj, int i) throws Exception {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return originField;
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
if (StringUtils.containsIgnoreCase(originField, ele.getId() + "")) {
|
||||
// 计算字段允许二次引用,这里递归查询完整引用链
|
||||
if (Objects.equals(ele.getExtField(), 0)) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(Db2Constants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
} else {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]", ele.getOriginName());
|
||||
originField = buildCalcField(originField, tableObj, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(Db2Constants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
}
|
||||
return originField;
|
||||
return null;
|
||||
}
|
||||
|
||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package io.dataease.provider.query.es;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||
@ -1322,27 +1324,54 @@ public class EsQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
try {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String buildCalcField(String originField, SQLObj tableObj, int i) throws Exception {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return originField;
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
if (StringUtils.containsIgnoreCase(originField, ele.getId() + "")) {
|
||||
// 计算字段允许二次引用,这里递归查询完整引用链
|
||||
if (Objects.equals(ele.getExtField(), 0)) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
} else {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]", ele.getOriginName());
|
||||
originField = buildCalcField(originField, tableObj, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
}
|
||||
return originField;
|
||||
return null;
|
||||
}
|
||||
|
||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package io.dataease.provider.query.hive;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||
@ -153,7 +155,7 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
if (StringUtils.isNotBlank(keyword)) {
|
||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
||||
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||
wheres.add(keyWhere);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
@ -1334,27 +1336,54 @@ public class HiveQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
try {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String buildCalcField(String originField, SQLObj tableObj, int i) throws Exception {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return originField;
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
if (StringUtils.containsIgnoreCase(originField, ele.getId() + "")) {
|
||||
// 计算字段允许二次引用,这里递归查询完整引用链
|
||||
if (Objects.equals(ele.getExtField(), 0)) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(HiveConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
} else {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]", ele.getOriginName());
|
||||
originField = buildCalcField(originField, tableObj, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(HiveConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
}
|
||||
return originField;
|
||||
return null;
|
||||
}
|
||||
|
||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package io.dataease.provider.query.impala;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||
@ -18,7 +20,6 @@ import io.dataease.plugins.common.request.chart.ChartExtFilterRequest;
|
||||
import io.dataease.plugins.common.request.permission.DataSetRowPermissionsTreeDTO;
|
||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem;
|
||||
import io.dataease.plugins.datasource.entity.Dateformat;
|
||||
import io.dataease.plugins.datasource.entity.PageInfo;
|
||||
import io.dataease.plugins.datasource.query.QueryProvider;
|
||||
import io.dataease.plugins.datasource.query.Utils;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@ -1306,27 +1307,54 @@ public class ImpalaQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
try {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String buildCalcField(String originField, SQLObj tableObj, int i) throws Exception {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return originField;
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
if (StringUtils.containsIgnoreCase(originField, ele.getId() + "")) {
|
||||
// 计算字段允许二次引用,这里递归查询完整引用链
|
||||
if (Objects.equals(ele.getExtField(), 0)) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(ImpalaConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
} else {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]", ele.getOriginName());
|
||||
originField = buildCalcField(originField, tableObj, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(ImpalaConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
}
|
||||
return originField;
|
||||
return null;
|
||||
}
|
||||
|
||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package io.dataease.provider.query.mongodb;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||
@ -139,7 +141,7 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (StringUtils.isNotBlank(keyword)) {
|
||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
||||
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||
wheres.add(keyWhere);
|
||||
}
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
@ -1159,27 +1161,54 @@ public class MongoQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
try {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String buildCalcField(String originField, SQLObj tableObj, int i) throws Exception {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return originField;
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
if (StringUtils.containsIgnoreCase(originField, ele.getId() + "")) {
|
||||
// 计算字段允许二次引用,这里递归查询完整引用链
|
||||
if (Objects.equals(ele.getExtField(), 0)) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
} else {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]", ele.getOriginName());
|
||||
originField = buildCalcField(originField, tableObj, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
}
|
||||
return originField;
|
||||
return null;
|
||||
}
|
||||
|
||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package io.dataease.provider.query.mysql;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||
@ -251,7 +253,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
|
||||
if (StringUtils.isNotBlank(keyword)) {
|
||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
||||
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||
wheres.add(keyWhere);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
@ -1426,27 +1428,54 @@ public class MysqlQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
try {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String buildCalcField(String originField, SQLObj tableObj, int i) throws Exception {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return originField;
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
if (StringUtils.containsIgnoreCase(originField, ele.getId() + "")) {
|
||||
// 计算字段允许二次引用,这里递归查询完整引用链
|
||||
if (Objects.equals(ele.getExtField(), 0)) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
} else {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]", ele.getOriginName());
|
||||
originField = buildCalcField(originField, tableObj, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(MySQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
}
|
||||
return originField;
|
||||
return null;
|
||||
}
|
||||
|
||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||
|
||||
@ -2,7 +2,9 @@ package io.dataease.provider.query.oracle;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.dto.datasource.OracleConfiguration;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||
@ -127,7 +129,7 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
if (StringUtils.isNotBlank(keyword)) {
|
||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
||||
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||
wheres.add(keyWhere);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
@ -1516,27 +1518,54 @@ public class OracleQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
try {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String buildCalcField(String originField, SQLObj tableObj, int i) throws Exception {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return originField;
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
if (StringUtils.containsIgnoreCase(originField, ele.getId() + "")) {
|
||||
// 计算字段允许二次引用,这里递归查询完整引用链
|
||||
if (Objects.equals(ele.getExtField(), 0)) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
} else {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]", ele.getOriginName());
|
||||
originField = buildCalcField(originField, tableObj, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
}
|
||||
return originField;
|
||||
return null;
|
||||
}
|
||||
|
||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||
|
||||
@ -2,6 +2,8 @@ package io.dataease.provider.query.pg;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||
@ -180,7 +182,7 @@ public class PgQueryProvider extends QueryProvider {
|
||||
List<String> wheres = new ArrayList<>();
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (StringUtils.isNotBlank(keyword)) {
|
||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
||||
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||
wheres.add(keyWhere);
|
||||
}
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
@ -1332,27 +1334,54 @@ public class PgQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
try {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String buildCalcField(String originField, SQLObj tableObj, int i) throws Exception {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return originField;
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
if (StringUtils.containsIgnoreCase(originField, ele.getId() + "")) {
|
||||
// 计算字段允许二次引用,这里递归查询完整引用链
|
||||
if (Objects.equals(ele.getExtField(), 0)) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
} else {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]", ele.getOriginName());
|
||||
originField = buildCalcField(originField, tableObj, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
}
|
||||
return originField;
|
||||
return null;
|
||||
}
|
||||
|
||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||
|
||||
@ -2,6 +2,8 @@ package io.dataease.provider.query.redshift;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||
@ -1313,27 +1315,54 @@ public class RedshiftQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
try {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String buildCalcField(String originField, SQLObj tableObj, int i) throws Exception {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return originField;
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
if (StringUtils.containsIgnoreCase(originField, ele.getId() + "")) {
|
||||
// 计算字段允许二次引用,这里递归查询完整引用链
|
||||
if (Objects.equals(ele.getExtField(), 0)) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
} else {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]", ele.getOriginName());
|
||||
originField = buildCalcField(originField, tableObj, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
}
|
||||
return originField;
|
||||
return null;
|
||||
}
|
||||
|
||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||
|
||||
@ -2,6 +2,8 @@ package io.dataease.provider.query.sqlserver;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.google.gson.Gson;
|
||||
import io.dataease.commons.exception.DEException;
|
||||
import io.dataease.i18n.Translator;
|
||||
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||
@ -269,7 +271,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
if (customWheres != null) wheres.add(customWheres);
|
||||
if (whereTrees != null) wheres.add(whereTrees);
|
||||
if (StringUtils.isNotBlank(keyword)) {
|
||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
||||
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||
wheres.add(keyWhere);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||
@ -282,7 +284,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
xOrders.add(order);
|
||||
}
|
||||
}
|
||||
if(ObjectUtils.isNotEmpty(limit)){
|
||||
if (ObjectUtils.isNotEmpty(limit)) {
|
||||
SQLObj limitFiled = SQLObj.builder().limitFiled(" top " + limit + " ").build();
|
||||
st_sql.add("limitFiled", limitFiled);
|
||||
}
|
||||
@ -1488,27 +1490,54 @@ public class SqlserverQueryProvider extends QueryProvider {
|
||||
}
|
||||
|
||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
try {
|
||||
int i = 0;
|
||||
return buildCalcField(originField, tableObj, i);
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String buildCalcField(String originField, SQLObj tableObj, int i) throws Exception {
|
||||
try {
|
||||
i++;
|
||||
if (i > 100) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
||||
// 正则提取[xxx]
|
||||
String regex = "\\[(.*?)]";
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(originField);
|
||||
Set<String> ids = new HashSet<>();
|
||||
while (matcher.find()) {
|
||||
String id = matcher.group(1);
|
||||
ids.add(id);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return originField;
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
if (StringUtils.containsIgnoreCase(originField, ele.getId() + "")) {
|
||||
// 计算字段允许二次引用,这里递归查询完整引用链
|
||||
if (Objects.equals(ele.getExtField(), 0)) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
} else {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]", ele.getOriginName());
|
||||
originField = buildCalcField(originField, tableObj, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return originField;
|
||||
} catch (Exception e) {
|
||||
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||
}
|
||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
||||
datasetTableFieldExample.createCriteria().andIdIn(new ArrayList<>(ids));
|
||||
List<DatasetTableField> calcFields = datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
||||
for (DatasetTableField ele : calcFields) {
|
||||
originField = originField.replaceAll("\\[" + ele.getId() + "]",
|
||||
String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), ele.getOriginName()));
|
||||
}
|
||||
return originField;
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -277,4 +277,6 @@ I18N_PANEL_PDF_TEMPLATE_ONLY_PIC=Default template only screenshot
|
||||
\u8FB9\u684610=Border 10
|
||||
I18n_name_cant_empty=Name can not be empty!
|
||||
I18n_del_admin_tips=Forbidden to delete the admin account
|
||||
I18N_NO_DRIVER_PERMISSION=Do not have permissions!
|
||||
I18N_NO_DRIVER_PERMISSION=Do not have permissions!
|
||||
i18n_field_circular_error=Field error
|
||||
i18n_field_circular_ref=Field has Circular Reference
|
||||
|
||||
@ -268,4 +268,5 @@ I18N_PANEL_PDF_TEMPLATE_ONLY_PIC=\u9ED8\u8BA4\u6A21\u677F(\u53EA\u622A\u56FE)
|
||||
I18n_name_cant_empty=\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\uFF01
|
||||
I18n_del_admin_tips=\u7981\u6B62\u5220\u9664admin\u8D26\u53F7
|
||||
I18N_NO_DRIVER_PERMISSION=\u6ca1\u6709\u6743\u9650\uff01
|
||||
|
||||
i18n_field_circular_error=\u5B57\u6BB5\u89E3\u6790\u9519\u8BEF\uFF0C\u53EF\u80FD\u539F\u56E0\uFF1A\u5B57\u6BB5\u5DF2\u5220\u9664\u3001\u8BA1\u7B97\u5B57\u6BB5\u5F15\u7528\u5C42\u7EA7\u8FC7\u6DF1\u3001\u5B58\u5728\u5FAA\u73AF\u5F15\u7528\u7B49\uFF0C\u8BF7\u68C0\u67E5\u8868\u8282\u70B9\u548C\u5B57\u6BB5\u5E76\u91CD\u65B0\u7F16\u8F91\u3002
|
||||
i18n_field_circular_ref=\u5B57\u6BB5\u5B58\u5728\u5FAA\u73AF\u5F15\u7528
|
||||
|
||||
@ -273,4 +273,6 @@ I18N_PANEL_PDF_TEMPLATE_ONLY_PIC=\u9ED8\u8A8D\u6A21\u677F(\u53EA\u622A\u5716)
|
||||
\u8FB9\u684610=\u908A\u6846 10
|
||||
I18n_name_cant_empty=\u540D\u7A31\u4E0D\u80FD\u70BA\u7A7A\uFF01
|
||||
I18n_del_admin_tips=\u7981\u6B62\u522A\u9664admin\u8CEC\u865F
|
||||
I18N_NO_DRIVER_PERMISSION=\u6c92\u6709\u8a31\u53ef\u6b0a\uff01
|
||||
I18N_NO_DRIVER_PERMISSION=\u6c92\u6709\u8a31\u53ef\u6b0a\uff01
|
||||
i18n_field_circular_error=\u5B57\u6BB5\u89E3\u6790\u932F\u8AA4\uFF0C\u53EF\u80FD\u539F\u56E0\uFF1A\u5B57\u6BB5\u5DF2\u522A\u9664\u3001\u8A08\u7B97\u5B57\u6BB5\u5F15\u7528\u5C64\u7D1A\u904E\u6DF1\u3001\u5B58\u5728\u5FAA\u74B0\u5F15\u7528\u7B49\uFF0C\u8ACB\u6AA2\u67E5\u8868\u7BC0\u9EDE\u548C\u5B57\u6BB5\u4E26\u91CD\u65B0\u7DE8\u8F2F\u3002
|
||||
i18n_field_circular_ref=\u5B57\u6BB5\u5B58\u5728\u5FAA\u74B0\u5F15\u7528
|
||||
|
||||
@ -415,16 +415,16 @@ export default {
|
||||
deep: true
|
||||
},
|
||||
'tableFields': function() {
|
||||
this.dimensionData = JSON.parse(JSON.stringify(this.tableFields.dimensionList)).filter(ele => ele.extField === 0)
|
||||
this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList)).filter(ele => ele.extField === 0)
|
||||
this.dimensionData = JSON.parse(JSON.stringify(this.tableFields.dimensionList))
|
||||
this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList))
|
||||
},
|
||||
'searchField': function(val) {
|
||||
if (val && val !== '') {
|
||||
this.dimensionData = JSON.parse(JSON.stringify(this.tableFields.dimensionList.filter(ele => ele.name.toLocaleLowerCase().includes(val.toLocaleLowerCase()) && ele.extField === 0)))
|
||||
this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList.filter(ele => ele.name.toLocaleLowerCase().includes(val.toLocaleLowerCase()) && ele.extField === 0)))
|
||||
this.dimensionData = JSON.parse(JSON.stringify(this.tableFields.dimensionList.filter(ele => ele.name.toLocaleLowerCase().includes(val.toLocaleLowerCase()))))
|
||||
this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList.filter(ele => ele.name.toLocaleLowerCase().includes(val.toLocaleLowerCase()))))
|
||||
} else {
|
||||
this.dimensionData = JSON.parse(JSON.stringify(this.tableFields.dimensionList)).filter(ele => ele.extField === 0)
|
||||
this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList)).filter(ele => ele.extField === 0)
|
||||
this.dimensionData = JSON.parse(JSON.stringify(this.tableFields.dimensionList))
|
||||
this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList))
|
||||
}
|
||||
},
|
||||
'searchFunction': function(val) {
|
||||
@ -572,8 +572,8 @@ export default {
|
||||
this.tableFields.dimensionListData = JSON.parse(JSON.stringify(this.tableFields.dimensionList))
|
||||
this.tableFields.quotaListData = JSON.parse(JSON.stringify(this.tableFields.quotaList))
|
||||
|
||||
this.dimensionData = JSON.parse(JSON.stringify(this.tableFields.dimensionList)).filter(ele => ele.extField === 0)
|
||||
this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList)).filter(ele => ele.extField === 0)
|
||||
this.dimensionData = JSON.parse(JSON.stringify(this.tableFields.dimensionList))
|
||||
this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList))
|
||||
|
||||
this.initField()
|
||||
})
|
||||
|
||||
@ -392,10 +392,10 @@ export default {
|
||||
tableFields: function() {
|
||||
this.dimensionData = JSON.parse(
|
||||
JSON.stringify(this.tableFields.dimensionList)
|
||||
).filter((ele) => ele.extField === 0)
|
||||
)
|
||||
this.quotaData = JSON.parse(
|
||||
JSON.stringify(this.tableFields.quotaList)
|
||||
).filter((ele) => ele.extField === 0)
|
||||
)
|
||||
},
|
||||
searchField: function(val) {
|
||||
if (val && val !== '') {
|
||||
@ -405,7 +405,7 @@ export default {
|
||||
(ele) =>
|
||||
ele.name
|
||||
.toLocaleLowerCase()
|
||||
.includes(val.toLocaleLowerCase()) && ele.extField === 0
|
||||
.includes(val.toLocaleLowerCase())
|
||||
)
|
||||
)
|
||||
)
|
||||
@ -415,17 +415,17 @@ export default {
|
||||
(ele) =>
|
||||
ele.name
|
||||
.toLocaleLowerCase()
|
||||
.includes(val.toLocaleLowerCase()) && ele.extField === 0
|
||||
.includes(val.toLocaleLowerCase())
|
||||
)
|
||||
)
|
||||
)
|
||||
} else {
|
||||
this.dimensionData = JSON.parse(
|
||||
JSON.stringify(this.tableFields.dimensionList)
|
||||
).filter((ele) => ele.extField === 0)
|
||||
)
|
||||
this.quotaData = JSON.parse(
|
||||
JSON.stringify(this.tableFields.quotaList)
|
||||
).filter((ele) => ele.extField === 0)
|
||||
)
|
||||
}
|
||||
},
|
||||
searchFunction: function(val) {
|
||||
@ -452,10 +452,10 @@ export default {
|
||||
this.initFunctions()
|
||||
this.dimensionData = JSON.parse(
|
||||
JSON.stringify(this.tableFields.dimensionList)
|
||||
).filter((ele) => ele.extField === 0)
|
||||
)
|
||||
this.quotaData = JSON.parse(
|
||||
JSON.stringify(this.tableFields.quotaList)
|
||||
).filter((ele) => ele.extField === 0)
|
||||
)
|
||||
this.initField()
|
||||
},
|
||||
methods: {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user