Commit 8b2ffc20 authored by 郝彦辉's avatar 郝彦辉

检测tidb的call_record表数据是否有重复数据工具

parent d40f406d
......@@ -802,14 +802,18 @@ public class CleanningTransactionLogService {
String CALL_SQL = "select * from call_record where transaction_id ='" + arry[0] + "' and uuid ='" + arry[1] +"'"
+" and url_type ='" + arry[2] + "' and code ='" +arry[3]+ "'; ";
List<CallRecord3> queryResult = tidbRiskJdbcTemplate.query(CALL_SQL, new BeanPropertyRowMapper<>(CallRecord3.class));
int size = (queryResult!=null ? queryResult.size(): 0);
if(queryResult!=null && queryResult.size()==2){
CallRecord3 bean1 = queryResult.get(0);
CallRecord3 bean2 = queryResult.get(1);
int second = Math.abs(bean1.getCreatedAt().compareTo(bean2.getCreatedAt()));
if(second <=3){
if(StringUtils.isEmpty(bean1.getRequestUrl()) && StringUtils.isEmpty(bean1.getChannelId())
&& StringUtils.isNotEmpty(bean2.getRequestUrl()) && StringUtils.isNotEmpty(bean2.getChannelId())){
&& ( StringUtils.isNotEmpty(bean2.getRequestUrl()) || StringUtils.isNotEmpty(bean2.getChannelId())
|| StringUtils.isNotEmpty(bean2.getChannelType())
)){
String sql = DELETE_CALL_SQL.replace("##ID##", ""+bean1.getId());
sql = sql.replace("##TRANSACTION_ID##", bean1.getTransactionId());
try {
......@@ -821,8 +825,9 @@ public class CleanningTransactionLogService {
}
}else if(StringUtils.isEmpty(bean2.getRequestUrl()) && StringUtils.isEmpty(bean2.getChannelId())
&& StringUtils.isNotEmpty(bean1.getRequestUrl()) && StringUtils.isNotEmpty(bean1.getChannelId())){
&& (StringUtils.isNotEmpty(bean1.getRequestUrl()) || StringUtils.isNotEmpty(bean1.getChannelId())
|| StringUtils.isNotEmpty(bean1.getChannelType())
)){
String sql = DELETE_CALL_SQL.replace("##ID##", ""+bean2.getId());
sql = sql.replace("##TRANSACTION_ID##", bean2.getTransactionId());
try {
......@@ -841,7 +846,7 @@ public class CleanningTransactionLogService {
log.info("查询call_record表,相差时间大于3秒, param: {} , List: {} ", tidbCallRecordCFList.get(i), (queryResult!=null ? JSON.toJSONString(queryResult): "null") );
}
}else{
log.info("查询call_record表,list大小不为2, param: {} , List: {} ", tidbCallRecordCFList.get(i), (queryResult!=null ? JSON.toJSONString(queryResult): "null") );
log.info("查询call_record表,list大小不为2, param: {} , size: {} , List: {} ", tidbCallRecordCFList.get(i), size, (queryResult!=null ? JSON.toJSONString(queryResult): "null") );
}
}
log.info("----删除bean数据完成----");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment