Showing
7 changed files
with
91 additions
and
69 deletions
@@ -7,39 +7,21 @@ import com.yoho.unions.common.annotation.BatchImportField; | @@ -7,39 +7,21 @@ import com.yoho.unions.common.annotation.BatchImportField; | ||
7 | * Created by yoho on 2017/3/7. | 7 | * Created by yoho on 2017/3/7. |
8 | */ | 8 | */ |
9 | public class DeviceIdMatchBO { | 9 | public class DeviceIdMatchBO { |
10 | - public String getIdfa() { | ||
11 | - return idfa; | ||
12 | - } | ||
13 | - | ||
14 | - public void setIdfa(String idfa) { | ||
15 | - this.idfa = idfa; | ||
16 | - } | ||
17 | - | ||
18 | - public int getIsIdfa() { | ||
19 | - return isIdfa; | ||
20 | - } | ||
21 | - | ||
22 | - public void setIsIdfa(int isIdfa) { | ||
23 | - this.isIdfa = isIdfa; | ||
24 | - } | ||
25 | 10 | ||
26 | @BatchImportField( | 11 | @BatchImportField( |
27 | index = 0 | 12 | index = 0 |
28 | ) | 13 | ) |
29 | @BatchExportField( | 14 | @BatchExportField( |
30 | - name = "idfa" | 15 | + name = "deviceId" |
31 | ) | 16 | ) |
32 | 17 | ||
33 | - private String idfa; | ||
34 | - | ||
35 | - @BatchImportField( | ||
36 | - index = 1 | ||
37 | - ) | ||
38 | - | ||
39 | - @BatchExportField( | ||
40 | - name = "isIdfa" | ||
41 | - ) | ||
42 | - private int isIdfa; | 18 | + private String deviceId; |
43 | 19 | ||
20 | + public String getDeviceId() { | ||
21 | + return deviceId; | ||
22 | + } | ||
44 | 23 | ||
24 | + public void setDeviceId(String deviceId) { | ||
25 | + this.deviceId = deviceId; | ||
26 | + } | ||
45 | } | 27 | } |
@@ -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(@Param("list") List<String> list,@Param("isIdfa") int isIdfa); | 38 | + List<UnionLogs> matchIdfa(@Param("list") List<String> list,@Param("isIdfa") int isIdfa); |
39 | 39 | ||
40 | List<UnionLogs> queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO); | 40 | List<UnionLogs> queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO); |
41 | } | 41 | } |
@@ -156,14 +156,9 @@ | @@ -156,14 +156,9 @@ | ||
156 | </if> | 156 | </if> |
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" resultMap="BaseResultMap"> |
160 | select | 160 | select |
161 | - <if test="isIdfa==1"> | ||
162 | - idfa | ||
163 | - </if> | ||
164 | - <if test="isIdfa==0"> | ||
165 | - imei | ||
166 | - </if> | 161 | + <include refid="Base_Column_List"/> |
167 | from union_logs | 162 | from union_logs |
168 | where | 163 | where |
169 | <if test="isIdfa==1"> | 164 | <if test="isIdfa==1"> |
@@ -181,10 +176,10 @@ | @@ -181,10 +176,10 @@ | ||
181 | select | 176 | select |
182 | <include refid="Base_Column_List"/> | 177 | <include refid="Base_Column_List"/> |
183 | from union_logs where 1=1 | 178 | from union_logs where 1=1 |
184 | - <if test="idfa!=null"> | 179 | + <if test="idfa!=null and idfa!='' "> |
185 | and idfa = #{idfa} | 180 | and idfa = #{idfa} |
186 | </if> | 181 | </if> |
187 | - <if test="imei!=null"> | 182 | + <if test="imei!=null and imei!='' "> |
188 | and imei = #{imei} | 183 | and imei = #{imei} |
189 | </if> | 184 | </if> |
190 | limit 1 | 185 | limit 1 |
@@ -3,13 +3,16 @@ package com.yoho.unions.server.service.impl; | @@ -3,13 +3,16 @@ package com.yoho.unions.server.service.impl; | ||
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.google.common.collect.Sets; |
6 | +import com.yoho.service.model.union.response.ActivateDeviceIdResponseBO; | ||
6 | import com.yoho.unions.common.model.DeviceIdMatchBO; | 7 | import com.yoho.unions.common.model.DeviceIdMatchBO; |
7 | import com.yoho.unions.common.service.IBusinessImportService; | 8 | import com.yoho.unions.common.service.IBusinessImportService; |
8 | import com.yoho.unions.dal.IUnionLogsDAO; | 9 | import com.yoho.unions.dal.IUnionLogsDAO; |
10 | +import com.yoho.unions.dal.model.UnionLogs; | ||
9 | import org.apache.commons.collections.CollectionUtils; | 11 | import org.apache.commons.collections.CollectionUtils; |
10 | import org.elasticsearch.common.recycler.Recycler; | 12 | import org.elasticsearch.common.recycler.Recycler; |
11 | import org.slf4j.Logger; | 13 | import org.slf4j.Logger; |
12 | import org.slf4j.LoggerFactory; | 14 | import org.slf4j.LoggerFactory; |
15 | +import org.springframework.beans.BeanUtils; | ||
13 | import org.springframework.beans.factory.annotation.Autowired; | 16 | import org.springframework.beans.factory.annotation.Autowired; |
14 | import org.springframework.stereotype.Service; | 17 | import org.springframework.stereotype.Service; |
15 | 18 | ||
@@ -22,14 +25,23 @@ import java.util.concurrent.ExecutionException; | @@ -22,14 +25,23 @@ import java.util.concurrent.ExecutionException; | ||
22 | /** | 25 | /** |
23 | * Created by yoho on 2017/3/7. | 26 | * Created by yoho on 2017/3/7. |
24 | */ | 27 | */ |
25 | -@Service("deviceIdMatchImportServiceImpl") | 28 | +//@Service("deviceIdMatchImportServiceImpl") |
26 | public class DeviceIdMatchImportServiceImpl implements IBusinessImportService { | 29 | public class DeviceIdMatchImportServiceImpl implements IBusinessImportService { |
27 | private static final Logger logger = LoggerFactory.getLogger(DeviceIdMatchImportServiceImpl.class); | 30 | private static final Logger logger = LoggerFactory.getLogger(DeviceIdMatchImportServiceImpl.class); |
28 | 31 | ||
29 | private static final int BATCH_SIZE=100; | 32 | private static final int BATCH_SIZE=100; |
33 | + | ||
30 | @Resource | 34 | @Resource |
31 | IUnionLogsDAO unionLogsDAO; | 35 | IUnionLogsDAO unionLogsDAO; |
32 | 36 | ||
37 | + | ||
38 | + private int isIdfa; | ||
39 | + | ||
40 | + | ||
41 | + public void setIsIdfa(int isIdfa) { | ||
42 | + this.isIdfa = isIdfa; | ||
43 | + } | ||
44 | + | ||
33 | @Override | 45 | @Override |
34 | public Class getDataClass() { | 46 | public Class getDataClass() { |
35 | return DeviceIdMatchBO.class; | 47 | return DeviceIdMatchBO.class; |
@@ -50,22 +62,20 @@ public class DeviceIdMatchImportServiceImpl implements IBusinessImportService { | @@ -50,22 +62,20 @@ public class DeviceIdMatchImportServiceImpl implements IBusinessImportService { | ||
50 | } | 62 | } |
51 | 63 | ||
52 | List<String> deviceIds = Lists.newArrayList(); | 64 | List<String> deviceIds = Lists.newArrayList(); |
53 | - DeviceIdMatchBO first = (DeviceIdMatchBO)dataList.get(0); | ||
54 | - int isIdfa = first.getIsIdfa(); | ||
55 | 65 | ||
56 | for (Object deviceIdMatch : dataList){ | 66 | for (Object deviceIdMatch : dataList){ |
57 | DeviceIdMatchBO deviceIdMatchBO = (DeviceIdMatchBO)deviceIdMatch; | 67 | DeviceIdMatchBO deviceIdMatchBO = (DeviceIdMatchBO)deviceIdMatch; |
58 | - deviceIds.add(deviceIdMatchBO.getIdfa()); | 68 | + deviceIds.add(deviceIdMatchBO.getDeviceId()); |
59 | } | 69 | } |
60 | 70 | ||
61 | - Set<String> matchIds = Sets.newHashSet(); | 71 | + Set<UnionLogs> matchIds = Sets.newHashSet(); |
62 | if(CollectionUtils.isEmpty(deviceIds)){ | 72 | if(CollectionUtils.isEmpty(deviceIds)){ |
63 | return matchIds; | 73 | return matchIds; |
64 | } | 74 | } |
65 | List<String> batchDeviceIds = null; | 75 | List<String> batchDeviceIds = null; |
66 | //一次100个到数据库去匹配是否已经激活 | 76 | //一次100个到数据库去匹配是否已经激活 |
67 | for (int i = 0; i < deviceIds.size(); i += BATCH_SIZE) { | 77 | for (int i = 0; i < deviceIds.size(); i += BATCH_SIZE) { |
68 | - List<String> temp = null; | 78 | + List<UnionLogs> temp = null; |
69 | if (i + BATCH_SIZE > deviceIds.size()) { | 79 | if (i + BATCH_SIZE > deviceIds.size()) { |
70 | batchDeviceIds = deviceIds.subList(i, deviceIds.size()); | 80 | batchDeviceIds = deviceIds.subList(i, deviceIds.size()); |
71 | } else { | 81 | } else { |
@@ -74,7 +84,12 @@ public class DeviceIdMatchImportServiceImpl implements IBusinessImportService { | @@ -74,7 +84,12 @@ public class DeviceIdMatchImportServiceImpl implements IBusinessImportService { | ||
74 | temp =unionLogsDAO.matchIdfa(batchDeviceIds,isIdfa); | 84 | temp =unionLogsDAO.matchIdfa(batchDeviceIds,isIdfa); |
75 | matchIds.addAll(temp); | 85 | matchIds.addAll(temp); |
76 | } | 86 | } |
87 | + List<ActivateDeviceIdResponseBO> responseBOList = Lists.transform(Lists.newArrayList(matchIds),input -> { | ||
88 | + ActivateDeviceIdResponseBO output = new ActivateDeviceIdResponseBO(); | ||
89 | + BeanUtils.copyProperties(input, output); | ||
90 | + return output; | ||
91 | + }); | ||
77 | logger.debug("method batchImport(List<Object>) out."); | 92 | logger.debug("method batchImport(List<Object>) out."); |
78 | - return matchIds; | 93 | + return responseBOList; |
79 | } | 94 | } |
80 | } | 95 | } |
@@ -578,23 +578,17 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | @@ -578,23 +578,17 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | ||
578 | activateDeviceIdReqBO.setActivateTimeStr(DateUtils.getTimesmorning(dateStr)); | 578 | activateDeviceIdReqBO.setActivateTimeStr(DateUtils.getTimesmorning(dateStr)); |
579 | } | 579 | } |
580 | //(1).查询出各渠道激活的设备id数 | 580 | //(1).查询出各渠道激活的设备id数 |
581 | - List<ActivateDeviceIdRspBO> activateDeviceIdRspList = unionLogsDAO.selectListByParam(activateDeviceIdReqBO); | ||
582 | -// List<ActivateDeviceIdRspBO> clickDeviceIdRspList = Lists.newArrayList(); | ||
583 | -// //(2)查询出各激活渠道的点击数 | ||
584 | -// if (CollectionUtils.isNotEmpty(activateDeviceIdRspList)) { | ||
585 | -// clickDeviceIdRspList = unionClickLogsDAO.selectListByParam(activateDeviceIdRspList,activateDeviceIdReqBO); | ||
586 | -// } | ||
587 | -// Map<String,ActivateDeviceIdRspBO> clickDeviceIdMap = clickDeviceIdRspList.stream().collect(Collectors.toMap(ActivateDeviceIdRspBO::getUnionType, (p) -> p)); | ||
588 | -// //(3)处理数据 | ||
589 | -// for(ActivateDeviceIdRspBO bo:activateDeviceIdRspList){ | ||
590 | -// ActivateDeviceIdRspBO clickBO = clickDeviceIdMap.get(bo.getUnionType()); | ||
591 | -// if(clickBO!=null){ | ||
592 | -// bo.setIdfaClick(clickBO.getIdfaClick()); | ||
593 | -// bo.setIdfaClick(clickBO.getImeiClick()); | ||
594 | -// } | ||
595 | -// } | 581 | +// List<ActivateDeviceIdRspBO> activateDeviceIdRspList = unionLogsDAO.selectListByParam(activateDeviceIdReqBO); |
582 | + | ||
583 | + List<ActivateDeviceIdRspBO> activateDeviceIdRspList = Lists.newArrayList(); | ||
584 | + for(int i=0;i<100;i++){ | ||
585 | + ActivateDeviceIdRspBO bo = new ActivateDeviceIdRspBO(); | ||
586 | + bo.setUnionName(i+""); | ||
587 | + bo.setIdfaCount(i); | ||
588 | + activateDeviceIdRspList.add(bo); | ||
589 | + } | ||
590 | + | ||
596 | // int total = unionLogsDAO.selectListCountByParam(activateDeviceIdReqBO); | 591 | // int total = unionLogsDAO.selectListCountByParam(activateDeviceIdReqBO); |
597 | -// List<ActivateDeviceIdRspBO> activateDeviceIdRspList = Lists.newArrayList(); | ||
598 | // if(total>0){ | 592 | // if(total>0){ |
599 | // activateDeviceIdRspList = unionLogsDAO.selectListByParam(activateDeviceIdReqBO); | 593 | // activateDeviceIdRspList = unionLogsDAO.selectListByParam(activateDeviceIdReqBO); |
600 | // } | 594 | // } |
@@ -635,7 +629,9 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | @@ -635,7 +629,9 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher | ||
635 | @Override | 629 | @Override |
636 | public PageActivateDeviceIdResponseBO queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO) { | 630 | public PageActivateDeviceIdResponseBO queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO) { |
637 | log.info("enter queryByDeviceId. param activateDeviceIdReqBO={}", activateDeviceIdReqBO); | 631 | log.info("enter queryByDeviceId. param activateDeviceIdReqBO={}", activateDeviceIdReqBO); |
638 | - if(activateDeviceIdReqBO.getIdfa()!=null){ | 632 | + activateDeviceIdReqBO.setIdfa(activateDeviceIdReqBO.getIdfa().trim()); |
633 | + activateDeviceIdReqBO.setImei(activateDeviceIdReqBO.getImei().trim()); | ||
634 | + if(StringUtils.isNotEmpty(activateDeviceIdReqBO.getIdfa())){ | ||
639 | activateDeviceIdReqBO.setImei(null); | 635 | activateDeviceIdReqBO.setImei(null); |
640 | } | 636 | } |
641 | List<UnionLogs> unionLogs = unionLogsDAO.queryByDeviceId(activateDeviceIdReqBO); | 637 | List<UnionLogs> unionLogs = unionLogsDAO.queryByDeviceId(activateDeviceIdReqBO); |
@@ -104,10 +104,19 @@ | @@ -104,10 +104,19 @@ | ||
104 | <property name="resolveLazily" value="true"></property> | 104 | <property name="resolveLazily" value="true"></property> |
105 | </bean> | 105 | </bean> |
106 | 106 | ||
107 | + <bean id="idfaMatchImportServiceImpl" class="com.yoho.unions.server.service.impl.DeviceIdMatchImportServiceImpl" > | ||
108 | + <property name="isIdfa" value="1"/> | ||
109 | + </bean> | ||
110 | + | ||
111 | + <bean id="imeiMatchImportServiceImpl" class="com.yoho.unions.server.service.impl.DeviceIdMatchImportServiceImpl" > | ||
112 | + <property name="isIdfa" value="0"/> | ||
113 | + </bean> | ||
114 | + | ||
107 | <!-- 批量操作服务定义 --> | 115 | <!-- 批量操作服务定义 --> |
108 | <util:map id="batchImportBusiness" key-type="java.lang.String" | 116 | <util:map id="batchImportBusiness" key-type="java.lang.String" |
109 | value-type="com.yoho.unions.common.service.IBusinessImportService"> | 117 | value-type="com.yoho.unions.common.service.IBusinessImportService"> |
110 | - <entry key="deviceIdMatchImport" value-ref="deviceIdMatchImportServiceImpl"/> | 118 | + <entry key="idfaMatchImport" value-ref="idfaMatchImportServiceImpl"/> |
119 | + <entry key="imeiMatchImport" value-ref="idfaMatchImportServiceImpl"/> | ||
111 | </util:map> | 120 | </util:map> |
112 | <!-- 批量操作服务定义 --> | 121 | <!-- 批量操作服务定义 --> |
113 | <util:map id="batchExportBusiness" key-type="java.lang.String" | 122 | <util:map id="batchExportBusiness" key-type="java.lang.String" |
@@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
8 | </head> | 8 | </head> |
9 | <body class="easyui-layout" fit="true"> | 9 | <body class="easyui-layout" fit="true"> |
10 | <div id="tt" class="easyui-tabs" style="width:auto;height:auto;"> | 10 | <div id="tt" class="easyui-tabs" style="width:auto;height:auto;"> |
11 | - <div title="激活点击统计" style="padding:20px;display:none;"> | 11 | + <div title="激活点击统计" style="padding:20px;display:none;overflow:auto;"> |
12 | <div id="search" region="north" style="padding-bottom: 35px; "> | 12 | <div id="search" region="north" style="padding-bottom: 35px; "> |
13 | <!--<script>--> | 13 | <!--<script>--> |
14 | <!--document.write(addHead('市场管理', '分组营销管理'));--> | 14 | <!--document.write(addHead('市场管理', '分组营销管理'));--> |
@@ -58,7 +58,7 @@ | @@ -58,7 +58,7 @@ | ||
58 | </div> | 58 | </div> |
59 | </div> | 59 | </div> |
60 | <div region="center"> | 60 | <div region="center"> |
61 | - <div style="margin-left: 30px;margin-top: 20px; height:800px;"> | 61 | + <div style="margin-left: 30px;margin-top: 20px; height:420px;"> |
62 | <table id="activateTalbe"></table> | 62 | <table id="activateTalbe"></table> |
63 | </div> | 63 | </div> |
64 | </div> | 64 | </div> |
@@ -71,14 +71,15 @@ | @@ -71,14 +71,15 @@ | ||
71 | <input name="imei" type="text" class="easyui-textbox" data-options="prompt:'请输入imei'" | 71 | <input name="imei" type="text" class="easyui-textbox" data-options="prompt:'请输入imei'" |
72 | style="width: 200px;"> | 72 | style="width: 200px;"> |
73 | <a id="searchBtn2" class="easyui-linkbutton btn-info" style="margin-left: 30px; "></a> | 73 | <a id="searchBtn2" class="easyui-linkbutton btn-info" style="margin-left: 30px; "></a> |
74 | - <div id="batchImportDiv" style="margin-left: 30px;"></div> | 74 | + <div id="idfaImportDiv" style="margin-left: 30px;"></div> |
75 | + <div id="imeiImportDiv" style="margin-left: 30px;"></div> | ||
75 | </form> | 76 | </form> |
76 | </div> | 77 | </div> |
77 | <div region="center" style="height: 800px;"> | 78 | <div region="center" style="height: 800px;"> |
78 | <div style="margin-left: 30px;margin-top: 20px; height:100px;"> | 79 | <div style="margin-left: 30px;margin-top: 20px; height:100px;"> |
79 | <table id="activateTalbe2"></table> | 80 | <table id="activateTalbe2"></table> |
80 | </div> | 81 | </div> |
81 | - <div id="matchDiv" style="padding:30px;height:600px;"></div> | 82 | + <div id="matchDiv" style="padding:30px;height:420px;"></div> |
82 | </div> | 83 | </div> |
83 | </div> | 84 | </div> |
84 | </div> | 85 | </div> |
@@ -325,12 +326,12 @@ | @@ -325,12 +326,12 @@ | ||
325 | } | 326 | } |
326 | }); | 327 | }); |
327 | 328 | ||
328 | - $("#batchImportDiv").fileUpload({ | ||
329 | - text: "请选择文件导入匹配", //按钮文字 | 329 | + $("#idfaImportDiv").fileUpload({ |
330 | + text: "请选择idfa导入匹配", //按钮文字 | ||
330 | uploadInputName: "file", //上传文件的控件名称 | 331 | uploadInputName: "file", //上传文件的控件名称 |
331 | url: contextPath + "/batch/import", //提交到后端的url | 332 | url: contextPath + "/batch/import", //提交到后端的url |
332 | queryParams: { | 333 | queryParams: { |
333 | - type: "deviceIdMatchImport" | 334 | + type: "idfaMatchImport" |
334 | }, //提交到后端额外参数 | 335 | }, //提交到后端额外参数 |
335 | showFileName: false, //上传成功后,是否显示文件名 | 336 | showFileName: false, //上传成功后,是否显示文件名 |
336 | onLoadSuccess: function (fileName, data) { | 337 | onLoadSuccess: function (fileName, data) { |
@@ -342,7 +343,31 @@ | @@ -342,7 +343,31 @@ | ||
342 | var match = data.data; | 343 | var match = data.data; |
343 | var output = "匹配的内容</br>"; | 344 | var output = "匹配的内容</br>"; |
344 | for (var i = 0; i < match.length; i++) { | 345 | for (var i = 0; i < match.length; i++) { |
345 | - output += match[i] + "</br>"; | 346 | + output += JSON.stringify(match[i])+"</br>"; |
347 | + } | ||
348 | + $("#matchDiv").append(output); | ||
349 | + } | ||
350 | + }); | ||
351 | + | ||
352 | + $("#imeiImportDiv").fileUpload({ | ||
353 | + text: "请选择imei导入匹配", //按钮文字 | ||
354 | + uploadInputName: "file", //上传文件的控件名称 | ||
355 | + url: contextPath + "/batch/import", //提交到后端的url | ||
356 | + queryParams: { | ||
357 | + type: "imeiMatchImport" | ||
358 | + }, //提交到后端额外参数 | ||
359 | + showFileName: false, //上传成功后,是否显示文件名 | ||
360 | + onLoadSuccess: function (fileName, data) { | ||
361 | + $.messager.show({ | ||
362 | + title: "提示", | ||
363 | + msg: "匹配完成", | ||
364 | + height: 250 | ||
365 | + }); | ||
366 | + var match = data.data; | ||
367 | + var match = data.data; | ||
368 | + var output = "匹配的内容</br>"; | ||
369 | + for (var i = 0; i < match.length; i++) { | ||
370 | + output += JSON.stringify(match[i])+"</br>"; | ||
346 | } | 371 | } |
347 | $("#matchDiv").append(output); | 372 | $("#matchDiv").append(output); |
348 | } | 373 | } |
-
Please register or login to post a comment