...
|
...
|
@@ -2,6 +2,13 @@ package com.yoho.unions.server.service.impl; |
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
import com.yoho.unions.common.redis.RedisValueCache;
|
|
|
import com.yoho.unions.dal.IMktMarketingUrlDAO;
|
|
|
import com.yoho.unions.dal.IUnionActivityLogsDAO;
|
|
|
import com.yoho.unions.dal.IUnionClickLogsDAO;
|
|
|
import com.yoho.unions.dal.model.MktMarketingUrl;
|
|
|
import com.yoho.unions.dal.model.UnionActivityLogs;
|
|
|
import com.yoho.unions.dal.model.UnionClickLogs;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
|
import org.apache.http.HttpStatus;
|
...
|
...
|
@@ -23,6 +30,9 @@ import com.yoho.unions.dal.IUnionsActiveRecordDAO; |
|
|
import com.yoho.unions.dal.model.UnionsActiveRecord;
|
|
|
import com.yoho.unions.server.service.DingdangService;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
@Service
|
|
|
public class DingdangServiceImpl implements DingdangService {
|
|
|
|
...
|
...
|
@@ -36,6 +46,18 @@ public class DingdangServiceImpl implements DingdangService { |
|
|
|
|
|
@Resource
|
|
|
IUnionsActiveRecordDAO unionsActiveRecordDAO;
|
|
|
|
|
|
@Resource
|
|
|
IUnionActivityLogsDAO unionActivityLogsDAO;
|
|
|
|
|
|
@Resource
|
|
|
IUnionClickLogsDAO unionClickLogsDAO;
|
|
|
|
|
|
@Resource
|
|
|
RedisValueCache redisValueCache;
|
|
|
|
|
|
@Resource
|
|
|
IMktMarketingUrlDAO mktMarketingUrlDAO;
|
|
|
|
|
|
private static final String unions_KEY = "yh:unions:dingdang_";
|
|
|
|
...
|
...
|
@@ -215,4 +237,91 @@ public class DingdangServiceImpl implements DingdangService { |
|
|
return bo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public UnionResponseBO addBigData(){
|
|
|
int beginTime = 1486339800;
|
|
|
int endTime = 1486366200;
|
|
|
try{
|
|
|
List<UnionActivityLogs> unionActivityLogsList = unionActivityLogsDAO.selectByTime(beginTime,endTime);
|
|
|
for(UnionActivityLogs unionActivityLogs:unionActivityLogsList){
|
|
|
String idfa = unionActivityLogs.getIdfa();
|
|
|
String imei = unionActivityLogs.getImei();
|
|
|
int createTime = unionActivityLogs.getCreateTime();
|
|
|
UnionClickLogs unionClickLogs = null;
|
|
|
if(StringUtils.isNotEmpty(idfa)){
|
|
|
unionClickLogs = unionClickLogsDAO.selectByIdfa(idfa,beginTime,createTime);
|
|
|
}else{
|
|
|
unionClickLogs = unionClickLogsDAO.selectByImei(imei,beginTime,endTime);
|
|
|
}
|
|
|
//如果依然为空,则用td+IP的形式去匹配
|
|
|
String td = unionActivityLogs.getTd();
|
|
|
String ip = unionActivityLogs.getClientIp();
|
|
|
if(null == unionClickLogs){
|
|
|
unionClickLogs = unionClickLogsDAO.selectByTDandIP(td,ip,beginTime,endTime);
|
|
|
if(null == unionClickLogs){
|
|
|
//如果依然为空,则td截取一下
|
|
|
String[] arr = td.split("_");
|
|
|
if (arr.length > 3) {
|
|
|
td = (arr[2] + "_" + arr[3]);
|
|
|
unionClickLogs = unionClickLogsDAO.selectByTDandIP(td,ip,beginTime,endTime);
|
|
|
}
|
|
|
if(unionClickLogs == null){
|
|
|
if(arr.length==3){
|
|
|
td = (arr[1]+"_"+arr[2]);
|
|
|
unionClickLogs = unionClickLogsDAO.selectByTDandIP(td,ip,beginTime,endTime);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//如果能找到对应的unionClickLogs,则记录大数据的日志
|
|
|
if(unionClickLogs!=null){
|
|
|
// 记录日志
|
|
|
JSONObject j = new JSONObject();
|
|
|
String dateid = DateUtil.timeStamp2Date(String.valueOf(createTime), "yyyy-MM-dd HH:mm:ss");
|
|
|
String unionType = unionClickLogs.getUnionType();
|
|
|
String unionTypekey = "yh:union:uniontype:"+unionType;
|
|
|
MktMarketingUrl mktMarketingUrl = redisValueCache.get(unionTypekey,MktMarketingUrl.class);
|
|
|
if(mktMarketingUrl==null){
|
|
|
mktMarketingUrl = mktMarketingUrlDAO.selectByPrimaryKey(Long.valueOf(unionType));
|
|
|
redisValueCache.set(unionTypekey,mktMarketingUrl,1, TimeUnit.HOURS);
|
|
|
}
|
|
|
String clientType = null;
|
|
|
if(StringUtils.isNotEmpty(unionActivityLogs.getIdfa())){
|
|
|
clientType = "ios";
|
|
|
}else{
|
|
|
clientType = "android";
|
|
|
}
|
|
|
j.put("apptype", clientType);
|
|
|
j.put("appid", unionActivityLogs.getAppId());
|
|
|
j.put("idfa", unionActivityLogs.getIdfa());
|
|
|
j.put("imei", unionActivityLogs.getImei());
|
|
|
j.put("udid", unionActivityLogs.getUdid());
|
|
|
j.put("dateid", dateid);
|
|
|
j.put("source", mktMarketingUrl == null ? "" : mktMarketingUrl.getName());
|
|
|
j.put("source_id",unionClickLogs.getUnionType());
|
|
|
j.put("ip", unionActivityLogs.getClientIp());
|
|
|
j.put("collect_ip", "");
|
|
|
j.put("app_key", unionActivityLogs.getAppKey());
|
|
|
j.put("active_type", "90");
|
|
|
j.put("tdid", "");
|
|
|
//打印90天的大数据日志
|
|
|
activeDingdang.info(j.toString());
|
|
|
|
|
|
j.put("active_type", "15");
|
|
|
//打印15天的大数据日志
|
|
|
activeDingdang.info(j.toString());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
log.error("addBigData exception is ",e.getMessage());
|
|
|
}
|
|
|
UnionResponseBO response = new UnionResponseBO();
|
|
|
response.setMsg("success");
|
|
|
response.setIsSuccess(true);
|
|
|
return response;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|