Merge branch 'dev' into pr@dev_one_dot_x

This commit is contained in:
dataeaseShu 2023-12-21 11:05:36 +08:00
commit c77ce44ff0
40 changed files with 852 additions and 234 deletions

View File

@ -11,6 +11,7 @@ import io.dataease.plugins.common.base.domain.DeDriverDetails;
import io.dataease.plugins.common.dto.datasource.DataSourceType;
import io.dataease.plugins.common.exception.DataEaseException;
import io.dataease.plugins.common.util.SpringContextUtil;
import io.dataease.service.datasource.DatasourceService;
import io.dataease.service.datasource.DriverService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -32,6 +33,8 @@ public class DriverMgmController {
@Resource
private DriverService driverService;
@Resource
private DatasourceService datasourceService;
@RequiresPermissions("datasource:read")
@ApiOperation("驱动列表")
@ -64,7 +67,7 @@ public class DriverMgmController {
driverDTO.setId("default");
driverDTO.setName("default");
driverDTO.setDriverClass("default");
SpringContextUtil.getApplicationContext().getBeansOfType(DataSourceType.class).values().forEach(dataSourceType -> {
datasourceService.types().forEach(dataSourceType -> {
if (dataSourceType.getType().equalsIgnoreCase(type)) {
driverDTO.setSurpportVersions(dataSourceType.getSurpportVersions());
}

View File

@ -18,7 +18,7 @@ public abstract class DDLProvider {
public abstract String replaceTable(String name);
public abstract String createTableSql(String name, List<DatasetTableField> datasetTableFields, Datasource engine);
public abstract String createTableSql(String name, List<DatasetTableField> datasetTableFields, Datasource engine, String version);
public abstract String insertSql(String name, List<String[]> dataList, int page, int pageNumber);
}

View File

@ -30,7 +30,7 @@ public class DDLProviderImpl extends DDLProvider {
}
@Override
public String createTableSql(String name, List<DatasetTableField> datasetTableFields, Datasource engine) {
public String createTableSql(String name, List<DatasetTableField> datasetTableFields, Datasource engine, String version) {
return null;
}

View File

@ -44,15 +44,15 @@ public class DorisDDLProvider extends DDLProviderImpl {
}
@Override
public String createTableSql(String tableName, List<DatasetTableField> datasetTableFields, Datasource engine) {
public String createTableSql(String tableName, List<DatasetTableField> datasetTableFields, Datasource engine, String version) {
DorisConfiguration dorisConfiguration = new Gson().fromJson(engine.getConfiguration(), DorisConfiguration.class);
String dorisTableColumnSql = createDorisTableColumnSql(datasetTableFields);
String dorisTableColumnSql = createDorisTableColumnSql(datasetTableFields, version);
return creatTableSql.replace("TABLE_NAME", tableName).replace("Column_Fields", dorisTableColumnSql)
.replace("BUCKETS_NUM", dorisConfiguration.getBucketNum().toString())
.replace("ReplicationNum", dorisConfiguration.getReplicationNum().toString());
}
private String createDorisTableColumnSql(final List<DatasetTableField> datasetTableFields) {
private String createDorisTableColumnSql(final List<DatasetTableField> datasetTableFields, String version) {
StringBuilder Column_Fields = new StringBuilder("dataease_uuid varchar(50), `");
for (DatasetTableField datasetTableField : datasetTableFields) {
Column_Fields.append(datasetTableField.getDataeaseName()).append("` ");
@ -73,7 +73,12 @@ public class DorisDDLProvider extends DDLProviderImpl {
break;
case 3:
if(datasetTableField.getType().equalsIgnoreCase("DECIMAL") && datasetTableField.getAccuracy() != 0){
Column_Fields.append("DecimalV3(" + datasetTableField.getSize() + "," + datasetTableField.getAccuracy() + ")").append(",`");
if(Integer.valueOf(version.split("5.7.")[1]) < 99){
Column_Fields.append("DECIMAL(" + datasetTableField.getSize() + "," + datasetTableField.getAccuracy() + ")").append(",`");
}else {
Column_Fields.append("DecimalV3(" + datasetTableField.getSize() + "," + datasetTableField.getAccuracy() + ")").append(",`");
}
}else {
Column_Fields.append("DOUBLE").append(",`");
}

View File

@ -71,7 +71,7 @@ public class MysqlDDLProvider extends DDLProviderImpl {
}
@Override
public String createTableSql(String tableName, List<DatasetTableField> datasetTableFields, Datasource engine) {
public String createTableSql(String tableName, List<DatasetTableField> datasetTableFields, Datasource engine, String version) {
String dorisTableColumnSql = createDorisTableColumnSql(datasetTableFields);
return creatTableSql.replace("TABLE_NAME", tableName).replace("Column_Fields", dorisTableColumnSql);
}

View File

@ -387,11 +387,39 @@ public class MysqlQueryProvider extends QueryProvider {
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(MysqlConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getDataeaseName());
} else {
originField = String.format(MysqlConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getDataeaseName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 计算字段和视图字段规则为 函数([原始字段id])这边把[原始字段id] 换成 表名.原始字段id
// 解析origin name中有关联的字段生成sql表达式
@ -432,8 +460,6 @@ public class MysqlQueryProvider extends QueryProvider {
}
}
List<SQLObj> yOrders = new ArrayList<>();
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
// 处理仪表板字段过滤

View File

@ -774,11 +774,38 @@ public class CKQueryProvider extends QueryProvider {
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
originField = String.format(CKConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
@ -816,7 +843,6 @@ public class CKQueryProvider extends QueryProvider {
}
}
}
List<SQLObj> yOrders = new ArrayList<>();
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);

View File

@ -760,11 +760,38 @@ public class Db2QueryProvider extends QueryProvider {
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(Db2Constants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
originField = String.format(Db2Constants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
@ -803,8 +830,6 @@ public class Db2QueryProvider extends QueryProvider {
}
}
List<SQLObj> yOrders = new ArrayList<>();
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
// 处理仪表板字段过滤

View File

@ -775,11 +775,44 @@ public class EsQueryProvider extends QueryProvider {
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_INT) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_TIME) {
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
if (x.getDeType() == 2) {
originField = String.format(EsSqlLConstants.CAST, String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()), "bigint");
} else if (x.getDeType() == 3) {
originField = String.format(EsSqlLConstants.CAST, String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName()), "float");
} else {
originField = String.format(EsSqlLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_INT) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
@ -822,8 +855,6 @@ public class EsQueryProvider extends QueryProvider {
}
}
List<SQLObj> yOrders = new ArrayList<>();
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
// 处理仪表板字段过滤

View File

@ -724,11 +724,38 @@ public class HiveQueryProvider extends QueryProvider {
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(HiveConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
originField = String.format(HiveConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
@ -766,7 +793,6 @@ public class HiveQueryProvider extends QueryProvider {
}
}
}
List<SQLObj> yOrders = new ArrayList<>();
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);

View File

@ -728,11 +728,38 @@ public class ImpalaQueryProvider extends QueryProvider {
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(ImpalaConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
originField = String.format(ImpalaConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
@ -770,7 +797,7 @@ public class ImpalaQueryProvider extends QueryProvider {
}
}
}
List<SQLObj> yOrders = new ArrayList<>();
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);

View File

@ -697,10 +697,41 @@ public class MongoQueryProvider extends QueryProvider {
.build();
List<SQLObj> xFields = new ArrayList<>();
List<SQLObj> xOrders = new ArrayList<>();
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_INT) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_TIME) {
originField = String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
originField = String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(MongoConstants.ALIAS_FIX, String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i));
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == DeTypeConstants.DE_INT) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
@ -710,8 +741,23 @@ public class MongoQueryProvider extends QueryProvider {
originField = String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_X_PREFIX, i);
// 处理横轴字段
xFields.add(getXFields(x, originField, fieldAlias));
if (i == baseXAxis.size()) {// 起止时间
String fieldName = String.format(MongoConstants.AGG_FIELD, "min", originField);
yFields.add(getXFields(x, fieldName, fieldAlias));
yWheres.add(getYWheres(x, originField, fieldAlias));
} else if (i == baseXAxis.size() + 1) {
String fieldName = String.format(MongoConstants.AGG_FIELD, "max", originField);
yFields.add(getXFields(x, fieldName, fieldAlias));
yWheres.add(getYWheres(x, originField, fieldAlias));
} else {
// 处理横轴字段
xFields.add(getXFields(x, originField, fieldAlias));
}
// 处理横轴排序
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
xOrders.add(SQLObj.builder()
@ -722,36 +768,7 @@ public class MongoQueryProvider extends QueryProvider {
}
}
}
List<SQLObj> yFields = new ArrayList<>();
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(yAxis)) {
for (int i = 0; i < yAxis.size(); i++) {
ChartViewFieldDTO y = yAxis.get(i);
String originField;
if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == DeTypeConstants.DE_INT) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(y.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(y.getExtField()) && y.getExtField() == DeTypeConstants.DE_TIME) {
originField = String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
} else {
originField = String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), y.getOriginName());
}
String fieldAlias = String.format(MongoConstants.ALIAS_FIX, String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i));
// 处理纵轴字段
yFields.add(getYFields(y, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(y, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(y.getSort()) && Utils.joinSort(y.getSort())) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(y.getSort())
.build());
}
}
}
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
// 处理仪表板字段过滤

View File

@ -422,11 +422,38 @@ public class MysqlQueryProvider extends QueryProvider {
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(MysqlConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getDataeaseName());
} else {
originField = String.format(MysqlConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getDataeaseName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 计算字段和视图字段规则为 函数([原始字段id])这边把[原始字段id] 换成 表名.原始字段id
// 解析origin name中有关联的字段生成sql表达式
@ -466,8 +493,6 @@ public class MysqlQueryProvider extends QueryProvider {
}
}
List<SQLObj> yOrders = new ArrayList<>();
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
// 处理仪表板字段过滤

View File

@ -830,11 +830,38 @@ public class OracleQueryProvider extends QueryProvider {
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
originField = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(OracleConstants.ALIAS_FIX, String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i));
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
@ -872,7 +899,7 @@ public class OracleQueryProvider extends QueryProvider {
}
}
}
List<SQLObj> yOrders = new ArrayList<>();
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);

View File

@ -754,11 +754,38 @@ public class PgQueryProvider extends QueryProvider {
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
@ -796,7 +823,6 @@ public class PgQueryProvider extends QueryProvider {
}
}
}
List<SQLObj> yOrders = new ArrayList<>();
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);

View File

@ -760,11 +760,38 @@ public class RedshiftQueryProvider extends QueryProvider {
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
originField = String.format(PgConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
@ -802,7 +829,7 @@ public class RedshiftQueryProvider extends QueryProvider {
}
}
}
List<SQLObj> yOrders = new ArrayList<>();
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);

View File

@ -838,11 +838,38 @@ public class SqlserverQueryProvider extends QueryProvider {
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
originField = String.format(SqlServerSQLConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
@ -880,7 +907,7 @@ public class SqlserverQueryProvider extends QueryProvider {
}
}
}
List<SQLObj> yOrders = new ArrayList<>();
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);
@ -1450,7 +1477,7 @@ public class SqlserverQueryProvider extends QueryProvider {
String whereValue = "";
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
if (request.getDatasetTableField() != null && request.getDatasetTableField().getType().equalsIgnoreCase("NVARCHAR")) {
if ((request.getDatasetTableField() != null && request.getDatasetTableField().getType().equalsIgnoreCase("NVARCHAR")) || (request.getDatasetTableFieldList() != null && request.getDatasetTableFieldList().stream().map(DatasetTableField::getType).collect(Collectors.toList()).contains("nvarchar"))) {
whereValue = "(" + value.stream().map(str -> {
return "N" + "'" + str + "'";
}).collect(Collectors.joining(",")) + ")";
@ -1472,7 +1499,7 @@ public class SqlserverQueryProvider extends QueryProvider {
}
} else {
if (request.getDatasetTableField() != null && request.getDatasetTableField().getType().equalsIgnoreCase("NVARCHAR")) {
if ((request.getDatasetTableField() != null && request.getDatasetTableField().getType().equalsIgnoreCase("NVARCHAR")) || (request.getDatasetTableFieldList() != null && request.getDatasetTableFieldList().stream().map(DatasetTableField::getType).collect(Collectors.toList()).contains("nvarchar"))) {
whereValue = String.format(SqlServerSQLConstants.WHERE_VALUE_VALUE_CH, value.get(0));
} else {
whereValue = String.format(SqlServerSQLConstants.WHERE_VALUE_VALUE, value.get(0));

View File

@ -57,6 +57,7 @@ import io.dataease.service.datasource.DatasourceService;
import io.dataease.service.engine.EngineService;
import io.dataease.service.panel.PanelGroupExtendDataService;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.pentaho.di.core.util.UUIDUtil;
@ -344,7 +345,9 @@ public class ChartViewService {
}
List<ChartViewFieldDTO> xAxis = gson.fromJson(view.getXAxis(), new TypeToken<List<ChartViewFieldDTO>>() {
}.getType());
if (StringUtils.equalsIgnoreCase(view.getType(), "table-pivot") || StringUtils.equalsIgnoreCase(view.getType(), "bar-time-range")) {
if (StringUtils.equalsAnyIgnoreCase(view.getType(), "table-pivot", "bar-time-range")
|| StringUtils.containsIgnoreCase(view.getType(), "group")
|| ("antv".equalsIgnoreCase(view.getRender()) && "line".equalsIgnoreCase(view.getType()))) {
List<ChartViewFieldDTO> xAxisExt = gson.fromJson(view.getXAxisExt(), new TypeToken<List<ChartViewFieldDTO>>() {
}.getType());
xAxis.addAll(xAxisExt);
@ -402,7 +405,7 @@ public class ChartViewService {
switch (view.getType()) {
case "label":
xAxis = xAxis.stream().filter(item -> !desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList());
xAxis = xAxis.stream().filter(item -> !desensitizationList.containsKey(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList());
yAxis = new ArrayList<>();
if (CollectionUtils.isEmpty(xAxis)) {
return new ArrayList<String[]>();
@ -412,7 +415,7 @@ public class ChartViewService {
case "gauge":
case "liquid":
xAxis = new ArrayList<>();
yAxis = yAxis.stream().filter(item -> !desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList());
yAxis = yAxis.stream().filter(item -> !desensitizationList.containsKey(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList());
if (CollectionUtils.isEmpty(yAxis)) {
return new ArrayList<String[]>();
}
@ -429,8 +432,8 @@ public class ChartViewService {
yAxis = yAxis.stream().filter(item -> dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList());
break;
default:
xAxis = xAxis.stream().filter(item -> !desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList());
yAxis = yAxis.stream().filter(item -> !desensitizationList.keySet().contains(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList());
xAxis = xAxis.stream().filter(item -> !desensitizationList.containsKey(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList());
yAxis = yAxis.stream().filter(item -> !desensitizationList.containsKey(item.getDataeaseName()) && dataeaseNames.contains(item.getDataeaseName())).collect(Collectors.toList());
}
List<ChartExtFilterRequest> extFilterList = new ArrayList<>();
@ -537,12 +540,12 @@ public class ChartViewService {
datasourceRequest.setQuery(qp.getSQLAsTmpScatter(sql, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extBubble, extStack, view));
} else if (StringUtils.equalsIgnoreCase("table-info", view.getType())) {
datasourceRequest.setQuery(qp.getSQLAsTmpTableInfo(sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view));
}else if (StringUtils.equalsIgnoreCase("bar-time-range", view.getType())) {
} else if (StringUtils.equalsIgnoreCase("bar-time-range", view.getType())) {
List<ChartViewFieldDTO> xAxisBase = gson.fromJson(view.getXAxis(), new TypeToken<List<ChartViewFieldDTO>>() {
}.getType());
datasourceRequest.setQuery(qp.getSQLAsTmpRangeBar(dataTableInfoDTO.getTable(), xAxisBase, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, view));
} else {
} else {
datasourceRequest.setQuery(qp.getSQLAsTmp(sql, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, view));
}
} else if (StringUtils.equalsIgnoreCase(table.getType(), DatasetType.UNION.name())) {
@ -1153,7 +1156,7 @@ public class ChartViewService {
totalPageSql = qp.getResultCount(false, sql, xAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view);
} else if (StringUtils.equalsIgnoreCase("bar-time-range", view.getType())) {
querySql = qp.getSQLAsTmpRangeBar(dataTableInfoDTO.getTable(), xAxisBase, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, view);
querySql = qp.getSQLAsTmpRangeBar(dataTableInfoDTO.getTable(), xAxisBase, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, view);
} else {
querySql = qp.getSQLAsTmp(sql, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, view);
@ -1268,7 +1271,7 @@ public class ChartViewService {
datasourceRequest.setQuery(qp.getSQLRangeBar(tableName, xAxisBase, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, extStack, ds, view));
}else {
} else {
datasourceRequest.setQuery(qp.getSQL(tableName, xAxis, yAxis, fieldCustomFilter, rowPermissionsTree, extFilterList, ds, view));
if (containDetailField(view) && CollectionUtils.isNotEmpty(viewFields)) {
detailFieldList.addAll(xAxis);
@ -1467,7 +1470,7 @@ public class ChartViewService {
} else if (StringUtils.equalsIgnoreCase(view.getType(), "bar-group-stack")) {
mapChart = ChartDataBuild.transGroupStackDataAntV(xAxisBase, xAxis, xAxisExt, yAxis, extStack, data, view, isDrill);
} else if (StringUtils.equalsIgnoreCase(view.getType(), "bar-time-range")) {
mapChart = ChartDataBuild.transTimeBarDataAntV(xAxisBase, xAxis, xAxisExt, yAxis, extStack, data, view, isDrill);
mapChart = ChartDataBuild.transTimeBarDataAntV(xAxisBase, xAxis, xAxisExt, yAxis, extStack, data, view, isDrill, drillRequestList);
} else if (StringUtils.containsIgnoreCase(view.getType(), "bar-stack")) {
mapChart = ChartDataBuild.transStackChartDataAntV(xAxis, yAxis, view, data, extStack, isDrill);
} else if (StringUtils.containsIgnoreCase(view.getType(), "line-stack")) {
@ -1495,6 +1498,18 @@ public class ChartViewService {
if (CollectionUtils.isNotEmpty(detailData)) {
mapTableNormal = ChartDataBuild.transTableNormalWithDetail(xAxis, yAxis, data, detailFieldList, detailData, desensitizationList);
} else {
if (StringUtils.equalsIgnoreCase(view.getType(), "bar-time-range") && !drillRequestList.isEmpty() && !xAxisExt.isEmpty()) { // 针对区间条形图还需要给xAxis排个序, 把xAxisExt放到最后
int count = 0;
for (int i = xAxis.size() - drillRequestList.size() - 1; i >= 0; i--) {
xAxis.remove(i);
count++;
if (xAxisExt.size() == count) {
break;
}
}
xAxis.addAll(xAxisExt);
}
mapTableNormal = ChartDataBuild.transTableNormal(xAxis, yAxis, view, data, extStack, desensitizationList);
}
chartViewDTO = uniteViewResult(datasourceRequest.getQuery(), mapChart, mapTableNormal, view, isDrill, drillFilters, dynamicAssistFields, assistData);
@ -1913,17 +1928,29 @@ public class ChartViewService {
ChartViewDTO view = getOne(id, requestList.getQueryFrom());
List<String[]> sqlData = sqlData(view, requestList, cache, fieldId);
List<ChartViewFieldDTO> fieldList = new ArrayList<>();
if (StringUtils.equalsIgnoreCase(fieldType, "xAxis")) {
fieldList = gson.fromJson(view.getXAxis(), new TypeToken<List<ChartViewFieldDTO>>() {
}.getType());
} else if (StringUtils.equalsIgnoreCase(fieldType, "extStack")) {
fieldList = gson.fromJson(view.getExtStack(), new TypeToken<List<ChartViewFieldDTO>>() {
}.getType());
switch (fieldType) {
case "xaxis": {
fieldList = gson.fromJson(view.getXAxis(), new TypeToken<List<ChartViewFieldDTO>>() {
}.getType());
break;
}
case "extStack": {
fieldList = gson.fromJson(view.getExtStack(), new TypeToken<List<ChartViewFieldDTO>>() {
}.getType());
break;
}
case "xaxisExt": {
fieldList = gson.fromJson(view.getXAxisExt(), new TypeToken<List<ChartViewFieldDTO>>() {
}.getType());
break;
}
default:
return Collections.emptyList();
}
DatasetTableField field = dataSetTableFieldsService.get(fieldId);
List<String> res = new ArrayList<>();
if (ObjectUtils.isNotEmpty(field) && fieldList.size() > 0) {
if (ObjectUtils.isNotEmpty(field) && !fieldList.isEmpty()) {
// 找到对应维度
ChartViewFieldDTO chartViewFieldDTO = null;
int index = 0;
@ -1947,10 +1974,22 @@ public class ChartViewService {
}
}
if (StringUtils.equalsIgnoreCase(fieldType, "extStack") && !skipAddIndex) {
List<ChartViewFieldDTO> stack = gson.fromJson(view.getXAxis(), new TypeToken<List<ChartViewFieldDTO>>() {
List<ChartViewFieldDTO> xaxis = gson.fromJson(view.getXAxis(), new TypeToken<List<ChartViewFieldDTO>>() {
}.getType());
index += stack.size();
getIndex += stack.size();
index += xaxis.size();
getIndex += xaxis.size();
if (StringUtils.containsIgnoreCase(view.getType(), "group")) {
List<ChartViewFieldDTO> ext = gson.fromJson(view.getXAxisExt(), new TypeToken<List<ChartViewFieldDTO>>() {
}.getType());
index += ext.size();
getIndex += ext.size();
}
}
if (StringUtils.equalsIgnoreCase(fieldType, "xaxisExt") && !skipAddIndex) {
List<ChartViewFieldDTO> xaxis = gson.fromJson(view.getXAxis(), new TypeToken<List<ChartViewFieldDTO>>() {
}.getType());
index += xaxis.size();
getIndex += xaxis.size();
}
List<String[]> sortResult = resultCustomSort(fieldList, sqlData);
if (ObjectUtils.isNotEmpty(chartViewFieldDTO) && (getIndex >= index)) {

View File

@ -1,6 +1,7 @@
package io.dataease.service.chart.util;
import cn.hutool.core.util.ArrayUtil;
import io.dataease.controller.request.chart.ChartDrillRequest;
import io.dataease.dto.chart.*;
import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs;
import io.dataease.plugins.common.dto.chart.ChartViewFieldDTO;
@ -1310,7 +1311,7 @@ public class ChartDataBuild {
}
}
public static Map<String, Object> transTimeBarDataAntV(List<ChartViewFieldDTO> xAxisBase, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> xAxisExt, List<ChartViewFieldDTO> yAxis, List<ChartViewFieldDTO> extStack, List<String[]> data, ChartViewWithBLOBs view, boolean isDrill) {
public static Map<String, Object> transTimeBarDataAntV(List<ChartViewFieldDTO> xAxisBase, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> xAxisExt, List<ChartViewFieldDTO> yAxis, List<ChartViewFieldDTO> extStack, List<String[]> data, ChartViewWithBLOBs view, boolean isDrill, List<ChartDrillRequest> drillRequestList) {
Map<String, Object> map = new HashMap<>();
if (CollectionUtils.isEmpty(xAxisBase) || CollectionUtils.isEmpty(xAxisExt) || xAxisExt.size() < 2) {
@ -1323,9 +1324,17 @@ public class ChartDataBuild {
}
List<Date> dates = new ArrayList<>();
List<BigDecimal> numbers = new ArrayList<>();
ChartViewFieldDTO xAxis1 = xAxis.get(xAxisBase.size());
SimpleDateFormat sdf = new SimpleDateFormat(getDateFormat(xAxis1.getDateStyle(), xAxis1.getDatePattern()));
boolean isDate = true;
if (StringUtils.equalsIgnoreCase(xAxis1.getGroupType(), "q")) {
isDate = false;
}
SimpleDateFormat sdf = null;
if (isDate) {
sdf = new SimpleDateFormat(getDateFormat(xAxis1.getDateStyle(), xAxis1.getDatePattern()));
}
List<Object> dataList = new ArrayList<>();
for (int i1 = 0; i1 < data.size(); i1++) {
@ -1350,49 +1359,67 @@ public class ChartDataBuild {
List<ChartDimensionDTO> dimensionList = new ArrayList<>();
for (int j = 0; j < xAxis.size(); j++) {
if (j == xAxisBase.size() || j == xAxisBase.size() + 1) {
continue;
}
int index = j;
if (j > xAxisBase.size() + 1) {
index = j - 2;
}
ChartDimensionDTO chartDimensionDTO = new ChartDimensionDTO();
chartDimensionDTO.setId(xAxis.get(j).getId());
chartDimensionDTO.setValue(row[j]);
chartDimensionDTO.setValue(row[index]);
dimensionList.add(chartDimensionDTO);
}
obj.put("dimensionList", dimensionList);
List<String> values = new ArrayList<>();
List<Object> values = new ArrayList<>();
// 由于起止时间字段是放到最后的yField里去查询的所以拿倒数两个
if (row[xAxis.size() - 1] == null || row[xAxis.size() - 2] == null) {
continue;
}
values.add(row[xAxis.size() - 2]);
values.add(row[xAxis.size() - 1]);
obj.put("values", values);
try {
Date date = sdf.parse(row[xAxis.size() - 2]);
if (date != null) {
dates.add(date);
if (isDate) {
values.add(row[xAxis.size() - 2]);
values.add(row[xAxis.size() - 1]);
obj.put("values", values);
try {
Date date = sdf.parse(row[xAxis.size() - 2]);
if (date != null) {
dates.add(date);
}
} catch (Exception ignore) {
}
} catch (Exception ignore) {
}
try {
Date date = sdf.parse(row[xAxis.size() - 1]);
if (date != null) {
dates.add(date);
try {
Date date = sdf.parse(row[xAxis.size() - 1]);
if (date != null) {
dates.add(date);
}
} catch (Exception ignore) {
}
} catch (Exception ignore) {
} else {
values.add(new BigDecimal(row[xAxis.size() - 2]));
values.add(new BigDecimal(row[xAxis.size() - 1]));
obj.put("values", values);
numbers.add(new BigDecimal(row[xAxis.size() - 2]));
numbers.add(new BigDecimal(row[xAxis.size() - 1]));
}
dataList.add(obj);
}
map.put("minTime", sdf.format(dates.stream().min(Date::compareTo).orElse(null)));
map.put("maxTime", sdf.format(dates.stream().max(Date::compareTo).orElse(null)));
if (isDate) {
map.put("minTime", sdf.format(dates.stream().min(Date::compareTo).orElse(null)));
map.put("maxTime", sdf.format(dates.stream().max(Date::compareTo).orElse(null)));
} else {
map.put("min", numbers.stream().min(BigDecimal::compareTo).orElse(null));
map.put("max", numbers.stream().max(BigDecimal::compareTo).orElse(null));
}
map.put("isDate", isDate);
map.put("data", dataList);
return map;

View File

@ -646,8 +646,10 @@ public class ExtractDataService {
JdbcProvider jdbcProvider = CommonBeanFactory.getBean(JdbcProvider.class);
DatasourceRequest datasourceRequest = new DatasourceRequest();
datasourceRequest.setDatasource(engine);
datasourceRequest.setQuery("SELECT VERSION()");
String version = jdbcProvider.getData(datasourceRequest).get(0)[0];
DDLProvider ddlProvider = ProviderFactory.getDDLProvider(engine.getType());
datasourceRequest.setQuery(ddlProvider.createTableSql(tableName, datasetTableFields, engine));
datasourceRequest.setQuery(ddlProvider.createTableSql(tableName, datasetTableFields, engine, version));
jdbcProvider.exec(datasourceRequest);
}

View File

@ -367,7 +367,9 @@ export default {
show: 0
},
view: {},
cancelTime: null
cancelTime: null,
// true
searchButtonReady: true
}
},
@ -422,7 +424,7 @@ export default {
},
filter() {
const filter = {}
filter.filter = this.initLoad && this.cfilters?.length === 0 ? this.filters : this.cfilters
filter.filter = (this.initLoad && this.cfilters?.length === 0) || !this.searchButtonReady ? this.filters : this.cfilters
filter.linkageFilters = this.element.linkageFilters
filter.outerParamsFilters = this.element.outerParamsFilters
filter.drill = this.drillClickDimensionList
@ -585,7 +587,13 @@ export default {
},
mounted() {
bus.$on('tab-canvas-change', this.tabSwitch)
bus.$on('trigger-search-button', this.triggerSearchButton)
this.bindPluginEvent()
this.$nextTick(() => {
if (this.filters && this.filters.length > 0) {
this.searchButtonReady = false
}
})
},
beforeDestroy() {
@ -624,6 +632,9 @@ export default {
}
},
methods: {
triggerSearchButton() {
this.searchButtonReady = true
},
groupFilter(filters) {
const result = {
ready: [],

View File

@ -1184,7 +1184,7 @@ export default {
chart_bar_stack: 'Stack Bar',
chart_percentage_bar_stack: 'Percentage Stack Bar',
chart_bar_horizontal: 'Horizontal Bar',
chart_bar_time_range: 'Time Bar',
chart_bar_time_range: 'Range Bar',
chart_bar_stack_horizontal: 'Stack Horizontal Bar',
chart_percentage_bar_stack_horizontal: 'Horizontal Percentage Stack Bar',
chart_bidirectional_bar: 'Bidirectional Bar',
@ -1497,7 +1497,7 @@ export default {
dynamic: 'Dynamic',
gauge_size_field_delete: 'Dynamic field changedplease edit again',
chart_group: 'Sub Type',
chart_bar_time: 'Times',
chart_bar_time: 'Range',
chart_bar_group: 'Bar Group',
chart_bar_group_stack: 'Group Stack Bar',
field_dynamic: 'Dynamic',
@ -1525,7 +1525,7 @@ export default {
set_zero: 'Set Zero',
ignore_data: 'Hide Data',
sub_dimension_tip: 'This field is required, and cannot be included in the type axis, you should choose non-group chart if you don\'t need it, or you will get unexpected chart.',
time_bar_tip: 'This field is required, and axis type must be time',
time_bar_tip: 'This field is required, and need two time dimensions or two quotas',
drill_dimension_tip: 'Only fields in the dataset can be drilled',
table_scroll_tip: 'The detail table is only effective when the pagination mode is "Drop-down".',
table_threshold_tip: 'Tip: Do not select fields repeatedly. If the same field is configured repeatedly, only the last field will take effect.',

View File

@ -1182,7 +1182,7 @@ export default {
chart_bar_stack: '堆疊柱狀圖',
chart_percentage_bar_stack: '百分比柱狀圖',
chart_bar_horizontal: '橫嚮柱狀圖',
chart_bar_time_range: '間條形圖',
chart_bar_time_range: '間條形圖',
chart_bar_stack_horizontal: '橫嚮堆疊柱狀圖',
chart_percentage_bar_stack_horizontal: '橫嚮百分比柱狀圖',
chart_bidirectional_bar: '對稱柱狀圖',
@ -1494,7 +1494,7 @@ export default {
dynamic: '動態值',
gauge_size_field_delete: '動態值中字段發生變更,請重新編輯',
chart_group: '子類別',
chart_bar_time: '起止時間',
chart_bar_time: '區間范圍',
chart_bar_group: '分組柱狀圖',
chart_bar_group_stack: '分組堆疊柱狀圖',
field_dynamic: '動態值',
@ -1522,7 +1522,7 @@ export default {
ignore_data: '隱藏空值',
empty_data_field_ctrl: '字段設置',
sub_dimension_tip: '該字段為必填項,且不應使用類別軸中的字段,若無需該字段,請選擇基礎圖表進行展示,否則展示效果不理想',
time_bar_tip: '該字段為必填項,且需要兩個時間類型字段',
time_bar_tip: '該字段為必填項,且需要兩個指標或者時間類型緯度字段',
drill_dimension_tip: '鑽取字段僅支持數據集中的字段',
table_scroll_tip: '明細表僅在分頁模式為"下拉"時生效。',
table_threshold_tip: '提示:請勿重複選擇字段,若同一字段重複配置,則只有最後的字段配置生效。',

View File

@ -1182,7 +1182,7 @@ export default {
chart_bar_stack: '堆叠柱状图',
chart_percentage_bar_stack: '百分比柱状图',
chart_bar_horizontal: '横向柱状图',
chart_bar_time_range: '间条形图',
chart_bar_time_range: '间条形图',
chart_bar_stack_horizontal: '横向堆叠柱状图',
chart_percentage_bar_stack_horizontal: '横向百分比柱状图',
chart_bidirectional_bar: '对称柱状图',
@ -1494,7 +1494,7 @@ export default {
dynamic: '动态值',
gauge_size_field_delete: '动态值中字段发生变更,请重新编辑',
chart_group: '子类别',
chart_bar_time: '起止时间',
chart_bar_time: '区间范围',
chart_bar_group: '分组柱状图',
chart_bar_group_stack: '分组堆叠柱状图',
field_dynamic: '动态值',
@ -1522,7 +1522,7 @@ export default {
set_zero: '置为0',
ignore_data: '隐藏空值',
sub_dimension_tip: '该字段为必填项,且不应使用类别轴中的字段,若无需该字段,请选择基础图表进行展示,否则展示效果不理想。',
time_bar_tip: '该字段为必填项,且需要两个时间类型字段',
time_bar_tip: '该字段为必填项,且需要两个指标或者时间类型纬度字段',
drill_dimension_tip: '钻取字段仅支持数据集中的字段',
table_scroll_tip: '明细表仅在分页模式为"下拉"时生效。',
table_threshold_tip: '提示:请勿重复选择字段,若同一字段重复配置,则只有最后的字段配置生效',

View File

@ -275,9 +275,14 @@ export function timeRangeBarOptionAntV(plot, container, chart, action) {
// data
const data = _.cloneDeep(chart.data.data)
const isDate = !!chart.data.isDate
const minTime = chart.data.minTime
const maxTime = chart.data.maxTime
const minNumber = chart.data.min
const maxNumber = chart.data.max
// config
const slider = getSlider(chart)
const analyse = getAnalyse(chart)
@ -297,13 +302,6 @@ export function timeRangeBarOptionAntV(plot, container, chart, action) {
slider: slider,
annotations: analyse,
isRange: true,
meta: {
values: {
type: 'time',
min: minTime,
max: maxTime
}
},
brush: {
enabled: true,
isStartEnable: (context) => {
@ -340,6 +338,24 @@ export function timeRangeBarOptionAntV(plot, container, chart, action) {
}
]
}
if (isDate) {
options.meta = {
values: {
type: 'time',
min: minTime,
max: maxTime
}
}
} else {
options.meta = {
values: {
min: minNumber,
max: maxNumber
}
}
}
// size
let customAttr = {}
if (chart.customAttr) {

View File

@ -927,7 +927,7 @@ export const BASE_CHART_STRING = {
yAxis: DEFAULT_YAXIS_STYLE,
yAxisExt: DEFAULT_YAXIS_EXT_STYLE
}),
customFilter: '[]'
customFilter: '{}'
}
export const BASE_CHART = {
@ -950,7 +950,7 @@ export const BASE_CHART = {
yAxis: DEFAULT_YAXIS_STYLE,
yAxisExt: DEFAULT_YAXIS_EXT_STYLE
},
customFilter: []
customFilter: {}
}
export const BASE_MAP = {

View File

@ -344,6 +344,9 @@ export function getTooltip(chart) {
// tooltip value formatter
if (chart.type && chart.type !== 'waterfall') {
if (chart.type === 'bar-group-stack') {
tooltip.fields = []
}
tooltip.formatter = function(param) {
let res = param.value
@ -455,7 +458,7 @@ export function getTooltip(chart) {
} else {
let name = ''
if (param.group) {
name = param.name + '-'
name = param.group + '-'
}
if (param.category) {
name += param.category

View File

@ -98,10 +98,9 @@ export function baseTableInfo(s2, container, chart, action, tableData, pageInfo)
if (s2Options.showSeriesNumber) {
s2Options.colCell = (node) => {
if (node.colIndex === 0) {
if (!customAttr.size.indexLabel) {
node.label = customAttr.size.indexLabel
if (!customAttr.size.indexLabel || customAttr.size.showTableHeader === false) {
node.label = ' '
} else {
node.label = customAttr.size.indexLabel
}
}
}
@ -120,6 +119,11 @@ export function baseTableInfo(s2, container, chart, action, tableData, pageInfo)
colCellVertical: false
}
}
s2Options.colCell = (node) => {
if (node.colIndex === 0) {
node.label = ' '
}
}
}
// 开始渲染

View File

@ -195,7 +195,7 @@
<el-dropdown-item :command="beforeSort('asc')">{{ $t('chart.asc') }}</el-dropdown-item>
<el-dropdown-item :command="beforeSort('desc')">{{ $t('chart.desc') }}</el-dropdown-item>
<el-dropdown-item
v-show="!item.chartId"
v-show="showCustomSort"
:command="beforeSort('custom_sort')"
>{{ $t('chart.custom_sort') }}...</el-dropdown-item>
</el-dropdown-menu>
@ -228,6 +228,7 @@
import { getItemType, getOriginFieldName } from '@/views/chart/components/dragItem/utils'
import FieldErrorTips from '@/views/chart/components/dragItem/components/FieldErrorTips'
import bus from '@/utils/bus'
import { equalsAny } from '@/utils/StringUtils'
export default {
name: 'ChartDragItem',
@ -273,6 +274,10 @@ export default {
this.chart.datasourceType === 'ds_doris' ||
this.chart.datasourceType === 'StarRocks' ||
this.chart.datasetMode === 1
},
showCustomSort() {
return !equalsAny(this.chart.type, 'scatter') &&
!this.item.chartId
}
},
watch: {

View File

@ -84,6 +84,12 @@
<el-dropdown-item :command="beforeSort('none')">{{ $t('chart.none') }}</el-dropdown-item>
<el-dropdown-item :command="beforeSort('asc')">{{ $t('chart.asc') }}</el-dropdown-item>
<el-dropdown-item :command="beforeSort('desc')">{{ $t('chart.desc') }}</el-dropdown-item>
<el-dropdown-item
v-show="showCustomSort"
:command="beforeSort('custom_sort')"
>
{{ $t('chart.custom_sort') }}...
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-dropdown-item>
@ -181,6 +187,7 @@
import { getItemType, getOriginFieldName } from '@/views/chart/components/dragItem/utils'
import FieldErrorTips from '@/views/chart/components/dragItem/components/FieldErrorTips'
import bus from '@/utils/bus'
import { equalsAny } from '@/utils/StringUtils'
export default {
name: 'DimensionExtItem',
@ -220,6 +227,10 @@ export default {
computed: {
hideSpecial() {
return this.chart.type === 'bar-time-range'
},
showCustomSort() {
return !equalsAny(this.chart.type, 'bar-time-range', 'scatter') &&
!this.item.chartId
}
},
watch: {
@ -265,8 +276,18 @@ export default {
}
},
sort(param) {
this.item.sort = param.type
this.$emit('onDimensionItemChange', this.item)
if (param.type === 'custom_sort') {
const item = {
index: this.index,
sort: param.type
}
this.$emit('onItemCustomSort', item)
} else {
this.item.index = this.index
this.item.sort = param.type
this.item.customSort = []
this.$emit('onDimensionItemChange', this.item)
}
},
beforeSort(type) {
return {

View File

@ -90,9 +90,11 @@
<el-dropdown-item :command="beforeSort('asc')">{{ $t('chart.asc') }}</el-dropdown-item>
<el-dropdown-item :command="beforeSort('desc')">{{ $t('chart.desc') }}</el-dropdown-item>
<el-dropdown-item
v-show="!item.chartId && (item.deType === 0 || item.deType === 5)"
v-show="showCustomSort"
:command="beforeSort('custom_sort')"
>{{ $t('chart.custom_sort') }}...</el-dropdown-item>
>
{{ $t('chart.custom_sort') }}...
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-dropdown-item>
@ -191,6 +193,7 @@ import { getItemType, getOriginFieldName } from '@/views/chart/components/dragIt
import FieldErrorTips from '@/views/chart/components/dragItem/components/FieldErrorTips'
import bus from '@/utils/bus'
import { formatterItem } from '@/views/chart/chart/formatter'
import { equalsAny } from '@/utils/StringUtils'
export default {
name: 'DimensionItem',
@ -228,6 +231,13 @@ export default {
showDateExt: false
}
},
computed: {
showCustomSort() {
return !equalsAny(this.chart.type, 'scatter') &&
!this.item.chartId &&
(this.item.deType === 0 || this.item.deType === 5)
}
},
watch: {
dimensionData: function() {
this.getItemTagType()

View File

@ -154,7 +154,7 @@
</el-dropdown-item>
<!--同比/环比等快速计算-->
<el-dropdown-item v-show="!item.chartId && chart.type !== 'table-info'">
<el-dropdown-item v-show="!item.chartId && chart.type !== 'table-info' && chart.type !== 'bar-time-range'">
<el-dropdown
placement="right-start"
size="mini"
@ -212,7 +212,7 @@
<span>{{ $t('chart.filter') }}...</span>
</el-dropdown-item>
<el-dropdown-item
v-if="chart.render === 'antv' && chart.type !== 'gauge' && chart.type !== 'liquid'"
v-if="chart.render === 'antv' && chart.type !== 'gauge' && chart.type !== 'liquid' && chart.type !== 'bar-time-range'"
icon="el-icon-notebook-2"
divided
:command="beforeClickItem('formatter')"

View File

@ -1046,7 +1046,7 @@ export default {
view.yaxis = JSON.stringify([])
view.yaxisExt = JSON.stringify([])
view.extStack = JSON.stringify([])
view.customFilter = JSON.stringify([])
view.customFilter = JSON.stringify({})
view.drillFields = JSON.stringify([])
view.extBubble = JSON.stringify([])
view.viewFields = JSON.stringify([])

View File

@ -568,6 +568,7 @@
:chart="chart"
@onDimensionItemChange="dimensionItemChange"
@onDimensionItemRemove="dimensionItemRemove"
@onItemCustomSort="item => onCustomSort(item, 'xaxisExt')"
@editItemFilter="showDimensionEditFilter"
@onNameEdit="showRename"
/>
@ -670,7 +671,7 @@
@editItemFilter="showDimensionEditFilter"
@onNameEdit="showRename"
@valueFormatter="valueFormatter"
@onCustomSort="onCustomSort"
@onCustomSort="item => onCustomSort(item, 'xaxis')"
/>
</template>
</transition-group>
@ -702,7 +703,8 @@
>*</span>
</span>
/
<span>{{ $t('chart.dimension') }}</span>
<span v-if="view.type !== 'bar-time-range'">{{ $t('chart.dimension') }}</span>
<span v-else>{{ $t('chart.dimension_or_quota') }}</span>
<el-tooltip
v-show="view.type !== 'line'"
class="item"
@ -737,20 +739,39 @@
@update="calcData(true)"
>
<transition-group class="draggable-group">
<dimension-ext-item
v-for="(item,index) in view.xaxisExt"
:key="item.id"
:param="param"
:index="index"
:item="item"
:dimension-data="dimension"
:quota-data="quota"
:chart="chart"
@onDimensionItemChange="dimensionExtItemChange"
@onDimensionItemRemove="dimensionItemRemove"
@editItemFilter="showDimensionEditFilter"
@onNameEdit="showRename"
/>
<template v-for="(item,index) in view.xaxisExt">
<dimension-ext-item
v-if="item.groupType === 'd'"
:key="item.id"
:param="param"
:index="index"
:item="item"
:dimension-data="dimension"
:quota-data="quota"
:chart="chart"
@onDimensionItemChange="dimensionExtItemChange"
@onDimensionItemRemove="dimensionItemExtRemove"
@onItemCustomSort="item => onCustomSort(item, 'xaxisExt')"
@editItemFilter="showDimensionEditFilter"
@onNameEdit="showRename"
/>
<quota-item
v-else-if="item.groupType === 'q'"
:key="item.id"
:param="param"
:index="index"
:item="item"
:chart="chart"
:dimension-data="dimension"
:quota-data="quota"
@onQuotaItemChange="dimensionExtItemChange"
@onQuotaItemRemove="dimensionItemExtRemove"
@editItemFilter="showQuotaEditFilter"
@onNameEdit="showRename"
@editItemCompare="showQuotaEditCompare"
@valueFormatter="valueFormatter"
/>
</template>
</transition-group>
</draggable>
<div
@ -947,7 +968,7 @@
:quota-data="quota"
@onItemChange="stackItemChange"
@onItemRemove="stackItemRemove"
@onItemCustomSort="stackItemCustomSort"
@onItemCustomSort="item => onCustomSort(item, 'extStack')"
@onNameEdit="showRename"
/>
</transition-group>
@ -1097,10 +1118,13 @@
>
<span class="data-area-label">
<span>{{ $t('chart.result_filter') }}</span>
<span v-if="!!view.customFilter.logic" class="setting">已设置</span>
<span
v-if="!!view.customFilter.logic"
class="setting"
>已设置</span>
<i
@click="deleteTreeFilter"
class="el-icon-arrow-down el-icon-delete data-area-clear"
@click="deleteTreeFilter"
/>
</span>
<div
@ -1748,7 +1772,7 @@
>
<custom-sort-edit
:chart="chart"
field-type="xAxis"
:field-type="customSortFieldType"
:field="customSortField"
@onSortChange="customSortChange"
/>
@ -1770,40 +1794,6 @@
</div>
</el-dialog>
<!--extStack自定义排序-->
<el-dialog
v-if="showStackCustomSort"
v-dialogDrag
:title="$t('chart.custom_sort')"
:visible="showStackCustomSort"
:show-close="false"
width="500px"
class="dialog-css"
>
<custom-sort-edit
:chart="chart"
field-type="extStack"
:field="customSortField"
@onSortChange="customSortChange"
/>
<div
slot="footer"
class="dialog-footer"
>
<el-button
size="mini"
@click="closeStackCustomSort"
>{{ $t('chart.cancel') }}
</el-button>
<el-button
type="primary"
size="mini"
@click="saveStackCustomSort"
>{{ $t('chart.confirm') }}
</el-button>
</div>
</el-dialog>
<!--视图计算字段弹框-->
<el-dialog
v-if="editChartCalcField"
@ -2068,7 +2058,8 @@ export default {
lastDimensionIndex: 0,
lastQuotaIndex: 0,
selectedDimension: [],
selectedQuota: []
selectedQuota: [],
customSortFieldType: 'xaxis'
}
},
computed: {
@ -2255,6 +2246,10 @@ export default {
this.view.xaxis = []
}
}
if (newVal.type !== oldVal.type && (newVal.type === 'bar-time-range' || oldVal.type === 'bar-time-range')) {
this.view.xaxisExt = []
this.view.yaxis = []
}
if (newVal.type !== oldVal.type || newVal.render !== oldVal.render) {
this.setChartDefaultOptions()
this.calcData(true, 'chart', true, newVal.type !== oldVal.type, newVal.render !== oldVal.render)
@ -2533,6 +2528,21 @@ export default {
if (!ele.filter) {
ele.filter = []
}
if (ele.chartId) {
ele.summary = ''
} else {
if (!ele.summary || ele.summary === '') {
if (ele.id === 'count' || ele.deType === 0 || ele.deType === 1) {
ele.summary = 'count'
} else {
ele.summary = 'sum'
}
}
}
if (!ele.compareCalc) {
ele.compareCalc = compareItem
}
})
}
@ -2849,9 +2859,10 @@ export default {
this.moveId = e.draggedContext.element.id
return true
},
onCustomSort(item) {
this.customSortField = this.view.xaxis[item.index]
this.customSort()
onCustomSort(item, axis) {
this.customSortFieldType = axis
this.customSortField = this.view[axis][item.index]
this.showCustomSort = true
},
dimensionItemChange(item) {
@ -2876,6 +2887,11 @@ export default {
}
this.calcData(true)
},
dimensionItemExtRemove(item) {
this.view.xaxisExt.splice(item.index, 1)
this.calcData(true)
},
quotaItemChange(item) {
this.calcData(true)
@ -3047,7 +3063,7 @@ export default {
return
}
}
if (this.quotaItem.filterType === 'quota') {
if (this.quotaItem.filterType === 'quota' && this.chart.type !== 'bar-time-range') {
this.view.yaxis[this.quotaItem.index].filter = this.quotaItem.filter
this.view.yaxis[this.quotaItem.index].logic = this.quotaItem.logic
} else if (this.quotaItem.filterType === 'quotaExt') {
@ -3056,6 +3072,9 @@ export default {
} else if (this.quotaItem.filterType === 'dimension') {
this.view.xaxis[this.quotaItem.index].filter = this.quotaItem.filter
this.view.xaxis[this.quotaItem.index].logic = this.quotaItem.logic
} else if (this.chart.type === 'bar-time-range') {
this.view.xaxisExt[this.quotaItem.index].filter = this.quotaItem.filter
this.view.xaxisExt[this.quotaItem.index].logic = this.quotaItem.logic
}
this.calcData(true)
this.closeQuotaFilter()
@ -3068,13 +3087,13 @@ export default {
saveRename() {
this.$refs['itemForm'].validate((valid) => {
if (valid) {
if (this.itemForm.renameType === 'quota') {
if (this.itemForm.renameType === 'quota' && this.chart.type !== 'bar-time-range') {
this.view.yaxis[this.itemForm.index].name = this.itemForm.name
} else if (this.itemForm.renameType === 'dimension') {
this.view.xaxis[this.itemForm.index].name = this.itemForm.name
} else if (this.itemForm.renameType === 'quotaExt') {
this.view.yaxisExt[this.itemForm.index].name = this.itemForm.name
} else if (this.itemForm.renameType === 'dimensionExt') {
} else if (this.itemForm.renameType === 'dimensionExt' || this.chart.type === 'bar-time-range') {
this.view.xaxisExt[this.itemForm.index].name = this.itemForm.name
} else if (this.itemForm.renameType === 'extStack') {
this.view.extStack[this.itemForm.index].name = this.itemForm.name
@ -3272,19 +3291,21 @@ export default {
addXaxisExt(e) {
this.multiAdd(e, this.view.xaxisExt)
this.dragMoveDuplicate(this.view.xaxisExt, e)
if (this.view.type !== 'table-info') {
if (this.view.type !== 'table-info' && this.view.type !== 'bar-time-range') {
this.dragCheckType(this.view.xaxisExt, 'd')
}
if (this.view.type === 'bar-time-range') {
//
if (this.view.xaxisExt && this.view.xaxisExt.length > 0) {
const baseXaxisExt = this.view.xaxisExt[0]
for (let i = this.view.xaxisExt.length - 1; i >= 0; i--) {
//
if (baseXaxisExt.groupType !== this.view.xaxisExt[i].groupType || baseXaxisExt.groupType === 'd' && this.view.xaxisExt[i].deType !== 1) {
this.view.xaxisExt.splice(i, 1)
continue
}
this.view.xaxisExt[i].dateStyle = baseXaxisExt.dateStyle
this.view.xaxisExt[i].datePattern = baseXaxisExt.datePattern
if (this.view.xaxisExt[i].deType !== 1) {
this.view.xaxisExt.splice(i, 1)
}
}
}
if (this.view.xaxisExt.length > 2) {
@ -3373,11 +3394,6 @@ export default {
this.view.extStack.splice(item.index, 1)
this.calcData(true)
},
stackItemCustomSort(item) {
this.customSortField = this.view.extStack[item.index]
this.stackCustomSort()
},
drillItemChange(item) {
this.calcData(true)
},
@ -3618,20 +3634,19 @@ export default {
return
}
//
if (this.valueFormatterItem.formatterType === 'quota') {
if (this.valueFormatterItem.formatterType === 'quota' && this.chart.type !== 'bar-time-range') {
this.view.yaxis[this.valueFormatterItem.index].formatterCfg = this.valueFormatterItem.formatterCfg
} else if (this.valueFormatterItem.formatterType === 'quotaExt') {
this.view.yaxisExt[this.valueFormatterItem.index].formatterCfg = this.valueFormatterItem.formatterCfg
} else if (this.valueFormatterItem.formatterType === 'dimension') {
this.view.xaxis[this.valueFormatterItem.index].formatterCfg = this.valueFormatterItem.formatterCfg
} else if (this.chart.type === 'bar-time-range') {
this.view.xaxisExt[this.valueFormatterItem.index].formatterCfg = this.valueFormatterItem.formatterCfg
}
this.calcData(true)
this.closeValueFormatter()
},
customSort() {
this.showCustomSort = true
},
customSortChange(val) {
this.customSortList = val
},
@ -3641,7 +3656,7 @@ export default {
this.customSortList = []
},
saveCustomSort() {
this.view.xaxis.forEach(ele => {
this.view[this.customSortFieldType].forEach(ele => {
if (ele.id === this.customSortField.id) {
ele.sort = 'custom_sort'
ele.customSort = this.customSortList
@ -3650,24 +3665,6 @@ export default {
this.closeCustomSort()
this.calcData(true)
},
stackCustomSort() {
this.showStackCustomSort = true
},
closeStackCustomSort() {
this.showStackCustomSort = false
},
saveStackCustomSort() {
this.view.extStack.forEach(ele => {
if (ele.id === this.customSortField.id) {
ele.sort = 'custom_sort'
ele.customSort = this.customSortList
}
})
this.closeStackCustomSort()
this.calcData(true)
},
fieldEdit(param) {
switch (param.type) {
case 'ds':

View File

@ -477,11 +477,41 @@ public class DmQueryProvider extends QueryProvider {
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(),
x.getOriginName());
} else {
originField = String.format(OracleConstants.KEYWORD_FIX, tableObj.getTableAlias(),
x.getOriginName());
}
String fieldAlias = String.format(OracleConstants.ALIAS_FIX,
String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i));
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
@ -521,7 +551,6 @@ public class DmQueryProvider extends QueryProvider {
}
}
}
List<SQLObj> yOrders = new ArrayList<>();
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);

View File

@ -464,11 +464,40 @@ public class KingbaseQueryProvider extends QueryProvider {
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(KingbaseConstants.KEYWORD_FIX, tableObj.getTableAlias(),
x.getOriginName());
} else {
originField = String.format(KingbaseConstants.KEYWORD_FIX, tableObj.getTableAlias(),
x.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
@ -508,7 +537,6 @@ public class KingbaseQueryProvider extends QueryProvider {
}
}
List<SQLObj> yOrders = new ArrayList<>();
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);

View File

@ -373,11 +373,38 @@ public class KylinQueryProvider extends QueryProvider {
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(KylinConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
originField = String.format(KylinConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
@ -414,7 +441,7 @@ public class KylinQueryProvider extends QueryProvider {
}
}
}
List<SQLObj> yOrders = new ArrayList<>();
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);

View File

@ -378,11 +378,38 @@ public class MaxcomputeQueryProvider extends QueryProvider {
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(MaxConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
originField = String.format(MaxConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
@ -419,7 +446,7 @@ public class MaxcomputeQueryProvider extends QueryProvider {
}
}
}
List<SQLObj> yOrders = new ArrayList<>();
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);

View File

@ -379,11 +379,38 @@ public class MongobiQueryProvider extends QueryProvider {
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
originField = String.format(MongoConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && Utils.joinSort(x.getSort())) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
@ -420,7 +447,7 @@ public class MongobiQueryProvider extends QueryProvider {
}
}
}
List<SQLObj> yOrders = new ArrayList<>();
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);

View File

@ -375,11 +375,38 @@ public class PrestoQueryProvider extends QueryProvider {
List<SQLObj> yFields = new ArrayList<>(); // 要把两个时间字段放进y里面
List<String> yWheres = new ArrayList<>();
List<SQLObj> yOrders = new ArrayList<>();
if (CollectionUtils.isNotEmpty(xAxis)) {
for (int i = 0; i < xAxis.size(); i++) {
ChartViewFieldDTO x = xAxis.get(i);
String originField;
if (StringUtils.equalsIgnoreCase(x.getGroupType(), "q")) {
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
} else if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 1) {
originField = String.format(PrestoConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
} else {
originField = String.format(PrestoConstants.KEYWORD_FIX, tableObj.getTableAlias(), x.getOriginName());
}
String fieldAlias = String.format(SQLConstants.FIELD_ALIAS_Y_PREFIX, i);
// 处理纵轴字段
yFields.add(getYFields(x, originField, fieldAlias));
// 处理纵轴过滤
yWheres.add(getYWheres(x, originField, fieldAlias));
// 处理纵轴排序
if (StringUtils.isNotEmpty(x.getSort()) && !StringUtils.equalsIgnoreCase(x.getSort(), "none")) {
yOrders.add(SQLObj.builder()
.orderField(originField)
.orderAlias(fieldAlias)
.orderDirection(x.getSort())
.build());
}
continue;
}
if (ObjectUtils.isNotEmpty(x.getExtField()) && x.getExtField() == 2) {
// 解析origin name中有关联的字段生成sql表达式
originField = calcFieldRegex(x.getOriginName(), tableObj);
@ -417,7 +444,7 @@ public class PrestoQueryProvider extends QueryProvider {
}
}
}
List<SQLObj> yOrders = new ArrayList<>();
// 处理视图中字段过滤
String customWheres = transChartFilterTrees(tableObj, fieldCustomFilter);