Authored by linlong

update

... ... @@ -7,39 +7,21 @@ import com.yoho.unions.common.annotation.BatchImportField;
* Created by yoho on 2017/3/7.
*/
public class DeviceIdMatchBO {
public String getIdfa() {
return idfa;
}
public void setIdfa(String idfa) {
this.idfa = idfa;
}
public int getIsIdfa() {
return isIdfa;
}
public void setIsIdfa(int isIdfa) {
this.isIdfa = isIdfa;
}
@BatchImportField(
index = 0
)
@BatchExportField(
name = "idfa"
name = "deviceId"
)
private String idfa;
@BatchImportField(
index = 1
)
@BatchExportField(
name = "isIdfa"
)
private int isIdfa;
private String deviceId;
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
}
... ...
... ... @@ -35,7 +35,7 @@ public interface IUnionLogsDAO {
List<ActivateDeviceIdRspBO> selectListByParam(ActivateDeviceIdReqBO activateDeviceIdReqBO);
List<String> matchIdfa(@Param("list") List<String> list,@Param("isIdfa") int isIdfa);
List<UnionLogs> matchIdfa(@Param("list") List<String> list,@Param("isIdfa") int isIdfa);
List<UnionLogs> queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO);
}
... ...
... ... @@ -156,14 +156,9 @@
</if>
group by union_type
</select>
<select id="matchIdfa" resultType="java.lang.String">
<select id="matchIdfa" resultMap="BaseResultMap">
select
<if test="isIdfa==1">
idfa
</if>
<if test="isIdfa==0">
imei
</if>
<include refid="Base_Column_List"/>
from union_logs
where
<if test="isIdfa==1">
... ... @@ -181,10 +176,10 @@
select
<include refid="Base_Column_List"/>
from union_logs where 1=1
<if test="idfa!=null">
<if test="idfa!=null and idfa!='' ">
and idfa = #{idfa}
</if>
<if test="imei!=null">
<if test="imei!=null and imei!='' ">
and imei = #{imei}
</if>
limit 1
... ...
... ... @@ -3,13 +3,16 @@ package com.yoho.unions.server.service.impl;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.yoho.service.model.union.response.ActivateDeviceIdResponseBO;
import com.yoho.unions.common.model.DeviceIdMatchBO;
import com.yoho.unions.common.service.IBusinessImportService;
import com.yoho.unions.dal.IUnionLogsDAO;
import com.yoho.unions.dal.model.UnionLogs;
import org.apache.commons.collections.CollectionUtils;
import org.elasticsearch.common.recycler.Recycler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
... ... @@ -22,14 +25,23 @@ import java.util.concurrent.ExecutionException;
/**
* Created by yoho on 2017/3/7.
*/
@Service("deviceIdMatchImportServiceImpl")
//@Service("deviceIdMatchImportServiceImpl")
public class DeviceIdMatchImportServiceImpl implements IBusinessImportService {
private static final Logger logger = LoggerFactory.getLogger(DeviceIdMatchImportServiceImpl.class);
private static final int BATCH_SIZE=100;
@Resource
IUnionLogsDAO unionLogsDAO;
private int isIdfa;
public void setIsIdfa(int isIdfa) {
this.isIdfa = isIdfa;
}
@Override
public Class getDataClass() {
return DeviceIdMatchBO.class;
... ... @@ -50,22 +62,20 @@ public class DeviceIdMatchImportServiceImpl implements IBusinessImportService {
}
List<String> deviceIds = Lists.newArrayList();
DeviceIdMatchBO first = (DeviceIdMatchBO)dataList.get(0);
int isIdfa = first.getIsIdfa();
for (Object deviceIdMatch : dataList){
DeviceIdMatchBO deviceIdMatchBO = (DeviceIdMatchBO)deviceIdMatch;
deviceIds.add(deviceIdMatchBO.getIdfa());
deviceIds.add(deviceIdMatchBO.getDeviceId());
}
Set<String> matchIds = Sets.newHashSet();
Set<UnionLogs> matchIds = Sets.newHashSet();
if(CollectionUtils.isEmpty(deviceIds)){
return matchIds;
}
List<String> batchDeviceIds = null;
//一次100个到数据库去匹配是否已经激活
for (int i = 0; i < deviceIds.size(); i += BATCH_SIZE) {
List<String> temp = null;
List<UnionLogs> temp = null;
if (i + BATCH_SIZE > deviceIds.size()) {
batchDeviceIds = deviceIds.subList(i, deviceIds.size());
} else {
... ... @@ -74,7 +84,12 @@ public class DeviceIdMatchImportServiceImpl implements IBusinessImportService {
temp =unionLogsDAO.matchIdfa(batchDeviceIds,isIdfa);
matchIds.addAll(temp);
}
List<ActivateDeviceIdResponseBO> responseBOList = Lists.transform(Lists.newArrayList(matchIds),input -> {
ActivateDeviceIdResponseBO output = new ActivateDeviceIdResponseBO();
BeanUtils.copyProperties(input, output);
return output;
});
logger.debug("method batchImport(List<Object>) out.");
return matchIds;
return responseBOList;
}
}
... ...
... ... @@ -578,23 +578,17 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
activateDeviceIdReqBO.setActivateTimeStr(DateUtils.getTimesmorning(dateStr));
}
//(1).查询出各渠道激活的设备id数
List<ActivateDeviceIdRspBO> activateDeviceIdRspList = unionLogsDAO.selectListByParam(activateDeviceIdReqBO);
// List<ActivateDeviceIdRspBO> clickDeviceIdRspList = Lists.newArrayList();
// //(2)查询出各激活渠道的点击数
// if (CollectionUtils.isNotEmpty(activateDeviceIdRspList)) {
// clickDeviceIdRspList = unionClickLogsDAO.selectListByParam(activateDeviceIdRspList,activateDeviceIdReqBO);
// }
// Map<String,ActivateDeviceIdRspBO> clickDeviceIdMap = clickDeviceIdRspList.stream().collect(Collectors.toMap(ActivateDeviceIdRspBO::getUnionType, (p) -> p));
// //(3)处理数据
// for(ActivateDeviceIdRspBO bo:activateDeviceIdRspList){
// ActivateDeviceIdRspBO clickBO = clickDeviceIdMap.get(bo.getUnionType());
// if(clickBO!=null){
// bo.setIdfaClick(clickBO.getIdfaClick());
// bo.setIdfaClick(clickBO.getImeiClick());
// }
// }
// List<ActivateDeviceIdRspBO> activateDeviceIdRspList = unionLogsDAO.selectListByParam(activateDeviceIdReqBO);
List<ActivateDeviceIdRspBO> activateDeviceIdRspList = Lists.newArrayList();
for(int i=0;i<100;i++){
ActivateDeviceIdRspBO bo = new ActivateDeviceIdRspBO();
bo.setUnionName(i+"");
bo.setIdfaCount(i);
activateDeviceIdRspList.add(bo);
}
// int total = unionLogsDAO.selectListCountByParam(activateDeviceIdReqBO);
// List<ActivateDeviceIdRspBO> activateDeviceIdRspList = Lists.newArrayList();
// if(total>0){
// activateDeviceIdRspList = unionLogsDAO.selectListByParam(activateDeviceIdReqBO);
// }
... ... @@ -635,7 +629,9 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
@Override
public PageActivateDeviceIdResponseBO queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO) {
log.info("enter queryByDeviceId. param activateDeviceIdReqBO={}", activateDeviceIdReqBO);
if(activateDeviceIdReqBO.getIdfa()!=null){
activateDeviceIdReqBO.setIdfa(activateDeviceIdReqBO.getIdfa().trim());
activateDeviceIdReqBO.setImei(activateDeviceIdReqBO.getImei().trim());
if(StringUtils.isNotEmpty(activateDeviceIdReqBO.getIdfa())){
activateDeviceIdReqBO.setImei(null);
}
List<UnionLogs> unionLogs = unionLogsDAO.queryByDeviceId(activateDeviceIdReqBO);
... ...
... ... @@ -104,10 +104,19 @@
<property name="resolveLazily" value="true"></property>
</bean>
<bean id="idfaMatchImportServiceImpl" class="com.yoho.unions.server.service.impl.DeviceIdMatchImportServiceImpl" >
<property name="isIdfa" value="1"/>
</bean>
<bean id="imeiMatchImportServiceImpl" class="com.yoho.unions.server.service.impl.DeviceIdMatchImportServiceImpl" >
<property name="isIdfa" value="0"/>
</bean>
<!-- 批量操作服务定义 -->
<util:map id="batchImportBusiness" key-type="java.lang.String"
value-type="com.yoho.unions.common.service.IBusinessImportService">
<entry key="deviceIdMatchImport" value-ref="deviceIdMatchImportServiceImpl"/>
<entry key="idfaMatchImport" value-ref="idfaMatchImportServiceImpl"/>
<entry key="imeiMatchImport" value-ref="idfaMatchImportServiceImpl"/>
</util:map>
<!-- 批量操作服务定义 -->
<util:map id="batchExportBusiness" key-type="java.lang.String"
... ...
... ... @@ -8,7 +8,7 @@
</head>
<body class="easyui-layout" fit="true">
<div id="tt" class="easyui-tabs" style="width:auto;height:auto;">
<div title="激活点击统计" style="padding:20px;display:none;">
<div title="激活点击统计" style="padding:20px;display:none;overflow:auto;">
<div id="search" region="north" style="padding-bottom: 35px; ">
<!--<script>-->
<!--document.write(addHead('市场管理', '分组营销管理'));-->
... ... @@ -58,7 +58,7 @@
</div>
</div>
<div region="center">
<div style="margin-left: 30px;margin-top: 20px; height:800px;">
<div style="margin-left: 30px;margin-top: 20px; height:420px;">
<table id="activateTalbe"></table>
</div>
</div>
... ... @@ -71,14 +71,15 @@
<input name="imei" type="text" class="easyui-textbox" data-options="prompt:'请输入imei'"
style="width: 200px;">
<a id="searchBtn2" class="easyui-linkbutton btn-info" style="margin-left: 30px; "></a>
<div id="batchImportDiv" style="margin-left: 30px;"></div>
<div id="idfaImportDiv" style="margin-left: 30px;"></div>
<div id="imeiImportDiv" style="margin-left: 30px;"></div>
</form>
</div>
<div region="center" style="height: 800px;">
<div style="margin-left: 30px;margin-top: 20px; height:100px;">
<table id="activateTalbe2"></table>
</div>
<div id="matchDiv" style="padding:30px;height:600px;"></div>
<div id="matchDiv" style="padding:30px;height:420px;"></div>
</div>
</div>
</div>
... ... @@ -325,12 +326,12 @@
}
});
$("#batchImportDiv").fileUpload({
text: "请选择文件导入匹配", //按钮文字
$("#idfaImportDiv").fileUpload({
text: "请选择idfa导入匹配", //按钮文字
uploadInputName: "file", //上传文件的控件名称
url: contextPath + "/batch/import", //提交到后端的url
queryParams: {
type: "deviceIdMatchImport"
type: "idfaMatchImport"
}, //提交到后端额外参数
showFileName: false, //上传成功后,是否显示文件名
onLoadSuccess: function (fileName, data) {
... ... @@ -342,7 +343,31 @@
var match = data.data;
var output = "匹配的内容</br>";
for (var i = 0; i < match.length; i++) {
output += match[i] + "</br>";
output += JSON.stringify(match[i])+"</br>";
}
$("#matchDiv").append(output);
}
});
$("#imeiImportDiv").fileUpload({
text: "请选择imei导入匹配", //按钮文字
uploadInputName: "file", //上传文件的控件名称
url: contextPath + "/batch/import", //提交到后端的url
queryParams: {
type: "imeiMatchImport"
}, //提交到后端额外参数
showFileName: false, //上传成功后,是否显示文件名
onLoadSuccess: function (fileName, data) {
$.messager.show({
title: "提示",
msg: "匹配完成",
height: 250
});
var match = data.data;
var match = data.data;
var output = "匹配的内容</br>";
for (var i = 0; i < match.length; i++) {
output += JSON.stringify(match[i])+"</br>";
}
$("#matchDiv").append(output);
}
... ...