Authored by qinchao

恶意ip显示

... ... @@ -102,6 +102,7 @@ public class MaliciousIpMapperImpl extends InfluxDBQuery implements MaliciousIpM
Map<String,String> m = new HashMap();
m.put("reason",(String) ls.get(s.getColumns().indexOf("reason")));
m.put("dur",(String) ls.get(s.getColumns().indexOf("dur")));
m.put("time",""+ls.get(s.getColumns().indexOf("time")));
resultMap.put(ip,m);
}
}
... ...
... ... @@ -357,6 +357,8 @@ public class MaliciousIpServiceImpl implements MaliciousIpService {
//组装数据
List<MaliciousIp> listMaliciousIp = new ArrayList<MaliciousIp>();
long ts=0l;
String insertTime="";
String insertTime2="";
for(String mipKey : mipKeys){
MaliciousIp mip = new MaliciousIp();
mip.setIp(mipKey);
... ... @@ -366,6 +368,7 @@ public class MaliciousIpServiceImpl implements MaliciousIpService {
if( awsIpInfo.get(mipKey) != null){
Map<String,String> awsInfo = awsIpInfo.get(mipKey);
String reason=awsInfo.get("reason");
insertTime=awsInfo.get("time");
try{
MaliciousIpModel model=JSON.parseObject(reason,MaliciousIpModel.class);
reason=model.toHtmlString();
... ... @@ -383,6 +386,7 @@ public class MaliciousIpServiceImpl implements MaliciousIpService {
reasonDur += "</br>";
}
String reason=qcloudInfo.get("reason");
insertTime2=qcloudInfo.get("time");
try{
MaliciousIpModel model=JSON.parseObject(reason,MaliciousIpModel.class);
reason=model.toHtmlString();
... ... @@ -399,7 +403,7 @@ public class MaliciousIpServiceImpl implements MaliciousIpService {
//reasonDur += "qcloud: " + qcloudInfo.get("dur")+ " -- "+ qcloudInfo.get("reason") ;
}
mip.setReasonDur(reasonDur);
if(ts>0){
/*if(ts>0){
String time="";
try{
time=new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ).format(new Date(ts));
... ... @@ -407,18 +411,42 @@ public class MaliciousIpServiceImpl implements MaliciousIpService {
}
mip.setTime(time);
}
}*/
mip.setTs(ts);
if(StringUtils.isNotBlank(insertTime)&&StringUtils.isNotBlank(insertTime2)){
try{
if(insertTime.compareTo(insertTime2)>0){
mip.setTime(insertTime.substring(0,10)+" "+insertTime.substring(11,19));
}else{
mip.setTime(insertTime2.substring(0,10)+" "+insertTime2.substring(11,19));
}
}catch (Exception e){
}
}
listMaliciousIp.add(mip);
}
//排序
Collections.sort(listMaliciousIp,new Comparator<MaliciousIp>(){
public int compare(MaliciousIp arg0, MaliciousIp arg1) {
long compare= arg0.getTs() - arg1.getTs();
/*long compare= arg0.getTs() - arg1.getTs();
if(compare<0L){
return 1;
}else{
return -1;
}*/
if(StringUtils.isBlank(arg0.getTime())){
return 1;
}else if(StringUtils.isBlank(arg1.getTime())){
return 1;
}else{
int i= arg0.getTime().compareTo(arg1.getTime());
if(i<0){
return 1;
}else{
return -1;
}
}
}
... ...