Merge branch 'v1.12' into dev
This commit is contained in:
commit
ad233b2881
@ -906,7 +906,9 @@ public class Db2QueryProvider extends QueryProvider {
|
|||||||
} else {
|
} else {
|
||||||
if (field.getDeType().equals(DeTypeConstants.DE_TIME)) {
|
if (field.getDeType().equals(DeTypeConstants.DE_TIME)) {
|
||||||
whereValue = String.format(Db2Constants.DATE_FORMAT, "'" + value + "'", Db2Constants.DEFAULT_DATE_FORMAT);
|
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);
|
whereValue = String.format(Db2Constants.WHERE_VALUE_VALUE, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -941,11 +943,14 @@ public class Db2QueryProvider extends QueryProvider {
|
|||||||
} else {
|
} else {
|
||||||
fieldList.add(request.getDatasetTableField());
|
fieldList.add(request.getDatasetTableField());
|
||||||
}
|
}
|
||||||
|
boolean isFloat = false;
|
||||||
for (DatasetTableField field : fieldList) {
|
for (DatasetTableField field : fieldList) {
|
||||||
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
|
if (CollectionUtils.isEmpty(value) || ObjectUtils.isEmpty(field)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(field.getDeType().equals(DeTypeConstants.DE_FLOAT)){
|
||||||
|
isFloat = true;
|
||||||
|
}
|
||||||
String whereName = "";
|
String whereName = "";
|
||||||
|
|
||||||
String originName;
|
String originName;
|
||||||
@ -1002,7 +1007,11 @@ public class Db2QueryProvider extends QueryProvider {
|
|||||||
String whereValue = "";
|
String whereValue = "";
|
||||||
|
|
||||||
if (StringUtils.containsIgnoreCase(request.getOperator(), "in")) {
|
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")) {
|
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "like")) {
|
||||||
whereValue = "'%" + value.get(0) + "%'";
|
whereValue = "'%" + value.get(0) + "%'";
|
||||||
} else if (StringUtils.containsIgnoreCase(request.getOperator(), "between")) {
|
} 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));
|
whereValue = String.format(Db2Constants.WHERE_BETWEEN, value.get(0), value.get(1));
|
||||||
}
|
}
|
||||||
} else {
|
} 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()
|
list.add(SQLObj.builder()
|
||||||
.whereField(whereName)
|
.whereField(whereName)
|
||||||
@ -1163,8 +1177,9 @@ public class Db2QueryProvider extends QueryProvider {
|
|||||||
} else {
|
} else {
|
||||||
if (y.getDeType().equals(DeTypeConstants.DE_TIME)) {
|
if (y.getDeType().equals(DeTypeConstants.DE_TIME)) {
|
||||||
whereValue = String.format(Db2Constants.DATE_FORMAT, "'" + f.getValue() + "'", Db2Constants.DEFAULT_DATE_FORMAT);
|
whereValue = String.format(Db2Constants.DATE_FORMAT, "'" + f.getValue() + "'", Db2Constants.DEFAULT_DATE_FORMAT);
|
||||||
;
|
} else if(y.getDeType().equals(DeTypeConstants.DE_FLOAT)){
|
||||||
} else {
|
whereValue = f.getValue();
|
||||||
|
}else {
|
||||||
whereValue = String.format(Db2Constants.WHERE_VALUE_VALUE, f.getValue());
|
whereValue = String.format(Db2Constants.WHERE_VALUE_VALUE, f.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -453,7 +453,7 @@ public class ChartViewService {
|
|||||||
}
|
}
|
||||||
} else if (StringUtils.equalsIgnoreCase(table.getType(), DatasetType.SQL.name())) {
|
} else if (StringUtils.equalsIgnoreCase(table.getType(), DatasetType.SQL.name())) {
|
||||||
String sql = dataTableInfoDTO.getSql();
|
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())) {
|
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));
|
datasourceRequest.setQuery(qp.getSQLSummaryAsTmp(sql, yAxis, fieldCustomFilter, extFilterList, view));
|
||||||
} else if (StringUtils.containsIgnoreCase(view.getType(), "stack")) {
|
} else if (StringUtils.containsIgnoreCase(view.getType(), "stack")) {
|
||||||
@ -829,7 +829,7 @@ public class ChartViewService {
|
|||||||
}
|
}
|
||||||
} else if (StringUtils.equalsIgnoreCase(table.getType(), DatasetType.SQL.name())) {
|
} else if (StringUtils.equalsIgnoreCase(table.getType(), DatasetType.SQL.name())) {
|
||||||
String sql = dataTableInfoDTO.getSql();
|
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())) {
|
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));
|
datasourceRequest.setQuery(qp.getSQLSummaryAsTmp(sql, yAxis, fieldCustomFilter, extFilterList, view));
|
||||||
} else if (StringUtils.containsIgnoreCase(view.getType(), "stack")) {
|
} else if (StringUtils.containsIgnoreCase(view.getType(), "stack")) {
|
||||||
@ -1500,23 +1500,19 @@ public class ChartViewService {
|
|||||||
chartViewMapper.updateByPrimaryKeySelective(chartView);
|
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())) {
|
if (requestList != null && CollectionUtils.isNotEmpty(requestList.getFilter())) {
|
||||||
for (ChartExtFilterRequest chartExtFilterRequest : requestList.getFilter()) {
|
for (ChartExtFilterRequest chartExtFilterRequest : requestList.getFilter()) {
|
||||||
if (CollectionUtils.isEmpty(chartExtFilterRequest.getValue())) {
|
if (CollectionUtils.isEmpty(chartExtFilterRequest.getValue())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(CollectionUtils.isEmpty(chartExtFilterRequest.getParameters())){
|
if (CollectionUtils.isEmpty(chartExtFilterRequest.getParameters())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (chartExtFilterRequest.getValue().size() > 1) {
|
|
||||||
for (String parameter : chartExtFilterRequest.getParameters()) {
|
String filter = qp.transFilter(chartExtFilterRequest);
|
||||||
sql = sql.replace("${" + parameter + "}", String.join(",", chartExtFilterRequest.getValue()));
|
for (String parameter : chartExtFilterRequest.getParameters()) {
|
||||||
}
|
sql = sql.replace("${" + parameter + "}", filter);
|
||||||
} else {
|
|
||||||
for (String parameter : chartExtFilterRequest.getParameters()) {
|
|
||||||
sql = sql.replace("${" + parameter + "}", chartExtFilterRequest.getValue().get(0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1010,9 +1010,11 @@ public class DataSetTableService {
|
|||||||
return sql;
|
return sql;
|
||||||
}
|
}
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
BinaryExpression binaryExpression = (BinaryExpression) expr;
|
BinaryExpression binaryExpression = null;
|
||||||
|
try{
|
||||||
if (!(binaryExpression.getLeftExpression() instanceof BinaryExpression) && !(binaryExpression.getRightExpression() instanceof BinaryExpression) && hasVarible(binaryExpression.toString())) {
|
binaryExpression = (BinaryExpression)expr;
|
||||||
|
}catch (Exception e){ }
|
||||||
|
if (binaryExpression != null && !(binaryExpression.getLeftExpression() instanceof BinaryExpression) && !(binaryExpression.getRightExpression() instanceof BinaryExpression) && hasVarible(binaryExpression.toString())) {
|
||||||
stringBuilder.append(SubstitutedSql);
|
stringBuilder.append(SubstitutedSql);
|
||||||
} else {
|
} else {
|
||||||
expr.accept(getExpressionDeParser(stringBuilder));
|
expr.accept(getExpressionDeParser(stringBuilder));
|
||||||
@ -2567,22 +2569,27 @@ public class DataSetTableService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visit(InExpression inExpression) {
|
public void visit(InExpression inExpression) {
|
||||||
inExpression.getLeftExpression().accept(this);
|
if (inExpression.getRightItemsList() != null && hasVarible(inExpression.getRightItemsList().toString())) {
|
||||||
if (inExpression.isNot()) {
|
stringBuilder.append(SubstitutedSql);
|
||||||
getBuffer().append(" " + "NOT IN" + " ");
|
return;
|
||||||
} else {
|
}
|
||||||
getBuffer().append(" " + "IN" + " ");
|
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) {
|
if (inExpression.getRightItemsList() != null) {
|
||||||
inExpression.getRightItemsList().accept(this);
|
getBuffer().append(inExpression.getRightItemsList());
|
||||||
}
|
}
|
||||||
if (inExpression.getRightExpression() != null) {
|
if (inExpression.getRightExpression() != null) {
|
||||||
|
getBuffer().append(" ( ");
|
||||||
inExpression.getRightExpression().accept(this);
|
inExpression.getRightExpression().accept(this);
|
||||||
|
getBuffer().append(" )");
|
||||||
}
|
}
|
||||||
|
|
||||||
getBuffer().append(")");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
package io.dataease.service.datasource;
|
package io.dataease.service.datasource;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
@ -140,6 +142,11 @@ public class DatasourceService {
|
|||||||
if (StringUtils.isNotEmpty(configuration.getCustomDriver()) && !configuration.getCustomDriver().equalsIgnoreCase("default")) {
|
if (StringUtils.isNotEmpty(configuration.getCustomDriver()) && !configuration.getCustomDriver().equalsIgnoreCase("default")) {
|
||||||
datasourceDTO.setCalculationMode(DatasourceCalculationMode.DIRECT);
|
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())){
|
if(datasourceDTO.getType().equalsIgnoreCase(DatasourceTypes.mysql.toString())){
|
||||||
|
|||||||
@ -1126,7 +1126,7 @@ export default {
|
|||||||
dataset: {
|
dataset: {
|
||||||
params_work: 'Effective only when editing SQL',
|
params_work: 'Effective only when editing SQL',
|
||||||
sql_variable_limit_1: '1、SQL variables can only be used in where conditions',
|
sql_variable_limit_1: '1、SQL variables can only be used in where conditions',
|
||||||
sql_variable_limit_2: '2、Example:select * from table_name where column_name=‘${parm_name}',
|
sql_variable_limit_2: '2、Example:select * from table_name where column_name1=${parm_name1} and column_name2 in ${parm_name2}',
|
||||||
select_year: 'Select Year',
|
select_year: 'Select Year',
|
||||||
select_month: 'Select Month',
|
select_month: 'Select Month',
|
||||||
select_date: 'Select Date',
|
select_date: 'Select Date',
|
||||||
|
|||||||
@ -1126,8 +1126,8 @@ export default {
|
|||||||
dataset: {
|
dataset: {
|
||||||
params_work: '僅在編輯 sql 時生效',
|
params_work: '僅在編輯 sql 時生效',
|
||||||
sql_variable_limit_1: '1、SQL變數只能在WHERE條件中使用',
|
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_year: '選擇年',
|
selesql_variable_limit_2ct_year: '選擇年',
|
||||||
select_month: '選擇月',
|
select_month: '選擇月',
|
||||||
select_date: '選擇日期',
|
select_date: '選擇日期',
|
||||||
select_time: '選擇時間',
|
select_time: '選擇時間',
|
||||||
|
|||||||
@ -1129,7 +1129,7 @@ export default {
|
|||||||
params_work: '仅在编辑sql时生效',
|
params_work: '仅在编辑sql时生效',
|
||||||
select_year: '选择年',
|
select_year: '选择年',
|
||||||
sql_variable_limit_1: '1、SQL 变量只能在 WHERE 条件中使用',
|
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_month: '选择月',
|
||||||
select_date: '选择日期',
|
select_date: '选择日期',
|
||||||
select_time: '选择时间',
|
select_time: '选择时间',
|
||||||
|
|||||||
@ -319,9 +319,6 @@ export default {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.form.configuration = JSON.parse(this.form.configuration)
|
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
|
this.disabled = this.params && this.params.id && this.params.showModel && this.params.showModel === 'show' && !this.canEdit
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user