|
|
|
@@ -19,7 +19,10 @@ import org.springframework.web.client.RestTemplate; |
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
import com.simple.domain.po.WxAppinfo;
|
|
|
|
import com.simple.domain.po.WxUserVisit;
|
|
|
|
import com.simple.service.WxAppinfoService;
|
|
|
|
import com.simple.service.WxUserVisitService;
|
|
|
|
|
|
|
|
@Component
|
|
|
|
@@ -37,24 +40,40 @@ public class WxAppVisitSchedule { |
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private WxUserVisitService wxUserVisitService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private WxAppinfoService WxAppinfoService;
|
|
|
|
|
|
|
|
|
|
|
|
// @Scheduled(cron = "0 */1 * * * *?")
|
|
|
|
@Scheduled(cron = "0 0 4 * * ? ")
|
|
|
|
@Scheduled(cron = "0 0 6 * * ? ")
|
|
|
|
public void start() {
|
|
|
|
try {
|
|
|
|
Calendar c =Calendar.getInstance();
|
|
|
|
c.add(Calendar.DAY_OF_YEAR, -1);
|
|
|
|
Date time = c.getTime();
|
|
|
|
String yesterday = new SimpleDateFormat("yyyyMMdd").format(time);
|
|
|
|
getData(yesterday);
|
|
|
|
// "wx8eb8275b78db4ede", "76c43df01296998d8ce12383f213ac10";
|
|
|
|
WxAppinfo appInfo = new WxAppinfo();
|
|
|
|
appInfo.setType(2);
|
|
|
|
PageInfo<WxAppinfo> page = WxAppinfoService.listAsPage(appInfo, 1, 10000);
|
|
|
|
for(WxAppinfo w :page.getList()) {
|
|
|
|
w.getAppId();
|
|
|
|
w.getSecret();
|
|
|
|
w.getTenantId();
|
|
|
|
//TODO 因为数据库表里数据问题,暂时不通过这种方式处理
|
|
|
|
}
|
|
|
|
String appId = "wx8eb8275b78db4ede";
|
|
|
|
String key ="76c43df01296998d8ce12383f213ac10";
|
|
|
|
String talentId ="456";
|
|
|
|
getData(yesterday,appId,key,talentId);
|
|
|
|
}catch(Exception e) {
|
|
|
|
logger.error("获取微信访问数据失败",e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void getData(String yesterday) throws Exception {
|
|
|
|
String accessToken = getAccessToken("wx8eb8275b78db4ede", "76c43df01296998d8ce12383f213ac10");
|
|
|
|
private void getData(String yesterday,String appId,String key,String talentId) throws Exception {
|
|
|
|
String accessToken = getAccessToken(appId, key);
|
|
|
|
HttpHeaders headers = new HttpHeaders();
|
|
|
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
|
|
|
Map<String, String> map = new HashMap<String, String>();
|
|
|
|
@@ -91,6 +110,7 @@ public class WxAppVisitSchedule { |
|
|
|
v.setStayTimeSession(itemMap.get("stay_time_session")+"");
|
|
|
|
v.setVisitDepth(itemMap.get("visit_depth")+"");
|
|
|
|
v.setStayTimeUv(itemMap.get("stay_time_uv")+"");
|
|
|
|
v.setTenantId(talentId);
|
|
|
|
wxUserVisitService.saveOrUpdate(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
|