Authored by linlong

Merge branch 'master' into fix_0223

@@ -75,7 +75,7 @@ public class GdtTransTask { @@ -75,7 +75,7 @@ public class GdtTransTask {
75 String url = urlEode(unionActivity,transInfo); 75 String url = urlEode(unionActivity,transInfo);
76 //改成httpclient方式调用 76 //改成httpclient方式调用
77 Pair<Integer, String> pair = HttpUtils.httpGet(url); 77 Pair<Integer, String> pair = HttpUtils.httpGet(url);
78 - log.info("GdtTransTask call union success url={}, and result={}", url, pair); 78 + log.info("GdtTransTask call union success url={},and ordercode is {}, and result={}", url,transInfo.getOrdercode(), pair);
79 if (pair.getLeft() != 200) { 79 if (pair.getLeft() != 200) {
80 log.warn("callback error with request={}", url); 80 log.warn("callback error with request={}", url);
81 } 81 }
1 package com.yoho.unions.server.task; 1 package com.yoho.unions.server.task;
2 2
  3 +import com.netflix.config.DynamicPropertyFactory;
  4 +import com.netflix.config.DynamicStringProperty;
  5 +import com.yoho.core.common.utils.LocalIp;
3 import com.yoho.service.model.union.request.TransPinYouRequestBO; 6 import com.yoho.service.model.union.request.TransPinYouRequestBO;
4 import com.yoho.service.model.union.request.ViewPinYouRequestBO; 7 import com.yoho.service.model.union.request.ViewPinYouRequestBO;
5 import com.yoho.unions.common.redis.RedisListCache; 8 import com.yoho.unions.common.redis.RedisListCache;
@@ -40,14 +43,30 @@ public class PinYouTask { @@ -40,14 +43,30 @@ public class PinYouTask {
40 @Scheduled(cron = "0 0 6 * * ?") 43 @Scheduled(cron = "0 0 6 * * ?")
41 public void run(){ 44 public void run(){
42 log.info("begin run pinyoutask"); 45 log.info("begin run pinyoutask");
  46 + DynamicStringProperty taskHostPro = DynamicPropertyFactory.getInstance().getStringProperty("union.host", "172.31.16.99");
  47 + String localIp = LocalIp.getLocalIp();
  48 + localIp = localIp == null ? "" : localIp;
  49 + String taskHost = taskHostPro.get();
  50 + log.info("ScheduledPinYouTask: localIp is {}, taskHost is {}", localIp, taskHost);
  51 + if(!taskHost.equals(localIp)){
  52 + log.warn("ScheduledPinYouTask service: execute timetask host is not local host");
  53 + return;
  54 + }
43 //从redis里面获取大数据的数据 55 //从redis里面获取大数据的数据
44 Long viewSize = redisListCache.size(UNION_VIEW_KEY); 56 Long viewSize = redisListCache.size(UNION_VIEW_KEY);
45 Long transSize = redisListCache.size(UNION_TRANS_KEY); 57 Long transSize = redisListCache.size(UNION_TRANS_KEY);
46 List<ViewPinYouRequestBO> viewPinYouRequestBOList = new ArrayList<>(); 58 List<ViewPinYouRequestBO> viewPinYouRequestBOList = new ArrayList<>();
47 int viewSizeInt = viewSize == null ? 0 : viewSize.intValue(); 59 int viewSizeInt = viewSize == null ? 0 : viewSize.intValue();
48 int transSizeInt = transSize == null ? 0:transSize.intValue(); 60 int transSizeInt = transSize == null ? 0:transSize.intValue();
49 - log.info("viewSize is {},transSize is {}",viewSizeInt,viewSizeInt); 61 + log.info("viewSize is {},transSize is {}",viewSizeInt,transSizeInt);
50 List<TransPinYouRequestBO> transPinYouRequestBOList = new ArrayList<>(); 62 List<TransPinYouRequestBO> transPinYouRequestBOList = new ArrayList<>();
  63 + if(transSizeInt>0){
  64 + for(int i=0; i < transSizeInt; i++){
  65 + TransPinYouRequestBO transPinYouRequestBO = redisListCache.rightPop(UNION_TRANS_KEY, TransPinYouRequestBO.class);
  66 + log.info("transPinYouRequestBO is {}",transPinYouRequestBO);
  67 + transPinYouRequestBOList.add(transPinYouRequestBO);
  68 + }
  69 + }
51 70
52 if(viewSizeInt>0){ 71 if(viewSizeInt>0){
53 for(int i=0; i < viewSizeInt; i++){ 72 for(int i=0; i < viewSizeInt; i++){
@@ -55,10 +74,11 @@ public class PinYouTask { @@ -55,10 +74,11 @@ public class PinYouTask {
55 viewPinYouRequestBOList.add(viewPinYouRequestBO); 74 viewPinYouRequestBOList.add(viewPinYouRequestBO);
56 } 75 }
57 } 76 }
58 - if(transSizeInt>0){  
59 - for(int i=0; i < transSizeInt; i++){  
60 - TransPinYouRequestBO transPinYouRequestBO = redisListCache.rightPop(UNION_TRANS_KEY, TransPinYouRequestBO.class);  
61 - transPinYouRequestBOList.add(transPinYouRequestBO); 77 +
  78 + if(CollectionUtils.isNotEmpty(transPinYouRequestBOList)){
  79 + log.info("transPinYouRequestBOList size is {}",transPinYouRequestBOList.size());
  80 + for(TransPinYouRequestBO transPinYouRequestBO:transPinYouRequestBOList){
  81 + sendTrans(transPinYouRequestBO);
62 } 82 }
63 } 83 }
64 84
@@ -69,12 +89,6 @@ public class PinYouTask { @@ -69,12 +89,6 @@ public class PinYouTask {
69 } 89 }
70 } 90 }
71 91
72 - if(CollectionUtils.isNotEmpty(transPinYouRequestBOList)){  
73 - log.info("transPinYouRequestBOList size is {}",transPinYouRequestBOList.size());  
74 - for(TransPinYouRequestBO transPinYouRequestBO:transPinYouRequestBOList){  
75 - sendTrans(transPinYouRequestBO);  
76 - }  
77 - }  
78 } 92 }
79 93
80 //给品友推送访问数据 94 //给品友推送访问数据