Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
I
ibzdst
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
ibiz4jteam
ibzdst
提交
592eac2e
提交
592eac2e
编写于
7月 24, 2023
作者:
hebao@lab.ibiz5.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cql数据支持删除无效result数据
上级
9616956e
变更
1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
56 行增加
和
47 行删除
+56
-47
ExecResultRepository.java
.../cn/ibizlab/core/extensions/cql/ExecResultRepository.java
+56
-47
未找到文件。
ibzdst-core/src/main/java/cn/ibizlab/core/extensions/cql/ExecResultRepository.java
浏览文件 @
592eac2e
...
...
@@ -36,6 +36,9 @@ public class ExecResultRepository {
@Value
(
"${ibiz.filterResultsData:false}"
)
private
boolean
filterResultsData
;
@Value
(
"${ibiz.deleteInvalidResultData:false}"
)
private
boolean
deleteInvalidResultData
;
public
ExecResultRepository
(
MappingManager
mappingManager
)
{
createTable
(
mappingManager
.
getSession
());
...
...
@@ -110,22 +113,26 @@ public class ExecResultRepository {
this
.
saveResultsMQMsg2
(
resultsMQMsg
);
return
;
}
final
ResultSet
result
=
session
.
execute
(
select
().
all
().
from
(
TABLE2
).
where
(
in
(
"ruleid"
,
resultsMQMsg
.
getRules
())).
and
(
eq
(
"keyvaluefield"
,
resultsMQMsg
.
getKeyValueField
())));
List
<
ExecResult2
>
list
=
mapper2
.
map
(
result
).
all
();
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
){}
if
(
deleteInvalidResultData
)
{
final
ResultSet
result
=
session
.
execute
(
select
().
all
().
from
(
TABLE2
).
where
(
in
(
"ruleid"
,
resultsMQMsg
.
getRules
())).
and
(
eq
(
"keyvaluefield"
,
resultsMQMsg
.
getKeyValueField
())));
List
<
ExecResult2
>
list
=
mapper2
.
map
(
result
).
all
();
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
)
{
}
}
}
List
<
ExecResult
>
results
=
resultsMQMsg
.
getDatas
();
if
(
results
!=
null
&&
results
.
size
()
>
0
){
...
...
@@ -138,47 +145,49 @@ public class ExecResultRepository {
public
void
saveResultsMQMsg2
(
ResultsMQMsg
resultsMQMsg
){
log
.
info
(
"--saveResultsMQMsg2--"
);
try
{
final
ResultSet
result
=
session
.
execute
(
select
().
all
().
from
(
TABLE2
).
where
(
in
(
"ruleid"
,
resultsMQMsg
.
getRules
())).
and
(
eq
(
"keyvaluefield"
,
resultsMQMsg
.
getKeyValueField
())));
List
<
ExecResult2
>
list
=
mapper2
.
map
(
result
).
all
();
List
<
ExecResult
>
results
=
resultsMQMsg
.
getDatas
();
//过滤需要删除的对象
if
(
results
!=
null
&&
results
.
size
()
>
0
)
{
for
(
ExecResult
result1
:
results
)
{
for
(
ExecResult2
result2
:
list
)
{
if
(
result2
.
getRuleid
().
equals
(
result1
.
getRuleid
())
&&
result2
.
getDimfield
().
equals
(
result1
.
getDimfield
())
&&
result2
.
getDomainsfield
().
equals
(
result1
.
getDomainsfield
())
&&
result2
.
getKeyvaluefield
().
equals
(
result1
.
getKeyvaluefield
())
&&
result2
.
getTimefield
().
equals
(
result1
.
getTimefield
()))
{
list
.
remove
(
result2
);
break
;
if
(
deleteInvalidResultData
)
{
final
ResultSet
result
=
session
.
execute
(
select
().
all
().
from
(
TABLE2
).
where
(
in
(
"ruleid"
,
resultsMQMsg
.
getRules
())).
and
(
eq
(
"keyvaluefield"
,
resultsMQMsg
.
getKeyValueField
())));
List
<
ExecResult2
>
list
=
mapper2
.
map
(
result
).
all
();
//过滤需要删除的对象
if
(
results
!=
null
&&
results
.
size
()
>
0
)
{
for
(
ExecResult
result1
:
results
)
{
for
(
ExecResult2
result2
:
list
)
{
if
(
result2
.
getRuleid
().
equals
(
result1
.
getRuleid
())
&&
result2
.
getDimfield
().
equals
(
result1
.
getDimfield
())
&&
result2
.
getDomainsfield
().
equals
(
result1
.
getDomainsfield
())
&&
result2
.
getKeyvaluefield
().
equals
(
result1
.
getKeyvaluefield
())
&&
result2
.
getTimefield
().
equals
(
result1
.
getTimefield
()))
{
list
.
remove
(
result2
);
break
;
}
}
}
}
}
//删除数据
PreparedStatement
ps
=
this
.
getDeleteStatement
();
PreparedStatement
ps2
=
this
.
getDeleteStatement2
();
BatchStatement
deleteBatch
=
new
BatchStatement
();
deleteBatch
.
setConsistencyLevel
(
ConsistencyLevel
.
ANY
);
// 设置一致性
BatchStatement
deleteBatch2
=
new
BatchStatement
();
deleteBatch2
.
setConsistencyLevel
(
ConsistencyLevel
.
ANY
);
// 设置一致性
for
(
ExecResult2
result2
:
list
)
{
BoundStatement
bs
=
ps
.
bind
(
result2
.
getRuleid
(),
1
,
result2
.
getDimfield
(),
result2
.
getTimefield
(),
result2
.
getDomainsfield
(),
result2
.
getKeyvaluefield
());
BoundStatement
bs2
=
ps2
.
bind
(
result2
.
getRuleid
(),
result2
.
getKeyvaluefield
(),
result2
.
getDimfield
(),
result2
.
getDomainsfield
(),
result2
.
getTimefield
());
deleteBatch
.
add
(
bs
);
deleteBatch2
.
add
(
bs2
);
if
(
deleteBatch
.
size
()
>
batchSize
)
{
//删除数据
PreparedStatement
ps
=
this
.
getDeleteStatement
();
PreparedStatement
ps2
=
this
.
getDeleteStatement2
();
BatchStatement
deleteBatch
=
new
BatchStatement
();
deleteBatch
.
setConsistencyLevel
(
ConsistencyLevel
.
ANY
);
// 设置一致性
BatchStatement
deleteBatch2
=
new
BatchStatement
();
deleteBatch2
.
setConsistencyLevel
(
ConsistencyLevel
.
ANY
);
// 设置一致性
for
(
ExecResult2
result2
:
list
)
{
BoundStatement
bs
=
ps
.
bind
(
result2
.
getRuleid
(),
1
,
result2
.
getDimfield
(),
result2
.
getTimefield
(),
result2
.
getDomainsfield
(),
result2
.
getKeyvaluefield
());
BoundStatement
bs2
=
ps2
.
bind
(
result2
.
getRuleid
(),
result2
.
getKeyvaluefield
(),
result2
.
getDimfield
(),
result2
.
getDomainsfield
(),
result2
.
getTimefield
());
deleteBatch
.
add
(
bs
);
deleteBatch2
.
add
(
bs2
);
if
(
deleteBatch
.
size
()
>
batchSize
)
{
session
.
execute
(
deleteBatch
);
deleteBatch
.
clear
();
session
.
execute
(
deleteBatch2
);
deleteBatch2
.
clear
();
}
}
if
(
deleteBatch
.
size
()
>
0
)
{
session
.
execute
(
deleteBatch
);
deleteBatch
.
clear
();
session
.
execute
(
deleteBatch2
);
deleteBatch2
.
clear
();
}
}
if
(
deleteBatch
.
size
()
>
0
)
{
session
.
execute
(
deleteBatch
);
deleteBatch
.
clear
();
session
.
execute
(
deleteBatch2
);
deleteBatch2
.
clear
();
}
//保存数据
for
(
ExecResult
execResult
:
results
)
{
save
(
execResult
);
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录