Authored by zhengwen.ge

IP优化有两个只取第一个

@@ -99,7 +99,11 @@ public class ActivateUnionRest { @@ -99,7 +99,11 @@ public class ActivateUnionRest {
99 log.warn("activateUnion error with param is {}", vo); 99 log.warn("activateUnion error with param is {}", vo);
100 return new ActiveUnionResponseBO(600, "error"); 100 return new ActiveUnionResponseBO(600, "error");
101 } 101 }
102 - bo.setClientIp(RemoteIPInterceptor.getRemoteIP()); 102 + //IP取出来的有可能是42.239.40.36,123.151.42.50,只取第一个
  103 + String IP = RemoteIPInterceptor.getRemoteIP();
  104 + String[] IPS = IP.split(",");
  105 + String clientIp = IPS[0];
  106 + bo.setClientIp(clientIp);
103 //多线程处理 107 //多线程处理
104 exe.execute(new RunActivate(bo)); 108 exe.execute(new RunActivate(bo));
105 return new ActiveUnionResponseBO(200, "success"); 109 return new ActiveUnionResponseBO(200, "success");
@@ -60,7 +60,11 @@ public class ClickUnionRest { @@ -60,7 +60,11 @@ public class ClickUnionRest {
60 if ("iphone".equals(request.getClient_type())) { 60 if ("iphone".equals(request.getClient_type())) {
61 request.setClient_type(ClientTypeEnum.IOS.getName()); 61 request.setClient_type(ClientTypeEnum.IOS.getName());
62 } 62 }
63 - request.setClientIp(RemoteIPInterceptor.getRemoteIP()); 63 + String IP = RemoteIPInterceptor.getRemoteIP();
  64 +// String IP = "42.236.215.29, 123.151.42.48";
  65 + String[] IPS = IP.split(",");
  66 + String clientIp = IPS[0];
  67 + request.setClientIp(clientIp);
64 clickUnion.info("addUnion with param is {}", request); 68 clickUnion.info("addUnion with param is {}", request);
65 UnionResponse response = unionService.clickUnion(request); 69 UnionResponse response = unionService.clickUnion(request);
66 log.info("addUnion with result is {}, and request is {}", response, request); 70 log.info("addUnion with result is {}, and request is {}", response, request);
@@ -85,8 +89,10 @@ public class ClickUnionRest { @@ -85,8 +89,10 @@ public class ClickUnionRest {
85 }else { 89 }else {
86 request = unionService.clickHttpRequestTOBO(httpServletRequest,request); 90 request = unionService.clickHttpRequestTOBO(httpServletRequest,request);
87 } 91 }
88 -  
89 - request.setClientIp(RemoteIPInterceptor.getRemoteIP()); 92 + String IP = RemoteIPInterceptor.getRemoteIP();
  93 + String[] IPS = IP.split(",");
  94 + String clientIp = IPS[0];
  95 + request.setClientIp(clientIp);
90 // IUnionService service = SpringContextUtil.getBean(bean, IUnionService.class); 96 // IUnionService service = SpringContextUtil.getBean(bean, IUnionService.class);
91 clickUnion.info("addCommonUnion request is {}",request); 97 clickUnion.info("addCommonUnion request is {}",request);
92 UnionResponse response = unionService.clickUnion(request); 98 UnionResponse response = unionService.clickUnion(request);
@@ -105,7 +111,10 @@ public class ClickUnionRest { @@ -105,7 +111,10 @@ public class ClickUnionRest {
105 public void addUnion4Special(ClickUnionRequestBO bo, HttpServletRequest request, HttpServletResponse response) { 111 public void addUnion4Special(ClickUnionRequestBO bo, HttpServletRequest request, HttpServletResponse response) {
106 log.info("addUnion4Special with param is {}", bo); 112 log.info("addUnion4Special with param is {}", bo);
107 try { 113 try {
108 - bo.setClientIp(RemoteIPInterceptor.getRemoteIP()); 114 + String IP = RemoteIPInterceptor.getRemoteIP();
  115 + String[] IPS = IP.split(",");
  116 + String clientIp = IPS[0];
  117 + bo.setClientIp(clientIp);
109 String agent = request.getHeader("user-agent"); 118 String agent = request.getHeader("user-agent");
110 log.info("user-agent={}", agent); 119 log.info("user-agent={}", agent);
111 if (StringUtils.isEmpty(agent)) { 120 if (StringUtils.isEmpty(agent)) {
@@ -156,7 +165,10 @@ public class ClickUnionRest { @@ -156,7 +165,10 @@ public class ClickUnionRest {
156 if (StringUtils.isEmpty(bo.getUnion_type())) { 165 if (StringUtils.isEmpty(bo.getUnion_type())) {
157 return; 166 return;
158 } 167 }
159 - bo.setClientIp(RemoteIPInterceptor.getRemoteIP()); 168 + String IP = RemoteIPInterceptor.getRemoteIP();
  169 + String[] IPS = IP.split(",");
  170 + String clientIp = IPS[0];
  171 + bo.setClientIp(clientIp);
160 bo.setClient_type("android"); 172 bo.setClient_type("android");
161 bo.setAppid("com.yoho"); 173 bo.setAppid("com.yoho");
162 String agent = request.getHeader("user-agent"); 174 String agent = request.getHeader("user-agent");
@@ -216,8 +228,11 @@ public class ClickUnionRest { @@ -216,8 +228,11 @@ public class ClickUnionRest {
216 String key = e.nextElement(); 228 String key = e.nextElement();
217 log.info("addMonitor with key={}, value={}", key, request.getParameter(key)); 229 log.info("addMonitor with key={}, value={}", key, request.getParameter(key));
218 } 230 }
  231 + String IP = RemoteIPInterceptor.getRemoteIP();
  232 + String[] IPS = IP.split(",");
  233 + String clientIp = IPS[0];
219 234
220 - bo.setClientIp(RemoteIPInterceptor.getRemoteIP()); 235 + bo.setClientIp(clientIp);
221 String agent = request.getHeader("user-agent"); 236 String agent = request.getHeader("user-agent");
222 log.info("addMonitor user-agent={}", agent); 237 log.info("addMonitor user-agent={}", agent);
223 try{ 238 try{
@@ -65,7 +65,10 @@ public class MobvistaUnionRest { @@ -65,7 +65,10 @@ public class MobvistaUnionRest {
65 req.setAppid("android"); 65 req.setAppid("android");
66 downloadURL = "http://cdn.yoho.cn/app-downfiles/yohoBuy_YOHO_2953.apk"; 66 downloadURL = "http://cdn.yoho.cn/app-downfiles/yohoBuy_YOHO_2953.apk";
67 } 67 }
68 - req.setIp(RemoteIPInterceptor.getRemoteIP()); 68 + String IP = RemoteIPInterceptor.getRemoteIP();
  69 + String[] IPS = IP.split(",");
  70 + String clientIp = IPS[0];
  71 + req.setIp(clientIp);
69 String url = "http://stat.mobvista.com/install?mobvista_pl="+req.getDevice_type()+"&mobvista_campuuid="+req.getUuid()+"" 72 String url = "http://stat.mobvista.com/install?mobvista_pl="+req.getDevice_type()+"&mobvista_campuuid="+req.getUuid()+""
70 + "&mobvista_ip="+req.getIp()+"&mobvista_clickid="+req.getClickid()+"&mobvista_gaid=&mobvista_devid="; 73 + "&mobvista_ip="+req.getIp()+"&mobvista_clickid="+req.getClickid()+"&mobvista_gaid=&mobvista_devid=";
71 req.setCallbackurl(url); 74 req.setCallbackurl(url);
@@ -37,7 +37,11 @@ public interface IUnionService { @@ -37,7 +37,11 @@ public interface IUnionService {
37 clickUnionRequestBO.setUnion_type(request.getParameter("union_type")); 37 clickUnionRequestBO.setUnion_type(request.getParameter("union_type"));
38 clickUnionRequestBO.setImei(request.getParameter("imei")); 38 clickUnionRequestBO.setImei(request.getParameter("imei"));
39 clickUnionRequestBO.setTd(request.getParameter("td")); 39 clickUnionRequestBO.setTd(request.getParameter("td"));
40 - clickUnionRequestBO.setClientIp(RemoteIPInterceptor.getRemoteIP()); 40 +
  41 + String IP = RemoteIPInterceptor.getRemoteIP();
  42 + String[] IPS = IP.split(",");
  43 + String clientIp = IPS[0];
  44 + clickUnionRequestBO.setClientIp(clientIp);
41 45
42 return clickUnionRequestBO; 46 return clickUnionRequestBO;
43 } 47 }