Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdst
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdst
提交
a4344e8d
提交
a4344e8d
编写于
12月 20, 2022
作者:
xuhui961310148
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add:支持删除cql数据库构建结果
上级
dfb9fab1
变更
2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
148 行增加
和
0 行删除
+148
-0
ExecResultRepository.java
.../cn/ibizlab/core/extensions/cql/ExecResultRepository.java
+45
-0
DACoreResource.java
...n/java/cn/ibizlab/api/rest/extensions/DACoreResource.java
+103
-0
未找到文件。
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/cql/ExecResultRepository.java
浏览文件 @
a4344e8d
...
@@ -419,4 +419,49 @@ public class ExecResultRepository {
...
@@ -419,4 +419,49 @@ public class ExecResultRepository {
return
insertStatement2
;
return
insertStatement2
;
}
}
/**
* 根据指标标识,业务数据主键,删除cql结果数据
* @param ruleids
* @param keyvaluefield
* @return
*/
public
void
deleteData
(
List
<
String
>
ruleids
,
String
keyvaluefield
){
final
ResultSet
result
=
session
.
execute
(
select
().
all
().
from
(
TABLE2
).
where
(
in
(
"ruleid"
,
ruleids
)).
and
(
eq
(
"keyvaluefield"
,
keyvaluefield
)));
List
<
ExecResult2
>
list
=
mapper2
.
map
(
result
).
all
();
if
(
list
.
size
()
>
0
){
doDelete
(
list
);
}
}
/**
* 删除数据
* @param list
*/
private
void
doDelete
(
List
<
ExecResult2
>
list
){
for
(
ExecResult2
execResult2
:
list
)
{
ExecResult
execResult
=
new
ExecResult
();
execResult
.
setRuleid
(
execResult2
.
getRuleid
());
execResult
.
setRetvalue
(
1
);
execResult
.
setDimfield
(
execResult2
.
getDimfield
());
execResult
.
setTimefield
(
execResult2
.
getTimefield
());
execResult
.
setDomainsfield
(
execResult2
.
getDomainsfield
());
execResult
.
setKeyvaluefield
(
execResult2
.
getKeyvaluefield
());
try
{
mapper
.
delete
(
execResult
);
}
catch
(
Exception
ex
){}
try
{
mapper2
.
delete
(
execResult2
);
}
catch
(
Exception
ex
){}
}
}
/**
* 根据指标标识,删除结果数据
* @param ruleids
* @return
*/
public
void
deleteData
(
List
<
String
>
ruleids
){
session
.
execute
(
delete
().
all
().
from
(
TABLE
).
where
(
in
(
"ruleid"
,
ruleids
)).
and
(
eq
(
"retvalue"
,
1
)));
}
}
}
ibzdst-provider/ibzdst-provider-api/src/main/java/cn/ibizlab/api/rest/extensions/DACoreResource.java
浏览文件 @
a4344e8d
package
cn
.
ibizlab
.
api
.
rest
.
extensions
;
package
cn
.
ibizlab
.
api
.
rest
.
extensions
;
import
cn.ibizlab.core.analysis.domain.DAMetric
;
import
cn.ibizlab.core.analysis.domain.DAReport
;
import
cn.ibizlab.core.analysis.domain.DAReport
;
import
cn.ibizlab.core.analysis.service.impl.DAReportServiceImpl
;
import
cn.ibizlab.core.analysis.service.impl.DAReportServiceImpl
;
import
cn.ibizlab.core.extensions.cql.ExecResult
;
import
cn.ibizlab.core.extensions.cql.ExecResultRepository
;
import
cn.ibizlab.core.extensions.domain.FetchMetricDatasParam
;
import
cn.ibizlab.core.extensions.domain.FetchMetricDatasParam
;
import
cn.ibizlab.core.extensions.service.DACoreService
;
import
cn.ibizlab.core.extensions.service.DACoreService
;
import
cn.ibizlab.core.extensions.service.DAMetricExService
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.errors.BadRequestAlertException
;
import
cn.ibizlab.util.helper.DataObject
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.toolkit.Wrappers
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Lazy
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -34,6 +42,16 @@ public class DACoreResource {
...
@@ -34,6 +42,16 @@ public class DACoreResource {
@Autowired
@Autowired
private
DAReportServiceImpl
daReportService
;
private
DAReportServiceImpl
daReportService
;
@Autowired
@Lazy
private
ExecResultRepository
execResultRepository
;
@Autowired
@Lazy
private
DAMetricExService
daMetricExService
;
// 删除cql结果批次大小
@Value
(
"${ibiz.execresult.deletesize: 20}"
)
private
int
deletesize
;
/**
/**
* 通过指标获取相应的规则结果数据
* 通过指标获取相应的规则结果数据
* @param param
* @param param
...
@@ -159,4 +177,89 @@ public class DACoreResource {
...
@@ -159,4 +177,89 @@ public class DACoreResource {
this
.
fetchReportDatas
(
param
);
this
.
fetchReportDatas
(
param
);
return
resultMap
;
return
resultMap
;
}
}
/**
* 删除cql库中结果数据
* @param param
* @return
*/
@PostMapping
(
value
=
"/dst/analyse/reportdata/deleteexecresult"
)
public
ResponseEntity
<
JSONObject
>
deleteRuleResultData
(
@RequestBody
JSONObject
param
){
long
t1
=
DataObject
.
getNow
().
getTime
();
JSONObject
jsonObject
=
new
JSONObject
();
try
{
String
type
=
param
.
getString
(
"type"
);
if
(
StringUtils
.
isEmpty
(
type
)){
jsonObject
.
put
(
"success"
,
false
);
jsonObject
.
put
(
"message"
,
"未指定清除类型!"
);
return
ResponseEntity
.
ok
().
body
(
jsonObject
);
}
JSONArray
list
=
param
.
getJSONArray
(
"list"
);
if
(
"datakey"
.
equalsIgnoreCase
(
type
)){
JSONArray
buildArray
=
param
.
getJSONArray
(
"build"
);
if
(
StringUtils
.
isEmpty
(
list
)
||
list
.
size
()
==
0
||
StringUtils
.
isEmpty
(
buildArray
)
||
buildArray
.
size
()
==
0
){
jsonObject
.
put
(
"success"
,
false
);
jsonObject
.
put
(
"message"
,
"业务数据主键集合或者构建主键集合为空!"
);
return
ResponseEntity
.
ok
().
body
(
jsonObject
);
}
// 获取所有构建分析数据对应的指标标识
List
<
String
>
ruleids
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
buildArray
.
size
();
i
++)
{
List
<
DAMetric
>
daMetricList
=
daMetricExService
.
list
(
Wrappers
.<
DAMetric
>
lambdaQuery
().
eq
(
DAMetric:
:
getBuildId
,
buildArray
.
getString
(
i
)));
for
(
DAMetric
daMetric
:
daMetricList
)
{
ruleids
.
add
(
daMetric
.
getMetricId
());
}
}
if
(
ruleids
.
size
()
==
0
){
jsonObject
.
put
(
"success"
,
false
);
jsonObject
.
put
(
"message"
,
"未获取到指定构建对应的指标标识!"
);
return
ResponseEntity
.
ok
().
body
(
jsonObject
);
}
List
<
String
>
tempList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
for
(
String
rule
:
ruleids
)
{
tempList
.
add
(
rule
);
if
(
tempList
.
size
()
>=
deletesize
){
long
start
=
DataObject
.
getNow
().
getTime
();
execResultRepository
.
deleteData
(
tempList
,
list
.
getString
(
i
));
log
.
info
(
"根据指标标识:"
+
tempList
+
",业务数据主键:"
+
list
.
getString
(
i
)
+
",删除cql结果,耗时:"
+
(
DataObject
.
getNow
().
getTime
()-
start
)
+
"毫秒"
);
tempList
.
clear
();
}
}
if
(
tempList
.
size
()
>
0
){
long
start
=
DataObject
.
getNow
().
getTime
();
execResultRepository
.
deleteData
(
tempList
,
list
.
getString
(
i
));
log
.
info
(
"根据指标标识:"
+
tempList
+
",业务数据主键:"
+
list
.
getString
(
i
)
+
",删除cql结果,耗时:"
+
(
DataObject
.
getNow
().
getTime
()-
start
)
+
"毫秒"
);
tempList
.
clear
();
}
}
jsonObject
.
put
(
"success"
,
true
);
jsonObject
.
put
(
"message"
,
"清除结果数据完成!"
);
}
else
if
(
"rule"
.
equalsIgnoreCase
(
type
)){
if
(
StringUtils
.
isEmpty
(
list
)
||
list
.
size
()
==
0
){
jsonObject
.
put
(
"success"
,
false
);
jsonObject
.
put
(
"message"
,
"指标标识集合为空!"
);
return
ResponseEntity
.
ok
().
body
(
jsonObject
);
}
List
<
String
>
tempList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
list
.
size
();
i
++)
{
tempList
.
add
(
list
.
getString
(
i
));
}
long
start
=
DataObject
.
getNow
().
getTime
();
execResultRepository
.
deleteData
(
tempList
);
log
.
info
(
"根据指标标识:"
+
list
+
",删除cql结果成功,耗时:"
+
(
DataObject
.
getNow
().
getTime
()-
start
)
+
"毫秒"
);
jsonObject
.
put
(
"success"
,
true
);
jsonObject
.
put
(
"message"
,
"清除结果数据完成!"
);
}
}
catch
(
Exception
e
){
e
.
printStackTrace
();
jsonObject
.
put
(
"success"
,
false
);
jsonObject
.
put
(
"message"
,
"清除结果数据失败!原因:"
+
e
.
getMessage
());
}
String
cost
=
(
DataObject
.
getNow
().
getTime
()
-
t1
)
+
"毫秒"
;
jsonObject
.
put
(
"cost"
,
cost
);
log
.
info
(
"删除cql结果数据执行完成,耗时:"
+
cost
);
return
ResponseEntity
.
ok
().
body
(
jsonObject
);
}
}
}
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录