Authored by zhengwen.ge

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

@@ -38,14 +38,14 @@ public class RedisValueCache { @@ -38,14 +38,14 @@ public class RedisValueCache {
38 * @param key 38 * @param key
39 * @param value 39 * @param value
40 */ 40 */
41 - public <T> void set(String key, T value) {  
42 - String v = RedisUtil.value2String(value);  
43 - if (v == null) {  
44 - log.warn("set redis error with key={}, value={}", key, value);  
45 - return;  
46 - }  
47 - yhValueOperations.set(key, v);  
48 - } 41 +// public <T> void set(String key, T value) {
  42 +// String v = RedisUtil.value2String(value);
  43 +// if (v == null) {
  44 +// log.warn("set redis error with key={}, value={}", key, value);
  45 +// return;
  46 +// }
  47 +// yhValueOperations.set(key, v);
  48 +// }
49 49
50 /** 50 /**
51 * 设置 51 * 设置
@@ -95,4 +95,20 @@ public class CommonJumpReqVO { @@ -95,4 +95,20 @@ public class CommonJumpReqVO {
95 public void setUnion_type(String union_type) { 95 public void setUnion_type(String union_type) {
96 this.union_type = union_type; 96 this.union_type = union_type;
97 } 97 }
  98 +
  99 +
  100 + @Override
  101 + public String toString() {
  102 + return "CommonJumpReqVO{" +
  103 + "client_id='" + client_id + '\'' +
  104 + ", union_type='" + union_type + '\'' +
  105 + ", channel_code='" + channel_code + '\'' +
  106 + ", go_url='" + go_url + '\'' +
  107 + ", utm_source='" + utm_source + '\'' +
  108 + ", utm_medium='" + utm_medium + '\'' +
  109 + ", utm_campaign='" + utm_campaign + '\'' +
  110 + ", u_id='" + u_id + '\'' +
  111 + ", union_data='" + union_data + '\'' +
  112 + '}';
  113 + }
98 } 114 }
@@ -25,6 +25,7 @@ @@ -25,6 +25,7 @@
25 <result column="union_name" property="unionName" jdbcType="VARCHAR"/> 25 <result column="union_name" property="unionName" jdbcType="VARCHAR"/>
26 <result column="idfa_count" property="idfaCount" jdbcType="INTEGER"/> 26 <result column="idfa_count" property="idfaCount" jdbcType="INTEGER"/>
27 <result column="imei_count" property="imeiCount" jdbcType="INTEGER"/> 27 <result column="imei_count" property="imeiCount" jdbcType="INTEGER"/>
  28 + <result column="total_count" property="totalCount" jdbcType="INTEGER"/>
28 </resultMap> 29 </resultMap>
29 <resultMap id="YHActivateMap" type="com.yoho.service.model.union.response.YHActivateDeviceIdRspBO"> 30 <resultMap id="YHActivateMap" type="com.yoho.service.model.union.response.YHActivateDeviceIdRspBO">
30 <result column="union_type" property="unionType" jdbcType="VARCHAR"/> 31 <result column="union_type" property="unionType" jdbcType="VARCHAR"/>
@@ -148,7 +149,7 @@ @@ -148,7 +149,7 @@
148 </select> 149 </select>
149 <select id="selectListByParam" resultMap="ActivateMap" 150 <select id="selectListByParam" resultMap="ActivateMap"
150 parameterType="com.yoho.service.model.union.request.ActivateDeviceIdReqBO"> 151 parameterType="com.yoho.service.model.union.request.ActivateDeviceIdReqBO">
151 - select union_type,union_name,count(idfa) as idfa_count,count(imei) as imei_count 152 + select union_type,union_name,count(*) as total_count, count(idfa) as idfa_count,count(imei) as imei_count
152 from union_logs 153 from union_logs
153 where 1=1 154 where 1=1
154 <if test="interfaceType != null and interfaceType !='' "> 155 <if test="interfaceType != null and interfaceType !='' ">
@@ -164,7 +165,7 @@ @@ -164,7 +165,7 @@
164 and union_type = #{unionType} 165 and union_type = #{unionType}
165 </if> 166 </if>
166 group by union_type 167 group by union_type
167 - order by count(idfa) desc,count(imei) desc 168 + order by count(*) desc,count(idfa) desc
168 </select> 169 </select>
169 <select id="matchIdfa" resultMap="BaseResultMap"> 170 <select id="matchIdfa" resultMap="BaseResultMap">
170 select 171 select
@@ -5,7 +5,7 @@ @@ -5,7 +5,7 @@
5 <parent> 5 <parent>
6 <groupId>com.yoho</groupId> 6 <groupId>com.yoho</groupId>
7 <artifactId>parent</artifactId> 7 <artifactId>parent</artifactId>
8 - <version>1.2.2-SNAPSHOT</version> 8 + <version>1.2.3-SNAPSHOT</version>
9 </parent> 9 </parent>
10 <groupId>com.yoho.dsf</groupId> 10 <groupId>com.yoho.dsf</groupId>
11 <artifactId>yoho-unions</artifactId> 11 <artifactId>yoho-unions</artifactId>
@@ -343,8 +343,7 @@ public class TencentMktServiceImpl implements ITencentMktService { @@ -343,8 +343,7 @@ public class TencentMktServiceImpl implements ITencentMktService {
343 } 343 }
344 344
345 activityBO = TencentMktActivityConvert.db2bo(db); 345 activityBO = TencentMktActivityConvert.db2bo(db);
346 - yhValueOperations.set(getCacheKey(activityCode), CacheKeyHelper.value2String(activityBO));  
347 - yhRedisTemplate.longExpire(getCacheKey(activityCode), 1, TimeUnit.MINUTES); 346 + yhValueOperations.set(getCacheKey(activityCode), CacheKeyHelper.value2String(activityBO), 1, TimeUnit.MINUTES);
348 347
349 log.debug("tencent mkt activity, activityId: {}, activityName: {}", activityBO.getId(), activityBO.getActivityName()); 348 log.debug("tencent mkt activity, activityId: {}, activityName: {}", activityBO.getId(), activityBO.getActivityName());
350 return activityBO; 349 return activityBO;
@@ -78,10 +78,14 @@ public class ActivateUnionRest { @@ -78,10 +78,14 @@ public class ActivateUnionRest {
78 vo.setClient_type(ClientTypeEnum.IOS.getName()); 78 vo.setClient_type(ClientTypeEnum.IOS.getName());
79 } 79 }
80 String agent = request.getHeader("user-agent"); 80 String agent = request.getHeader("user-agent");
  81 + if(StringUtils.isEmpty(agent) && StringUtils.isEmpty(vo.getTd())){
  82 + log.warn("activateUnion failed. user-agent is null. agent is {}, request vo is {}", agent, vo);
  83 + return new UnionResponse(200,"success","user-agent is null");
  84 + }
81 String clientType = vo.getClient_type(); 85 String clientType = vo.getClient_type();
82 log.info("addMonitor user-agent={}", agent); 86 log.info("addMonitor user-agent={}", agent);
83 - String[] arr = agent.split(";");  
84 - if (StringUtils.isEmpty(vo.getTd()) && StringUtils.isNotEmpty(agent) && ClientTypeEnum.IOS.getName().equalsIgnoreCase(clientType)) { 87 + String[] arr = (null == agent)? null : agent.split(";");
  88 + if (StringUtils.isEmpty(vo.getTd()) && StringUtils.isNotEmpty(agent) && ClientTypeEnum.IOS.getName().equalsIgnoreCase(clientType) && (null != arr)) {
85 for (String str : arr) { 89 for (String str : arr) {
86 if (str.indexOf("OS/iOS") >= 0) { 90 if (str.indexOf("OS/iOS") >= 0) {
87 String version = str.substring(str.indexOf("OS/iOS") + 6); 91 String version = str.substring(str.indexOf("OS/iOS") + 6);
@@ -36,9 +36,8 @@ public class MobvistaServiceImpl implements IMobvistaService { @@ -36,9 +36,8 @@ public class MobvistaServiceImpl implements IMobvistaService {
36 //保存到缓存中,有效期one day 36 //保存到缓存中,有效期one day
37 String key = UNION_KEY + "_" + req.getIp(); 37 String key = UNION_KEY + "_" + req.getIp();
38 log.info("mobvista set redis with req={}", req); 38 log.info("mobvista set redis with req={}", req);
39 - yhValueOperations.set(key, JSON.toJSONString(req));  
40 DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty("activeTime", 24 * 60 * 60); 39 DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty("activeTime", 24 * 60 * 60);
41 - yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.SECONDS); 40 + yhValueOperations.set(key, JSON.toJSONString(req), activeTime.get(), TimeUnit.SECONDS);
42 log.info("mobvista set redis success with request={}", req); 41 log.info("mobvista set redis success with request={}", req);
43 } 42 }
44 43
@@ -164,18 +164,9 @@ public class RedirectServiceImpl implements IRedirectService { @@ -164,18 +164,9 @@ public class RedirectServiceImpl implements IRedirectService {
164 private String builderCommonUrl(CommonJumpReqVO commonJumpReqVO){ 164 private String builderCommonUrl(CommonJumpReqVO commonJumpReqVO){
165 logger.info("builderCommonUrl request is {}", commonJumpReqVO); 165 logger.info("builderCommonUrl request is {}", commonJumpReqVO);
166 String go_url = commonJumpReqVO.getGo_url(); 166 String go_url = commonJumpReqVO.getGo_url();
167 -  
168 -// if (StringUtils.isNotBlank(go_url)){  
169 -// try{  
170 -// StringBuilder goUrlTemp = new StringBuilder();  
171 -// goUrlTemp.append(go_url.substring(0,go_url.lastIndexOf("/")+1));  
172 -// goUrlTemp.append(URLEncoder.encode(go_url.substring(go_url.lastIndexOf("/")+1),"UTF-8"));  
173 -// go_url = goUrlTemp.toString();  
174 -// }catch (UnsupportedEncodingException e){  
175 -// logger.error("builderCommonUrl go_url is {}", go_url);  
176 -// }  
177 -// }  
178 - 167 + if(StringUtils.isEmpty(go_url)){
  168 + go_url = "http://www.yohobuy.com";
  169 + }
179 //如果go_url没有http:需要代码加上,不然301跳转不过去 170 //如果go_url没有http:需要代码加上,不然301跳转不过去
180 StringBuffer bf = new StringBuffer(); 171 StringBuffer bf = new StringBuffer();
181 if(!go_url.startsWith("http")){ 172 if(!go_url.startsWith("http")){
@@ -183,7 +174,6 @@ public class RedirectServiceImpl implements IRedirectService { @@ -183,7 +174,6 @@ public class RedirectServiceImpl implements IRedirectService {
183 } 174 }
184 StringBuffer targetUrl = new StringBuffer(go_url); 175 StringBuffer targetUrl = new StringBuffer(go_url);
185 targetUrl = StringUtils.isEmpty(targetUrl) ? new StringBuffer(WAP_URL) : targetUrl; 176 targetUrl = StringUtils.isEmpty(targetUrl) ? new StringBuffer(WAP_URL) : targetUrl;
186 -// String redirectUrl = null;  
187 if(targetUrl.toString().contains("?")){ 177 if(targetUrl.toString().contains("?")){
188 targetUrl.append("&union_type=").append(commonJumpReqVO.getUnion_type()); 178 targetUrl.append("&union_type=").append(commonJumpReqVO.getUnion_type());
189 }else { 179 }else {
@@ -205,31 +205,17 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher @@ -205,31 +205,17 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
205 //保存到缓存中,根据不同的厂商,设置不同的有效期,3: 205 //保存到缓存中,根据不同的厂商,设置不同的有效期,3:
206 // log.info("clickUnion set redis with key={}, value={}", key, JSON.toJSONString(request)); 206 // log.info("clickUnion set redis with key={}, value={}", key, JSON.toJSONString(request));
207 clickUnion.info("clickUnion set redis with key={}, value={}", key, JSON.toJSONString(request)); 207 clickUnion.info("clickUnion set redis with key={}, value={}", key, JSON.toJSONString(request));
208 - yhValueOperations.set(key, JSON.toJSONString(request)); 208 +
209 String invalidTime = "activeTime"+"_"+request.getUnion_type(); 209 String invalidTime = "activeTime"+"_"+request.getUnion_type();
210 // 有效时间改成5天 210 // 有效时间改成5天
211 DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty(invalidTime, 5 * 24); 211 DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty(invalidTime, 5 * 24);
212 - yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS);  
213 -  
214 - 212 + yhValueOperations.set(key, JSON.toJSONString(request), activeTime.get(), TimeUnit.HOURS);
  213 +
215 //把IP作为key,也保存到redis 214 //把IP作为key,也保存到redis
216 key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getAppkey(); 215 key = UNION_KEY + "_" + request.getClientIp() + "_" + request.getAppkey();
217 - yhValueOperations.set(key, JSON.toJSONString(request));  
218 - yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.HOURS); 216 + yhValueOperations.set(key, JSON.toJSONString(request), activeTime.get(), TimeUnit.HOURS);
219 clickUnion.info("clickUnion set redis second success. with key={}, value={}", key, JSON.toJSONString(request)); 217 clickUnion.info("clickUnion set redis second success. with key={}, value={}", key, JSON.toJSONString(request));
220 218
221 -// UnionActivityTrans unionActivityTrans = new UnionActivityTrans();  
222 -// List<UnionActivityTrans> list = new ArrayList<>();  
223 -// for(int i=0;i<3;i++){  
224 -// UnionActivityTrans unionActivityTrans = new UnionActivityTrans();  
225 -// unionActivityTrans.setOrdercode("123");  
226 -// unionActivityTrans.setUdid("234");  
227 -// unionActivityTrans.setOrderAmount(new BigDecimal(12));  
228 -// unionActivityTrans.setUid("12");  
229 -// list.add(unionActivityTrans);  
230 -// }  
231 -// redisListCache.rightPushAll("UNION:KEY:123",list,activeTime.get(),TimeUnit.HOURS);  
232 -  
233 return new UnionResponse(); 219 return new UnionResponse();
234 } catch (Exception e) { 220 } catch (Exception e) {
235 log.error("clickUnion error with request={}", request, e); 221 log.error("clickUnion error with request={}", request, e);
@@ -417,10 +403,10 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher @@ -417,10 +403,10 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
417 app_key = "yohomars_ios"; 403 app_key = "yohomars_ios";
418 } 404 }
419 List<AppActivateIdfaList> _90DayIdfaList = appActivateIdfaListDAO.selectByUdidAndDate(new AppActivateIdfaList(Long.valueOf(yesterday), request.getUdid(), app_key)); 405 List<AppActivateIdfaList> _90DayIdfaList = appActivateIdfaListDAO.selectByUdidAndDate(new AppActivateIdfaList(Long.valueOf(yesterday), request.getUdid(), app_key));
420 - 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)); 406 + 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));
421 407
422 List<AppActivateIdfaList> _15DayIdfaList = appActivateIdfaListDAO.select15DaysByIdfaAndDate(new AppActivateIdfaList(Long.valueOf(yesterday), request.getIdfa(), app_key, null)); 408 List<AppActivateIdfaList> _15DayIdfaList = appActivateIdfaListDAO.select15DaysByIdfaAndDate(new AppActivateIdfaList(Long.valueOf(yesterday), request.getIdfa(), app_key, null));
423 - 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)); 409 + 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));
424 410
425 //判断90天内是否在大数据有记录 411 //判断90天内是否在大数据有记录
426 if (CollectionUtils.isNotEmpty(_90DayIdfaList)) { 412 if (CollectionUtils.isNotEmpty(_90DayIdfaList)) {
@@ -471,8 +457,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher @@ -471,8 +457,7 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
471 try{ 457 try{
472 DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty("activeTime_pay_channel", 90); 458 DynamicIntProperty activeTime = DynamicPropertyFactory.getInstance().getIntProperty("activeTime_pay_channel", 90);
473 String payChannelKey = UNION_PAY_CHANNEL_KEY_PRE + request.getUdid(); 459 String payChannelKey = UNION_PAY_CHANNEL_KEY_PRE + request.getUdid();
474 - yhValueOperations.set(payChannelKey, request.getClient_type());  
475 - yHRedisTemplate.longExpire(key, activeTime.get(), TimeUnit.DAYS); 460 + yhValueOperations.set(payChannelKey, request.getClient_type(), activeTime.get(), TimeUnit.DAYS);
476 }catch (Exception e){ 461 }catch (Exception e){
477 log.warn("set redis cache error, udid is {}, client_type is {}", request.getUdid(), request.getClient_type()); 462 log.warn("set redis cache error, udid is {}, client_type is {}", request.getUdid(), request.getClient_type());
478 } 463 }
@@ -638,7 +623,11 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher @@ -638,7 +623,11 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
638 //(1).查询出各渠道激活的设备id数 623 //(1).查询出各渠道激活的设备id数
639 List<ActivateDeviceIdRspBO> activateDeviceIdRspList = unionLogsDAO.selectListByParam(activateDeviceIdReqBO); 624 List<ActivateDeviceIdRspBO> activateDeviceIdRspList = unionLogsDAO.selectListByParam(activateDeviceIdReqBO);
640 625
641 - 626 +// if(null != activateDeviceIdRspList && activateDeviceIdRspList.size() > 0){
  627 +// for(ActivateDeviceIdRspBO rspBO: activateDeviceIdRspList){
  628 +// rspBO.setTotalCount(rspBO.getIdfaCount() + rspBO.getImeiCount());
  629 +// }
  630 +// }
642 // int total = unionLogsDAO.selectListCountByParam(activateDeviceIdReqBO); 631 // int total = unionLogsDAO.selectListCountByParam(activateDeviceIdReqBO);
643 // if(total>0){ 632 // if(total>0){
644 // activateDeviceIdRspList = unionLogsDAO.selectListByParam(activateDeviceIdReqBO); 633 // activateDeviceIdRspList = unionLogsDAO.selectListByParam(activateDeviceIdReqBO);
@@ -45,7 +45,7 @@ public class PinYouTask { @@ -45,7 +45,7 @@ public class PinYouTask {
45 /** 45 /**
46 * 每天早上6点执行 46 * 每天早上6点执行
47 */ 47 */
48 - @Scheduled(cron = "0 0/2 6,7 * * ?") 48 + @Scheduled(cron = "0 0/10 6,9 * * ?")
49 public void run(){ 49 public void run(){
50 log.info("begin run pinyoutask"); 50 log.info("begin run pinyoutask");
51 DynamicStringProperty taskHostPro = DynamicPropertyFactory.getInstance().getStringProperty("union.host", "172.31.16.99"); 51 DynamicStringProperty taskHostPro = DynamicPropertyFactory.getInstance().getStringProperty("union.host", "172.31.16.99");
@@ -228,12 +228,22 @@ @@ -228,12 +228,22 @@
228 field: "unionName", 228 field: "unionName",
229 width: 250, 229 width: 250,
230 align: "center" 230 align: "center"
231 - }, { 231 + }, {
  232 + title: "激活总数",
  233 + field: "totalCount",
  234 + width: 180,
  235 + align: "center"
  236 + },{
232 title: "激活IOS数", 237 title: "激活IOS数",
233 field: "idfaCount", 238 field: "idfaCount",
234 width: 180, 239 width: 180,
235 align: "center" 240 align: "center"
236 - }, { 241 + }, {
  242 + title: "激活安卓数",
  243 + field: "imeiCount",
  244 + width: 180,
  245 + align: "center"
  246 + },{
237 title: "点击IOS数", 247 title: "点击IOS数",
238 field: "idfaClick", 248 field: "idfaClick",
239 width: 180, 249 width: 180,
@@ -243,11 +253,6 @@ @@ -243,11 +253,6 @@
243 return str; 253 return str;
244 } 254 }
245 }, { 255 }, {
246 - title: "激活安卓数",  
247 - field: "imeiCount",  
248 - width: 180,  
249 - align: "center"  
250 - }, {  
251 title: "点击安卓数", 256 title: "点击安卓数",
252 field: "imeiClick", 257 field: "imeiClick",
253 width: 180, 258 width: 180,
@@ -354,6 +359,7 @@ @@ -354,6 +359,7 @@
354 $('#activateTalbe').datagrid('appendRow', { 359 $('#activateTalbe').datagrid('appendRow', {
355 unionType: '<span class="subtotal">统计</span>', 360 unionType: '<span class="subtotal">统计</span>',
356 unionName: '<span class="subtotal"></span>', 361 unionName: '<span class="subtotal"></span>',
  362 + totalCount: '<span class="subtotal">' + compute("totalCount") + '</span>',
357 idfaCount: '<span class="subtotal">' + compute("idfaCount") + '</span>', 363 idfaCount: '<span class="subtotal">' + compute("idfaCount") + '</span>',
358 idfaClick: '<span class="subtotal">0</span>', 364 idfaClick: '<span class="subtotal">0</span>',
359 imeiCount: '<span class="subtotal">' + compute("imeiCount") + '</span>', 365 imeiCount: '<span class="subtotal">' + compute("imeiCount") + '</span>',