Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdst
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdst
提交
f52fe928
提交
f52fe928
编写于
1月 22, 2024
作者:
xuhui961310148
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update:临时解决高检信访报表数据量大,查询一年等报表数据查询报错问题。
上级
33df7395
变更
1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
119 行增加
和
0 行删除
+119
-0
ExecResultRepository.java
.../cn/ibizlab/core/extensions/cql/ExecResultRepository.java
+119
-0
未找到文件。
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/cql/ExecResultRepository.java
浏览文件 @
f52fe928
...
...
@@ -11,6 +11,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import
org.springframework.stereotype.Repository
;
import
java.sql.Timestamp
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.UUID
;
...
...
@@ -42,6 +43,11 @@ public class ExecResultRepository {
@Value
(
"${ibiz.saveAsyncResultData:false}"
)
private
boolean
saveAsync
;
@Value
(
"${ibiz.splitRule:false}"
)
private
boolean
splitRule
;
@Value
(
"${ibiz.splitRuleSize:10}"
)
private
int
splitRuleSize
;
public
ExecResultRepository
(
MappingManager
mappingManager
)
{
createTable
(
mappingManager
.
getSession
());
...
...
@@ -212,6 +218,24 @@ public class ExecResultRepository {
public
List
<
ExecResult
>
sum
(
Collection
<
String
>
ruleids
,
Integer
retValue
,
List
<
String
>
dims
,
Timestamp
start
,
Timestamp
end
)
{
LocalDate
st
=
ExecResult
.
time2LocalDate
(
start
);
LocalDate
ed
=
ExecResult
.
time2LocalDate
(
end
);
if
(
splitRule
){
log
.
info
(
"sum规则切分查询"
);
List
<
String
>
list
=
new
ArrayList
<>(
ruleids
);
List
<
List
<
String
>>
lists
=
this
.
splitList
(
list
,
splitRuleSize
);
if
(
lists
.
size
()
>
0
){
List
<
ExecResult
>
execResults
=
new
ArrayList
<>();
for
(
List
<
String
>
ruleidList
:
lists
)
{
ResultSet
result
=
session
.
execute
(
select
().
column
(
"ruleid"
).
column
(
"retvalue"
).
column
(
"dimfield"
).
sum
(
"metricfield"
).
as
(
"metricfield"
).
from
(
TABLE
).
where
(
in
(
"ruleid"
,
ruleidList
)).
and
(
eq
(
"retvalue"
,
retValue
)).
and
(
in
(
"dimfield"
,
dims
)).
and
(
gte
(
"timefield"
,
st
)).
and
(
lte
(
"timefield"
,
ed
)).
groupBy
(
"ruleid"
,
"retvalue"
,
"dimfield"
).
limit
(
5000
).
setReadTimeoutMillis
(
200000
));
execResults
.
addAll
(
mapper
.
map
(
result
).
all
());
}
return
execResults
;
}
}
final
ResultSet
result
=
session
.
execute
(
select
().
column
(
"ruleid"
).
column
(
"retvalue"
).
column
(
"dimfield"
).
sum
(
"metricfield"
).
as
(
"metricfield"
).
from
(
TABLE
).
where
(
in
(
"ruleid"
,
ruleids
)).
...
...
@@ -234,6 +258,24 @@ public class ExecResultRepository {
public
List
<
ExecResult
>
sum
(
Collection
<
String
>
ruleids
,
Integer
retValue
,
List
<
String
>
dims
,
Timestamp
start
,
Timestamp
end
,
String
ext_1field
)
{
LocalDate
st
=
ExecResult
.
time2LocalDate
(
start
);
LocalDate
ed
=
ExecResult
.
time2LocalDate
(
end
);
if
(
splitRule
){
log
.
info
(
"sum-ext_1field规则切分查询"
);
List
<
String
>
list
=
new
ArrayList
<>(
ruleids
);
List
<
List
<
String
>>
lists
=
this
.
splitList
(
list
,
splitRuleSize
);
if
(
lists
.
size
()
>
0
){
List
<
ExecResult
>
execResults
=
new
ArrayList
<>();
for
(
List
<
String
>
ruleidList
:
lists
)
{
ResultSet
result
=
session
.
execute
(
select
().
column
(
"ruleid"
).
column
(
"retvalue"
).
column
(
"dimfield"
).
sum
(
"metricfield"
).
as
(
"metricfield"
).
from
(
TABLE
).
where
(
in
(
"ruleid"
,
ruleidList
)).
and
(
eq
(
"retvalue"
,
retValue
)).
and
(
in
(
"dimfield"
,
dims
)).
and
(
gte
(
"timefield"
,
st
)).
and
(
lte
(
"timefield"
,
ed
)).
and
(
eq
(
"ext_1field"
,
ext_1field
)).
groupBy
(
"ruleid"
,
"retvalue"
,
"dimfield"
).
allowFiltering
().
limit
(
5000
).
setReadTimeoutMillis
(
200000
));
execResults
.
addAll
(
mapper
.
map
(
result
).
all
());
}
return
execResults
;
}
}
final
ResultSet
result
=
session
.
execute
(
select
().
column
(
"ruleid"
).
column
(
"retvalue"
).
column
(
"dimfield"
).
sum
(
"metricfield"
).
as
(
"metricfield"
).
from
(
TABLE
).
where
(
in
(
"ruleid"
,
ruleids
)).
...
...
@@ -246,6 +288,24 @@ public class ExecResultRepository {
public
List
<
ExecResult
>
avg
(
Collection
<
String
>
ruleids
,
Integer
retValue
,
List
<
String
>
dims
,
Timestamp
start
,
Timestamp
end
)
{
LocalDate
st
=
ExecResult
.
time2LocalDate
(
start
);
LocalDate
ed
=
ExecResult
.
time2LocalDate
(
end
);
if
(
splitRule
){
log
.
info
(
"avg规则切分查询"
);
List
<
String
>
list
=
new
ArrayList
<>(
ruleids
);
List
<
List
<
String
>>
lists
=
this
.
splitList
(
list
,
splitRuleSize
);
if
(
lists
.
size
()
>
0
){
List
<
ExecResult
>
execResults
=
new
ArrayList
<>();
for
(
List
<
String
>
ruleidList
:
lists
)
{
ResultSet
result
=
session
.
execute
(
select
().
column
(
"ruleid"
).
column
(
"retvalue"
).
column
(
"dimfield"
).
avg
(
"metricfield"
).
as
(
"metricfield"
).
from
(
TABLE
).
where
(
in
(
"ruleid"
,
ruleidList
)).
and
(
eq
(
"retvalue"
,
retValue
)).
and
(
in
(
"dimfield"
,
dims
)).
and
(
gte
(
"timefield"
,
st
)).
and
(
lte
(
"timefield"
,
ed
)).
groupBy
(
"ruleid"
,
"retvalue"
,
"dimfield"
).
limit
(
5000
).
setReadTimeoutMillis
(
200000
));
execResults
.
addAll
(
mapper
.
map
(
result
).
all
());
}
return
execResults
;
}
}
final
ResultSet
result
=
session
.
execute
(
select
().
column
(
"ruleid"
).
column
(
"retvalue"
).
column
(
"dimfield"
).
avg
(
"metricfield"
).
as
(
"metricfield"
).
from
(
TABLE
).
where
(
in
(
"ruleid"
,
ruleids
)).
...
...
@@ -268,6 +328,24 @@ public class ExecResultRepository {
public
List
<
ExecResult
>
avg
(
Collection
<
String
>
ruleids
,
Integer
retValue
,
List
<
String
>
dims
,
Timestamp
start
,
Timestamp
end
,
String
ext_1field
)
{
LocalDate
st
=
ExecResult
.
time2LocalDate
(
start
);
LocalDate
ed
=
ExecResult
.
time2LocalDate
(
end
);
if
(
splitRule
){
log
.
info
(
"avg--ext_1field规则切分查询"
);
List
<
String
>
list
=
new
ArrayList
<>(
ruleids
);
List
<
List
<
String
>>
lists
=
this
.
splitList
(
list
,
splitRuleSize
);
if
(
lists
.
size
()
>
0
){
List
<
ExecResult
>
execResults
=
new
ArrayList
<>();
for
(
List
<
String
>
ruleidList
:
lists
)
{
ResultSet
result
=
session
.
execute
(
select
().
column
(
"ruleid"
).
column
(
"retvalue"
).
column
(
"dimfield"
).
avg
(
"metricfield"
).
as
(
"metricfield"
).
from
(
TABLE
).
where
(
in
(
"ruleid"
,
ruleidList
)).
and
(
eq
(
"retvalue"
,
retValue
)).
and
(
in
(
"dimfield"
,
dims
)).
and
(
gte
(
"timefield"
,
st
)).
and
(
lte
(
"timefield"
,
ed
)).
and
(
eq
(
"ext_1field"
,
ext_1field
)).
groupBy
(
"ruleid"
,
"retvalue"
,
"dimfield"
).
allowFiltering
().
limit
(
5000
).
setReadTimeoutMillis
(
200000
));
execResults
.
addAll
(
mapper
.
map
(
result
).
all
());
}
return
execResults
;
}
}
final
ResultSet
result
=
session
.
execute
(
select
().
column
(
"ruleid"
).
column
(
"retvalue"
).
column
(
"dimfield"
).
avg
(
"metricfield"
).
as
(
"metricfield"
).
from
(
TABLE
).
where
(
in
(
"ruleid"
,
ruleids
)).
...
...
@@ -388,6 +466,23 @@ public class ExecResultRepository {
public
List
<
ExecResult
>
sumPerformancePiece
(
List
<
String
>
ruleids
,
Integer
retValue
,
List
<
String
>
dims
,
Timestamp
start
,
Timestamp
end
)
{
LocalDate
st
=
ExecResult
.
time2LocalDate
(
start
);
LocalDate
ed
=
ExecResult
.
time2LocalDate
(
end
);
if
(
splitRule
){
log
.
info
(
"sumPerformancePiece规则切分查询"
);
List
<
List
<
String
>>
lists
=
this
.
splitList
(
ruleids
,
splitRuleSize
);
if
(
lists
.
size
()
>
0
){
List
<
ExecResult
>
execResults
=
new
ArrayList
<>();
for
(
List
<
String
>
ruleidList
:
lists
)
{
ResultSet
result
=
session
.
execute
(
select
().
column
(
"dimfield"
).
column
(
"keyvaluefield"
).
from
(
TABLE
).
where
(
in
(
"ruleid"
,
ruleidList
)).
and
(
eq
(
"retvalue"
,
retValue
)).
and
(
in
(
"dimfield"
,
dims
)).
and
(
gte
(
"timefield"
,
st
)).
and
(
lte
(
"timefield"
,
ed
)).
limit
(
5000
).
setReadTimeoutMillis
(
200000
));
execResults
.
addAll
(
mapper
.
map
(
result
).
all
());
}
return
execResults
;
}
}
final
ResultSet
result
=
session
.
execute
(
select
().
column
(
"dimfield"
).
column
(
"keyvaluefield"
).
from
(
TABLE
).
where
(
in
(
"ruleid"
,
ruleids
)).
...
...
@@ -459,4 +554,28 @@ public class ExecResultRepository {
session
.
execute
(
delete
().
all
().
from
(
TABLE
).
where
(
in
(
"ruleid"
,
ruleids
)).
and
(
eq
(
"retvalue"
,
1
)));
}
public
static
<
T
>
List
<
List
<
T
>>
splitList
(
List
<
T
>
list
,
int
count
){
List
<
List
<
T
>>
lists
=
new
ArrayList
<
List
<
T
>>();
// 结果集
int
listSize
=
list
.
size
();
// 原集合长度
int
listCount
=
listSize
/
count
;
// 可直接拆分集合数量
// 按量拆分
for
(
int
i
=
0
;
i
<
listCount
;
i
++)
{
List
<
T
>
sub2
=
new
ArrayList
<>();
for
(
int
j
=
i
*
count
;
j
<(
i
+
1
)
*
count
;
j
++)
sub2
.
add
(
list
.
get
(
j
));
lists
.
add
(
sub2
);
}
// 如果按量拆分后还有剩余, 收尾
int
remainder
=
listSize
%
count
;
if
(
remainder
>
0
)
{
List
<
T
>
sub2
=
new
ArrayList
<>();
for
(
int
j
=
listSize
-
remainder
;
j
<
listSize
;
j
++)
sub2
.
add
(
list
.
get
(
j
));
lists
.
add
(
sub2
);
}
return
lists
;
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录