|
|
|
@@ -44,9 +44,30 @@ public class WxAppVisitSchedule { |
|
|
|
private WxAppinfoService WxAppinfoService; |
|
|
|
|
|
|
|
|
|
|
|
//@Scheduled(cron = "*/10 * * * * ?") // 测试10秒中一次 |
|
|
|
@Scheduled(cron = "0 0 2,3,4 * * ? ") //2,3,4点做一次 |
|
|
|
@Scheduled(cron = "0 0 9 * * ? ") //早晨9点做一次,获取前一日,微信时间为GMT |
|
|
|
public void daliyVisitRetrive() { |
|
|
|
try { |
|
|
|
|
|
|
|
WxAppinfo appInfo = new WxAppinfo(); |
|
|
|
appInfo.setType(EnumAppType.C.getCode()); |
|
|
|
PageInfo<WxAppinfo> page = WxAppinfoService.listAsPage(appInfo, 1, 10000); |
|
|
|
for(WxAppinfo w :page.getList()) { |
|
|
|
if(StringUtils.isBlank(w.getAppId())||StringUtils.isBlank(w.getSecret())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
Calendar c = Calendar.getInstance(); |
|
|
|
c.add(Calendar.DAY_OF_YEAR, -1); |
|
|
|
String date = new SimpleDateFormat("yyyyMMdd").format(c.getTime()); |
|
|
|
getData(date,w); |
|
|
|
} |
|
|
|
}catch(Exception e) { |
|
|
|
logger.error("获取微信访问数据失败",e); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Scheduled(cron = "0 0 2 * * ? ") //2点做一次补录 |
|
|
|
public void completeVisitRetrive() { |
|
|
|
try { |
|
|
|
|
|
|
|
WxAppinfo appInfo = new WxAppinfo(); |
|
|
|
@@ -59,7 +80,7 @@ public class WxAppVisitSchedule { |
|
|
|
Calendar c = Calendar.getInstance(); |
|
|
|
String date; |
|
|
|
for(int i = 0; i < 7; i++) { //查找最近7天有没有漏掉的数据 |
|
|
|
c.add(Calendar.DAY_OF_YEAR, -1); |
|
|
|
c.add(Calendar.DAY_OF_YEAR, -2); |
|
|
|
date = new SimpleDateFormat("yyyyMMdd").format(c.getTime()); |
|
|
|
if (!checkData(date,w)) |
|
|
|
getData(date,w); |
|
|
|
@@ -87,7 +108,7 @@ public class WxAppVisitSchedule { |
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON); |
|
|
|
Map<String, String> map = new HashMap<String, String>(); |
|
|
|
map.put("begin_date", date); |
|
|
|
map.put("end_date",date); |
|
|
|
map.put("end_date", date); |
|
|
|
RestTemplate restTemplate = new RestTemplate(); |
|
|
|
HttpEntity<Map<String,String>> entity = new HttpEntity<Map<String,String>>(map, headers); |
|
|
|
String reqUrl =visit+accessToken; |
|
|
|
|