Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdst
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdst
提交
db56e1b7
提交
db56e1b7
编写于
4月 10, 2023
作者:
hebao@lab.ibiz5.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
报表指标类型支持COUNT_DISTINCT_EXT1(根据Ext1Field的值去重计数)
上级
38895eca
变更
4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
131 行增加
和
2 行删除
+131
-2
ExecResultExMapper.java
...cn/ibizlab/core/extensions/mapper/ExecResultExMapper.java
+1
-0
BuildResultService.java
...n/ibizlab/core/extensions/service/BuildResultService.java
+89
-2
ExecResultExService.java
.../ibizlab/core/extensions/service/ExecResultExService.java
+21
-0
ExecResultExMapper.xml
...n/resources/mapper/rule/execresult/ExecResultExMapper.xml
+20
-0
未找到文件。
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/mapper/ExecResultExMapper.java
浏览文件 @
db56e1b7
...
...
@@ -20,6 +20,7 @@ public interface ExecResultExMapper extends BaseMapper<EntityObj>{
List
<
ExecResult
>
sumResult
(
@Param
(
"resultTableName"
)
String
tableName
,
@Param
(
"ruleids"
)
List
<
String
>
ruleids
,
@Param
(
"dimfields"
)
List
<
String
>
dimfields
,
@Param
(
"domainsfields"
)
List
<
String
>
domainsfields
,
@Param
(
"from"
)
Timestamp
from
,
@Param
(
"to"
)
Timestamp
to
);
List
<
ExecResult
>
avgResult
(
@Param
(
"resultTableName"
)
String
tableName
,
@Param
(
"ruleids"
)
List
<
String
>
ruleids
,
@Param
(
"dimfields"
)
List
<
String
>
dimfields
,
@Param
(
"domainsfields"
)
List
<
String
>
domainsfields
,
@Param
(
"from"
)
Timestamp
from
,
@Param
(
"to"
)
Timestamp
to
);
List
<
ExecResult
>
countDistExt1Result
(
@Param
(
"resultTableName"
)
String
tableName
,
@Param
(
"ruleids"
)
List
<
String
>
ruleids
,
@Param
(
"dimfields"
)
List
<
String
>
dimfields
,
@Param
(
"domainsfields"
)
List
<
String
>
domainsfields
,
@Param
(
"from"
)
Timestamp
from
,
@Param
(
"to"
)
Timestamp
to
);
Page
<
ExecResult
>
lookupResult
(
IPage
page
,
@Param
(
"resultTableName"
)
String
tableName
,
@Param
(
"columns"
)
String
columns
,
@Param
(
"ruleid"
)
String
ruleid
,
@Param
(
"dimfield"
)
String
dimfield
,
@Param
(
"domainsfields"
)
List
<
String
>
domainsfields
,
@Param
(
"from"
)
Timestamp
from
,
@Param
(
"to"
)
Timestamp
to
);
...
...
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/BuildResultService.java
浏览文件 @
db56e1b7
...
...
@@ -286,7 +286,7 @@ public class BuildResultService {
{
subMetricIds
=
new
LinkedHashSet
<>();
for
(
DAMetric
item:
fetchParam
.
getMetrics
().
values
()){
if
(!
"AVG"
.
equals
(
item
.
getMetricType
()))
if
(!
"AVG"
.
equals
(
item
.
getMetricType
())
&&
!
"COUNT_DISTINCT_EXT1"
.
equals
(
item
.
getMetricType
())
)
subMetricIds
.
add
(
item
.
getMetricId
());
}
}
...
...
@@ -387,6 +387,59 @@ public class BuildResultService {
}
public
List
<
BuildResult
>
countDistExt1
(
FetchParam
fetchParam
,
Set
<
String
>
subMetricIds
,
Timestamp
start
,
Timestamp
end
)
{
List
<
BuildResult
>
ret
=
new
ArrayList
<>();
Timestamp
startTime
=(
start
==
null
)?
fetchParam
.
getStartTime
():
start
;
Timestamp
endTime
=(
end
==
null
)?
fetchParam
.
getEndTime
():
end
;
if
(
subMetricIds
==
null
)
{
subMetricIds
=
new
LinkedHashSet
<>();
for
(
DAMetric
item:
fetchParam
.
getMetrics
().
values
()){
if
(
"COUNT_DISTINCT_EXT1"
.
equals
(
item
.
getMetricType
()))
subMetricIds
.
add
(
item
.
getMetricId
());
}
}
if
(!
StringUtils
.
isEmpty
(
cassandraHost
))
{
List
<
cn
.
ibizlab
.
core
.
extensions
.
cql
.
ExecResult
>
list
=
execResultRepository
.
sum
(
subMetricIds
,
1
,
fetchParam
.
getDimValues
(),
startTime
,
endTime
);
list
.
forEach
(
item
->{
ret
.
add
(
new
BuildResult
().
setCqlResult
(
item
));
});
}
else
{
//prepareFetchParam(fetchParam);
Map
<
String
,
Set
<
String
>>
tab
=
fetchParam
.
getDimTables
();
for
(
String
key:
tab
.
keySet
()){
String
[]
args
=
key
.
split
(
"\\|"
);
String
dsName
=
args
[
0
];
String
tableName
=
args
[
1
];
Set
<
String
>
tmpSet
=
new
LinkedHashSet
<>();
for
(
String
id:
tab
.
get
(
key
))
{
if
(
subMetricIds
.
contains
(
id
))
tmpSet
.
add
(
id
);
}
if
(
tmpSet
.
size
()>
0
)
{
List
<
ExecResult
>
list
=
execResultExService
.
countDistExt1Result
(
dsName
,
tableName
,
new
ArrayList
<>(
tmpSet
),
fetchParam
.
getDimValues
(),
fetchParam
.
getDomains
(),
startTime
,
endTime
);
list
.
forEach
(
item
->{
ret
.
add
(
new
BuildResult
().
setSqlResult
(
item
));
});
}
}
}
return
ret
;
}
@Cacheable
(
value
=
"dataAnalyse"
,
key
=
"'rows:lookup:'+#p0.getId()"
)
public
LookupResult
lookup
(
FetchParam
fetchParam
)
{
prepareFetchParam
(
fetchParam
);
...
...
@@ -453,6 +506,7 @@ public class BuildResultService {
Set
<
String
>
sum
=
new
LinkedHashSet
<>();
Set
<
String
>
avg
=
new
LinkedHashSet
<
String
>();
Set
<
String
>
countDistExt1
=
new
LinkedHashSet
<
String
>();
Set
<
String
>
sum_yoy
=
new
LinkedHashSet
<>();
Set
<
String
>
sum_mom
=
new
LinkedHashSet
<>();
...
...
@@ -464,6 +518,11 @@ public class BuildResultService {
Set
<
String
>
avg_y3
=
new
LinkedHashSet
<>();
List
<
DAMetric
>
avg_per
=
new
ArrayList
<>();
Set
<
String
>
countDistExt1_yoy
=
new
LinkedHashSet
<>();
Set
<
String
>
countDistExt1_mom
=
new
LinkedHashSet
<>();
Set
<
String
>
countDistExt1_y3
=
new
LinkedHashSet
<>();
List
<
DAMetric
>
countDistExt1_per
=
new
ArrayList
<>();
for
(
DAMetric
metric:
fetchParam
.
getMetrics
().
values
())
{
...
...
@@ -479,6 +538,19 @@ public class BuildResultService {
else
if
(
"PER"
.
equals
(
metric
.
getExtOp
())
||
"PER_ORI"
.
equals
(
metric
.
getExtOp
()))
avg_per
.
add
(
metric
);
}
else
if
(
"COUNT_DISTINCT_EXT1"
.
equals
(
metric
.
getMetricType
()))
{
countDistExt1
.
add
(
metric
.
getMetricId
());
if
(
"YOY"
.
equals
(
metric
.
getExtOp
()))
countDistExt1_yoy
.
add
(
metric
.
getMetricId
());
else
if
(
"MOM"
.
equals
(
metric
.
getExtOp
()))
countDistExt1_mom
.
add
(
metric
.
getMetricId
());
else
if
(
"Y3"
.
equals
(
metric
.
getExtOp
()))
countDistExt1_y3
.
add
(
metric
.
getMetricId
());
else
if
(
"PER"
.
equals
(
metric
.
getExtOp
())
||
"PER_ORI"
.
equals
(
metric
.
getExtOp
()))
countDistExt1_per
.
add
(
metric
);
}
else
{
...
...
@@ -547,7 +619,11 @@ public class BuildResultService {
List
<
BuildResult
>
listavg
=
avg
(
fetchParam
,
avg
,
null
,
null
);
list
.
addAll
(
listavg
);
}
if
(
countDistExt1
.
size
()>
0
)
{
List
<
BuildResult
>
listcountDistExt1
=
countDistExt1
(
fetchParam
,
countDistExt1
,
null
,
null
);
list
.
addAll
(
listcountDistExt1
);
}
for
(
BuildResult
res:
list
)
{
if
(!
dimsSet
.
containsKey
(
res
.
getDimField
()))
...
...
@@ -584,6 +660,11 @@ public class BuildResultService {
List
<
BuildResult
>
listavg
=
avg
(
fetchParam
,
avg_yoy
,
FetchParam
.
getLastYear
(
fetchParam
.
getStartTime
()),
FetchParam
.
getLastYear
(
fetchParam
.
getEndTime
()));
list_yoy
.
addAll
(
listavg
);
}
if
(
countDistExt1_yoy
.
size
()>
0
)
{
List
<
BuildResult
>
temp
=
countDistExt1
(
fetchParam
,
countDistExt1_yoy
,
FetchParam
.
getLastYear
(
fetchParam
.
getStartTime
()),
FetchParam
.
getLastYear
(
fetchParam
.
getEndTime
()));
list_yoy
.
addAll
(
temp
);
}
for
(
BuildResult
res:
list_yoy
)
{
...
...
@@ -659,6 +740,11 @@ public class BuildResultService {
List
<
BuildResult
>
listavg
=
avg
(
fetchParam
,
avg_mom
,
FetchParam
.
getLastMonth
(
fetchParam
.
getStartTime
()),
FetchParam
.
getLastMonth
(
fetchParam
.
getEndTime
()));
list_mom
.
addAll
(
listavg
);
}
if
(
countDistExt1_mom
.
size
()>
0
)
{
List
<
BuildResult
>
temp
=
countDistExt1
(
fetchParam
,
countDistExt1_mom
,
FetchParam
.
getLastMonth
(
fetchParam
.
getStartTime
()),
FetchParam
.
getLastMonth
(
fetchParam
.
getEndTime
()));
list_mom
.
addAll
(
temp
);
}
for
(
BuildResult
res:
list_mom
)
{
...
...
@@ -723,6 +809,7 @@ public class BuildResultService {
//占比
sum_per
.
addAll
(
avg_per
);
sum_per
.
addAll
(
countDistExt1_per
);
for
(
DAMetric
res:
sum_per
)
{
...
...
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/service/ExecResultExService.java
浏览文件 @
db56e1b7
...
...
@@ -326,6 +326,27 @@ public class ExecResultExService extends ExecResultServiceImpl {
return
result
;
}
public
List
<
ExecResult
>
countDistExt1Result
(
String
dsName
,
String
tableName
,
List
<
String
>
ruleids
,
List
<
String
>
dimfields
,
List
<
String
>
domainsfields
,
Timestamp
from
,
Timestamp
to
)
{
List
<
ExecResult
>
result
=
null
;
try
{
if
(!
Default_ResultDataSource
.
equalsIgnoreCase
(
dsName
)){
dstDataSourceService
.
initDataSource
(
dsName
);
DynamicDataSourceContextHolder
.
push
(
dsName
);
}
result
=
execResultExMapper
.
countDistExt1Result
(
tableName
,
ruleids
,
dimfields
,
domainsfields
,
from
,
to
);
}
catch
(
Exception
ex
)
{
result
=
new
ArrayList
<>();
log
.
error
(
"存储规则结果发生异常,详细错误信息:"
+
ex
.
getMessage
());
}
finally
{
if
(!
Default_ResultDataSource
.
equalsIgnoreCase
(
dsName
))
{
DynamicDataSourceContextHolder
.
poll
();
}
}
return
result
;
}
public
Page
<
ExecResult
>
lookupResult
(
int
current
,
int
size
,
String
dsName
,
String
tableName
,
String
columns
,
String
ruleid
,
String
dimfield
,
List
<
String
>
domainsfields
,
Timestamp
from
,
Timestamp
to
)
{
if
(
StringUtils
.
isEmpty
(
columns
))
columns
=
"*"
;
...
...
ibzdst-core/src/main/resources/mapper/rule/execresult/ExecResultExMapper.xml
浏览文件 @
db56e1b7
...
...
@@ -154,6 +154,26 @@
</select>
<select
id=
"countDistExt1Result"
resultType=
"cn.ibizlab.core.rule.domain.ExecResult"
>
select ruleid, 1 as retvalue,dimfield,count(distinct(ext1field)) as metricfield from ${resultTableName} where ruleid in
<foreach
item=
"id"
index=
"index"
collection=
"ruleids"
open=
"("
separator=
","
close=
")"
>
#{id}
</foreach>
and RETVALUE=1 and DIMFIELD in
<foreach
item=
"id"
index=
"index"
collection=
"dimfields"
open=
"("
separator=
","
close=
")"
>
#{id}
</foreach>
<choose><when
test=
"domainsfields != null"
>
and DOMAINSFIELD in
<foreach
item=
"id"
index=
"index"
collection=
"domainsfields"
open=
"("
separator=
","
close=
")"
>
#{id}
</foreach>
</when></choose>
and TIMEFIELD
<![CDATA[ >= ]]>
#{from} and TIMEFIELD
<![CDATA[ <= ]]>
#{to}
group by ruleid,dimfield
</select>
<select
id=
"lookupResult"
resultType=
"cn.ibizlab.core.rule.domain.ExecResult"
>
select ${columns} from ${resultTableName} where ruleid = #{ruleid}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录