Merge branch 'dev' into pr@dev_one_dot_x
This commit is contained in:
commit
0aefe3a4f3
@ -8,10 +8,6 @@
|
|||||||
<a href="https://app.fossa.com/projects/git%2Bgithub.com%2F1dataease%2Fdataease?ref=badge_shield"><img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fdataease%2Fdataease.svg?type=shield" alt="FOSSA Status"></a>
|
<a href="https://app.fossa.com/projects/git%2Bgithub.com%2F1dataease%2Fdataease?ref=badge_shield"><img src="https://app.fossa.com/api/projects/git%2Bgithub.com%2Fdataease%2Fdataease.svg?type=shield" alt="FOSSA Status"></a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|说明|
|
|
||||||
|------------------|
|
|
||||||
|此分支为 DataEase v1.18 版本的开发分支。[DataEase v2.0.0](https://github.com/dataease/dataease/releases/tag/v2.0.0) 也已经正式发布,v2 版本的开发分支为 [dev-v2](https://github.com/dataease/dataease/tree/dev-v2)。v2 版本正在快速迭代中,如是在生产环境部署 DataEase,建议继续使用 v1.18.* 的最新稳定版本。|
|
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
## 什么是 DataEase?
|
## 什么是 DataEase?
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package io.dataease.provider.engine.doris;
|
package io.dataease.provider.engine.doris;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
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.ChartViewWithBLOBs;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||||
@ -197,7 +199,7 @@ public class DorisQueryProvider extends QueryProvider {
|
|||||||
if (customWheres != null) wheres.add(customWheres);
|
if (customWheres != null) wheres.add(customWheres);
|
||||||
if (whereTrees != null) wheres.add(whereTrees);
|
if (whereTrees != null) wheres.add(whereTrees);
|
||||||
if (StringUtils.isNotBlank(keyword)) {
|
if (StringUtils.isNotBlank(keyword)) {
|
||||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||||
wheres.add(keyWhere);
|
wheres.add(keyWhere);
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
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) {
|
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
try {
|
||||||
// 正则提取[xxx]
|
int i = 0;
|
||||||
String regex = "\\[(.*?)]";
|
return buildCalcField(originField, tableObj, i);
|
||||||
Pattern pattern = Pattern.compile(regex);
|
} catch (Exception e) {
|
||||||
Matcher matcher = pattern.matcher(originField);
|
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||||
Set<String> ids = new HashSet<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
String id = matcher.group(1);
|
|
||||||
ids.add(id);
|
|
||||||
}
|
}
|
||||||
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;
|
return originField;
|
||||||
|
} catch (Exception e) {
|
||||||
|
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||||
}
|
}
|
||||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
return null;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package io.dataease.provider.engine.mysql;
|
package io.dataease.provider.engine.mysql;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
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.ChartViewWithBLOBs;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||||
@ -167,7 +169,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
|||||||
if (customWheres != null) wheres.add(customWheres);
|
if (customWheres != null) wheres.add(customWheres);
|
||||||
if (whereTrees != null) wheres.add(whereTrees);
|
if (whereTrees != null) wheres.add(whereTrees);
|
||||||
if (StringUtils.isNotBlank(keyword)) {
|
if (StringUtils.isNotBlank(keyword)) {
|
||||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||||
wheres.add(keyWhere);
|
wheres.add(keyWhere);
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
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) {
|
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
try {
|
||||||
// 正则提取[xxx]
|
int i = 0;
|
||||||
String regex = "\\[(.*?)]";
|
return buildCalcField(originField, tableObj, i);
|
||||||
Pattern pattern = Pattern.compile(regex);
|
} catch (Exception e) {
|
||||||
Matcher matcher = pattern.matcher(originField);
|
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||||
Set<String> ids = new HashSet<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
String id = matcher.group(1);
|
|
||||||
ids.add(id);
|
|
||||||
}
|
}
|
||||||
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;
|
return originField;
|
||||||
|
} catch (Exception e) {
|
||||||
|
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||||
}
|
}
|
||||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
return null;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||||
|
|||||||
@ -1,7 +1,9 @@
|
|||||||
package io.dataease.provider.query.ck;
|
package io.dataease.provider.query.ck;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import io.dataease.commons.exception.DEException;
|
||||||
import io.dataease.commons.utils.BeanUtils;
|
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.ChartViewWithBLOBs;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||||
@ -196,7 +198,7 @@ public class CKQueryProvider extends QueryProvider {
|
|||||||
if (customWheres != null) wheres.add(customWheres);
|
if (customWheres != null) wheres.add(customWheres);
|
||||||
if (whereTrees != null) wheres.add(whereTrees);
|
if (whereTrees != null) wheres.add(whereTrees);
|
||||||
if (StringUtils.isNotBlank(keyword)) {
|
if (StringUtils.isNotBlank(keyword)) {
|
||||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||||
wheres.add(keyWhere);
|
wheres.add(keyWhere);
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
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) {
|
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
try {
|
||||||
// 正则提取[xxx]
|
int i = 0;
|
||||||
String regex = "\\[(.*?)]";
|
return buildCalcField(originField, tableObj, i);
|
||||||
Pattern pattern = Pattern.compile(regex);
|
} catch (Exception e) {
|
||||||
Matcher matcher = pattern.matcher(originField);
|
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||||
Set<String> ids = new HashSet<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
String id = matcher.group(1);
|
|
||||||
ids.add(id);
|
|
||||||
}
|
}
|
||||||
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;
|
return originField;
|
||||||
|
} catch (Exception e) {
|
||||||
|
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||||
}
|
}
|
||||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
return null;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||||
|
|||||||
@ -2,7 +2,9 @@ package io.dataease.provider.query.db2;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import io.dataease.commons.exception.DEException;
|
||||||
import io.dataease.dto.datasource.Db2Configuration;
|
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.ChartViewWithBLOBs;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||||
@ -172,7 +174,7 @@ public class Db2QueryProvider extends QueryProvider {
|
|||||||
if (customWheres != null) wheres.add(customWheres);
|
if (customWheres != null) wheres.add(customWheres);
|
||||||
if (whereTrees != null) wheres.add(whereTrees);
|
if (whereTrees != null) wheres.add(whereTrees);
|
||||||
if (StringUtils.isNotBlank(keyword)) {
|
if (StringUtils.isNotBlank(keyword)) {
|
||||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||||
wheres.add(keyWhere);
|
wheres.add(keyWhere);
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
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) {
|
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
try {
|
||||||
// 正则提取[xxx]
|
int i = 0;
|
||||||
String regex = "\\[(.*?)]";
|
return buildCalcField(originField, tableObj, i);
|
||||||
Pattern pattern = Pattern.compile(regex);
|
} catch (Exception e) {
|
||||||
Matcher matcher = pattern.matcher(originField);
|
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||||
Set<String> ids = new HashSet<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
String id = matcher.group(1);
|
|
||||||
ids.add(id);
|
|
||||||
}
|
}
|
||||||
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;
|
return originField;
|
||||||
|
} catch (Exception e) {
|
||||||
|
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||||
}
|
}
|
||||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
return null;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package io.dataease.provider.query.es;
|
package io.dataease.provider.query.es;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
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.ChartViewWithBLOBs;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||||
@ -1322,27 +1324,54 @@ public class EsQueryProvider extends QueryProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
try {
|
||||||
// 正则提取[xxx]
|
int i = 0;
|
||||||
String regex = "\\[(.*?)]";
|
return buildCalcField(originField, tableObj, i);
|
||||||
Pattern pattern = Pattern.compile(regex);
|
} catch (Exception e) {
|
||||||
Matcher matcher = pattern.matcher(originField);
|
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||||
Set<String> ids = new HashSet<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
String id = matcher.group(1);
|
|
||||||
ids.add(id);
|
|
||||||
}
|
}
|
||||||
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;
|
return originField;
|
||||||
|
} catch (Exception e) {
|
||||||
|
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||||
}
|
}
|
||||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
return null;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package io.dataease.provider.query.hive;
|
package io.dataease.provider.query.hive;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
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.ChartViewWithBLOBs;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||||
@ -153,7 +155,7 @@ public class HiveQueryProvider extends QueryProvider {
|
|||||||
if (customWheres != null) wheres.add(customWheres);
|
if (customWheres != null) wheres.add(customWheres);
|
||||||
if (whereTrees != null) wheres.add(whereTrees);
|
if (whereTrees != null) wheres.add(whereTrees);
|
||||||
if (StringUtils.isNotBlank(keyword)) {
|
if (StringUtils.isNotBlank(keyword)) {
|
||||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||||
wheres.add(keyWhere);
|
wheres.add(keyWhere);
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
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) {
|
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
try {
|
||||||
// 正则提取[xxx]
|
int i = 0;
|
||||||
String regex = "\\[(.*?)]";
|
return buildCalcField(originField, tableObj, i);
|
||||||
Pattern pattern = Pattern.compile(regex);
|
} catch (Exception e) {
|
||||||
Matcher matcher = pattern.matcher(originField);
|
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||||
Set<String> ids = new HashSet<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
String id = matcher.group(1);
|
|
||||||
ids.add(id);
|
|
||||||
}
|
}
|
||||||
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;
|
return originField;
|
||||||
|
} catch (Exception e) {
|
||||||
|
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||||
}
|
}
|
||||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
return null;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package io.dataease.provider.query.impala;
|
package io.dataease.provider.query.impala;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
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.ChartViewWithBLOBs;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
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.DataSetRowPermissionsTreeDTO;
|
||||||
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem;
|
import io.dataease.plugins.common.request.permission.DatasetRowPermissionsTreeItem;
|
||||||
import io.dataease.plugins.datasource.entity.Dateformat;
|
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.QueryProvider;
|
||||||
import io.dataease.plugins.datasource.query.Utils;
|
import io.dataease.plugins.datasource.query.Utils;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
@ -1306,27 +1307,54 @@ public class ImpalaQueryProvider extends QueryProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
try {
|
||||||
// 正则提取[xxx]
|
int i = 0;
|
||||||
String regex = "\\[(.*?)]";
|
return buildCalcField(originField, tableObj, i);
|
||||||
Pattern pattern = Pattern.compile(regex);
|
} catch (Exception e) {
|
||||||
Matcher matcher = pattern.matcher(originField);
|
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||||
Set<String> ids = new HashSet<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
String id = matcher.group(1);
|
|
||||||
ids.add(id);
|
|
||||||
}
|
}
|
||||||
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;
|
return originField;
|
||||||
|
} catch (Exception e) {
|
||||||
|
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||||
}
|
}
|
||||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
return null;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package io.dataease.provider.query.mongodb;
|
package io.dataease.provider.query.mongodb;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
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.ChartViewWithBLOBs;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||||
@ -139,7 +141,7 @@ public class MongoQueryProvider extends QueryProvider {
|
|||||||
List<String> wheres = new ArrayList<>();
|
List<String> wheres = new ArrayList<>();
|
||||||
if (customWheres != null) wheres.add(customWheres);
|
if (customWheres != null) wheres.add(customWheres);
|
||||||
if (StringUtils.isNotBlank(keyword)) {
|
if (StringUtils.isNotBlank(keyword)) {
|
||||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||||
wheres.add(keyWhere);
|
wheres.add(keyWhere);
|
||||||
}
|
}
|
||||||
if (whereTrees != null) wheres.add(whereTrees);
|
if (whereTrees != null) wheres.add(whereTrees);
|
||||||
@ -1159,27 +1161,54 @@ public class MongoQueryProvider extends QueryProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
try {
|
||||||
// 正则提取[xxx]
|
int i = 0;
|
||||||
String regex = "\\[(.*?)]";
|
return buildCalcField(originField, tableObj, i);
|
||||||
Pattern pattern = Pattern.compile(regex);
|
} catch (Exception e) {
|
||||||
Matcher matcher = pattern.matcher(originField);
|
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||||
Set<String> ids = new HashSet<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
String id = matcher.group(1);
|
|
||||||
ids.add(id);
|
|
||||||
}
|
}
|
||||||
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;
|
return originField;
|
||||||
|
} catch (Exception e) {
|
||||||
|
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||||
}
|
}
|
||||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
return null;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
package io.dataease.provider.query.mysql;
|
package io.dataease.provider.query.mysql;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
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.ChartViewWithBLOBs;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||||
@ -251,7 +253,7 @@ public class MysqlQueryProvider extends QueryProvider {
|
|||||||
if (whereTrees != null) wheres.add(whereTrees);
|
if (whereTrees != null) wheres.add(whereTrees);
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(keyword)) {
|
if (StringUtils.isNotBlank(keyword)) {
|
||||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||||
wheres.add(keyWhere);
|
wheres.add(keyWhere);
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
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) {
|
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
try {
|
||||||
// 正则提取[xxx]
|
int i = 0;
|
||||||
String regex = "\\[(.*?)]";
|
return buildCalcField(originField, tableObj, i);
|
||||||
Pattern pattern = Pattern.compile(regex);
|
} catch (Exception e) {
|
||||||
Matcher matcher = pattern.matcher(originField);
|
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||||
Set<String> ids = new HashSet<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
String id = matcher.group(1);
|
|
||||||
ids.add(id);
|
|
||||||
}
|
}
|
||||||
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;
|
return originField;
|
||||||
|
} catch (Exception e) {
|
||||||
|
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||||
}
|
}
|
||||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
return null;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||||
|
|||||||
@ -2,7 +2,9 @@ package io.dataease.provider.query.oracle;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import io.dataease.commons.exception.DEException;
|
||||||
import io.dataease.dto.datasource.OracleConfiguration;
|
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.ChartViewWithBLOBs;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||||
@ -127,7 +129,7 @@ public class OracleQueryProvider extends QueryProvider {
|
|||||||
if (customWheres != null) wheres.add(customWheres);
|
if (customWheres != null) wheres.add(customWheres);
|
||||||
if (whereTrees != null) wheres.add(whereTrees);
|
if (whereTrees != null) wheres.add(whereTrees);
|
||||||
if (StringUtils.isNotBlank(keyword)) {
|
if (StringUtils.isNotBlank(keyword)) {
|
||||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||||
wheres.add(keyWhere);
|
wheres.add(keyWhere);
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
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) {
|
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
try {
|
||||||
// 正则提取[xxx]
|
int i = 0;
|
||||||
String regex = "\\[(.*?)]";
|
return buildCalcField(originField, tableObj, i);
|
||||||
Pattern pattern = Pattern.compile(regex);
|
} catch (Exception e) {
|
||||||
Matcher matcher = pattern.matcher(originField);
|
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||||
Set<String> ids = new HashSet<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
String id = matcher.group(1);
|
|
||||||
ids.add(id);
|
|
||||||
}
|
}
|
||||||
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;
|
return originField;
|
||||||
|
} catch (Exception e) {
|
||||||
|
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||||
}
|
}
|
||||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
return null;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||||
|
|||||||
@ -2,6 +2,8 @@ package io.dataease.provider.query.pg;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.google.gson.Gson;
|
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.ChartViewWithBLOBs;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||||
@ -180,7 +182,7 @@ public class PgQueryProvider extends QueryProvider {
|
|||||||
List<String> wheres = new ArrayList<>();
|
List<String> wheres = new ArrayList<>();
|
||||||
if (customWheres != null) wheres.add(customWheres);
|
if (customWheres != null) wheres.add(customWheres);
|
||||||
if (StringUtils.isNotBlank(keyword)) {
|
if (StringUtils.isNotBlank(keyword)) {
|
||||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||||
wheres.add(keyWhere);
|
wheres.add(keyWhere);
|
||||||
}
|
}
|
||||||
if (whereTrees != null) wheres.add(whereTrees);
|
if (whereTrees != null) wheres.add(whereTrees);
|
||||||
@ -1332,27 +1334,54 @@ public class PgQueryProvider extends QueryProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
try {
|
||||||
// 正则提取[xxx]
|
int i = 0;
|
||||||
String regex = "\\[(.*?)]";
|
return buildCalcField(originField, tableObj, i);
|
||||||
Pattern pattern = Pattern.compile(regex);
|
} catch (Exception e) {
|
||||||
Matcher matcher = pattern.matcher(originField);
|
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||||
Set<String> ids = new HashSet<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
String id = matcher.group(1);
|
|
||||||
ids.add(id);
|
|
||||||
}
|
}
|
||||||
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;
|
return originField;
|
||||||
|
} catch (Exception e) {
|
||||||
|
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||||
}
|
}
|
||||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
return null;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||||
|
|||||||
@ -2,6 +2,8 @@ package io.dataease.provider.query.redshift;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.google.gson.Gson;
|
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.ChartViewWithBLOBs;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||||
@ -1313,27 +1315,54 @@ public class RedshiftQueryProvider extends QueryProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
try {
|
||||||
// 正则提取[xxx]
|
int i = 0;
|
||||||
String regex = "\\[(.*?)]";
|
return buildCalcField(originField, tableObj, i);
|
||||||
Pattern pattern = Pattern.compile(regex);
|
} catch (Exception e) {
|
||||||
Matcher matcher = pattern.matcher(originField);
|
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||||
Set<String> ids = new HashSet<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
String id = matcher.group(1);
|
|
||||||
ids.add(id);
|
|
||||||
}
|
}
|
||||||
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;
|
return originField;
|
||||||
|
} catch (Exception e) {
|
||||||
|
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||||
}
|
}
|
||||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
return null;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
private String sqlLimit(String sql, ChartViewWithBLOBs view) {
|
||||||
|
|||||||
@ -2,6 +2,8 @@ package io.dataease.provider.query.sqlserver;
|
|||||||
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.google.gson.Gson;
|
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.ChartViewWithBLOBs;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
import io.dataease.plugins.common.base.domain.DatasetTableField;
|
||||||
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
import io.dataease.plugins.common.base.domain.DatasetTableFieldExample;
|
||||||
@ -110,94 +112,15 @@ public class SqlserverQueryProvider extends QueryProvider {
|
|||||||
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree, sortFields, limit, keyword);
|
return createQuerySQL("(" + sqlFix(sql) + ")", fields, isGroup, null, fieldCustomFilter, rowPermissionsTree, sortFields, limit, keyword);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Override
|
private boolean anyFieldExceed(List<DatasetTableField> fields) {
|
||||||
public String createQuerySQLWithLimit(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
if (CollectionUtils.isEmpty(fields)) return false;
|
||||||
SQLObj tableObj = SQLObj.builder()
|
return fields.stream().anyMatch(field -> field.getDeExtractType().equals(DeTypeConstants.DE_STRING) && field.getSize() > 8000);
|
||||||
.tableName((table.startsWith("(") && table.endsWith(")")) ? table : String.format(SqlServerSQLConstants.KEYWORD_TABLE, table))
|
}
|
||||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
|
||||||
.build();
|
|
||||||
setSchema(tableObj, ds);
|
|
||||||
|
|
||||||
List<SQLObj> xFields = new ArrayList<>();
|
|
||||||
if (CollectionUtils.isNotEmpty(fields)) {
|
|
||||||
for (int i = 0; i < fields.size(); i++) {
|
|
||||||
DatasetTableField f = fields.get(i);
|
|
||||||
String originField;
|
|
||||||
if (ObjectUtils.isNotEmpty(f.getExtField()) && f.getExtField() == 2) {
|
|
||||||
// 解析origin name中有关联的字段生成sql表达式
|
|
||||||
originField = calcFieldRegex(f.getOriginName(), tableObj);
|
|
||||||
} else if (ObjectUtils.isNotEmpty(f.getExtField()) && f.getExtField() == 1) {
|
|
||||||
originField = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), f.getOriginName());
|
|
||||||
} else {
|
|
||||||
originField = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), f.getOriginName());
|
|
||||||
}
|
|
||||||
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
|
|
||||||
String fieldName;
|
|
||||||
// 处理横轴字段
|
|
||||||
if (f.getDeExtractType() == DeTypeConstants.DE_TIME) { // 时间 转为 数值
|
|
||||||
if (f.getDeType() == DeTypeConstants.DE_INT || f.getDeType() == DeTypeConstants.DE_FLOAT) {
|
|
||||||
fieldName = String.format(SqlServerSQLConstants.UNIX_TIMESTAMP, originField);
|
|
||||||
} else {
|
|
||||||
fieldName = originField;
|
|
||||||
}
|
|
||||||
} else if (f.getDeExtractType() == DeTypeConstants.DE_STRING) {
|
|
||||||
if (f.getDeType() == DeTypeConstants.DE_INT) {
|
|
||||||
fieldName = String.format(SqlServerSQLConstants.CONVERT, SqlServerSQLConstants.DEFAULT_INT_FORMAT, originField);
|
|
||||||
} else if (f.getDeType() == DeTypeConstants.DE_FLOAT) {
|
|
||||||
fieldName = String.format(SqlServerSQLConstants.CONVERT, SqlServerSQLConstants.DEFAULT_FLOAT_FORMAT, originField);
|
|
||||||
} else if (f.getDeType() == DeTypeConstants.DE_TIME) { //字符串转时间
|
|
||||||
fieldName = String.format(SqlServerSQLConstants.STRING_TO_DATE, originField, StringUtils.isNotEmpty(f.getDateFormat()) ? f.getDateFormat() : SqlServerSQLConstants.DEFAULT_DATE_FORMAT);
|
|
||||||
} else {
|
|
||||||
fieldName = originField;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (f.getDeType() == DeTypeConstants.DE_TIME) { // 数值转时间
|
|
||||||
String cast = String.format(SqlServerSQLConstants.LONG_TO_DATE, originField + "/1000");
|
|
||||||
fieldName = String.format(SqlServerSQLConstants.FROM_UNIXTIME, cast);
|
|
||||||
} else if (f.getDeType() == DeTypeConstants.DE_INT) {
|
|
||||||
fieldName = String.format(SqlServerSQLConstants.CONVERT, SqlServerSQLConstants.DEFAULT_INT_FORMAT, originField);
|
|
||||||
} else {
|
|
||||||
fieldName = originField;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xFields.add(SQLObj.builder()
|
|
||||||
.fieldName(fieldName)
|
|
||||||
.fieldAlias(fieldAlias)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
STGroup stg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
|
||||||
ST st_sql = stg.getInstanceOf("previewSql");
|
|
||||||
st_sql.add("isGroup", isGroup);
|
|
||||||
if (CollectionUtils.isNotEmpty(xFields)) st_sql.add("groups", xFields);
|
|
||||||
if (ObjectUtils.isNotEmpty(tableObj)) st_sql.add("table", tableObj);
|
|
||||||
String customWheres = transCustomFilterList(tableObj, fieldCustomFilter);
|
|
||||||
// row permissions tree
|
|
||||||
String whereTrees = transFilterTrees(tableObj, rowPermissionsTree);
|
|
||||||
List<String> wheres = new ArrayList<>();
|
|
||||||
if (customWheres != null) wheres.add(customWheres);
|
|
||||||
if (whereTrees != null) wheres.add(whereTrees);
|
|
||||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
|
||||||
List<SQLObj> xOrders = new ArrayList<>();
|
|
||||||
if (CollectionUtils.isNotEmpty(sortFields)) {
|
|
||||||
int step = fields.size();
|
|
||||||
for (int i = step; i < (step + sortFields.size()); i++) {
|
|
||||||
DeSortField deSortField = sortFields.get(i - step);
|
|
||||||
SQLObj order = buildSortField(deSortField, tableObj, i);
|
|
||||||
xOrders.add(order);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(limit != null){
|
|
||||||
SQLObj limitFiled = SQLObj.builder().limitFiled(" top " + limit + " ").build();
|
|
||||||
st_sql.add("limitFiled", limitFiled);
|
|
||||||
}
|
|
||||||
if (ObjectUtils.isNotEmpty(xOrders)) {
|
|
||||||
st_sql.add("orders", xOrders);
|
|
||||||
}
|
|
||||||
return st_sql.render();
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
private boolean anySortFieldExceed(List<DeSortField> fields) {
|
||||||
|
if (CollectionUtils.isEmpty(fields)) return false;
|
||||||
|
return fields.stream().anyMatch(field -> field.getDeExtractType().equals(DeTypeConstants.DE_STRING) && field.getSize() > 8000);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
public String createQuerySQL(String table, List<DatasetTableField> fields, boolean isGroup, Datasource ds, List<ChartFieldCustomFilterDTO> fieldCustomFilter, List<DataSetRowPermissionsTreeDTO> rowPermissionsTree, List<DeSortField> sortFields, Long limit, String keyword) {
|
||||||
@ -206,11 +129,46 @@ public class SqlserverQueryProvider extends QueryProvider {
|
|||||||
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
.tableAlias(String.format(TABLE_ALIAS_PREFIX, 0))
|
||||||
.build();
|
.build();
|
||||||
setSchema(tableObj, ds);
|
setSchema(tableObj, ds);
|
||||||
|
List<String> exceedList = null;
|
||||||
|
if (anyFieldExceed(fields) || anySortFieldExceed(sortFields)) {
|
||||||
|
exceedList = new ArrayList<>();
|
||||||
|
List<DatasetTableField> calcFieldList = new ArrayList<>(fields);
|
||||||
|
if (CollectionUtils.isNotEmpty(sortFields)) {
|
||||||
|
calcFieldList.addAll(sortFields);
|
||||||
|
}
|
||||||
|
List<SQLObj> sqlObjList = new ArrayList<>();
|
||||||
|
sqlObjList.add(SQLObj.builder().fieldName("*").build());
|
||||||
|
for (DatasetTableField f : calcFieldList) {
|
||||||
|
boolean exceed = f.getDeExtractType().equals(DeTypeConstants.DE_STRING) && f.getSize() > 8000;
|
||||||
|
if (!exceedList.contains(f.getOriginName()) && exceed) {
|
||||||
|
exceedList.add(f.getOriginName());
|
||||||
|
String originField = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), f.getOriginName());
|
||||||
|
String newOriginName = f.getOriginName() + "_exceed";
|
||||||
|
String format = String.format(SqlServerSQLConstants.TO_STRING, originField, newOriginName);
|
||||||
|
sqlObjList.add(SQLObj.builder().fieldName(format).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
STGroup tabStg = new STGroupFile(SQLConstants.SQL_TEMPLATE);
|
||||||
|
ST st_sql = tabStg.getInstanceOf("previewSql");
|
||||||
|
st_sql.add("isGroup", false);
|
||||||
|
st_sql.add("notUseAs", true);
|
||||||
|
st_sql.add("table", tableObj);
|
||||||
|
st_sql.add("groups", sqlObjList);
|
||||||
|
String render = st_sql.render();
|
||||||
|
tableObj = SQLObj.builder()
|
||||||
|
.tableName(" (" + render + ") ")
|
||||||
|
.tableAlias(String.format(TABLE_ALIAS_PREFIX, "_exceed"))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
List<SQLObj> xFields = new ArrayList<>();
|
List<SQLObj> xFields = new ArrayList<>();
|
||||||
if (CollectionUtils.isNotEmpty(fields)) {
|
if (CollectionUtils.isNotEmpty(fields)) {
|
||||||
for (int i = 0; i < fields.size(); i++) {
|
for (int i = 0; i < fields.size(); i++) {
|
||||||
DatasetTableField f = fields.get(i);
|
DatasetTableField f = fields.get(i);
|
||||||
|
if (CollectionUtils.isNotEmpty(exceedList) && exceedList.contains(f.getOriginName())) {
|
||||||
|
f.setOriginName(f.getOriginName() + "_exceed");
|
||||||
|
}
|
||||||
String originField;
|
String originField;
|
||||||
if (ObjectUtils.isNotEmpty(f.getExtField()) && f.getExtField() == 2) {
|
if (ObjectUtils.isNotEmpty(f.getExtField()) && f.getExtField() == 2) {
|
||||||
// 解析origin name中有关联的字段生成sql表达式
|
// 解析origin name中有关联的字段生成sql表达式
|
||||||
@ -269,7 +227,7 @@ public class SqlserverQueryProvider extends QueryProvider {
|
|||||||
if (customWheres != null) wheres.add(customWheres);
|
if (customWheres != null) wheres.add(customWheres);
|
||||||
if (whereTrees != null) wheres.add(whereTrees);
|
if (whereTrees != null) wheres.add(whereTrees);
|
||||||
if (StringUtils.isNotBlank(keyword)) {
|
if (StringUtils.isNotBlank(keyword)) {
|
||||||
String keyWhere = "("+transKeywordFilterList(tableObj, xFields, keyword)+")";
|
String keyWhere = "(" + transKeywordFilterList(tableObj, xFields, keyword) + ")";
|
||||||
wheres.add(keyWhere);
|
wheres.add(keyWhere);
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
if (CollectionUtils.isNotEmpty(wheres)) st_sql.add("filters", wheres);
|
||||||
@ -278,11 +236,14 @@ public class SqlserverQueryProvider extends QueryProvider {
|
|||||||
int step = fields.size();
|
int step = fields.size();
|
||||||
for (int i = step; i < (step + sortFields.size()); i++) {
|
for (int i = step; i < (step + sortFields.size()); i++) {
|
||||||
DeSortField deSortField = sortFields.get(i - step);
|
DeSortField deSortField = sortFields.get(i - step);
|
||||||
|
if (CollectionUtils.isNotEmpty(exceedList) && exceedList.contains(deSortField.getOriginName())) {
|
||||||
|
deSortField.setOriginName(deSortField.getOriginName() + "_exceed");
|
||||||
|
}
|
||||||
SQLObj order = buildSortField(deSortField, tableObj, i);
|
SQLObj order = buildSortField(deSortField, tableObj, i);
|
||||||
xOrders.add(order);
|
xOrders.add(order);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ObjectUtils.isNotEmpty(limit)){
|
if (ObjectUtils.isNotEmpty(limit)) {
|
||||||
SQLObj limitFiled = SQLObj.builder().limitFiled(" top " + limit + " ").build();
|
SQLObj limitFiled = SQLObj.builder().limitFiled(" top " + limit + " ").build();
|
||||||
st_sql.add("limitFiled", limitFiled);
|
st_sql.add("limitFiled", limitFiled);
|
||||||
}
|
}
|
||||||
@ -1488,27 +1449,54 @@ public class SqlserverQueryProvider extends QueryProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
private String calcFieldRegex(String originField, SQLObj tableObj) {
|
||||||
originField = originField.replaceAll("[\\t\\n\\r]]", "");
|
try {
|
||||||
// 正则提取[xxx]
|
int i = 0;
|
||||||
String regex = "\\[(.*?)]";
|
return buildCalcField(originField, tableObj, i);
|
||||||
Pattern pattern = Pattern.compile(regex);
|
} catch (Exception e) {
|
||||||
Matcher matcher = pattern.matcher(originField);
|
DEException.throwException(Translator.get("i18n_field_circular_ref"));
|
||||||
Set<String> ids = new HashSet<>();
|
|
||||||
while (matcher.find()) {
|
|
||||||
String id = matcher.group(1);
|
|
||||||
ids.add(id);
|
|
||||||
}
|
}
|
||||||
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;
|
return originField;
|
||||||
|
} catch (Exception e) {
|
||||||
|
DEException.throwException(Translator.get("i18n_field_circular_error"));
|
||||||
}
|
}
|
||||||
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
return null;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -18,6 +18,8 @@ import java.util.*;
|
|||||||
@Service
|
@Service
|
||||||
public class ReptileService {
|
public class ReptileService {
|
||||||
String blogUrl = "https://blog.fit2cloud.com/categories/dataease";
|
String blogUrl = "https://blog.fit2cloud.com/categories/dataease";
|
||||||
|
|
||||||
|
String blogBaseUrl = "https://blog.fit2cloud.com";
|
||||||
//获取最新的前几条数据
|
//获取最新的前几条数据
|
||||||
private static int infoCount=5;
|
private static int infoCount=5;
|
||||||
|
|
||||||
@ -33,7 +35,7 @@ public class ReptileService {
|
|||||||
Element info = elementsContent.get(i).children().get(0);
|
Element info = elementsContent.get(i).children().get(0);
|
||||||
Map<String, String> infoMap = new HashMap();
|
Map<String, String> infoMap = new HashMap();
|
||||||
infoMap.put("title",info.attr("title"));
|
infoMap.put("title",info.attr("title"));
|
||||||
infoMap.put("href",info.attr("href"));
|
infoMap.put("href",blogBaseUrl + info.attr("href"));
|
||||||
result.add(infoMap);
|
result.add(infoMap);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@ -277,4 +277,6 @@ I18N_PANEL_PDF_TEMPLATE_ONLY_PIC=Default template only screenshot
|
|||||||
\u8FB9\u684610=Border 10
|
\u8FB9\u684610=Border 10
|
||||||
I18n_name_cant_empty=Name can not be empty!
|
I18n_name_cant_empty=Name can not be empty!
|
||||||
I18n_del_admin_tips=Forbidden to delete the admin account
|
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_name_cant_empty=\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A\uFF01
|
||||||
I18n_del_admin_tips=\u7981\u6B62\u5220\u9664admin\u8D26\u53F7
|
I18n_del_admin_tips=\u7981\u6B62\u5220\u9664admin\u8D26\u53F7
|
||||||
I18N_NO_DRIVER_PERMISSION=\u6ca1\u6709\u6743\u9650\uff01
|
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
|
\u8FB9\u684610=\u908A\u6846 10
|
||||||
I18n_name_cant_empty=\u540D\u7A31\u4E0D\u80FD\u70BA\u7A7A\uFF01
|
I18n_name_cant_empty=\u540D\u7A31\u4E0D\u80FD\u70BA\u7A7A\uFF01
|
||||||
I18n_del_admin_tips=\u7981\u6B62\u522A\u9664admin\u8CEC\u865F
|
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
|
||||||
|
|||||||
@ -524,8 +524,8 @@ const data = {
|
|||||||
element.options.manualModify = false
|
element.options.manualModify = false
|
||||||
}
|
}
|
||||||
// 去掉首选项
|
// 去掉首选项
|
||||||
if (element.options?.attr?.selectFirst) {
|
if (element.options?.attrs?.selectFirst) {
|
||||||
element.options.attr.selectFirst = false
|
element.options.attrs.selectFirst = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@ -415,16 +415,16 @@ export default {
|
|||||||
deep: true
|
deep: true
|
||||||
},
|
},
|
||||||
'tableFields': function() {
|
'tableFields': function() {
|
||||||
this.dimensionData = JSON.parse(JSON.stringify(this.tableFields.dimensionList)).filter(ele => ele.extField === 0)
|
this.dimensionData = JSON.parse(JSON.stringify(this.tableFields.dimensionList))
|
||||||
this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList)).filter(ele => ele.extField === 0)
|
this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList))
|
||||||
},
|
},
|
||||||
'searchField': function(val) {
|
'searchField': function(val) {
|
||||||
if (val && 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.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()) && ele.extField === 0)))
|
this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList.filter(ele => ele.name.toLocaleLowerCase().includes(val.toLocaleLowerCase()))))
|
||||||
} else {
|
} else {
|
||||||
this.dimensionData = JSON.parse(JSON.stringify(this.tableFields.dimensionList)).filter(ele => ele.extField === 0)
|
this.dimensionData = JSON.parse(JSON.stringify(this.tableFields.dimensionList))
|
||||||
this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList)).filter(ele => ele.extField === 0)
|
this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'searchFunction': function(val) {
|
'searchFunction': function(val) {
|
||||||
@ -572,8 +572,8 @@ export default {
|
|||||||
this.tableFields.dimensionListData = JSON.parse(JSON.stringify(this.tableFields.dimensionList))
|
this.tableFields.dimensionListData = JSON.parse(JSON.stringify(this.tableFields.dimensionList))
|
||||||
this.tableFields.quotaListData = JSON.parse(JSON.stringify(this.tableFields.quotaList))
|
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.dimensionData = JSON.parse(JSON.stringify(this.tableFields.dimensionList))
|
||||||
this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList)).filter(ele => ele.extField === 0)
|
this.quotaData = JSON.parse(JSON.stringify(this.tableFields.quotaList))
|
||||||
|
|
||||||
this.initField()
|
this.initField()
|
||||||
})
|
})
|
||||||
|
|||||||
@ -392,10 +392,10 @@ export default {
|
|||||||
tableFields: function() {
|
tableFields: function() {
|
||||||
this.dimensionData = JSON.parse(
|
this.dimensionData = JSON.parse(
|
||||||
JSON.stringify(this.tableFields.dimensionList)
|
JSON.stringify(this.tableFields.dimensionList)
|
||||||
).filter((ele) => ele.extField === 0)
|
)
|
||||||
this.quotaData = JSON.parse(
|
this.quotaData = JSON.parse(
|
||||||
JSON.stringify(this.tableFields.quotaList)
|
JSON.stringify(this.tableFields.quotaList)
|
||||||
).filter((ele) => ele.extField === 0)
|
)
|
||||||
},
|
},
|
||||||
searchField: function(val) {
|
searchField: function(val) {
|
||||||
if (val && val !== '') {
|
if (val && val !== '') {
|
||||||
@ -405,7 +405,7 @@ export default {
|
|||||||
(ele) =>
|
(ele) =>
|
||||||
ele.name
|
ele.name
|
||||||
.toLocaleLowerCase()
|
.toLocaleLowerCase()
|
||||||
.includes(val.toLocaleLowerCase()) && ele.extField === 0
|
.includes(val.toLocaleLowerCase())
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -415,17 +415,17 @@ export default {
|
|||||||
(ele) =>
|
(ele) =>
|
||||||
ele.name
|
ele.name
|
||||||
.toLocaleLowerCase()
|
.toLocaleLowerCase()
|
||||||
.includes(val.toLocaleLowerCase()) && ele.extField === 0
|
.includes(val.toLocaleLowerCase())
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
this.dimensionData = JSON.parse(
|
this.dimensionData = JSON.parse(
|
||||||
JSON.stringify(this.tableFields.dimensionList)
|
JSON.stringify(this.tableFields.dimensionList)
|
||||||
).filter((ele) => ele.extField === 0)
|
)
|
||||||
this.quotaData = JSON.parse(
|
this.quotaData = JSON.parse(
|
||||||
JSON.stringify(this.tableFields.quotaList)
|
JSON.stringify(this.tableFields.quotaList)
|
||||||
).filter((ele) => ele.extField === 0)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
searchFunction: function(val) {
|
searchFunction: function(val) {
|
||||||
@ -452,10 +452,10 @@ export default {
|
|||||||
this.initFunctions()
|
this.initFunctions()
|
||||||
this.dimensionData = JSON.parse(
|
this.dimensionData = JSON.parse(
|
||||||
JSON.stringify(this.tableFields.dimensionList)
|
JSON.stringify(this.tableFields.dimensionList)
|
||||||
).filter((ele) => ele.extField === 0)
|
)
|
||||||
this.quotaData = JSON.parse(
|
this.quotaData = JSON.parse(
|
||||||
JSON.stringify(this.tableFields.quotaList)
|
JSON.stringify(this.tableFields.quotaList)
|
||||||
).filter((ele) => ele.extField === 0)
|
)
|
||||||
this.initField()
|
this.initField()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@ -97,7 +97,7 @@
|
|||||||
@editItemCompare="showQuotaEditCompare"
|
@editItemCompare="showQuotaEditCompare"
|
||||||
@editItemFilter="showQuotaEditFilter"
|
@editItemFilter="showQuotaEditFilter"
|
||||||
@onNameEdit="showRename"
|
@onNameEdit="showRename"
|
||||||
@onQuotaItemChange="quotaItemChange"
|
@onQuotaItemChange="quotaExtItemChange"
|
||||||
@onQuotaItemRemove="quotaItemRemove"
|
@onQuotaItemRemove="quotaItemRemove"
|
||||||
@valueFormatter="valueFormatter"
|
@valueFormatter="valueFormatter"
|
||||||
/>
|
/>
|
||||||
@ -152,6 +152,7 @@ import QuotaItem from '../../../components/views/QuotaItem'
|
|||||||
import QuotaExtItem from '../../../components/views/QuotaExtItem'
|
import QuotaExtItem from '../../../components/views/QuotaExtItem'
|
||||||
import FilterItem from '../../../components/views/FilterItem'
|
import FilterItem from '../../../components/views/FilterItem'
|
||||||
import messages from '@/de-base/lang/messages'
|
import messages from '@/de-base/lang/messages'
|
||||||
|
import {defaultTo} from "lodash-es"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: {
|
props: {
|
||||||
@ -174,6 +175,8 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
yChartType: undefined,
|
||||||
|
yExtChartType: undefined,
|
||||||
widgets: [],
|
widgets: [],
|
||||||
places: [],
|
places: [],
|
||||||
moveId: -1,
|
moveId: -1,
|
||||||
@ -229,8 +232,19 @@ export default {
|
|||||||
created() {
|
created() {
|
||||||
this.$emit('on-add-languages', messages)
|
this.$emit('on-add-languages', messages)
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
if (this.view.yaxis && this.view.yaxis[0]) {
|
||||||
|
this.yChartType = this.view.yaxis[0].chartType
|
||||||
|
}
|
||||||
|
if (this.view.yaxisExt && this.view.yaxisExt[0]) {
|
||||||
|
this.yExtChartType = this.view.yaxisExt[0].chartType
|
||||||
|
}
|
||||||
|
this.yChartType = defaultTo(this.yChartType, 'bar');
|
||||||
|
this.yExtChartType = defaultTo(this.yExtChartType, 'line');
|
||||||
|
|
||||||
|
},
|
||||||
watch: {
|
watch: {
|
||||||
listenLists: function(val) {
|
/*listenLists: function(val) {
|
||||||
if (this.listenLists[0] <= 1 && this.listenLists[1] <= 1) {
|
if (this.listenLists[0] <= 1 && this.listenLists[1] <= 1) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -243,7 +257,7 @@ export default {
|
|||||||
this.view.yaxisExt = [this.view.yaxisExt[0]]
|
this.view.yaxisExt = [this.view.yaxisExt[0]]
|
||||||
}
|
}
|
||||||
this.calcData(true)
|
this.calcData(true)
|
||||||
}
|
}*/
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
executeAxios(url, type, data, callBack) {
|
executeAxios(url, type, data, callBack) {
|
||||||
@ -284,20 +298,29 @@ export default {
|
|||||||
this.multiAdd(e, this.view.yaxis)
|
this.multiAdd(e, this.view.yaxis)
|
||||||
this.dragMoveDuplicate(this.view.yaxis, e)
|
this.dragMoveDuplicate(this.view.yaxis, e)
|
||||||
this.dragCheckType(this.view.yaxis, 'q')
|
this.dragCheckType(this.view.yaxis, 'q')
|
||||||
if (this.view.yaxis.length <= 1) {
|
|
||||||
this.calcData(true)
|
for (let i = 0; i < this.view.yaxis.length; i++) {
|
||||||
|
this.view.yaxis[i].chartType = this.yChartType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if (this.view.yaxis.length <= 1) {
|
||||||
|
this.calcData(true)
|
||||||
|
//}
|
||||||
},
|
},
|
||||||
addYaxisExt(e) {
|
addYaxisExt(e) {
|
||||||
this.multiAdd(e, this.view.yaxisExt)
|
this.multiAdd(e, this.view.yaxisExt)
|
||||||
this.dragMoveDuplicate(this.view.yaxisExt, e)
|
this.dragMoveDuplicate(this.view.yaxisExt, e)
|
||||||
this.dragCheckType(this.view.yaxisExt, 'q')
|
this.dragCheckType(this.view.yaxisExt, 'q')
|
||||||
if (this.view.yaxisExt.length <= 1) {
|
|
||||||
this.calcData(true)
|
for (let i = 0; i < this.view.yaxisExt.length; i++) {
|
||||||
|
this.view.yaxisExt[i].chartType = this.yExtChartType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if (this.view.yaxisExt.length <= 1) {
|
||||||
|
this.calcData(true)
|
||||||
|
//}
|
||||||
},
|
},
|
||||||
calcData(cache) {
|
calcData(cache) {
|
||||||
console.log(cache)
|
|
||||||
//this.view.xaxis = [...this.source, ...this.target]
|
//this.view.xaxis = [...this.source, ...this.target]
|
||||||
|
|
||||||
this.$emit('plugin-call-back', {
|
this.$emit('plugin-call-back', {
|
||||||
@ -339,6 +362,17 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
quotaItemChange(item) {
|
quotaItemChange(item) {
|
||||||
|
this.yChartType = item.chartType;
|
||||||
|
for (let i = 0; i < this.view.yaxis.length; i++) {
|
||||||
|
this.view.yaxis[i].chartType = this.yChartType
|
||||||
|
}
|
||||||
|
this.calcData(true)
|
||||||
|
},
|
||||||
|
quotaExtItemChange(item) {
|
||||||
|
this.yExtChartType = item.chartType;
|
||||||
|
for (let i = 0; i < this.view.yaxisExt.length; i++) {
|
||||||
|
this.view.yaxisExt[i].chartType = this.yExtChartType
|
||||||
|
}
|
||||||
this.calcData(true)
|
this.calcData(true)
|
||||||
},
|
},
|
||||||
quotaItemRemove(item) {
|
quotaItemRemove(item) {
|
||||||
@ -391,8 +425,8 @@ export default {
|
|||||||
newItems = groupDie ? this.selectedDimension : this.selectedQuota
|
newItems = groupDie ? this.selectedDimension : this.selectedQuota
|
||||||
}
|
}
|
||||||
const preIds = list
|
const preIds = list
|
||||||
.filter((_, i) => i < e.newDraggableIndex || i >= e.newDraggableIndex + newItems.length)
|
.filter((_, i) => i < e.newDraggableIndex || i >= e.newDraggableIndex + newItems.length)
|
||||||
.map(i => i.id)
|
.map(i => i.id)
|
||||||
// 倒序删除
|
// 倒序删除
|
||||||
for (let i = e.newDraggableIndex + newItems.length - 1; i >= e.newDraggableIndex; i--) {
|
for (let i = e.newDraggableIndex + newItems.length - 1; i >= e.newDraggableIndex; i--) {
|
||||||
if (preIds.includes(list[i].id)) {
|
if (preIds.includes(list[i].id)) {
|
||||||
|
|||||||
@ -43,7 +43,7 @@ import {
|
|||||||
getLineDash, DEFAULT_COLOR_CASE, formatterItem, DEFAULT_YAXIS_EXT_STYLE
|
getLineDash, DEFAULT_COLOR_CASE, formatterItem, DEFAULT_YAXIS_EXT_STYLE
|
||||||
} from '../../../utils/map';
|
} from '../../../utils/map';
|
||||||
import ChartTitleUpdate from '../../../components/views/ChartTitleUpdate';
|
import ChartTitleUpdate from '../../../components/views/ChartTitleUpdate';
|
||||||
import _ from 'lodash';
|
import {map, filter, join, flatten, cloneDeep} from 'lodash-es';
|
||||||
import {clear} from 'size-sensor'
|
import {clear} from 'size-sensor'
|
||||||
import {valueFormatter} from '../../../utils/formatter'
|
import {valueFormatter} from '../../../utils/formatter'
|
||||||
|
|
||||||
@ -310,135 +310,54 @@ export default {
|
|||||||
|
|
||||||
const names = [];
|
const names = [];
|
||||||
|
|
||||||
let _data = this.chart.data && this.chart.data.data && this.chart.data.data.length > 0 ? _.map(_.filter(this.chart.data.data, (c, _index) => {
|
const yChartData = this.chart.data && this.chart.data.data && this.chart.data.data.length > 0 ? map(filter(this.chart.data.data, (c, _index) => {
|
||||||
return _index < yaxisCount;
|
return _index < yaxisCount;
|
||||||
}), (t, _index) => {
|
}), (t, _index) => {
|
||||||
|
names.push(t.name);
|
||||||
|
|
||||||
const _labelSetting = _.cloneDeep(labelSetting);
|
return map(t.data, (v) => {
|
||||||
if (_labelSetting && yaxisList[_index].formatterCfg) {
|
return {
|
||||||
_labelSetting.formatter = function (x) {
|
quotaList: v.quotaList,
|
||||||
return valueFormatter(x.value, yaxisList[_index].formatterCfg);
|
dimensionList: v.dimensionList,
|
||||||
}
|
key: join(map(v.dimensionList, (d) => d.value), "\n"),
|
||||||
|
value: v.value,
|
||||||
|
name: t.name,
|
||||||
|
i: _index,
|
||||||
|
t: 'yaxis'
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
) : [];
|
||||||
|
|
||||||
names.push(t.name);
|
const yData = [this.getYData(flatten(yChartData), labelSetting, labelPosition, yaxisList, colors, gradient, alpha, xAxis, yAxis, yaxisExtList.length)];
|
||||||
|
|
||||||
const _chartType = this.getChartType(yaxisList[_index].chartType);
|
const yExtChartData = this.chart.data && this.chart.data.data && this.chart.data.data.length > 0 ? map(filter(this.chart.data.data, (c, _index) => {
|
||||||
|
return _index >= yaxisCount;
|
||||||
|
}), (t, _index) => {
|
||||||
|
names.push(t.name);
|
||||||
|
|
||||||
if (_labelSetting) {
|
return map(t.data, (v) => {
|
||||||
if (_chartType === "column") {
|
return {
|
||||||
_labelSetting.position = labelPosition;
|
quotaList: v.quotaList,
|
||||||
} else {
|
dimensionList: v.dimensionList,
|
||||||
_labelSetting.position = undefined;
|
key: join(map(v.dimensionList, (d) => d.value), "\n"),
|
||||||
}
|
value: v.value,
|
||||||
|
name: t.name,
|
||||||
|
i: _index,
|
||||||
|
t: 'yaxisExt'
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
) : [];
|
||||||
|
|
||||||
let color = colors && _index < colors.length ? hexColorToRGBA(colors[_index], alpha) : undefined;
|
const yExtData = [this.getYExtData(flatten(yExtChartData), labelSetting, labelPosition, yaxisExtList, colors, gradient, alpha, xAxis, yAxisExt, yaxisCount)];
|
||||||
if (color && gradient) {
|
|
||||||
color = setGradientColor(color, true, 270)
|
|
||||||
}
|
|
||||||
|
|
||||||
const setting = {
|
|
||||||
type: _chartType,
|
|
||||||
name: t.name,
|
|
||||||
options: {
|
|
||||||
data: _.map(t.data, (v) => {
|
|
||||||
return {
|
|
||||||
quotaList: v.quotaList,
|
|
||||||
dimensionList: v.dimensionList,
|
|
||||||
key: _.join(_.map(v.dimensionList, (d) => d.value), "\n"),
|
|
||||||
value: v.value,
|
|
||||||
i: _index,
|
|
||||||
t: 'yaxis'
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
xField: 'key',
|
|
||||||
yField: 'value',
|
|
||||||
meta: {
|
|
||||||
key: {
|
|
||||||
sync: true,
|
|
||||||
},
|
|
||||||
value: {
|
|
||||||
alias: t.name,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
color: color,
|
|
||||||
label: _labelSetting,
|
|
||||||
xAxis: xAxis,
|
|
||||||
yAxis: yAxis,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.setSizeSetting(setting);
|
|
||||||
}) : [];
|
|
||||||
|
|
||||||
let _dataExt = this.chart.data && this.chart.data.data && this.chart.data.data.length > 0 ? _.map(_.filter(this.chart.data.data, (c, _index) => {
|
|
||||||
return _index >= yaxisCount;
|
|
||||||
}), (t, _index) => {
|
|
||||||
|
|
||||||
const _labelSetting = _.cloneDeep(labelSetting);
|
|
||||||
if (_labelSetting && yaxisExtList[_index].formatterCfg) {
|
|
||||||
_labelSetting.formatter = function (x) {
|
|
||||||
return valueFormatter(x.value, yaxisExtList[_index].formatterCfg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
names.push(t.name);
|
|
||||||
|
|
||||||
const _chartType = this.getChartType(yaxisExtList[_index].chartType);
|
|
||||||
|
|
||||||
if (_labelSetting) {
|
|
||||||
if (_chartType === "column") {
|
|
||||||
_labelSetting.position = labelPosition;
|
|
||||||
} else {
|
|
||||||
_labelSetting.position = undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let color = colors && (yaxisCount + _index) < colors.length ? hexColorToRGBA(colors[yaxisCount + _index], alpha) : undefined;
|
|
||||||
if (color && gradient) {
|
|
||||||
color = setGradientColor(color, true, 270)
|
|
||||||
}
|
|
||||||
|
|
||||||
const setting = {
|
|
||||||
type: _chartType,
|
|
||||||
name: t.name,
|
|
||||||
options: {
|
|
||||||
data: _.map(t.data, (v) => {
|
|
||||||
return {
|
|
||||||
quotaList: v.quotaList,
|
|
||||||
dimensionList: v.dimensionList,
|
|
||||||
key: _.join(_.map(v.dimensionList, (d) => d.value), "\n"),
|
|
||||||
value: v.value,
|
|
||||||
i: _index,
|
|
||||||
t: 'yaxisExt'
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
xField: 'key',
|
|
||||||
yField: 'value',
|
|
||||||
meta: {
|
|
||||||
key: {
|
|
||||||
sync: true,
|
|
||||||
},
|
|
||||||
value: {
|
|
||||||
alias: t.name,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
color: color,
|
|
||||||
label: _labelSetting,
|
|
||||||
xAxis: false,
|
|
||||||
yAxis: yAxisExt,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.setSizeSetting(setting);
|
|
||||||
}) : [];
|
|
||||||
|
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
tooltip: false,
|
tooltip: false,
|
||||||
syncViewPadding: true,
|
syncViewPadding: true,
|
||||||
plots: [
|
plots: [
|
||||||
..._data,
|
...yData,
|
||||||
..._dataExt
|
...yExtData
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -471,7 +390,7 @@ export default {
|
|||||||
item.value = valueFormatter(item.data.value, yaxisExtList[item.data.i].formatterCfg)
|
item.value = valueFormatter(item.data.value, yaxisExtList[item.data.i].formatterCfg)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return _.filter(originalItems, (item) => {
|
return filter(originalItems, (item) => {
|
||||||
const v = item.data.key;
|
const v = item.data.key;
|
||||||
if (item.title === v && item.title === item.value && item.name === "key" || !names.includes(item.name)) {
|
if (item.title === v && item.title === item.value && item.name === "key" || !names.includes(item.name)) {
|
||||||
return false;
|
return false;
|
||||||
@ -489,7 +408,8 @@ export default {
|
|||||||
|
|
||||||
params.annotations = this.getAnalyse(this.chart);
|
params.annotations = this.getAnalyse(this.chart);
|
||||||
|
|
||||||
params.legend = this.getLegend(this.chart);
|
//两个轴只能展示一个轴的图例,所以隐藏
|
||||||
|
//params.legend = this.getLegend(this.chart);
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
},
|
},
|
||||||
@ -755,6 +675,116 @@ export default {
|
|||||||
return axis
|
return axis
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getYData(data, labelSetting, labelPosition, yaxisList, colors, gradient, alpha, xAxis, yAxis, yaxisExtCount) {
|
||||||
|
|
||||||
|
const _labelSetting = cloneDeep(labelSetting);
|
||||||
|
if (_labelSetting) {
|
||||||
|
_labelSetting.formatter = function (x) {
|
||||||
|
for (let i = 0; i < yaxisList.length; i++) {
|
||||||
|
if (i === x.i && yaxisList[i].formatterCfg) {
|
||||||
|
return valueFormatter(x.value, yaxisList[i].formatterCfg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return x.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const _chartType = this.getChartType(yaxisList && yaxisList.length > 0 ? yaxisList[0].chartType : undefined);
|
||||||
|
|
||||||
|
if (_labelSetting) {
|
||||||
|
if (_chartType === "column") {
|
||||||
|
_labelSetting.position = labelPosition;
|
||||||
|
} else {
|
||||||
|
_labelSetting.position = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const color = [];
|
||||||
|
for (let i = 0; i < yaxisList.length; i++) {
|
||||||
|
if (gradient) {
|
||||||
|
color.push(setGradientColor(hexColorToRGBA(colors[i % colors.length], alpha), true, 270))
|
||||||
|
} else {
|
||||||
|
color.push(hexColorToRGBA(colors[i % colors.length], alpha))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const setting = {
|
||||||
|
type: _chartType,
|
||||||
|
options: {
|
||||||
|
data: data,
|
||||||
|
xField: 'key',
|
||||||
|
yField: 'value',
|
||||||
|
seriesField: 'name',
|
||||||
|
colorField: 'name',
|
||||||
|
isGroup: true,
|
||||||
|
meta: {
|
||||||
|
key: {
|
||||||
|
sync: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
color: color,
|
||||||
|
label: _labelSetting,
|
||||||
|
xAxis: yaxisList.length > 0 || yaxisExtCount === 0 ? xAxis : false,
|
||||||
|
yAxis: yAxis,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.setSizeSetting(setting);
|
||||||
|
},
|
||||||
|
|
||||||
|
getYExtData(data, labelSetting, labelPosition, yaxisExtList, colors, gradient, alpha, xAxis, yAxisExt, yaxisCount) {
|
||||||
|
const _labelSetting = cloneDeep(labelSetting);
|
||||||
|
if (_labelSetting) {
|
||||||
|
_labelSetting.formatter = function (x) {
|
||||||
|
for (let i = 0; i < yaxisExtList.length; i++) {
|
||||||
|
if (i === x.i && yaxisExtList[i].formatterCfg) {
|
||||||
|
return valueFormatter(x.value, yaxisExtList[i].formatterCfg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return x.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const _chartType = this.getChartType(yaxisExtList && yaxisExtList.length > 0 ? yaxisExtList[0].chartType : undefined);
|
||||||
|
|
||||||
|
if (_labelSetting) {
|
||||||
|
if (_chartType === "column") {
|
||||||
|
_labelSetting.position = labelPosition;
|
||||||
|
} else {
|
||||||
|
_labelSetting.position = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const color = [];
|
||||||
|
for (let i = yaxisCount; i < yaxisExtList.length + yaxisCount; i++) {
|
||||||
|
if (gradient) {
|
||||||
|
color.push(setGradientColor(hexColorToRGBA(colors[i % colors.length], alpha), true, 270))
|
||||||
|
} else {
|
||||||
|
color.push(hexColorToRGBA(colors[i % colors.length], alpha))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const setting = {
|
||||||
|
type: _chartType,
|
||||||
|
options: {
|
||||||
|
data: data,
|
||||||
|
xField: 'key',
|
||||||
|
yField: 'value',
|
||||||
|
seriesField: 'name',
|
||||||
|
isGroup: true,
|
||||||
|
meta: {
|
||||||
|
key: {
|
||||||
|
sync: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
color: color,
|
||||||
|
label: _labelSetting,
|
||||||
|
xAxis: yaxisCount > 0 || yaxisExtList.length === 0 ? false : xAxis,
|
||||||
|
yAxis: yAxisExt,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this.setSizeSetting(setting);
|
||||||
|
},
|
||||||
|
|
||||||
setSizeSetting(setting) {
|
setSizeSetting(setting) {
|
||||||
let customAttr = undefined;
|
let customAttr = undefined;
|
||||||
if (this.chart.customAttr) {
|
if (this.chart.customAttr) {
|
||||||
|
|||||||
@ -11,10 +11,8 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
import java.util.stream.Collectors;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
@ -124,7 +122,7 @@ public class SymbolMapRSHandler implements PluginViewRSHandler<Map> {
|
|||||||
ChartQuotaDTO chartQuotaDTO = new ChartQuotaDTO();
|
ChartQuotaDTO chartQuotaDTO = new ChartQuotaDTO();
|
||||||
chartQuotaDTO.setId(curY.getId());
|
chartQuotaDTO.setId(curY.getId());
|
||||||
axisChartDataDTO.getQuotaList().add(chartQuotaDTO);
|
axisChartDataDTO.getQuotaList().add(chartQuotaDTO);
|
||||||
axisChartDataDTO.getProperties().put(curY.getName(), row[i + step]);
|
axisChartDataDTO.getProperties().put(curY.getName(), formatLabel(curY, row[i + step]));
|
||||||
axisChartDataDTO.setLongitude(dimensionList.get(0).getValue());
|
axisChartDataDTO.setLongitude(dimensionList.get(0).getValue());
|
||||||
axisChartDataDTO.setLatitude(dimensionList.get(1).getValue());
|
axisChartDataDTO.setLatitude(dimensionList.get(1).getValue());
|
||||||
if (StringUtils.equals(curY.getTypeField(), "yAxis") && !valueFilled) {
|
if (StringUtils.equals(curY.getTypeField(), "yAxis") && !valueFilled) {
|
||||||
@ -139,4 +137,13 @@ public class SymbolMapRSHandler implements PluginViewRSHandler<Map> {
|
|||||||
map.put("data", datalist);
|
map.put("data", datalist);
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String formatLabel(PluginViewField field, String val) {
|
||||||
|
if (StringUtils.isBlank(val)) return val;
|
||||||
|
String typeField = field.getTypeField();
|
||||||
|
if (StringUtils.isNotBlank(typeField) && trans2Ykeys.contains(typeField)) {
|
||||||
|
return Arrays.stream(val.split(",")).distinct().collect(Collectors.joining(","));
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -47,4 +47,6 @@ public class SqlServerSQLConstants extends SQLConstants {
|
|||||||
|
|
||||||
public static final String DEFAULT_DATE_FORMAT = "120";
|
public static final String DEFAULT_DATE_FORMAT = "120";
|
||||||
|
|
||||||
|
public static final String TO_STRING = "cast(%s as varchar(max)) as %s";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user