/** * 单元下创意数不超过50个 * * @param adgroupIds * @return */ public List<CreativeType> getAllCreative(List<Long> adgroupIds) { List<CreativeType> creativeTypes = new ArrayList<>(); if (logger.isDebugEnabled()) { logger.debug("推广单元总数: " + adgroupIds.size()); } try { CreativeService creativeService = commonService.getService(CreativeService.class); GetCreativeByAdgroupIdRequest getCreativeByAdgroupIdRequest = new GetCreativeByAdgroupIdRequest(); List<Long> subList = new ArrayList<>(2 << 5); for (int i = 1; i <= adgroupIds.size(); i++) { Long agid = adgroupIds.get(i - 1); subList.add(agid); if (i % 200 == 0) { getCreativeByAdgroupIdRequest.setAdgroupIds(subList); GetCreativeByAdgroupIdResponse response = creativeService.getCreativeByAdgroupId(getCreativeByAdgroupIdRequest); if (response != null) { List<GroupCreative> creatives = response.getGroupCreatives(); for (GroupCreative groupCreative : creatives) { creativeTypes.addAll(groupCreative.getCreativeTypes()); } } subList.clear(); } } if (subList.size() > 0) { getCreativeByAdgroupIdRequest.setAdgroupIds(subList); GetCreativeByAdgroupIdResponse response = creativeService.getCreativeByAdgroupId(getCreativeByAdgroupIdRequest); if (response != null) { List<GroupCreative> creatives = response.getGroupCreatives(); for (GroupCreative groupCreative : creatives) { List<CreativeType> types = groupCreative.getCreativeTypes(); creativeTypes.addAll(types); } } subList.clear(); } } catch (ApiException e) { e.printStackTrace(); } return creativeTypes; }
public List<QualityType> getKeywordQuality(List<Long> keywordIds) { try { KeywordService keywordService = commonService.getService(KeywordService.class); GetKeywordQualityRequest request = new GetKeywordQualityRequest(); request.setIds(keywordIds); request.setType(11); // 3: 表示指定id数组为计划id 5:表示指定id数组为单元id 11:表示指定id为关键词id GetKeywordQualityResponse response = keywordService.getKeywordQuality(request); if (response == null) { return Collections.emptyList(); } return response.getQualities(); } catch (ApiException e) { e.printStackTrace(); } return Collections.emptyList(); }