Commit bc2cd7ab authored by gao's avatar gao

频次认证

parent 9ad12350
...@@ -3,6 +3,7 @@ package com.legalPersonMonitor.connections; ...@@ -3,6 +3,7 @@ package com.legalPersonMonitor.connections;
import org.apache.http.*; import org.apache.http.*;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity; import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
...@@ -40,5 +41,19 @@ public class HttpClientPool { ...@@ -40,5 +41,19 @@ public class HttpClientPool {
} }
public static String getRequest(String url) throws IOException {
CloseableHttpClient hc = HttpClients.createDefault();
HttpGet httpget = new HttpGet(url);
CloseableHttpResponse response;
try {
response = hc.execute(httpget);
HttpEntity et = response.getEntity();
return EntityUtils.toString(et);
} catch (IOException e) {
throw e;
}
}
} }
package com.legalPersonMonitor.utils; package com.legalPersonMonitor.utils;
import java.text.SimpleDateFormat;
import java.util.Date;
public class FormatBytesUtil { public class FormatBytesUtil {
/** /**
* 将byte数组转换为short类型 * 将byte数组转换为short类型
...@@ -49,6 +52,19 @@ public class FormatBytesUtil { ...@@ -49,6 +52,19 @@ public class FormatBytesUtil {
return bytes; return bytes;
} }
/**
* 时间戳转换为时间
* @param s
* @return
*/
public static String stampToDate(String s){
String res;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
long lt = new Long(s);
Date date = new Date(lt);
res = simpleDateFormat.format(date);
return res;
}
/** /**
* 时间戳 * 时间戳
* *
...@@ -59,6 +75,7 @@ public class FormatBytesUtil { ...@@ -59,6 +75,7 @@ public class FormatBytesUtil {
// byte[] time = getBytesOfInt(i); // byte[] time = getBytesOfInt(i);
// return time; // return time;
// } // }
public static String getTimestamp() { public static String getTimestamp() {
long i = (System.currentTimeMillis()); long i = (System.currentTimeMillis());
String time = String.valueOf(i); String time = String.valueOf(i);
......
...@@ -7,6 +7,7 @@ import com.legalPersonMonitor.connections.SocketSender; ...@@ -7,6 +7,7 @@ import com.legalPersonMonitor.connections.SocketSender;
import com.legalPersonMonitor.data.AuthApplyRetainBean; import com.legalPersonMonitor.data.AuthApplyRetainBean;
import com.legalPersonMonitor.data.AuthRequestBean; import com.legalPersonMonitor.data.AuthRequestBean;
import com.legalPersonMonitor.data.AuthResponseBean; import com.legalPersonMonitor.data.AuthResponseBean;
import com.legalPersonMonitor.monitor.ServiceStateMonitoring;
import com.legalPersonMonitor.utils.FormatBytesUtil; import com.legalPersonMonitor.utils.FormatBytesUtil;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
...@@ -19,6 +20,8 @@ import java.util.Map; ...@@ -19,6 +20,8 @@ import java.util.Map;
*/ */
public class test { public class test {
public static void main(String[] args){ public static void main(String[] args){
String authFrequencyStr= ServiceStateMonitoring.authFrequency("1517443200000","1517702400000");
System.out.println(authFrequencyStr);
} }
} }
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