forked from github/dataease
Merge pull request #7258 from dataease/pr@dev-v2@fixDatasource
fix: 【查询组件】-时间范围绑定参数,无法获取可绑定参数
This commit is contained in:
commit
24cbddf2c2
@ -67,6 +67,8 @@ public class ChartDataManage {
|
||||
@Resource
|
||||
private CorePermissionManage corePermissionManage;
|
||||
|
||||
public static final String START_END_SEPARATOR = "_START_END_SPLIT";
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ChartDataManage.class);
|
||||
|
||||
public ChartViewDTO calcData(ChartViewDTO view) throws Exception {
|
||||
@ -246,7 +248,8 @@ public class ChartDataManage {
|
||||
List<SqlVariableDetails> sqlVariables = datasetGroupManage.getSqlParams(Arrays.asList(view.getTableId()));
|
||||
if (CollectionUtil.isNotEmpty(sqlVariables)) {
|
||||
for (SqlVariableDetails parameter : Optional.ofNullable(request.getParameters()).orElse(new ArrayList<>())) {
|
||||
if (sqlVariables.stream().map(SqlVariableDetails::getId).collect(Collectors.toList()).contains(parameter.getId())) {
|
||||
String parameterId = StringUtils.endsWith(parameter.getId(), START_END_SEPARATOR) ? parameter.getId().split(START_END_SEPARATOR)[0] : parameter.getId();
|
||||
if (sqlVariables.stream().map(SqlVariableDetails::getId).collect(Collectors.toList()).contains(parameterId)) {
|
||||
hasParameters = true;
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static io.dataease.chart.manage.ChartDataManage.START_END_SEPARATOR;
|
||||
import static org.apache.calcite.sql.SqlKind.*;
|
||||
|
||||
public class SqlparserUtils {
|
||||
@ -166,7 +167,11 @@ public class SqlparserUtils {
|
||||
return "'" + String.join("','", sqlVariableDetails.getValue()) + "'";
|
||||
} else if (sqlVariableDetails.getOperator().equals("between")) {
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(sqlVariableDetails.getType().size() > 1 ? (String) sqlVariableDetails.getType().get(1).replace("DD", "dd") : "YYYY");
|
||||
return simpleDateFormat.format(new Date(Long.parseLong((String) sqlVariableDetails.getValue().get(0))));
|
||||
if (StringUtils.endsWith(sqlVariableDetails.getId(), START_END_SEPARATOR)) {
|
||||
return simpleDateFormat.format(new Date(Long.parseLong((String) sqlVariableDetails.getValue().get(1))));
|
||||
} else {
|
||||
return simpleDateFormat.format(new Date(Long.parseLong((String) sqlVariableDetails.getValue().get(0))));
|
||||
}
|
||||
} else {
|
||||
return (String) sqlVariableDetails.getValue().get(0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user