Showing
7 changed files
with
52 additions
and
24 deletions
@@ -35,7 +35,7 @@ public interface IUnionLogsDAO { | @@ -35,7 +35,7 @@ public interface IUnionLogsDAO { | ||
35 | 35 | ||
36 | List<ActivateDeviceIdRspBO> selectListByParam(ActivateDeviceIdReqBO activateDeviceIdReqBO); | 36 | List<ActivateDeviceIdRspBO> selectListByParam(ActivateDeviceIdReqBO activateDeviceIdReqBO); |
37 | 37 | ||
38 | - List<String> matchIdfa(List<String> list); | 38 | + List<String> matchIdfa(@Param("list") List<String> list,@Param("isIdfa") int isIdfa); |
39 | 39 | ||
40 | - UnionLogs queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO); | 40 | + List<UnionLogs> queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO); |
41 | } | 41 | } |
@@ -157,8 +157,22 @@ | @@ -157,8 +157,22 @@ | ||
157 | group by union_type | 157 | group by union_type |
158 | </select> | 158 | </select> |
159 | <select id="matchIdfa" resultType="java.lang.String"> | 159 | <select id="matchIdfa" resultType="java.lang.String"> |
160 | - select idfa from union_logs | ||
161 | - where idfa in | 160 | + select |
161 | + <if test="isIdfa==1"> | ||
162 | + idfa | ||
163 | + </if> | ||
164 | + <if test="isIdfa==0"> | ||
165 | + imei | ||
166 | + </if> | ||
167 | + from union_logs | ||
168 | + where | ||
169 | + <if test="isIdfa==1"> | ||
170 | + idfa | ||
171 | + </if> | ||
172 | + <if test="isIdfa==0"> | ||
173 | + imei | ||
174 | + </if> | ||
175 | + in | ||
162 | <foreach item="item" index="index" collection="list" open="(" separator="," close=")"> | 176 | <foreach item="item" index="index" collection="list" open="(" separator="," close=")"> |
163 | #{item} | 177 | #{item} |
164 | </foreach> | 178 | </foreach> |
@@ -11,8 +11,7 @@ import javax.servlet.http.HttpServletRequest; | @@ -11,8 +11,7 @@ import javax.servlet.http.HttpServletRequest; | ||
11 | import javax.servlet.http.HttpServletResponse; | 11 | import javax.servlet.http.HttpServletResponse; |
12 | 12 | ||
13 | import com.yoho.service.model.union.request.ActivateDeviceIdReqBO; | 13 | import com.yoho.service.model.union.request.ActivateDeviceIdReqBO; |
14 | -import com.yoho.service.model.union.response.ActivateDeviceIdResponseBO; | ||
15 | -import com.yoho.service.model.union.response.PageActivateDeviceIdRspBO; | 14 | +import com.yoho.service.model.union.response.*; |
16 | import com.yoho.unions.common.ApiResponse; | 15 | import com.yoho.unions.common.ApiResponse; |
17 | import com.yoho.unions.server.service.IPinYouService; | 16 | import com.yoho.unions.server.service.IPinYouService; |
18 | import org.apache.commons.lang3.StringUtils; | 17 | import org.apache.commons.lang3.StringUtils; |
@@ -26,8 +25,6 @@ import org.springframework.web.bind.annotation.ResponseBody; | @@ -26,8 +25,6 @@ import org.springframework.web.bind.annotation.ResponseBody; | ||
26 | import com.alibaba.fastjson.JSONObject; | 25 | import com.alibaba.fastjson.JSONObject; |
27 | import com.yoho.service.model.union.request.ActivateUnionRequestBO; | 26 | import com.yoho.service.model.union.request.ActivateUnionRequestBO; |
28 | import com.yoho.service.model.union.request.ActivateUnionRequestVO; | 27 | import com.yoho.service.model.union.request.ActivateUnionRequestVO; |
29 | -import com.yoho.service.model.union.response.ActiveUnionResponseBO; | ||
30 | -import com.yoho.service.model.union.response.UnionResponse; | ||
31 | import com.yoho.unions.common.constant.UnionConstant; | 28 | import com.yoho.unions.common.constant.UnionConstant; |
32 | import com.yoho.unions.common.enums.ClientTypeEnum; | 29 | import com.yoho.unions.common.enums.ClientTypeEnum; |
33 | import com.yoho.unions.common.utils.DateUtil; | 30 | import com.yoho.unions.common.utils.DateUtil; |
@@ -247,9 +244,9 @@ public class ActivateUnionRest { | @@ -247,9 +244,9 @@ public class ActivateUnionRest { | ||
247 | if (null==activateDeviceIdReqBO || (StringUtils.isEmpty(activateDeviceIdReqBO.getImei()))&&StringUtils.isEmpty(activateDeviceIdReqBO.getIdfa())){ | 244 | if (null==activateDeviceIdReqBO || (StringUtils.isEmpty(activateDeviceIdReqBO.getImei()))&&StringUtils.isEmpty(activateDeviceIdReqBO.getIdfa())){ |
248 | return new ApiResponse.ApiResponseBuilder().code(500).message("失败").data("缺少参数").build(); | 245 | return new ApiResponse.ApiResponseBuilder().code(500).message("失败").data("缺少参数").build(); |
249 | } | 246 | } |
250 | - ActivateDeviceIdResponseBO activateDeviceIdResponseBO = unionService.queryByDeviceId(activateDeviceIdReqBO); | ||
251 | - log.info("out queryByDeviceId.result activateDeviceIdResponseBO={}", activateDeviceIdResponseBO); | ||
252 | - return new ApiResponse.ApiResponseBuilder().code(200).message("成功").data(activateDeviceIdResponseBO).build(); | 247 | + PageActivateDeviceIdResponseBO pageActivateDeviceIdResponseBO = unionService.queryByDeviceId(activateDeviceIdReqBO); |
248 | + log.info("out queryByDeviceId.result pageActivateDeviceIdResponseBO={}", pageActivateDeviceIdResponseBO); | ||
249 | + return new ApiResponse.ApiResponseBuilder().code(200).message("成功").data(pageActivateDeviceIdResponseBO).build(); | ||
253 | } | 250 | } |
254 | 251 | ||
255 | } | 252 | } |
@@ -8,6 +8,7 @@ import com.yoho.service.model.union.request.ActivateDeviceIdReqBO; | @@ -8,6 +8,7 @@ import com.yoho.service.model.union.request.ActivateDeviceIdReqBO; | ||
8 | import com.yoho.service.model.union.request.ActivateUnionRequestBO; | 8 | import com.yoho.service.model.union.request.ActivateUnionRequestBO; |
9 | import com.yoho.service.model.union.request.ClickUnionRequestBO; | 9 | import com.yoho.service.model.union.request.ClickUnionRequestBO; |
10 | import com.yoho.service.model.union.response.ActivateDeviceIdResponseBO; | 10 | import com.yoho.service.model.union.response.ActivateDeviceIdResponseBO; |
11 | +import com.yoho.service.model.union.response.PageActivateDeviceIdResponseBO; | ||
11 | import com.yoho.service.model.union.response.PageActivateDeviceIdRspBO; | 12 | import com.yoho.service.model.union.response.PageActivateDeviceIdRspBO; |
12 | import com.yoho.service.model.union.response.UnionResponse; | 13 | import com.yoho.service.model.union.response.UnionResponse; |
13 | import com.yoho.unions.common.enums.ClientTypeEnum; | 14 | import com.yoho.unions.common.enums.ClientTypeEnum; |
@@ -75,5 +76,5 @@ public interface IUnionService { | @@ -75,5 +76,5 @@ public interface IUnionService { | ||
75 | 76 | ||
76 | Integer queryActivateCount(ActivateDeviceIdReqBO activateDeviceIdReqBO); | 77 | Integer queryActivateCount(ActivateDeviceIdReqBO activateDeviceIdReqBO); |
77 | 78 | ||
78 | - ActivateDeviceIdResponseBO queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO); | 79 | + PageActivateDeviceIdResponseBO queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO); |
79 | } | 80 | } |
@@ -2,6 +2,7 @@ package com.yoho.unions.server.service.impl; | @@ -2,6 +2,7 @@ package com.yoho.unions.server.service.impl; | ||
2 | 2 | ||
3 | import com.google.common.collect.Lists; | 3 | import com.google.common.collect.Lists; |
4 | import com.google.common.collect.Maps; | 4 | import com.google.common.collect.Maps; |
5 | +import com.google.common.collect.Sets; | ||
5 | import com.yoho.unions.common.model.DeviceIdMatchBO; | 6 | import com.yoho.unions.common.model.DeviceIdMatchBO; |
6 | import com.yoho.unions.common.service.IBusinessImportService; | 7 | import com.yoho.unions.common.service.IBusinessImportService; |
7 | import com.yoho.unions.dal.IUnionLogsDAO; | 8 | import com.yoho.unions.dal.IUnionLogsDAO; |
@@ -15,6 +16,7 @@ import org.springframework.stereotype.Service; | @@ -15,6 +16,7 @@ import org.springframework.stereotype.Service; | ||
15 | import javax.annotation.Resource; | 16 | import javax.annotation.Resource; |
16 | import java.util.List; | 17 | import java.util.List; |
17 | import java.util.Map; | 18 | import java.util.Map; |
19 | +import java.util.Set; | ||
18 | import java.util.concurrent.ExecutionException; | 20 | import java.util.concurrent.ExecutionException; |
19 | 21 | ||
20 | /** | 22 | /** |
@@ -24,6 +26,7 @@ import java.util.concurrent.ExecutionException; | @@ -24,6 +26,7 @@ import java.util.concurrent.ExecutionException; | ||
24 | public class DeviceIdMatchImportServiceImpl implements IBusinessImportService { | 26 | public class DeviceIdMatchImportServiceImpl implements IBusinessImportService { |
25 | private static final Logger logger = LoggerFactory.getLogger(DeviceIdMatchImportServiceImpl.class); | 27 | private static final Logger logger = LoggerFactory.getLogger(DeviceIdMatchImportServiceImpl.class); |
26 | 28 | ||
29 | + private static final int BATCH_SIZE=100; | ||
27 | @Resource | 30 | @Resource |
28 | IUnionLogsDAO unionLogsDAO; | 31 | IUnionLogsDAO unionLogsDAO; |
29 | 32 | ||
@@ -55,14 +58,21 @@ public class DeviceIdMatchImportServiceImpl implements IBusinessImportService { | @@ -55,14 +58,21 @@ public class DeviceIdMatchImportServiceImpl implements IBusinessImportService { | ||
55 | deviceIds.add(deviceIdMatchBO.getIdfa()); | 58 | deviceIds.add(deviceIdMatchBO.getIdfa()); |
56 | } | 59 | } |
57 | 60 | ||
58 | - List<String> matchIds = Lists.newArrayList(); | 61 | + Set<String> matchIds = Sets.newHashSet(); |
59 | if(CollectionUtils.isEmpty(deviceIds)){ | 62 | if(CollectionUtils.isEmpty(deviceIds)){ |
60 | return matchIds; | 63 | return matchIds; |
61 | } | 64 | } |
62 | - if(isIdfa>0){ | ||
63 | - matchIds = unionLogsDAO.matchIdfa(deviceIds); | ||
64 | - }else{ | ||
65 | - | 65 | + List<String> batchDeviceIds = null; |
66 | + //一次100个到数据库去匹配是否已经激活 | ||
67 | + for (int i = 0; i < deviceIds.size(); i += BATCH_SIZE) { | ||
68 | + List<String> temp = null; | ||
69 | + if (i + BATCH_SIZE > deviceIds.size()) { | ||
70 | + batchDeviceIds = deviceIds.subList(i, deviceIds.size()); | ||
71 | + } else { | ||
72 | + batchDeviceIds = deviceIds.subList(i, i + BATCH_SIZE); | ||
73 | + } | ||
74 | + temp =unionLogsDAO.matchIdfa(batchDeviceIds,isIdfa); | ||
75 | + matchIds.addAll(temp); | ||
66 | } | 76 | } |
67 | logger.debug("method batchImport(List<Object>) out."); | 77 | logger.debug("method batchImport(List<Object>) out."); |
68 | return matchIds; | 78 | return matchIds; |
@@ -6,6 +6,7 @@ package com.yoho.unions.server.service.impl; | @@ -6,6 +6,7 @@ package com.yoho.unions.server.service.impl; | ||
6 | 6 | ||
7 | import com.alibaba.fastjson.JSON; | 7 | import com.alibaba.fastjson.JSON; |
8 | import com.alibaba.fastjson.JSONObject; | 8 | import com.alibaba.fastjson.JSONObject; |
9 | +import com.google.common.collect.Lists; | ||
9 | import com.netflix.config.DynamicIntProperty; | 10 | import com.netflix.config.DynamicIntProperty; |
10 | import com.netflix.config.DynamicPropertyFactory; | 11 | import com.netflix.config.DynamicPropertyFactory; |
11 | import com.yoho.core.common.utils.MD5; | 12 | import com.yoho.core.common.utils.MD5; |
@@ -633,15 +634,20 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | @@ -633,15 +634,20 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | ||
633 | } | 634 | } |
634 | 635 | ||
635 | @Override | 636 | @Override |
636 | - public ActivateDeviceIdResponseBO queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO) { | 637 | + public PageActivateDeviceIdResponseBO queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO) { |
637 | log.info("enter queryByDeviceId. param activateDeviceIdReqBO={}", activateDeviceIdReqBO); | 638 | log.info("enter queryByDeviceId. param activateDeviceIdReqBO={}", activateDeviceIdReqBO); |
638 | if(activateDeviceIdReqBO.getIdfa()!=null){ | 639 | if(activateDeviceIdReqBO.getIdfa()!=null){ |
639 | activateDeviceIdReqBO.setImei(null); | 640 | activateDeviceIdReqBO.setImei(null); |
640 | } | 641 | } |
641 | - UnionLogs unionLogs = unionLogsDAO.queryByDeviceId(activateDeviceIdReqBO); | ||
642 | - ActivateDeviceIdResponseBO activateDeviceIdResponseBO = new ActivateDeviceIdResponseBO(); | ||
643 | - BeanUtils.copyProperties(unionLogs,activateDeviceIdResponseBO); | ||
644 | - return activateDeviceIdResponseBO; | 642 | + List<UnionLogs> unionLogs = unionLogsDAO.queryByDeviceId(activateDeviceIdReqBO); |
643 | + List<ActivateDeviceIdResponseBO> activateDeviceIdResponseBOList =Lists.transform(unionLogs,input -> { | ||
644 | + ActivateDeviceIdResponseBO output = new ActivateDeviceIdResponseBO(); | ||
645 | + BeanUtils.copyProperties(input, output); | ||
646 | + return output; | ||
647 | + }); | ||
648 | + PageActivateDeviceIdResponseBO pageActivateDeviceIdResponseBO = new PageActivateDeviceIdResponseBO(); | ||
649 | + pageActivateDeviceIdResponseBO.setList(activateDeviceIdResponseBOList); | ||
650 | + return pageActivateDeviceIdResponseBO; | ||
645 | } | 651 | } |
646 | 652 | ||
647 | 653 |
@@ -75,10 +75,10 @@ | @@ -75,10 +75,10 @@ | ||
75 | </form> | 75 | </form> |
76 | </div> | 76 | </div> |
77 | <div region="center" style="height: 800px;"> | 77 | <div region="center" style="height: 800px;"> |
78 | - <div style="margin-left: 30px;margin-top: 20px; height:800px;"> | 78 | + <div style="margin-left: 30px;margin-top: 20px; height:100px;"> |
79 | <table id="activateTalbe2"></table> | 79 | <table id="activateTalbe2"></table> |
80 | </div> | 80 | </div> |
81 | - <div id="matchDiv" style="padding:30px;"></div> | 81 | + <div id="matchDiv" style="padding:30px;height:600px;"></div> |
82 | </div> | 82 | </div> |
83 | </div> | 83 | </div> |
84 | </div> | 84 | </div> |
-
Please register or login to post a comment