Authored by zhengwen.ge

Merge branch 'master' into 通过Kafak获取数据上报

... ... @@ -38,14 +38,14 @@ public class RedisValueCache {
* @param key
* @param value
*/
public <T> void set(String key, T value) {
String v = RedisUtil.value2String(value);
if (v == null) {
log.warn("set redis error with key={}, value={}", key, value);
return;
}
yhValueOperations.set(key, v);
}
// public <T> void set(String key, T value) {
// String v = RedisUtil.value2String(value);
// if (v == null) {
// log.warn("set redis error with key={}, value={}", key, value);
// return;
// }
// yhValueOperations.set(key, v);
// }
/**
* 设置
... ...
... ... @@ -95,4 +95,20 @@ public class CommonJumpReqVO {
public void setUnion_type(String union_type) {
this.union_type = union_type;
}
@Override
public String toString() {
return "CommonJumpReqVO{" +
"client_id='" + client_id + '\'' +
", union_type='" + union_type + '\'' +
", channel_code='" + channel_code + '\'' +
", go_url='" + go_url + '\'' +
", utm_source='" + utm_source + '\'' +
", utm_medium='" + utm_medium + '\'' +
", utm_campaign='" + utm_campaign + '\'' +
", u_id='" + u_id + '\'' +
", union_data='" + union_data + '\'' +
'}';
}
}
... ...
... ... @@ -25,6 +25,7 @@
<result column="union_name" property="unionName" jdbcType="VARCHAR"/>
<result column="idfa_count" property="idfaCount" jdbcType="INTEGER"/>
<result column="imei_count" property="imeiCount" jdbcType="INTEGER"/>
<result column="total_count" property="totalCount" jdbcType="INTEGER"/>
</resultMap>
<resultMap id="YHActivateMap" type="com.yoho.service.model.union.response.YHActivateDeviceIdRspBO">
<result column="union_type" property="unionType" jdbcType="VARCHAR"/>
... ... @@ -148,7 +149,7 @@
</select>
<select id="selectListByParam" resultMap="ActivateMap"
parameterType="com.yoho.service.model.union.request.ActivateDeviceIdReqBO">
select union_type,union_name,count(idfa) as idfa_count,count(imei) as imei_count
select union_type,union_name,count(*) as total_count, count(idfa) as idfa_count,count(imei) as imei_count
from union_logs
where 1=1
<if test="interfaceType != null and interfaceType !='' ">
... ... @@ -164,7 +165,7 @@
and union_type = #{unionType}
</if>
group by union_type
order by count(idfa) desc,count(imei) desc
order by count(*) desc,count(idfa) desc
</select>
<select id="matchIdfa" resultMap="BaseResultMap">
select
... ...
... ... @@ -5,7 +5,7 @@
<parent>
<groupId>com.yoho</groupId>
<artifactId>parent</artifactId>
<version>1.2.2-SNAPSHOT</version>
<version>1.2.3-SNAPSHOT</version>
</parent>
<groupId>com.yoho.dsf</groupId>
<artifactId>yoho-unions</artifactId>
... ...
... ... @@ -343,8 +343,7 @@ public class TencentMktServiceImpl implements ITencentMktService {
}
activityBO = TencentMktActivityConvert.db2bo(db);
yhValueOperations.set(getCacheKey(activityCode), CacheKeyHelper.value2String(activityBO));
yhRedisTemplate.longExpire(getCacheKey(activityCode), 1, TimeUnit.MINUTES);
yhValueOperations.set(getCacheKey(activityCode), CacheKeyHelper.value2String(activityBO), 1, TimeUnit.MINUTES);
log.debug("tencent mkt activity, activityId: {}, activityName: {}", activityBO.getId(), activityBO.getActivityName());
return activityBO;
... ...
... ... @@ -78,10 +78,14 @@ public class ActivateUnionRest {
vo.setClient_type(ClientTypeEnum.IOS.getName());
}
String agent = request.getHeader("user-agent");
if(StringUtils.isEmpty(agent) && StringUtils.isEmpty(vo.getTd())){
log.warn("activateUnion failed. user-agent is null. agent is {}, request vo is {}", agent, vo);
return new UnionResponse(200,"success","user-agent is null");
}
String clientType = vo.getClient_type();
log.info("addMonitor user-agent={}", agent);
String[] arr = agent.split(";");
if (StringUtils.isEmpty(vo.getTd()) && StringUtils.isNotEmpty(agent) && ClientTypeEnum.IOS.getName().equalsIgnoreCase(clientType)) {
String[] arr = (null == agent)? null : agent.split(";");
if (StringUtils.isEmpty(vo.getTd()) && StringUtils.isNotEmpty(agent) && ClientTypeEnum.IOS.getName().equalsIgnoreCase(clientType) && (null != arr)) {
for (String str : arr) {
if (str.indexOf("OS/iOS") >= 0) {
String version = str.substring(str.indexOf("OS/iOS") + 6);
... ...
... ... @@ -36,9 +36,8 @@ public class MobvistaServiceImpl implements IMobvistaService {
//保存到缓存中,有效期one day
String key = UNION_KEY + "_" + req.getIp();
log.info("mobvista set redis with req={}", req);
yhValueOperations.set(key, JSON.toJSONString(req));
DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty("activeTime", 24 * 60 * 60);
yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.SECONDS);
yhValueOperations.set(key, JSON.toJSONString(req), activeTime.get(), TimeUnit.SECONDS);
log.info("mobvista set redis success with request={}", req);
}
... ...
... ... @@ -164,18 +164,9 @@ public class RedirectServiceImpl implements IRedirectService {
private String builderCommonUrl(CommonJumpReqVO commonJumpReqVO){
logger.info("builderCommonUrl request is {}", commonJumpReqVO);
String go_url = commonJumpReqVO.getGo_url();
// if (StringUtils.isNotBlank(go_url)){
// try{
// StringBuilder goUrlTemp = new StringBuilder();
// goUrlTemp.append(go_url.substring(0,go_url.lastIndexOf("/")+1));
// goUrlTemp.append(URLEncoder.encode(go_url.substring(go_url.lastIndexOf("/")+1),"UTF-8"));
// go_url = goUrlTemp.toString();
// }catch (UnsupportedEncodingException e){
// logger.error("builderCommonUrl go_url is {}", go_url);
// }
// }
if(StringUtils.isEmpty(go_url)){
go_url = "http://www.yohobuy.com";
}
//如果go_url没有http:需要代码加上,不然301跳转不过去
StringBuffer bf = new StringBuffer();
if(!go_url.startsWith("http")){
... ... @@ -183,7 +174,6 @@ public class RedirectServiceImpl implements IRedirectService {
}
StringBuffer targetUrl = new StringBuffer(go_url);
targetUrl = StringUtils.isEmpty(targetUrl) ? new StringBuffer(WAP_URL) : targetUrl;
// String redirectUrl = null;
if(targetUrl.toString().contains("?")){
targetUrl.append("&union_type=").append(commonJumpReqVO.getUnion_type());
}else {
... ...
... ... @@ -205,31 +205,17 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
//保存到缓存中,根据不同的厂商,设置不同的有效期,3:
// log.info("clickUnion set redis with key={}, value={}", key, JSON.toJSONString(request));
clickUnion.info("clickUnion set redis with key={}, value={}", key, JSON.toJSONString(request));
yhValueOperations.set(key, JSON.toJSONString(request));
String invalidTime = "activeTime"+"_"+request.getUnion_type();
// 有效时间改成5天
DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty(invalidTime, 5 * 24);
yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS);
yhValueOperations.set(key, JSON.toJSONString(request), activeTime.get(), TimeUnit.HOURS);
//把IP作为key,也保存到redis
key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getAppkey();
yhValueOperations.set(key, JSON.toJSONString(request));
yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS);
yhValueOperations.set(key, JSON.toJSONString(request), activeTime.get(), TimeUnit.HOURS);
clickUnion.info("clickUnion set redis second success. with key={}, value={}", key, JSON.toJSONString(request));
// UnionActivityTrans unionActivityTrans = new UnionActivityTrans();
// List<UnionActivityTrans> list = new ArrayList<>();
// for(int i=0;i<3;i++){
// UnionActivityTrans unionActivityTrans = new UnionActivityTrans();
// unionActivityTrans.setOrdercode("123");
// unionActivityTrans.setUdid("234");
// unionActivityTrans.setOrderAmount(new BigDecimal(12));
// unionActivityTrans.setUid("12");
// list.add(unionActivityTrans);
// }
// redisListCache.rightPushAll("UNION:KEY:123",list,activeTime.get(),TimeUnit.HOURS);
return new UnionResponse();
} catch (Exception e) {
log.error("clickUnion error with request={}", request, e);
... ... @@ -417,10 +403,10 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
app_key = "yohomars_ios";
}
List<AppActivateIdfaList> _90DayIdfaList = appActivateIdfaListDAO.selectByUdidAndDate(new AppActivateIdfaList(Long.valueOf(yesterday), request.getUdid(), app_key));
activeUnion.info("check ios active info in 90 days. udid is {} and app_key is {},yesterday is {} and result is {}", request.getUdid(), app_key, yesterday, (_90DayIdfaList.isEmpty())? "null": _90DayIdfaList.get(0));
activeUnion.info("check ios active info in 90 days. udid is {} and app_key is {},yesterday is {} and result is {}", request.getUdid(), app_key, yesterday, (_90DayIdfaList.isEmpty() || _90DayIdfaList.size() == 0)? "null": _90DayIdfaList.get(0));
List<AppActivateIdfaList> _15DayIdfaList = appActivateIdfaListDAO.select15DaysByIdfaAndDate(new AppActivateIdfaList(Long.valueOf(yesterday), request.getIdfa(), app_key, null));
activeUnion.info("check ios active info in 15 days. udid is {} and app_key is {},yesterday is {} and result is {}", request.getUdid(), app_key, yesterday, (_90DayIdfaList.isEmpty())? "null": _15DayIdfaList.get(0));
activeUnion.info("check ios active info in 15 days. udid is {} and app_key is {},yesterday is {} and result is {}", request.getUdid(), app_key, yesterday, (_15DayIdfaList.isEmpty() || _15DayIdfaList.size() == 0)? "null": _15DayIdfaList.get(0));
//判断90天内是否在大数据有记录
if (CollectionUtils.isNotEmpty(_90DayIdfaList)) {
... ... @@ -471,8 +457,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
try{
DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty("activeTime_pay_channel", 90);
String payChannelKey = UNION_PAY_CHANNEL_KEY_PRE + request.getUdid();
yhValueOperations.set(payChannelKey, request.getClient_type());
yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.DAYS);
yhValueOperations.set(payChannelKey, request.getClient_type(), activeTime.get(), TimeUnit.DAYS);
}catch (Exception e){
log.warn("set redis cache error, udid is {}, client_type is {}", request.getUdid(), request.getClient_type());
}
... ... @@ -638,7 +623,11 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
//(1).查询出各渠道激活的设备id数
List<ActivateDeviceIdRspBO> activateDeviceIdRspList = unionLogsDAO.selectListByParam(activateDeviceIdReqBO);
// if(null != activateDeviceIdRspList && activateDeviceIdRspList.size() > 0){
// for(ActivateDeviceIdRspBO rspBO: activateDeviceIdRspList){
// rspBO.setTotalCount(rspBO.getIdfaCount() + rspBO.getImeiCount());
// }
// }
// int total = unionLogsDAO.selectListCountByParam(activateDeviceIdReqBO);
// if(total>0){
// activateDeviceIdRspList = unionLogsDAO.selectListByParam(activateDeviceIdReqBO);
... ...
... ... @@ -45,7 +45,7 @@ public class PinYouTask {
/**
* 每天早上6点执行
*/
@Scheduled(cron = "0 0/2 6,7 * * ?")
@Scheduled(cron = "0 0/10 6,9 * * ?")
public void run(){
log.info("begin run pinyoutask");
DynamicStringProperty taskHostPro = DynamicPropertyFactory.getInstance().getStringProperty("union.host", "172.31.16.99");
... ...
... ... @@ -229,11 +229,21 @@
width: 250,
align: "center"
}, {
title: "激活总数",
field: "totalCount",
width: 180,
align: "center"
},{
title: "激活IOS数",
field: "idfaCount",
width: 180,
align: "center"
}, {
title: "激活安卓数",
field: "imeiCount",
width: 180,
align: "center"
},{
title: "点击IOS数",
field: "idfaClick",
width: 180,
... ... @@ -243,11 +253,6 @@
return str;
}
}, {
title: "激活安卓数",
field: "imeiCount",
width: 180,
align: "center"
}, {
title: "点击安卓数",
field: "imeiClick",
width: 180,
... ... @@ -354,6 +359,7 @@
$('#activateTalbe').datagrid('appendRow', {
unionType: '<span class="subtotal">统计</span>',
unionName: '<span class="subtotal"></span>',
totalCount: '<span class="subtotal">' + compute("totalCount") + '</span>',
idfaCount: '<span class="subtotal">' + compute("idfaCount") + '</span>',
idfaClick: '<span class="subtotal">0</span>',
imeiCount: '<span class="subtotal">' + compute("imeiCount") + '</span>',
... ...