Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
zhu
dataease
Commits
14ea9837
提交
14ea9837
authored
11月 01, 2021
作者:
taojinlong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: 规范代码结构
上级
8935dd2e
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
22 行增加
和
108 行删除
+22
-108
MysqlConfigration.java
...in/java/io/dataease/dto/datasource/MysqlConfigration.java
+0
-20
EsQueryProvider.java
...n/java/io/dataease/provider/query/es/EsQueryProvider.java
+22
-88
没有找到文件。
backend/src/main/java/io/dataease/dto/datasource/MysqlConfigration.java
deleted
100644 → 0
浏览文件 @
8935dd2e
package
io
.
dataease
.
dto
.
datasource
;
import
lombok.Getter
;
import
lombok.Setter
;
@Getter
@Setter
public
class
MysqlConfigration
extends
JdbcConfiguration
{
private
String
driver
=
"com.mysql.cj.jdbc.Driver"
;
public
String
getJdbc
()
{
// 连接参数先写死,后边要把编码、时区等参数放到数据源的设置中
return
"jdbc:mysql://HOSTNAME:PORT/DATABASE?characterEncoding=UTF-8&connectTimeout=5000&useSSL=false"
.
replace
(
"HOSTNAME"
,
getHost
().
trim
())
.
replace
(
"PORT"
,
getPort
().
toString
().
trim
())
.
replace
(
"DATABASE"
,
getDataBase
().
trim
());
}
}
\ No newline at end of file
backend/src/main/java/io/dataease/provider/query/es/EsQueryProvider.java
浏览文件 @
14ea9837
package
io
.
dataease
.
provider
.
query
.
es
;
import
io.dataease.base.domain.ChartViewWithBLOBs
;
import
io.dataease.base.domain.DatasetTableField
;
import
io.dataease.base.domain.DatasetTableFieldExample
;
import
io.dataease.base.domain.Datasource
;
...
...
@@ -197,7 +198,7 @@ public class EsQueryProvider extends QueryProvider {
}
@Override
public
String
getSQL
(
String
table
,
List
<
ChartViewFieldDTO
>
xAxis
,
List
<
ChartViewFieldDTO
>
yAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
,
Datasource
ds
)
{
public
String
getSQL
(
String
table
,
List
<
ChartViewFieldDTO
>
xAxis
,
List
<
ChartViewFieldDTO
>
yAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
,
Datasource
ds
,
ChartViewWithBLOBs
view
)
{
SQLObj
tableObj
=
SQLObj
.
builder
()
.
tableName
((
table
.
startsWith
(
"("
)
&&
table
.
endsWith
(
")"
))
?
table
:
String
.
format
(
EsSqlLConstants
.
KEYWORD_TABLE
,
table
))
.
tableAlias
(
String
.
format
(
TABLE_ALIAS_PREFIX
,
0
))
...
...
@@ -299,94 +300,27 @@ public class EsQueryProvider extends QueryProvider {
if
(
CollectionUtils
.
isNotEmpty
(
aggWheres
))
st
.
add
(
"filters"
,
aggWheres
);
if
(
CollectionUtils
.
isNotEmpty
(
orders
))
st
.
add
(
"orders"
,
orders
);
if
(
ObjectUtils
.
isNotEmpty
(
tableSQL
))
st
.
add
(
"table"
,
tableSQL
);
return
s
t
.
render
(
);
return
s
qlLimit
(
st
.
render
(),
view
);
}
@Override
public
String
getSQLAsTmp
(
String
sql
,
List
<
ChartViewFieldDTO
>
xAxis
,
List
<
ChartViewFieldDTO
>
yAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
)
{
return
getSQL
(
"("
+
sqlFix
(
sql
)
+
")"
,
xAxis
,
yAxis
,
customFilter
,
extFilterRequestList
,
null
);
public
String
getSQLAsTmp
(
String
sql
,
List
<
ChartViewFieldDTO
>
xAxis
,
List
<
ChartViewFieldDTO
>
yAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
,
ChartViewWithBLOBs
view
)
{
return
getSQL
(
"("
+
sqlFix
(
sql
)
+
")"
,
xAxis
,
yAxis
,
customFilter
,
extFilterRequestList
,
null
,
view
);
}
@Override
public
String
getSQLTableInfo
(
String
table
,
List
<
ChartViewFieldDTO
>
xAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
,
Datasource
ds
)
{
SQLObj
tableObj
=
SQLObj
.
builder
()
.
tableName
((
table
.
startsWith
(
"("
)
&&
table
.
endsWith
(
")"
))
?
table
:
String
.
format
(
EsSqlLConstants
.
KEYWORD_TABLE
,
table
))
.
tableAlias
(
String
.
format
(
TABLE_ALIAS_PREFIX
,
0
))
.
build
();
List
<
SQLObj
>
xFields
=
new
ArrayList
<>();
List
<
SQLObj
>
xWheres
=
new
ArrayList
<>();
List
<
SQLObj
>
xOrders
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
xAxis
))
{
for
(
int
i
=
0
;
i
<
xAxis
.
size
();
i
++)
{
ChartViewFieldDTO
x
=
xAxis
.
get
(
i
);
String
originField
;
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
(
EsSqlLConstants
.
KEYWORD_FIX
,
tableObj
.
getTableAlias
(),
x
.
getOriginName
());
}
else
{
originField
=
String
.
format
(
EsSqlLConstants
.
KEYWORD_FIX
,
tableObj
.
getTableAlias
(),
x
.
getOriginName
());
}
String
fieldAlias
=
String
.
format
(
SQLConstants
.
FIELD_ALIAS_X_PREFIX
,
i
);
// 处理横轴字段
xFields
.
add
(
getXFields
(
x
,
originField
,
fieldAlias
));
// 处理横轴过滤
// xWheres.addAll(getXWheres(x, originField, fieldAlias));
// 处理横轴排序
if
(
StringUtils
.
isNotEmpty
(
x
.
getSort
())
&&
!
StringUtils
.
equalsIgnoreCase
(
x
.
getSort
(),
"none"
))
{
xOrders
.
add
(
SQLObj
.
builder
()
.
orderField
(
originField
)
.
orderAlias
(
fieldAlias
)
.
orderDirection
(
x
.
getSort
())
.
build
());
}
}
}
// 处理视图中字段过滤
List
<
SQLObj
>
customWheres
=
transCustomFilterList
(
tableObj
,
customFilter
);
// 处理仪表板字段过滤
List
<
SQLObj
>
extWheres
=
transExtFilterList
(
tableObj
,
extFilterRequestList
);
// 构建sql所有参数
List
<
SQLObj
>
fields
=
new
ArrayList
<>();
fields
.
addAll
(
xFields
);
List
<
SQLObj
>
wheres
=
new
ArrayList
<>();
wheres
.
addAll
(
xWheres
);
if
(
customWheres
!=
null
)
wheres
.
addAll
(
customWheres
);
if
(
extWheres
!=
null
)
wheres
.
addAll
(
extWheres
);
List
<
SQLObj
>
groups
=
new
ArrayList
<>();
groups
.
addAll
(
xFields
);
// 外层再次套sql
List
<
SQLObj
>
orders
=
new
ArrayList
<>();
orders
.
addAll
(
xOrders
);
STGroup
stg
=
new
STGroupFile
(
SQLConstants
.
SQL_TEMPLATE
);
ST
st_sql
=
stg
.
getInstanceOf
(
"previewSql"
);
st_sql
.
add
(
"isGroup"
,
false
);
if
(
CollectionUtils
.
isNotEmpty
(
xFields
))
st_sql
.
add
(
"groups"
,
xFields
);
if
(
CollectionUtils
.
isNotEmpty
(
wheres
))
st_sql
.
add
(
"filters"
,
wheres
);
if
(
ObjectUtils
.
isNotEmpty
(
tableObj
))
st_sql
.
add
(
"table"
,
tableObj
);
String
sql
=
st_sql
.
render
();
ST
st
=
stg
.
getInstanceOf
(
"previewSql"
);
st
.
add
(
"isGroup"
,
false
);
SQLObj
tableSQL
=
SQLObj
.
builder
()
.
tableName
(
String
.
format
(
EsSqlLConstants
.
BRACKETS
,
sql
))
.
tableAlias
(
String
.
format
(
TABLE_ALIAS_PREFIX
,
1
))
.
build
();
if
(
CollectionUtils
.
isNotEmpty
(
orders
))
st
.
add
(
"orders"
,
orders
);
if
(
ObjectUtils
.
isNotEmpty
(
tableSQL
))
st
.
add
(
"table"
,
tableSQL
);
return
st
.
render
();
public
String
getSQLTableInfo
(
String
table
,
List
<
ChartViewFieldDTO
>
xAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
,
Datasource
ds
,
ChartViewWithBLOBs
view
)
{
return
null
;
}
@Override
public
String
getSQLAsTmpTableInfo
(
String
sql
,
List
<
ChartViewFieldDTO
>
xAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
,
Datasource
ds
)
{
return
getSQLTableInfo
(
"("
+
sqlFix
(
sql
)
+
")"
,
xAxis
,
customFilter
,
extFilterRequestList
,
null
)
;
public
String
getSQLAsTmpTableInfo
(
String
sql
,
List
<
ChartViewFieldDTO
>
xAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
,
Datasource
ds
,
ChartViewWithBLOBs
view
)
{
return
null
;
}
@Override
public
String
getSQLStack
(
String
table
,
List
<
ChartViewFieldDTO
>
xAxis
,
List
<
ChartViewFieldDTO
>
yAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
,
List
<
ChartViewFieldDTO
>
extStack
,
Datasource
ds
)
{
public
String
getSQLStack
(
String
table
,
List
<
ChartViewFieldDTO
>
xAxis
,
List
<
ChartViewFieldDTO
>
yAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
,
List
<
ChartViewFieldDTO
>
extStack
,
Datasource
ds
,
ChartViewWithBLOBs
view
)
{
SQLObj
tableObj
=
SQLObj
.
builder
()
.
tableName
((
table
.
startsWith
(
"("
)
&&
table
.
endsWith
(
")"
))
?
table
:
String
.
format
(
EsSqlLConstants
.
KEYWORD_TABLE
,
table
))
.
tableAlias
(
String
.
format
(
TABLE_ALIAS_PREFIX
,
0
))
...
...
@@ -491,16 +425,16 @@ public class EsQueryProvider extends QueryProvider {
if
(
CollectionUtils
.
isNotEmpty
(
aggWheres
))
st
.
add
(
"filters"
,
aggWheres
);
if
(
CollectionUtils
.
isNotEmpty
(
orders
))
st
.
add
(
"orders"
,
orders
);
if
(
ObjectUtils
.
isNotEmpty
(
tableSQL
))
st
.
add
(
"table"
,
tableSQL
);
return
s
t
.
render
(
);
return
s
qlLimit
(
st
.
render
(),
view
);
}
@Override
public
String
getSQLAsTmpStack
(
String
table
,
List
<
ChartViewFieldDTO
>
xAxis
,
List
<
ChartViewFieldDTO
>
yAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
,
List
<
ChartViewFieldDTO
>
extStack
)
{
return
getSQLStack
(
"("
+
sqlFix
(
table
)
+
")"
,
xAxis
,
yAxis
,
customFilter
,
extFilterRequestList
,
extStack
,
null
);
public
String
getSQLAsTmpStack
(
String
table
,
List
<
ChartViewFieldDTO
>
xAxis
,
List
<
ChartViewFieldDTO
>
yAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
,
List
<
ChartViewFieldDTO
>
extStack
,
ChartViewWithBLOBs
view
)
{
return
getSQLStack
(
"("
+
sqlFix
(
table
)
+
")"
,
xAxis
,
yAxis
,
customFilter
,
extFilterRequestList
,
extStack
,
null
,
view
);
}
@Override
public
String
getSQLScatter
(
String
table
,
List
<
ChartViewFieldDTO
>
xAxis
,
List
<
ChartViewFieldDTO
>
yAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
,
List
<
ChartViewFieldDTO
>
extBubble
,
Datasource
ds
)
{
public
String
getSQLScatter
(
String
table
,
List
<
ChartViewFieldDTO
>
xAxis
,
List
<
ChartViewFieldDTO
>
yAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
,
List
<
ChartViewFieldDTO
>
extBubble
,
Datasource
ds
,
ChartViewWithBLOBs
view
)
{
SQLObj
tableObj
=
SQLObj
.
builder
()
.
tableName
((
table
.
startsWith
(
"("
)
&&
table
.
endsWith
(
")"
))
?
table
:
String
.
format
(
EsSqlLConstants
.
KEYWORD_TABLE
,
table
))
.
tableAlias
(
String
.
format
(
TABLE_ALIAS_PREFIX
,
0
))
...
...
@@ -605,12 +539,12 @@ public class EsQueryProvider extends QueryProvider {
if
(
CollectionUtils
.
isNotEmpty
(
aggWheres
))
st
.
add
(
"filters"
,
aggWheres
);
if
(
CollectionUtils
.
isNotEmpty
(
orders
))
st
.
add
(
"orders"
,
orders
);
if
(
ObjectUtils
.
isNotEmpty
(
tableSQL
))
st
.
add
(
"table"
,
tableSQL
);
return
s
t
.
render
(
);
return
s
qlLimit
(
st
.
render
(),
view
);
}
@Override
public
String
getSQLAsTmpScatter
(
String
table
,
List
<
ChartViewFieldDTO
>
xAxis
,
List
<
ChartViewFieldDTO
>
yAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
,
List
<
ChartViewFieldDTO
>
extBubble
)
{
return
getSQLScatter
(
"("
+
sqlFix
(
table
)
+
")"
,
xAxis
,
yAxis
,
customFilter
,
extFilterRequestList
,
extBubble
,
null
);
public
String
getSQLAsTmpScatter
(
String
table
,
List
<
ChartViewFieldDTO
>
xAxis
,
List
<
ChartViewFieldDTO
>
yAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
,
List
<
ChartViewFieldDTO
>
extBubble
,
ChartViewWithBLOBs
view
)
{
return
getSQLScatter
(
"("
+
sqlFix
(
table
)
+
")"
,
xAxis
,
yAxis
,
customFilter
,
extFilterRequestList
,
extBubble
,
null
,
view
);
}
@Override
...
...
@@ -619,7 +553,7 @@ public class EsQueryProvider extends QueryProvider {
}
@Override
public
String
getSQLSummary
(
String
table
,
List
<
ChartViewFieldDTO
>
yAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
)
{
public
String
getSQLSummary
(
String
table
,
List
<
ChartViewFieldDTO
>
yAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
,
ChartViewWithBLOBs
view
)
{
// 字段汇总 排序等
SQLObj
tableObj
=
SQLObj
.
builder
()
.
tableName
((
table
.
startsWith
(
"("
)
&&
table
.
endsWith
(
")"
))
?
table
:
String
.
format
(
EsSqlLConstants
.
KEYWORD_TABLE
,
table
))
...
...
@@ -687,12 +621,12 @@ public class EsQueryProvider extends QueryProvider {
if
(
CollectionUtils
.
isNotEmpty
(
aggWheres
))
st
.
add
(
"filters"
,
aggWheres
);
if
(
CollectionUtils
.
isNotEmpty
(
orders
))
st
.
add
(
"orders"
,
orders
);
if
(
ObjectUtils
.
isNotEmpty
(
tableSQL
))
st
.
add
(
"table"
,
tableSQL
);
return
s
t
.
render
(
);
return
s
qlLimit
(
st
.
render
(),
view
);
}
@Override
public
String
getSQLSummaryAsTmp
(
String
sql
,
List
<
ChartViewFieldDTO
>
yAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
)
{
return
getSQLSummary
(
"("
+
sqlFix
(
sql
)
+
")"
,
yAxis
,
customFilter
,
extFilterRequestList
);
public
String
getSQLSummaryAsTmp
(
String
sql
,
List
<
ChartViewFieldDTO
>
yAxis
,
List
<
ChartCustomFilterDTO
>
customFilter
,
List
<
ChartExtFilterRequest
>
extFilterRequestList
,
ChartViewWithBLOBs
view
)
{
return
getSQLSummary
(
"("
+
sqlFix
(
sql
)
+
")"
,
yAxis
,
customFilter
,
extFilterRequestList
,
view
);
}
@Override
...
...
@@ -721,7 +655,7 @@ public class EsQueryProvider extends QueryProvider {
}
@Override
public
String
convertTableToSql
(
String
tableName
,
Datasource
ds
){
public
String
convertTableToSql
(
String
tableName
,
Datasource
ds
)
{
return
createSQLPreview
(
"SELECT * FROM "
+
String
.
format
(
EsSqlLConstants
.
KEYWORD_TABLE
,
tableName
),
null
);
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论