...
|
...
|
@@ -35,14 +35,13 @@ public class CheckConnectionDao { |
|
|
|
|
|
|
|
|
/**
|
|
|
* 插入ping结果。在插入数据之前,删除掉当前时间前1小时的数据,即只保留1小时的数据。
|
|
|
* 插入ping结果。在插入数据之前,删除掉当前时间前30分钟的数据,即只保留30分钟的数据。
|
|
|
* @param bean
|
|
|
*/
|
|
|
public void addPingConnectionState(ConnectionStateBean bean){
|
|
|
try {
|
|
|
deleteBeforeData();
|
|
|
sqlmapClient.insert("addPingConnectionState", bean);
|
|
|
log.info("******* CheckConnectionDao **** execute method addPingConnectionState ******");
|
|
|
} catch (SQLException e) {
|
|
|
log.error("Exception while addPingConnectionState.",e);
|
|
|
}
|
...
|
...
|
@@ -51,12 +50,11 @@ public class CheckConnectionDao { |
|
|
|
|
|
|
|
|
/**
|
|
|
* 清除TB_CONNECTION_STATE表里1小时前的数据。
|
|
|
* 清除TB_CONNECTION_STATE表里30分钟前的数据。
|
|
|
*/
|
|
|
public void deleteBeforeData(){
|
|
|
long temp=new Date().getTime()-1000*60*60;
|
|
|
long temp=new Date().getTime()-1000*60*30;
|
|
|
String sql="DELETE from TB_CONNECTION_STATE where CREATE_DATE < "+temp;
|
|
|
log.info("******* deleteBeforeData **** sql["+sql+"]******");
|
|
|
try {
|
|
|
sqlmapClient.delete("deleteBeforeData", sql);
|
|
|
} catch (Exception e) {
|
...
|
...
|
@@ -79,4 +77,26 @@ public class CheckConnectionDao { |
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 根据ip查询该ip是否能ping通,时间按照倒序排序。
|
|
|
* @param sql
|
|
|
* @return
|
|
|
*/
|
|
|
public String getPingResultByIp(String sql){
|
|
|
List<ConnectionStateBean> beanList=new ArrayList<ConnectionStateBean>();
|
|
|
try {
|
|
|
beanList=sqlmapClient.queryForList("getPingResultByIp", sql);
|
|
|
} catch (SQLException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
String result="";
|
|
|
log.info("&&&&&&&& beanList.size()="+beanList.size()+" &&&&&&&&&&&&&&&&&&&&&&");
|
|
|
if(null !=beanList && beanList.size()>0){
|
|
|
ConnectionStateBean bean=beanList.get(0);
|
|
|
log.info("&&&&&&&& ConnectionStateBean ="+bean.toString()+" &&&&&&&&&&&&&&&&&&&&&&");
|
|
|
result=bean.getDEVICE_STATE();
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|