...
|
...
|
@@ -7,6 +7,7 @@ package com.yoho.unions.server.service.impl; |
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import com.netflix.config.DynamicIntProperty;
|
|
|
import com.netflix.config.DynamicPropertyFactory;
|
|
|
import com.yoho.core.common.utils.MD5;
|
...
|
...
|
@@ -48,6 +49,7 @@ import javax.annotation.Resource; |
|
|
import java.net.URLDecoder;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.LinkedBlockingQueue;
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
...
|
...
|
@@ -205,7 +207,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher |
|
|
clickUnion.info("clickUnion set redis with key={}, value={}", key, JSON.toJSONString(request));
|
|
|
yhValueOperations.set(key, JSON.toJSONString(request));
|
|
|
String invalidTime = "activeTime"+"_"+request.getUnion_type();
|
|
|
DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty(invalidTime, 3);
|
|
|
DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty(invalidTime, 48);
|
|
|
yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS);
|
|
|
|
|
|
|
...
|
...
|
@@ -830,29 +832,51 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher |
|
|
public PageActivateDeviceIdRspBO queryActivateHour(ActivateDeviceIdReqBO activateDeviceIdReqBO) {
|
|
|
log.info("enter queryActivateHour. param activateDeviceIdReqBO={}", activateDeviceIdReqBO);
|
|
|
|
|
|
//(1).查询出各渠道激活的设备id数
|
|
|
List<ActivateDeviceIdRspBO> activateDeviceIdRspList = Lists.newArrayList();
|
|
|
|
|
|
int beginTime = DateUtils.getTodayZero();
|
|
|
//1.初始化map,用于存放24个小时的激活idfa和imei
|
|
|
Map<Integer,List<Integer>> countMap = Maps.newHashMap();
|
|
|
for(int i=0;i<24;i++){
|
|
|
activateDeviceIdReqBO.setActivateHourBegin(beginTime);
|
|
|
activateDeviceIdReqBO.setActivateHourEnd(beginTime+3600);
|
|
|
activateDeviceIdRspList.addAll(unionLogsDAO.selectListByHour(activateDeviceIdReqBO));
|
|
|
beginTime +=3600;
|
|
|
List<Integer> countList = Lists.newArrayList();
|
|
|
countList.add(0);
|
|
|
countList.add(0);
|
|
|
countMap.put(i,countList);
|
|
|
}
|
|
|
|
|
|
|
|
|
String searchDay = DateUtils.int2DateStr(activateDeviceIdReqBO.getActivateTimeEnd(),"yyyy/MM/dd");
|
|
|
int beginTime = DateUtils.getTimesmorning(searchDay);
|
|
|
int endTime = beginTime+3600*24-1;
|
|
|
activateDeviceIdReqBO.setActivateHourBegin(beginTime);
|
|
|
activateDeviceIdReqBO.setActivateHourEnd(endTime);
|
|
|
//2.查询出一个渠道一天的激活数
|
|
|
List<UnionLogs> unionLogs = unionLogsDAO.selectListByHour(activateDeviceIdReqBO);
|
|
|
|
|
|
for(int i=0;i<unionLogs.size();i++){
|
|
|
UnionLogs unionLog = unionLogs.get(i);
|
|
|
String createTime = DateUtils.int2DateStr(unionLog.getCreateTime(),"yyyy-MM-dd HH:mm:ss");
|
|
|
//3.遍历一天的记录,统计每小时的激活数
|
|
|
int key = Integer.parseInt(createTime.substring(11,13));
|
|
|
List<Integer> countList = countMap.get(key);
|
|
|
//list第一个元素是idfa的激活数
|
|
|
if(StringUtils.isNotEmpty(unionLog.getIdfa())){
|
|
|
countList.set(0,countList.get(0)+1);
|
|
|
}
|
|
|
//list第二个元素是idfa的激活数
|
|
|
if (StringUtils.isNotEmpty(unionLog.getImei())){
|
|
|
countList.set(1,countList.get(1)+1);
|
|
|
}
|
|
|
}
|
|
|
List<ActivateDeviceIdRspBO> activateDeviceIdRspList = Lists.newArrayList();
|
|
|
for(int i=0;i<24;i++){
|
|
|
ActivateDeviceIdRspBO bo = activateDeviceIdRspList.get(i);
|
|
|
ActivateDeviceIdRspBO bo = new ActivateDeviceIdRspBO();
|
|
|
String hour = i<10?"0"+i+":00--"+"0"+i+":59":i+":00--"+i+":59";
|
|
|
bo.setHour(hour);
|
|
|
List<Integer> countList = countMap.get(i);
|
|
|
bo.setIdfaCount(countList.get(0));
|
|
|
bo.setImeiCount(countList.get(1));
|
|
|
activateDeviceIdRspList.add(bo);
|
|
|
}
|
|
|
|
|
|
PageActivateDeviceIdRspBO pageActivateDeviceIdRspBO = new PageActivateDeviceIdRspBO();
|
|
|
pageActivateDeviceIdRspBO.setList(activateDeviceIdRspList);
|
|
|
//不需要分页了
|
|
|
// pageActivateDeviceIdRspBO.setTotal(total);
|
|
|
// pageActivateDeviceIdRspBO.setPage(activateDeviceIdReqBO.getPage());
|
|
|
return pageActivateDeviceIdRspBO;
|
|
|
}
|
|
|
|
...
|
...
|
|