Authored by linlong

update

... ... @@ -35,7 +35,7 @@ public interface IUnionLogsDAO {
List<ActivateDeviceIdRspBO> selectListByParam(ActivateDeviceIdReqBO activateDeviceIdReqBO);
List<String> matchIdfa(List<String> list);
List<String> matchIdfa(@Param("list") List<String> list,@Param("isIdfa") int isIdfa);
UnionLogs queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO);
List<UnionLogs> queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO);
}
... ...
... ... @@ -157,8 +157,22 @@
group by union_type
</select>
<select id="matchIdfa" resultType="java.lang.String">
select idfa from union_logs
where idfa in
select
<if test="isIdfa==1">
idfa
</if>
<if test="isIdfa==0">
imei
</if>
from union_logs
where
<if test="isIdfa==1">
idfa
</if>
<if test="isIdfa==0">
imei
</if>
in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
... ...
... ... @@ -11,8 +11,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.yoho.service.model.union.request.ActivateDeviceIdReqBO;
import com.yoho.service.model.union.response.ActivateDeviceIdResponseBO;
import com.yoho.service.model.union.response.PageActivateDeviceIdRspBO;
import com.yoho.service.model.union.response.*;
import com.yoho.unions.common.ApiResponse;
import com.yoho.unions.server.service.IPinYouService;
import org.apache.commons.lang3.StringUtils;
... ... @@ -26,8 +25,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
import com.alibaba.fastjson.JSONObject;
import com.yoho.service.model.union.request.ActivateUnionRequestBO;
import com.yoho.service.model.union.request.ActivateUnionRequestVO;
import com.yoho.service.model.union.response.ActiveUnionResponseBO;
import com.yoho.service.model.union.response.UnionResponse;
import com.yoho.unions.common.constant.UnionConstant;
import com.yoho.unions.common.enums.ClientTypeEnum;
import com.yoho.unions.common.utils.DateUtil;
... ... @@ -247,9 +244,9 @@ public class ActivateUnionRest {
if (null==activateDeviceIdReqBO || (StringUtils.isEmpty(activateDeviceIdReqBO.getImei()))&&StringUtils.isEmpty(activateDeviceIdReqBO.getIdfa())){
return new ApiResponse.ApiResponseBuilder().code(500).message("失败").data("缺少参数").build();
}
ActivateDeviceIdResponseBO activateDeviceIdResponseBO = unionService.queryByDeviceId(activateDeviceIdReqBO);
log.info("out queryByDeviceId.result activateDeviceIdResponseBO={}", activateDeviceIdResponseBO);
return new ApiResponse.ApiResponseBuilder().code(200).message("成功").data(activateDeviceIdResponseBO).build();
PageActivateDeviceIdResponseBO pageActivateDeviceIdResponseBO = unionService.queryByDeviceId(activateDeviceIdReqBO);
log.info("out queryByDeviceId.result pageActivateDeviceIdResponseBO={}", pageActivateDeviceIdResponseBO);
return new ApiResponse.ApiResponseBuilder().code(200).message("成功").data(pageActivateDeviceIdResponseBO).build();
}
}
... ...
... ... @@ -8,6 +8,7 @@ import com.yoho.service.model.union.request.ActivateDeviceIdReqBO;
import com.yoho.service.model.union.request.ActivateUnionRequestBO;
import com.yoho.service.model.union.request.ClickUnionRequestBO;
import com.yoho.service.model.union.response.ActivateDeviceIdResponseBO;
import com.yoho.service.model.union.response.PageActivateDeviceIdResponseBO;
import com.yoho.service.model.union.response.PageActivateDeviceIdRspBO;
import com.yoho.service.model.union.response.UnionResponse;
import com.yoho.unions.common.enums.ClientTypeEnum;
... ... @@ -75,5 +76,5 @@ public interface IUnionService {
Integer queryActivateCount(ActivateDeviceIdReqBO activateDeviceIdReqBO);
ActivateDeviceIdResponseBO queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO);
PageActivateDeviceIdResponseBO queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO);
}
... ...
... ... @@ -2,6 +2,7 @@ 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.unions.common.model.DeviceIdMatchBO;
import com.yoho.unions.common.service.IBusinessImportService;
import com.yoho.unions.dal.IUnionLogsDAO;
... ... @@ -15,6 +16,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutionException;
/**
... ... @@ -24,6 +26,7 @@ import java.util.concurrent.ExecutionException;
public class DeviceIdMatchImportServiceImpl implements IBusinessImportService {
private static final Logger logger = LoggerFactory.getLogger(DeviceIdMatchImportServiceImpl.class);
private static final int BATCH_SIZE=100;
@Resource
IUnionLogsDAO unionLogsDAO;
... ... @@ -55,14 +58,21 @@ public class DeviceIdMatchImportServiceImpl implements IBusinessImportService {
deviceIds.add(deviceIdMatchBO.getIdfa());
}
List<String> matchIds = Lists.newArrayList();
Set<String> matchIds = Sets.newHashSet();
if(CollectionUtils.isEmpty(deviceIds)){
return matchIds;
}
if(isIdfa>0){
matchIds = unionLogsDAO.matchIdfa(deviceIds);
}else{
List<String> batchDeviceIds = null;
//一次100个到数据库去匹配是否已经激活
for (int i = 0; i < deviceIds.size(); i += BATCH_SIZE) {
List<String> temp = null;
if (i + BATCH_SIZE > deviceIds.size()) {
batchDeviceIds = deviceIds.subList(i, deviceIds.size());
} else {
batchDeviceIds = deviceIds.subList(i, i + BATCH_SIZE);
}
temp =unionLogsDAO.matchIdfa(batchDeviceIds,isIdfa);
matchIds.addAll(temp);
}
logger.debug("method batchImport(List<Object>) out.");
return matchIds;
... ...
... ... @@ -6,6 +6,7 @@ package com.yoho.unions.server.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.common.collect.Lists;
import com.netflix.config.DynamicIntProperty;
import com.netflix.config.DynamicPropertyFactory;
import com.yoho.core.common.utils.MD5;
... ... @@ -633,15 +634,20 @@ public class UnionServiceImpl implements IUnionService,ApplicationEventPublisher
}
@Override
public ActivateDeviceIdResponseBO queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO) {
public PageActivateDeviceIdResponseBO queryByDeviceId(ActivateDeviceIdReqBO activateDeviceIdReqBO) {
log.info("enter queryByDeviceId. param activateDeviceIdReqBO={}", activateDeviceIdReqBO);
if(activateDeviceIdReqBO.getIdfa()!=null){
activateDeviceIdReqBO.setImei(null);
}
UnionLogs unionLogs = unionLogsDAO.queryByDeviceId(activateDeviceIdReqBO);
ActivateDeviceIdResponseBO activateDeviceIdResponseBO = new ActivateDeviceIdResponseBO();
BeanUtils.copyProperties(unionLogs,activateDeviceIdResponseBO);
return activateDeviceIdResponseBO;
List<UnionLogs> unionLogs = unionLogsDAO.queryByDeviceId(activateDeviceIdReqBO);
List<ActivateDeviceIdResponseBO> activateDeviceIdResponseBOList =Lists.transform(unionLogs,input -> {
ActivateDeviceIdResponseBO output = new ActivateDeviceIdResponseBO();
BeanUtils.copyProperties(input, output);
return output;
});
PageActivateDeviceIdResponseBO pageActivateDeviceIdResponseBO = new PageActivateDeviceIdResponseBO();
pageActivateDeviceIdResponseBO.setList(activateDeviceIdResponseBOList);
return pageActivateDeviceIdResponseBO;
}
... ...
... ... @@ -75,10 +75,10 @@
</form>
</div>
<div region="center" style="height: 800px;">
<div style="margin-left: 30px;margin-top: 20px; height:800px;">
<div style="margin-left: 30px;margin-top: 20px; height:100px;">
<table id="activateTalbe2"></table>
</div>
<div id="matchDiv" style="padding:30px;"></div>
<div id="matchDiv" style="padding:30px;height:600px;"></div>
</div>
</div>
</div>
... ...