Commit 7eb7d224 authored by gao's avatar gao

修改频次认证

parent 3ab18d62
...@@ -16,9 +16,8 @@ import java.util.Date; ...@@ -16,9 +16,8 @@ import java.util.Date;
* Created by gaoxiang on 2018/1/22. * Created by gaoxiang on 2018/1/22.
*/ */
public class SendToWeixin { public class SendToWeixin {
private static String startTime="1517895000000"; private static String startTime="1503123818000";
// private static String startTime="1517722200000"; private static String endTime="1517305049000";
private static String endTime="";
public static void sendToWeixinMain(){ public static void sendToWeixinMain(){
endTime= FormatBytesUtil.getTimestamp(); endTime= FormatBytesUtil.getTimestamp();
......
...@@ -76,10 +76,8 @@ public class ServiceStateMonitoring { ...@@ -76,10 +76,8 @@ public class ServiceStateMonitoring {
String authFrequencyStr=""; String authFrequencyStr="";
JSONArray authFrequencyList=null; JSONArray authFrequencyList=null;
String str="法人代理在"; String str="法人代理在";
Object key1=""; String key="";
Object key2=""; String value="";
Object value="";
int count=1;
int i=1; int i=1;
try { try {
authFrequencyStr= HttpClientPool.getRequest("http://121.22.111.251:9003/legalPerson/v1.0/authFreqStats?startTime="+startTime+"&endTime="+endTime+"&customerNumber=gtyx01&units=Hour"); authFrequencyStr= HttpClientPool.getRequest("http://121.22.111.251:9003/legalPerson/v1.0/authFreqStats?startTime="+startTime+"&endTime="+endTime+"&customerNumber=gtyx01&units=Hour");
...@@ -87,30 +85,28 @@ public class ServiceStateMonitoring { ...@@ -87,30 +85,28 @@ public class ServiceStateMonitoring {
} catch (IOException e) { } catch (IOException e) {
return "法人代理频次请求失败"; return "法人代理频次请求失败";
} }
value= (JSONObject.fromObject(authFrequencyList.get(0)).get("count")).toString();
if(authFrequencyList.size()==1&&value.equals("0")){
str="<div>"+str+FormatBytesUtil.stampToDate(startTime)+"时至"+FormatBytesUtil.stampToDate(endTime)+"时 时间段内没有认证"+"</div>";
return str;
}
if(authFrequencyList.size()==1){ if(authFrequencyList.size()==1){
value = (JSONObject.fromObject(authFrequencyList.get(0)).get("count")); key = (JSONObject.fromObject(authFrequencyList.get(0)).get("time")).toString();
str="<div>"+str+FormatBytesUtil.stampToDate(startTime)+"时至"+FormatBytesUtil.stampToDate(endTime)+"时 时间段内认证"+value+"次"+"</div>"; str="<div>"+str+key+"时至"+ FormatBytesUtil.dateAddOneHour( key)+"时 时间段内认证"+value+"</div>";
return str; return str;
} }
i=authFrequencyList.size(); i=authFrequencyList.size();
for(int j=0;j<authFrequencyList.size();j++){ for(int j=0;j<authFrequencyList.size();j++){
key = (JSONObject.fromObject(authFrequencyList.get(j)).get("time")).toString();
value = (JSONObject.fromObject(authFrequencyList.get(j)).get("count")).toString();
if(i==authFrequencyList.size()){ if(i==authFrequencyList.size()){
key1 = (JSONObject.fromObject(authFrequencyList.get(count)).get("time")); str="<div>"+str+key+"时至"+FormatBytesUtil.dateAddOneHour( key)+"时 时间段内认证"+value+"次"+"</div>";
value = (JSONObject.fromObject(authFrequencyList.get(count-1)).get("count"));
str="<div>"+str+FormatBytesUtil.stampToDate(startTime)+"时至"+key1+"时 时间段内认证"+value+"次"+"</div>";
i--; i--;
count++;
} else if (i!=1){ } else if (i!=1){
key2 = (JSONObject.fromObject(authFrequencyList.get(count)).get("time")); str=str+"<div>在"+key+"时至"+FormatBytesUtil.dateAddOneHour(key)+"时 时间段内认证"+value+"次"+"</div>";
value = (JSONObject.fromObject(authFrequencyList.get(count-1)).get("count"));
str=str+"<div>在"+key1+"时至"+key2+"时 时间段内认证"+value+"次"+"</div>";
key1=key2;
count++;
i--; i--;
}else{ }else{
value = (JSONObject.fromObject(authFrequencyList.get(count-1)).get("count")); str=str+"<div>在"+key+"时至"+FormatBytesUtil.dateAddOneHour(key)+"时 时间段内认证"+value+"次"+"</div>";
str=str+"<div>在"+key1+"时至"+FormatBytesUtil.stampToDate(endTime)+"时 时间段内认证"+value+"次"+"</div>";
count++;
break; break;
} }
} }
......
package com.legalPersonMonitor.utils; package com.legalPersonMonitor.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
...@@ -52,6 +53,18 @@ public class FormatBytesUtil { ...@@ -52,6 +53,18 @@ public class FormatBytesUtil {
return bytes; return bytes;
} }
/**
* 时间戳
*
* @return
*/
public static String getTimestamp() {
long i = (System.currentTimeMillis());
String time = String.valueOf(i);
return time;
}
/** /**
* 时间戳转换为时间 * 时间戳转换为时间
* @param s * @param s
...@@ -66,15 +79,43 @@ public class FormatBytesUtil { ...@@ -66,15 +79,43 @@ public class FormatBytesUtil {
return res; return res;
} }
/** /**
* 时间戳 * 将时间做加一小时处理
*
* @return 13位时间戳
*/ */
public static String dateAddOneHour(String s) {
public static String getTimestamp() { String res;
long i = (System.currentTimeMillis()); Long timeStamp;
String time = String.valueOf(i); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
return time; Date date = null;
try {
date = simpleDateFormat.parse(s);
} catch (ParseException e) {
e.printStackTrace();
}
long ts = date.getTime();
res = String.valueOf(ts);
timeStamp=Long.parseLong(res);
timeStamp=timeStamp+3600000;
res=String.valueOf(timeStamp);
long lt = new Long(res);
date = new Date(lt);
res = simpleDateFormat.format(date);
return res;
}
/**
* 将时间转换为时间戳
*/
public static String dateToStamp(String s) {
String res;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
Date date = null;
try {
date = simpleDateFormat.parse(s);
} catch (ParseException e) {
e.printStackTrace();
}
long ts = date.getTime();
res = String.valueOf(ts);
return res;
} }
/** /**
......
package com.test; package com.test;
import com.legalPersonMonitor.auth.Authentication;
import com.legalPersonMonitor.config.ParameterConfig; import com.legalPersonMonitor.connections.SendRequset;
import com.legalPersonMonitor.connections.HttpClientPool; import com.legalPersonMonitor.data.AccessTokenRequset;
import com.legalPersonMonitor.connections.SocketSender; import com.legalPersonMonitor.data.AccessTokenResponse;
import com.legalPersonMonitor.data.AuthApplyRetainBean; import com.legalPersonMonitor.data.WxResponseBean;
import com.legalPersonMonitor.data.AuthRequestBean;
import com.legalPersonMonitor.data.AuthResponseBean;
import com.legalPersonMonitor.monitor.ServiceStateMonitoring; import com.legalPersonMonitor.monitor.ServiceStateMonitoring;
import com.legalPersonMonitor.utils.FormatBytesUtil; import com.legalPersonMonitor.utils.FormatBytesUtil;
import net.sf.json.JSONObject;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/** /**
* Created by gaoxiang on 2018/1/22. * Created by gaoxiang on 2018/1/22.
*/ */
public class test { public class test {
private static String startTime="1503123818000";
private static String endTime="1517305049000";
public static void main(String[] args){ public static void main(String[] args){
String authFrequencyStr= ServiceStateMonitoring.authCount("1517443200000","1517702400000"); String authFrequencyStr= ServiceStateMonitoring.authFrequency("1478793600000","1478829600000");
System.out.println(authFrequencyStr); System.out.println(authFrequencyStr);
//
// String aa="2018-02-09 16:18:35";
// if(aa.substring(12,16).equals("2018-02-09 16:18")){
// System.out.println(111);
// }
// System.out.println( aa.substring(14,16));
// Object s = FormatBytesUtil.dateAddOneHour("2018-02-09 16");
// System.out.println(s);
// Object s1 = FormatBytesUtil.stampToDate("1518163200000");
// System.out.println(s1);
//
// Object s2 = FormatBytesUtil.dateToStamp("2018-02-09 17");
// System.out.println("222 "+s2);
/*微信推送频率*/
// 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);
// String sendjson="{ \"touser\": \"@all\", \"toparty\": \" \", \"totag\": \" \", \"msgtype\": \"mpnews\", \"agentid\": "+1000003+", "
// + "\"mpnews\": { \"articles\":[ "
// + "{ \"title\": \""+"身份认证监控系统"+"\", "
// + "\"thumb_media_id\": \""+"2_VLquGGm4PEhhG-vG5_9SEfdLvNrvNPbdLH6DrZqieHHH5LqXbfqvLWljvcgGvF4"+"\", "
// + "\"author\": \"\", "
// + "\"content_source_url\": \"\", "
// + "\"content\": \"<div > "+authFrequencyStr+" </div>"
// + "\"digest\": \""+"\", "
// + "\"show_cover_pic\": \"1\" } ] }, "
// + "\"safe\":0}";
// WxResponseBean wx=sr.sendTextMessage(asresponse, sendjson);
} }
} }
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
<bean id="checkXMLInput" class="com.legalPersonMonitor.monitor.SendToWeixin" /> <bean id="checkXMLInput" class="com.legalPersonMonitor.monitor.SendToWeixin" />
<task:scheduled-tasks> <task:scheduled-tasks>
<task:scheduled ref="checkXMLInput" method="sendToWeixinMain" cron="0 30 8 ? * *"/> <task:scheduled ref="checkXMLInput" method="sendToWeixinMain" cron="0 00 8 ? * *"/>
<task:scheduled ref="checkXMLInput" method="sendToWeixinMain" cron="0 30 11 ? * *"/> <task:scheduled ref="checkXMLInput" method="sendToWeixinMain" cron="0 00 11 ? * *"/>
<task:scheduled ref="checkXMLInput" method="sendToWeixinMain" cron="0 30 13 ? * *"/> <task:scheduled ref="checkXMLInput" method="sendToWeixinMain" cron="0 00 14 ? * *"/>
<task:scheduled ref="checkXMLInput" method="sendToWeixinMain" cron="0 30 16 ? * *"/> <task:scheduled ref="checkXMLInput" method="sendToWeixinMain" cron="0 00 17 ? * *"/>
</task:scheduled-tasks> </task:scheduled-tasks>
</beans> </beans>
\ No newline at end of file
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