Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataease
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
njgzx
dataease
Commits
83081b94
提交
83081b94
authored
5月 26, 2022
作者:
junjun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: 树形过滤器sql拼接
上级
653f539c
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
143 行增加
和
80 行删除
+143
-80
MysqlQueryProvider.java
...io/dataease/provider/engine/mysql/MysqlQueryProvider.java
+50
-32
MysqlQueryProvider.java
.../io/dataease/provider/query/mysql/MysqlQueryProvider.java
+50
-33
ChartViewService.java
...main/java/io/dataease/service/chart/ChartViewService.java
+43
-15
没有找到文件。
backend/src/main/java/io/dataease/provider/engine/mysql/MysqlQueryProvider.java
浏览文件 @
83081b94
...
...
@@ -848,48 +848,66 @@ public class MysqlQueryProvider extends QueryProvider {
List
<
SQLObj
>
list
=
new
ArrayList
<>();
for
(
ChartExtFilterRequest
request
:
requestList
)
{
List
<
String
>
value
=
request
.
getValue
();
DatasetTableField
field
=
request
.
getDatasetTableField
();
if
(
CollectionUtils
.
isEmpty
(
value
)
||
ObjectUtils
.
isEmpty
(
field
))
{
continue
;
}
String
whereName
=
""
;
String
whereTerm
=
transMysqlFilterTerm
(
request
.
getOperator
());
String
whereValue
=
""
;
String
originName
;
if
(
ObjectUtils
.
isNotEmpty
(
field
.
getExtField
())
&&
field
.
getExtField
()
==
2
)
{
// 解析origin name中有关联的字段生成sql表达式
originName
=
calcFieldRegex
(
field
.
getOriginName
(),
tableObj
);
}
else
if
(
ObjectUtils
.
isNotEmpty
(
field
.
getExtField
())
&&
field
.
getExtField
()
==
1
)
{
originName
=
String
.
format
(
MysqlConstants
.
KEYWORD_FIX
,
tableObj
.
getTableAlias
(),
field
.
getDataeaseName
());
List
<
String
>
whereNameList
=
new
ArrayList
<>();
List
<
DatasetTableField
>
fieldList
=
new
ArrayList
<>();
if
(
request
.
getIsTree
())
{
fieldList
.
addAll
(
request
.
getDatasetTableFieldList
());
}
else
{
originName
=
String
.
format
(
MysqlConstants
.
KEYWORD_FIX
,
tableObj
.
getTableAlias
(),
field
.
getDataeaseName
());
fieldList
.
add
(
request
.
getDatasetTableField
());
}
if
(
field
.
getDeType
()
==
1
)
{
if
(
field
.
getDeExtractType
()
==
0
||
field
.
getDeExtractType
()
==
5
||
field
.
getDeExtractType
()
==
1
)
{
whereName
=
String
.
format
(
MysqlConstants
.
STR_TO_DATE
,
originName
,
MysqlConstants
.
DEFAULT_DATE_FORMAT
);
}
if
(
field
.
getDeExtractType
()
==
2
||
field
.
getDeExtractType
()
==
3
||
field
.
getDeExtractType
()
==
4
)
{
String
cast
=
String
.
format
(
MysqlConstants
.
CAST
,
originName
,
MysqlConstants
.
DEFAULT_INT_FORMAT
)
+
"/1000"
;
whereName
=
String
.
format
(
MysqlConstants
.
FROM_UNIXTIME
,
cast
,
MysqlConstants
.
DEFAULT_DATE_FORMAT
);
for
(
DatasetTableField
field
:
fieldList
)
{
if
(
CollectionUtils
.
isEmpty
(
value
)
||
ObjectUtils
.
isEmpty
(
field
))
{
continue
;
}
}
else
if
(
field
.
getDeType
()
==
0
&&
field
.
getDeExtractType
()
==
0
)
{
whereName
=
String
.
format
(
MysqlConstants
.
CAST
,
originName
,
MysqlConstants
.
CHAR
);
}
else
if
(
field
.
getDeType
()
==
2
||
field
.
getDeType
()
==
3
)
{
if
(
field
.
getDeExtractType
()
==
0
||
field
.
getDeExtractType
()
==
5
)
{
whereName
=
String
.
format
(
MysqlConstants
.
CAST
,
originName
,
MysqlConstants
.
DEFAULT_FLOAT_FORMAT
);
}
if
(
field
.
getDeExtractType
()
==
1
)
{
whereName
=
String
.
format
(
MysqlConstants
.
UNIX_TIMESTAMP
,
originName
)
+
"*1000"
;
String
whereName
=
""
;
String
originName
;
if
(
ObjectUtils
.
isNotEmpty
(
field
.
getExtField
())
&&
field
.
getExtField
()
==
2
)
{
// 解析origin name中有关联的字段生成sql表达式
originName
=
calcFieldRegex
(
field
.
getOriginName
(),
tableObj
);
}
else
if
(
ObjectUtils
.
isNotEmpty
(
field
.
getExtField
())
&&
field
.
getExtField
()
==
1
)
{
originName
=
String
.
format
(
MysqlConstants
.
KEYWORD_FIX
,
tableObj
.
getTableAlias
(),
field
.
getDataeaseName
());
}
else
{
originName
=
String
.
format
(
MysqlConstants
.
KEYWORD_FIX
,
tableObj
.
getTableAlias
(),
field
.
getDataeaseName
());
}
if
(
field
.
getDeExtractType
()
==
2
||
field
.
getDeExtractType
()
==
3
||
field
.
getDeExtractType
()
==
4
)
{
if
(
field
.
getDeType
()
==
1
)
{
if
(
field
.
getDeExtractType
()
==
0
||
field
.
getDeExtractType
()
==
5
||
field
.
getDeExtractType
()
==
1
)
{
whereName
=
String
.
format
(
MysqlConstants
.
STR_TO_DATE
,
originName
,
MysqlConstants
.
DEFAULT_DATE_FORMAT
);
}
if
(
field
.
getDeExtractType
()
==
2
||
field
.
getDeExtractType
()
==
3
||
field
.
getDeExtractType
()
==
4
)
{
String
cast
=
String
.
format
(
MysqlConstants
.
CAST
,
originName
,
MysqlConstants
.
DEFAULT_INT_FORMAT
)
+
"/1000"
;
whereName
=
String
.
format
(
MysqlConstants
.
FROM_UNIXTIME
,
cast
,
MysqlConstants
.
DEFAULT_DATE_FORMAT
);
}
}
else
if
(
field
.
getDeType
()
==
0
&&
field
.
getDeExtractType
()
==
0
)
{
whereName
=
String
.
format
(
MysqlConstants
.
CAST
,
originName
,
MysqlConstants
.
CHAR
);
}
else
if
(
field
.
getDeType
()
==
2
||
field
.
getDeType
()
==
3
)
{
if
(
field
.
getDeExtractType
()
==
0
||
field
.
getDeExtractType
()
==
5
)
{
whereName
=
String
.
format
(
MysqlConstants
.
CAST
,
originName
,
MysqlConstants
.
DEFAULT_FLOAT_FORMAT
);
}
if
(
field
.
getDeExtractType
()
==
1
)
{
whereName
=
String
.
format
(
MysqlConstants
.
UNIX_TIMESTAMP
,
originName
)
+
"*1000"
;
}
if
(
field
.
getDeExtractType
()
==
2
||
field
.
getDeExtractType
()
==
3
||
field
.
getDeExtractType
()
==
4
)
{
whereName
=
originName
;
}
}
else
{
whereName
=
originName
;
}
}
else
{
whereName
=
originName
;
whereNameList
.
add
(
whereName
);
}
String
whereName
=
""
;
if
(
request
.
getIsTree
())
{
whereName
=
"CONCAT("
+
StringUtils
.
join
(
whereNameList
,
",',',"
)
+
")"
;
}
else
{
whereName
=
whereNameList
.
get
(
0
);
}
String
whereTerm
=
transMysqlFilterTerm
(
request
.
getOperator
());
String
whereValue
=
""
;
if
(
StringUtils
.
containsIgnoreCase
(
request
.
getOperator
(),
"in"
))
{
whereValue
=
"('"
+
StringUtils
.
join
(
value
,
"','"
)
+
"')"
;
...
...
backend/src/main/java/io/dataease/provider/query/mysql/MysqlQueryProvider.java
浏览文件 @
83081b94
...
...
@@ -829,49 +829,66 @@ public class MysqlQueryProvider extends QueryProvider {
List
<
SQLObj
>
list
=
new
ArrayList
<>();
for
(
ChartExtFilterRequest
request
:
requestList
)
{
List
<
String
>
value
=
request
.
getValue
();
DatasetTableField
field
=
request
.
getDatasetTableField
();
if
(
CollectionUtils
.
isEmpty
(
value
)
||
ObjectUtils
.
isEmpty
(
field
))
{
continue
;
}
String
whereName
=
""
;
String
whereTerm
=
transMysqlFilterTerm
(
request
.
getOperator
());
String
whereValue
=
""
;
String
originName
;
if
(
ObjectUtils
.
isNotEmpty
(
field
.
getExtField
())
&&
field
.
getExtField
()
==
2
)
{
// 解析origin name中有关联的字段生成sql表达式
originName
=
calcFieldRegex
(
field
.
getOriginName
(),
tableObj
);
}
else
if
(
ObjectUtils
.
isNotEmpty
(
field
.
getExtField
())
&&
field
.
getExtField
()
==
1
)
{
originName
=
String
.
format
(
MySQLConstants
.
KEYWORD_FIX
,
tableObj
.
getTableAlias
(),
field
.
getOriginName
());
List
<
String
>
whereNameList
=
new
ArrayList
<>();
List
<
DatasetTableField
>
fieldList
=
new
ArrayList
<>();
if
(
request
.
getIsTree
())
{
fieldList
.
addAll
(
request
.
getDatasetTableFieldList
());
}
else
{
originName
=
String
.
format
(
MySQLConstants
.
KEYWORD_FIX
,
tableObj
.
getTableAlias
(),
field
.
getOriginName
());
fieldList
.
add
(
request
.
getDatasetTableField
());
}
if
(
field
.
getDeType
()
==
1
)
{
if
(
field
.
getDeExtractType
()
==
0
||
field
.
getDeExtractType
()
==
5
)
{
whereName
=
String
.
format
(
MySQLConstants
.
STR_TO_DATE
,
originName
,
MySQLConstants
.
DEFAULT_DATE_FORMAT
);
}
if
(
field
.
getDeExtractType
()
==
2
||
field
.
getDeExtractType
()
==
3
||
field
.
getDeExtractType
()
==
4
)
{
String
cast
=
String
.
format
(
MySQLConstants
.
CAST
,
originName
,
MySQLConstants
.
DEFAULT_INT_FORMAT
)
+
"/1000"
;
whereName
=
String
.
format
(
MySQLConstants
.
FROM_UNIXTIME
,
cast
,
MySQLConstants
.
DEFAULT_DATE_FORMAT
);
}
if
(
field
.
getDeExtractType
()
==
1
)
{
whereName
=
originName
;
}
}
else
if
(
field
.
getDeType
()
==
2
||
field
.
getDeType
()
==
3
)
{
if
(
field
.
getDeExtractType
()
==
0
||
field
.
getDeExtractType
()
==
5
)
{
whereName
=
String
.
format
(
MySQLConstants
.
CAST
,
originName
,
MySQLConstants
.
DEFAULT_FLOAT_FORMAT
);
for
(
DatasetTableField
field
:
fieldList
)
{
if
(
CollectionUtils
.
isEmpty
(
value
)
||
ObjectUtils
.
isEmpty
(
field
))
{
continue
;
}
if
(
field
.
getDeExtractType
()
==
1
)
{
whereName
=
String
.
format
(
MySQLConstants
.
UNIX_TIMESTAMP
,
originName
);
String
whereName
=
""
;
String
originName
;
if
(
ObjectUtils
.
isNotEmpty
(
field
.
getExtField
())
&&
field
.
getExtField
()
==
2
)
{
// 解析origin name中有关联的字段生成sql表达式
originName
=
calcFieldRegex
(
field
.
getOriginName
(),
tableObj
);
}
else
if
(
ObjectUtils
.
isNotEmpty
(
field
.
getExtField
())
&&
field
.
getExtField
()
==
1
)
{
originName
=
String
.
format
(
MySQLConstants
.
KEYWORD_FIX
,
tableObj
.
getTableAlias
(),
field
.
getOriginName
());
}
else
{
originName
=
String
.
format
(
MySQLConstants
.
KEYWORD_FIX
,
tableObj
.
getTableAlias
(),
field
.
getOriginName
());
}
if
(
field
.
getDeExtractType
()
==
2
||
field
.
getDeExtractType
()
==
3
||
field
.
getDeExtractType
()
==
4
)
{
if
(
field
.
getDeType
()
==
1
)
{
if
(
field
.
getDeExtractType
()
==
0
||
field
.
getDeExtractType
()
==
5
)
{
whereName
=
String
.
format
(
MySQLConstants
.
STR_TO_DATE
,
originName
,
MySQLConstants
.
DEFAULT_DATE_FORMAT
);
}
if
(
field
.
getDeExtractType
()
==
2
||
field
.
getDeExtractType
()
==
3
||
field
.
getDeExtractType
()
==
4
)
{
String
cast
=
String
.
format
(
MySQLConstants
.
CAST
,
originName
,
MySQLConstants
.
DEFAULT_INT_FORMAT
)
+
"/1000"
;
whereName
=
String
.
format
(
MySQLConstants
.
FROM_UNIXTIME
,
cast
,
MySQLConstants
.
DEFAULT_DATE_FORMAT
);
}
if
(
field
.
getDeExtractType
()
==
1
)
{
whereName
=
originName
;
}
}
else
if
(
field
.
getDeType
()
==
2
||
field
.
getDeType
()
==
3
)
{
if
(
field
.
getDeExtractType
()
==
0
||
field
.
getDeExtractType
()
==
5
)
{
whereName
=
String
.
format
(
MySQLConstants
.
CAST
,
originName
,
MySQLConstants
.
DEFAULT_FLOAT_FORMAT
);
}
if
(
field
.
getDeExtractType
()
==
1
)
{
whereName
=
String
.
format
(
MySQLConstants
.
UNIX_TIMESTAMP
,
originName
);
}
if
(
field
.
getDeExtractType
()
==
2
||
field
.
getDeExtractType
()
==
3
||
field
.
getDeExtractType
()
==
4
)
{
whereName
=
originName
;
}
}
else
{
whereName
=
originName
;
}
}
else
{
whereName
=
originName
;
whereNameList
.
add
(
whereName
);
}
String
whereName
=
""
;
if
(
request
.
getIsTree
())
{
whereName
=
"CONCAT("
+
StringUtils
.
join
(
whereNameList
,
",',',"
)
+
")"
;
}
else
{
whereName
=
whereNameList
.
get
(
0
);
}
String
whereTerm
=
transMysqlFilterTerm
(
request
.
getOperator
());
String
whereValue
=
""
;
if
(
StringUtils
.
containsIgnoreCase
(
request
.
getOperator
(),
"in"
))
{
whereValue
=
"('"
+
StringUtils
.
join
(
value
,
"','"
)
+
"')"
;
...
...
backend/src/main/java/io/dataease/service/chart/ChartViewService.java
浏览文件 @
83081b94
...
...
@@ -542,8 +542,10 @@ public class ChartViewService {
if
(
ObjectUtils
.
isEmpty
(
view
))
{
throw
new
RuntimeException
(
Translator
.
get
(
"i18n_chart_delete"
));
}
Type
tokenType
=
new
TypeToken
<
List
<
ChartViewFieldDTO
>>()
{}.
getType
();
Type
filterTokenType
=
new
TypeToken
<
List
<
ChartFieldCustomFilterDTO
>>()
{}.
getType
();
Type
tokenType
=
new
TypeToken
<
List
<
ChartViewFieldDTO
>>()
{
}.
getType
();
Type
filterTokenType
=
new
TypeToken
<
List
<
ChartFieldCustomFilterDTO
>>()
{
}.
getType
();
List
<
ChartViewFieldDTO
>
viewFields
=
gson
.
fromJson
(
view
.
getViewFields
(),
tokenType
);
Map
<
String
,
List
<
ChartViewFieldDTO
>>
extFieldsMap
=
null
;
...
...
@@ -640,24 +642,50 @@ public class ChartViewService {
String
fieldId
=
request
.
getFieldId
();
if
(
StringUtils
.
isNotEmpty
(
fieldId
))
{
String
[]
fieldIds
=
fieldId
.
split
(
","
);
for
(
String
fId
:
fieldIds
)
{
if
(
request
.
getIsTree
()
)
{
ChartExtFilterRequest
filterRequest
=
new
ChartExtFilterRequest
();
BeanUtils
.
copyBean
(
filterRequest
,
request
);
filterRequest
.
setFieldId
(
fId
);
DatasetTableField
datasetTableField
=
dataSetTableFieldsService
.
get
(
fId
);
if
(
datasetTableField
==
null
)
{
continue
;
filterRequest
.
setDatasetTableFieldList
(
new
ArrayList
<>());
for
(
String
fId
:
fieldIds
)
{
DatasetTableField
datasetTableField
=
dataSetTableFieldsService
.
get
(
fId
);
if
(
datasetTableField
==
null
)
{
continue
;
}
if
(!
desensitizationList
.
contains
(
datasetTableField
.
getDataeaseName
())
&&
dataeaseNames
.
contains
(
datasetTableField
.
getDataeaseName
()))
{
if
(
StringUtils
.
equalsIgnoreCase
(
datasetTableField
.
getTableId
(),
view
.
getTableId
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
filterRequest
.
getViewIds
()))
{
if
(
filterRequest
.
getViewIds
().
contains
(
view
.
getId
()))
{
filterRequest
.
getDatasetTableFieldList
().
add
(
datasetTableField
);
}
}
else
{
filterRequest
.
getDatasetTableFieldList
().
add
(
datasetTableField
);
}
}
}
}
if
(!
desensitizationList
.
contains
(
datasetTableField
.
getDataeaseName
())
&&
dataeaseNames
.
contains
(
datasetTableField
.
getDataeaseName
()))
{
filterRequest
.
setDatasetTableField
(
datasetTableField
);
if
(
StringUtils
.
equalsIgnoreCase
(
datasetTableField
.
getTableId
(),
view
.
getTableId
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
filterRequest
.
getViewIds
()))
{
if
(
filterRequest
.
getViewIds
().
contains
(
view
.
getId
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
filterRequest
.
getDatasetTableFieldList
()))
{
extFilterList
.
add
(
filterRequest
);
}
}
else
{
for
(
String
fId
:
fieldIds
)
{
ChartExtFilterRequest
filterRequest
=
new
ChartExtFilterRequest
();
BeanUtils
.
copyBean
(
filterRequest
,
request
);
filterRequest
.
setFieldId
(
fId
);
DatasetTableField
datasetTableField
=
dataSetTableFieldsService
.
get
(
fId
);
if
(
datasetTableField
==
null
)
{
continue
;
}
if
(!
desensitizationList
.
contains
(
datasetTableField
.
getDataeaseName
())
&&
dataeaseNames
.
contains
(
datasetTableField
.
getDataeaseName
()))
{
filterRequest
.
setDatasetTableField
(
datasetTableField
);
if
(
StringUtils
.
equalsIgnoreCase
(
datasetTableField
.
getTableId
(),
view
.
getTableId
()))
{
if
(
CollectionUtils
.
isNotEmpty
(
filterRequest
.
getViewIds
()))
{
if
(
filterRequest
.
getViewIds
().
contains
(
view
.
getId
()))
{
extFilterList
.
add
(
filterRequest
);
}
}
else
{
extFilterList
.
add
(
filterRequest
);
}
}
else
{
extFilterList
.
add
(
filterRequest
);
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论