Merge branch 'v1.12' into dev

This commit is contained in:
taojinlong 2022-07-04 00:46:11 +08:00
commit ad233b2881
8 changed files with 60 additions and 38 deletions

View File

@ -906,7 +906,9 @@ public class Db2QueryProvider extends QueryProvider {
} else {
if (field.getDeType().equals(DeTypeConstants.DE_TIME)) {
whereValue = String.format(Db2Constants.DATE_FORMAT, "'" + value + "'", Db2Constants.DEFAULT_DATE_FORMAT);
} else {
} else if(field.getDeType().equals(DeTypeConstants.DE_FLOAT)) {
whereValue = value;
}else {
whereValue = String.format(Db2Constants.WHERE_VALUE_VALUE, value);
}
}
@ -941,11 +943,14 @@ public class Db2QueryProvider extends QueryProvider {
} else {
fieldList.add(request.getDatasetTableField());
}
boolean isFloat = false;
for (DatasetTableField field : fieldList) {
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
continue;
}
if(field.getDeType().equals(DeTypeConstants.DE_FLOAT)){
isFloat = true;
}
String whereName = "";
String originName;
@ -1002,7 +1007,11 @@ public class Db2QueryProvider extends QueryProvider {
String whereValue = "";
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
whereValue = "('" + StringUtils.join(value, "','") + "')";
if(isFloat){
whereValue = "(" + StringUtils.join(value, ",") + ")";
}else {
whereValue = "('" + StringUtils.join(value, "','") + "')";
}
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
whereValue = "'%" + value.get(0) + "%'";
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
@ -1015,7 +1024,12 @@ public class Db2QueryProvider extends QueryProvider {
whereValue = String.format(Db2Constants.WHERE_BETWEEN, value.get(0), value.get(1));
}
} else {
whereValue = String.format(Db2Constants.WHERE_VALUE_VALUE, value.get(0));
if(isFloat){
whereValue = value.get(0);
}else {
whereValue = String.format(Db2Constants.WHERE_VALUE_VALUE, value.get(0));
}
}
list.add(SQLObj.builder()
.whereField(whereName)
@ -1163,8 +1177,9 @@ public class Db2QueryProvider extends QueryProvider {
} else {
if (y.getDeType().equals(DeTypeConstants.DE_TIME)) {
whereValue = String.format(Db2Constants.DATE_FORMAT, "'" + f.getValue() + "'", Db2Constants.DEFAULT_DATE_FORMAT);
;
} else {
} else if(y.getDeType().equals(DeTypeConstants.DE_FLOAT)){
whereValue = f.getValue();
}else {
whereValue = String.format(Db2Constants.WHERE_VALUE_VALUE, f.getValue());
}
}

View File

@ -453,7 +453,7 @@ public class ChartViewService {
}
} else if (StringUtils.equalsIgnoreCase(table.getType(), DatasetType.SQL.name())) {
String sql = dataTableInfoDTO.getSql();
sql = handleVariable(sql, requestList);
sql = handleVariable(sql, requestList, qp);
if (StringUtils.equalsIgnoreCase("text", view.getType()) || StringUtils.equalsIgnoreCase("gauge", view.getType()) || StringUtils.equalsIgnoreCase("liquid", view.getType())) {
datasourceRequest.setQuery(qp.getSQLSummaryAsTmp(sql, yAxis, fieldCustomFilter, extFilterList, view));
} else if (StringUtils.containsIgnoreCase(view.getType(), "stack")) {
@ -829,7 +829,7 @@ public class ChartViewService {
}
} else if (StringUtils.equalsIgnoreCase(table.getType(), DatasetType.SQL.name())) {
String sql = dataTableInfoDTO.getSql();
sql = handleVariable(sql, requestList);
sql = handleVariable(sql, requestList, qp);
if (StringUtils.equalsIgnoreCase("text", view.getType()) || StringUtils.equalsIgnoreCase("gauge", view.getType()) || StringUtils.equalsIgnoreCase("liquid", view.getType())) {
datasourceRequest.setQuery(qp.getSQLSummaryAsTmp(sql, yAxis, fieldCustomFilter, extFilterList, view));
} else if (StringUtils.containsIgnoreCase(view.getType(), "stack")) {
@ -1500,23 +1500,19 @@ public class ChartViewService {
chartViewMapper.updateByPrimaryKeySelective(chartView);
}
private String handleVariable(String sql, ChartExtRequest requestList) throws Exception {
private String handleVariable(String sql, ChartExtRequest requestList, QueryProvider qp) throws Exception {
if (requestList != null && CollectionUtils.isNotEmpty(requestList.getFilter())) {
for (ChartExtFilterRequest chartExtFilterRequest : requestList.getFilter()) {
if (CollectionUtils.isEmpty(chartExtFilterRequest.getValue())) {
continue;
}
if(CollectionUtils.isEmpty(chartExtFilterRequest.getParameters())){
if (CollectionUtils.isEmpty(chartExtFilterRequest.getParameters())) {
continue;
}
if (chartExtFilterRequest.getValue().size() > 1) {
for (String parameter : chartExtFilterRequest.getParameters()) {
sql = sql.replace("${" + parameter + "}", String.join(",", chartExtFilterRequest.getValue()));
}
} else {
for (String parameter : chartExtFilterRequest.getParameters()) {
sql = sql.replace("${" + parameter + "}", chartExtFilterRequest.getValue().get(0));
}
String filter = qp.transFilter(chartExtFilterRequest);
for (String parameter : chartExtFilterRequest.getParameters()) {
sql = sql.replace("${" + parameter + "}", filter);
}
}
}

View File

@ -1010,9 +1010,11 @@ public class DataSetTableService {
return sql;
}
StringBuilder stringBuilder = new StringBuilder();
BinaryExpression binaryExpression = (BinaryExpression) expr;
if (!(binaryExpression.getLeftExpression() instanceof BinaryExpression) && !(binaryExpression.getRightExpression() instanceof BinaryExpression) && hasVarible(binaryExpression.toString())) {
BinaryExpression binaryExpression = null;
try{
binaryExpression = (BinaryExpression)expr;
}catch (Exception e){ }
if (binaryExpression != null && !(binaryExpression.getLeftExpression() instanceof BinaryExpression) && !(binaryExpression.getRightExpression() instanceof BinaryExpression) && hasVarible(binaryExpression.toString())) {
stringBuilder.append(SubstitutedSql);
} else {
expr.accept(getExpressionDeParser(stringBuilder));
@ -2567,22 +2569,27 @@ public class DataSetTableService {
@Override
public void visit(InExpression inExpression) {
inExpression.getLeftExpression().accept(this);
if (inExpression.isNot()) {
getBuffer().append(" " + "NOT IN" + " ");
} else {
getBuffer().append(" " + "IN" + " ");
if (inExpression.getRightItemsList() != null && hasVarible(inExpression.getRightItemsList().toString())) {
stringBuilder.append(SubstitutedSql);
return;
}
if (inExpression.getRightExpression() != null && inExpression.getRightExpression().toString().equals(SubstitutedParams)) {
stringBuilder.append(SubstitutedSql);
return;
}
if (inExpression.isNot()) {
getBuffer().append(" " + " NOT IN " + " ");
} else {
getBuffer().append(" IN " );
}
getBuffer().append("(");
if (inExpression.getRightItemsList() != null) {
inExpression.getRightItemsList().accept(this);
getBuffer().append(inExpression.getRightItemsList());
}
if (inExpression.getRightExpression() != null) {
getBuffer().append(" ( ");
inExpression.getRightExpression().accept(this);
getBuffer().append(" )");
}
getBuffer().append(")");
}

View File

@ -1,5 +1,7 @@
package io.dataease.service.datasource;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
@ -140,6 +142,11 @@ public class DatasourceService {
if (StringUtils.isNotEmpty(configuration.getCustomDriver()) && !configuration.getCustomDriver().equalsIgnoreCase("default")) {
datasourceDTO.setCalculationMode(DatasourceCalculationMode.DIRECT);
}
JSONObject jsonObject = JSONObject.parseObject(datasourceDTO.getConfiguration());
if(jsonObject.getString("queryTimeout") == null){
jsonObject.put("queryTimeout", 30);
datasourceDTO.setConfiguration(jsonObject.toString());
}
}
if(datasourceDTO.getType().equalsIgnoreCase(DatasourceTypes.mysql.toString())){

View File

@ -1126,7 +1126,7 @@ export default {
dataset: {
params_work: 'Effective only when editing SQL',
sql_variable_limit_1: '1、SQL variables can only be used in where conditions',
sql_variable_limit_2: '2、Exampleselect * from table_name where column_name=${parm_name}',
sql_variable_limit_2: '2、Exampleselect * from table_name where column_name1=${parm_name1} and column_name2 in ${parm_name2}',
select_year: 'Select Year',
select_month: 'Select Month',
select_date: 'Select Date',

View File

@ -1126,8 +1126,8 @@ export default {
dataset: {
params_work: '僅在編輯 sql 時生效',
sql_variable_limit_1: '1、SQL變數只能在WHERE條件中使用',
sql_variable_limit_2: '2、示例select * from table_name where column_name=${parm_name}',
select_year: '選擇年',
sql_variable_limit_2: '2、示例select * from table_name where column_name1=${parm_name1} and column_name2 in ${parm_name2}',
selesql_variable_limit_2ct_year: '選擇年',
select_month: '選擇月',
select_date: '選擇日期',
select_time: '選擇時間',

View File

@ -1129,7 +1129,7 @@ export default {
params_work: '仅在编辑sql时生效',
select_year: '选择年',
sql_variable_limit_1: '1、SQL 变量只能在 WHERE 条件中使用',
sql_variable_limit_2: '2、示例select * from table_name where column_name=${parm_name}',
sql_variable_limit_2: '2、示例select * from table_name where column_name1=${parm_name1} and column_name2 in ${parm_name2} ',
select_month: '选择月',
select_date: '选择日期',
select_time: '选择时间',

View File

@ -319,9 +319,6 @@ export default {
} else {
this.form.configuration = JSON.parse(this.form.configuration)
if(this.form.configuration.queryTimeout === undefined){
this.form.configuration.queryTimeout = 30
}
}
this.disabled = this.params && this.params.id && this.params.showModel && this.params.showModel === 'show' && !this.canEdit
},