Commit 9d1609e6 authored by gao's avatar gao

修改频次认证

parent f5210fb7
package com.legalPersonMonitor.monitor;
import com.legalPersonMonitor.connections.HttpClientPool;
import com.legalPersonMonitor.connections.SendRequset;
import com.legalPersonMonitor.data.AccessTokenRequset;
import com.legalPersonMonitor.data.AccessTokenResponse;
import com.legalPersonMonitor.data.WxResponseBean;
import com.legalPersonMonitor.utils.FormatBytesUtil;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Created by gaoxiang on 2018/1/22.
*/
public class SendToWeixin {
public void test(){
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!");
}
private static String startTime="1517895000000";
// private static String startTime="1517722200000";
private static String endTime="";
public void sendToWeixinMain(){
String msgServiceState= "0X4F模式下的服务状态监控"+ServiceStateMonitoring.serviceStateMonitoringServer()+" ";
String msgTrustedPlatformStatus= "0X4F模式下的可信平台状态监控"+new TrustedPlatformStatusMonitoring().trustedPlatformStatusMonitoringServer()+" ";
String msgSignatureServerStatus = "签名服务器状态监控"+new SignatureServerStatusMonitoring().signatureServerStatusMonitoringServer();
endTime= FormatBytesUtil.getTimestamp();
String msgServiceState= "0X4F模式下的法人代理返回结果:"+ServiceStateMonitoring.serviceStateMonitoringServer();
String msgTrustedPlatformStatus= "0X4F模式下的可信平台返回结果:"+new TrustedPlatformStatusMonitoring().trustedPlatformStatusMonitoringServer();
String msgSignatureServerStatus = "签名服务器状态监控:"+new SignatureServerStatusMonitoring().signatureServerStatusMonitoringServer();
String correctRateQueryStr=ServiceStateMonitoring.correctRateQuery(startTime,endTime);
String authCountStr=ServiceStateMonitoring.authCount(startTime,endTime);
String authFrequencyStr=ServiceStateMonitoring.authFrequency(startTime,endTime);
startTime=endTime;
SendRequset sr=new SendRequset();
AccessTokenRequset atrequset=new AccessTokenRequset("https://qyapi.weixin.qq.com/cgi-bin/gettoken","wx4244612882ba3018","5dqLUQ9S3CjhFfKXsmgl4Q9PogJEG6qieoyr4AEw1UI" );
AccessTokenResponse asresponse=sr.getAccessToken(atrequset);
......@@ -25,10 +38,21 @@ public class SendToWeixin {
+ "\"thumb_media_id\": \""+"2_VLquGGm4PEhhG-vG5_9SEfdLvNrvNPbdLH6DrZqieHHH5LqXbfqvLWljvcgGvF4"+"\", "
+ "\"author\": \"\", "
+ "\"content_source_url\": \"\", "
+ "\"content\": \""+msgServiceState+msgTrustedPlatformStatus+msgSignatureServerStatus+"\", "
+ "\"content\": \"<div > "+msgServiceState+" </div>" +
"<br>" +
"<div > "+ correctRateQueryStr+" </div>" +
"<br>" +
"<div > "+ authCountStr+" </div>" +
"<br>" +
"<div > "+ authFrequencyStr+" </div>" +
"<br>" +
"<div > "+ msgTrustedPlatformStatus+" </div>" +
"<br>" +
"<div > "+ msgSignatureServerStatus+" </div>\", "
+ "\"digest\": \""+"\", "
+ "\"show_cover_pic\": \"1\" } ] }, "
+ "\"safe\":0}";
WxResponseBean wx=sr.sendTextMessage(asresponse, sendjson);
}
}
......@@ -3,10 +3,13 @@ package com.legalPersonMonitor.monitor;
import com.legalPersonMonitor.config.ParameterConfig;
import com.legalPersonMonitor.connections.HttpClientPool;
import com.legalPersonMonitor.data.*;
import com.legalPersonMonitor.utils.FormatBytesUtil;
import net.sf.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* Created by gaoxiang on 2018/1/22.
......@@ -37,13 +40,86 @@ public class ServiceStateMonitoring {
}
msgDescription=authResponseBean.getAuthResult();
}catch (Exception e){
msgDescription="服务状态监控超时错误";
msgDescription="法人代理监控超时错误";
}
return msgDescription;
}
/**
* 正确率查询
*/
public static String correctRateQuery(String startTime,String endTime){
String correctRateQueryStr="";
try {
correctRateQueryStr= HttpClientPool.getRequest("http://121.22.111.251:9002/legalPerson/v1.0/authSucStats?startTime="+startTime+"&endTime="+endTime+"&customer=gtyx01");
} catch (IOException e) {
e.printStackTrace();
}
JSONObject correctRateQueryStrJson = JSONObject.fromObject(correctRateQueryStr);
String str="法人代理在"+ FormatBytesUtil.stampToDate(startTime)+"时 至"+FormatBytesUtil.stampToDate(endTime)+"时 时间段内认证认证成功率是"+correctRateQueryStrJson.get("correctRate");
return str;
}
public static String authCount(String startTime,String endTime){
String authCountStr="";
try {
authCountStr= HttpClientPool.getRequest("http://121.22.111.251:9002/legalPerson/v1.0/authQtyStats?startTime="+startTime+"&endTime="+endTime+"&customer=gtyx01");
} catch (IOException e) {
e.printStackTrace();
}
JSONObject correctRateQueryStrJson = JSONObject.fromObject(authCountStr);
String str="法人代理在"+ FormatBytesUtil.stampToDate(startTime)+"时 至"+FormatBytesUtil.stampToDate(endTime)+"时 时间段内认证总计"+correctRateQueryStrJson.get("quantity")+"次";
return str;
}
public static String authFrequency(String startTime,String endTime){
String authFrequencyStr="";
String str="法人代理在";
String key1="";
String key2="";
String value="";
int count=1;
int i=1;
try {
authFrequencyStr= HttpClientPool.getRequest("http://121.22.111.251:9002/legalPerson/v1.0/authFreqStats?startTime="+startTime+"&endTime="+endTime+"&customerNumber=gtyx01&units=Hour");
} catch (IOException e) {
e.printStackTrace();
}
JSONObject correctRateQueryStrJson=JSONObject.fromObject(authFrequencyStr);
Iterator iterator = correctRateQueryStrJson.keys();
Iterator iterator1 = correctRateQueryStrJson.keys();
List<String> listKey=new ArrayList();
while(iterator1.hasNext()){
listKey.add((String) iterator1.next());
}
i=correctRateQueryStrJson.size();
if(listKey.size()==1){
value = correctRateQueryStrJson.getString(listKey.get(count-1));
str="<div>"+str+FormatBytesUtil.stampToDate(startTime)+"时至"+FormatBytesUtil.stampToDate(endTime)+"时 时间段内认证"+value+"次"+"</div>";
return str;
}
while(iterator.hasNext()){
if(i==correctRateQueryStrJson.size()){
key1 = listKey.get(count);
value = correctRateQueryStrJson.getString(listKey.get(count-1));
str="<div>"+str+FormatBytesUtil.stampToDate(startTime)+"时至"+key1+"时 时间段内认证"+value+"次"+"</div>";
i--;
count++;
} else if (i!=1){
key2 = listKey.get(count);
value = correctRateQueryStrJson.getString(listKey.get(count-1));
str=str+"<div>在"+key1+"时至"+key2+"时 时间段内认证"+value+"次"+"</div>";
key1=key2;
count++;
i--;
}else{
value = correctRateQueryStrJson.getString(listKey.get(count-1));
str=str+"<div>在"+key1+"时至"+FormatBytesUtil.stampToDate(endTime)+"时 时间段内认证"+value+"次"+"</div>";
count++;
break;
}
}
return str;
}
}
......@@ -21,9 +21,9 @@ public class SignatureServerStatusMonitoring {
try {
boolean aa = oldVerificationImpl.signCheck(VERIFICANTION_BYTE);
if (aa) {
msgDescription = "签名服务器正常运行";
msgDescription = "正常运行";
} else {
msgDescription = "签名服务器出错";
msgDescription = "出错";
}
}catch (Exception e){
msgDescription="连接超时";
......
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