提交 592eac2e 编写于 作者: hebao@lab.ibiz5.com's avatar hebao@lab.ibiz5.com

cql数据支持删除无效result数据

上级 9616956e
...@@ -36,6 +36,9 @@ public class ExecResultRepository { ...@@ -36,6 +36,9 @@ public class ExecResultRepository {
@Value("${ibiz.filterResultsData:false}") @Value("${ibiz.filterResultsData:false}")
private boolean filterResultsData; private boolean filterResultsData;
@Value("${ibiz.deleteInvalidResultData:false}")
private boolean deleteInvalidResultData;
public ExecResultRepository(MappingManager mappingManager) { public ExecResultRepository(MappingManager mappingManager) {
createTable(mappingManager.getSession()); createTable(mappingManager.getSession());
...@@ -110,22 +113,26 @@ public class ExecResultRepository { ...@@ -110,22 +113,26 @@ public class ExecResultRepository {
this.saveResultsMQMsg2(resultsMQMsg); this.saveResultsMQMsg2(resultsMQMsg);
return; return;
} }
final ResultSet result = session.execute(select().all().from(TABLE2).where(in("ruleid",resultsMQMsg.getRules())).and(eq("keyvaluefield",resultsMQMsg.getKeyValueField()))); 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(); List<ExecResult2> list = mapper2.map(result).all();
for(ExecResult2 execResult2:list) { for (ExecResult2 execResult2 : list) {
ExecResult execResult=new ExecResult(); ExecResult execResult = new ExecResult();
execResult.setRuleid(execResult2.getRuleid()); execResult.setRuleid(execResult2.getRuleid());
execResult.setRetvalue(1); execResult.setRetvalue(1);
execResult.setDimfield(execResult2.getDimfield()); execResult.setDimfield(execResult2.getDimfield());
execResult.setTimefield(execResult2.getTimefield()); execResult.setTimefield(execResult2.getTimefield());
execResult.setDomainsfield(execResult2.getDomainsfield()); execResult.setDomainsfield(execResult2.getDomainsfield());
execResult.setKeyvaluefield(execResult2.getKeyvaluefield()); execResult.setKeyvaluefield(execResult2.getKeyvaluefield());
try{ try {
mapper.delete(execResult); mapper.delete(execResult);
}catch(Exception ex){} } catch (Exception ex) {
try{ }
try {
mapper2.delete(execResult2); mapper2.delete(execResult2);
}catch(Exception ex){} } catch (Exception ex) {
}
}
} }
List<ExecResult> results = resultsMQMsg.getDatas(); List<ExecResult> results = resultsMQMsg.getDatas();
if(results != null && results.size() > 0){ if(results != null && results.size() > 0){
...@@ -138,9 +145,10 @@ public class ExecResultRepository { ...@@ -138,9 +145,10 @@ public class ExecResultRepository {
public void saveResultsMQMsg2(ResultsMQMsg resultsMQMsg){ public void saveResultsMQMsg2(ResultsMQMsg resultsMQMsg){
log.info("--saveResultsMQMsg2--"); log.info("--saveResultsMQMsg2--");
try { try {
List<ExecResult> results = resultsMQMsg.getDatas();
if(deleteInvalidResultData) {
final ResultSet result = session.execute(select().all().from(TABLE2).where(in("ruleid", resultsMQMsg.getRules())).and(eq("keyvaluefield", resultsMQMsg.getKeyValueField()))); 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<ExecResult2> list = mapper2.map(result).all();
List<ExecResult> results = resultsMQMsg.getDatas();
//过滤需要删除的对象 //过滤需要删除的对象
if (results != null && results.size() > 0) { if (results != null && results.size() > 0) {
for (ExecResult result1 : results) { for (ExecResult result1 : results) {
...@@ -166,7 +174,7 @@ public class ExecResultRepository { ...@@ -166,7 +174,7 @@ public class ExecResultRepository {
BoundStatement bs2 = ps2.bind(result2.getRuleid(), result2.getKeyvaluefield(), result2.getDimfield(), result2.getDomainsfield(), result2.getTimefield()); BoundStatement bs2 = ps2.bind(result2.getRuleid(), result2.getKeyvaluefield(), result2.getDimfield(), result2.getDomainsfield(), result2.getTimefield());
deleteBatch.add(bs); deleteBatch.add(bs);
deleteBatch2.add(bs2); deleteBatch2.add(bs2);
if ( deleteBatch.size() > batchSize) { if (deleteBatch.size() > batchSize) {
session.execute(deleteBatch); session.execute(deleteBatch);
deleteBatch.clear(); deleteBatch.clear();
session.execute(deleteBatch2); session.execute(deleteBatch2);
...@@ -179,6 +187,7 @@ public class ExecResultRepository { ...@@ -179,6 +187,7 @@ public class ExecResultRepository {
session.execute(deleteBatch2); session.execute(deleteBatch2);
deleteBatch2.clear(); deleteBatch2.clear();
} }
}
//保存数据 //保存数据
for (ExecResult execResult : results) { for (ExecResult execResult : results) {
save(execResult); save(execResult);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册