...
|
...
|
@@ -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;
|
|
|
}
|
|
|
} |
...
|
...
|
|