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