|
@@ -71,32 +71,21 @@ public class RankStrategyBy687 extends RankStrategyBasic {
|
|
|
}
|
|
|
|
|
|
// 选择一个客户
|
|
|
- List<String> customers = rankItems.stream()
|
|
|
- .map(i -> i.getExt().getOrDefault(CUSTOMER_FIELD_NAME, ""))
|
|
|
- .map(Objects::toString)
|
|
|
- .filter(StringUtils::isNotEmpty)
|
|
|
- .distinct()
|
|
|
- .collect(Collectors.toList());
|
|
|
+ List<String> customers = rankItems.stream().map(i -> i.getExt().getOrDefault(CUSTOMER_FIELD_NAME, "")).map(Objects::toString).filter(StringUtils::isNotEmpty).distinct().collect(Collectors.toList());
|
|
|
String keyFormat = "ad:engine:customer:layer:info:%s:" + userLayer;
|
|
|
List<HotRankFeatureInfo> customerFeature = this.multiGetFeature(customers, keyFormat);
|
|
|
String customer = this.choose(customerFeature);
|
|
|
|
|
|
// 从当前客户的所有创意中,选择一个创意
|
|
|
- List<String> customerCreativeIds = rankItems.stream()
|
|
|
- .filter(c -> StringUtils.equals(c.getExt().getOrDefault(CUSTOMER_FIELD_NAME, "").toString(), customer))
|
|
|
- .map(AdRankItem::getAdId)
|
|
|
- .map(Objects::toString)
|
|
|
- .collect(Collectors.toList());
|
|
|
+ List<String> customerCreativeIds = rankItems.stream().filter(c -> StringUtils.equals(c.getExt().getOrDefault(CUSTOMER_FIELD_NAME, "").toString(), customer)).map(AdRankItem::getAdId).map(Objects::toString).collect(Collectors.toList());
|
|
|
String cidKeyFormat = "ad:engine:cid:layer:info:%s:" + userLayer;
|
|
|
List<HotRankFeatureInfo> creativeFeature = this.multiGetFeature(customerCreativeIds, cidKeyFormat);
|
|
|
String chooseCreativeIdStr = this.choose(creativeFeature);
|
|
|
Long chooseCreativeId = Long.parseLong(chooseCreativeIdStr);
|
|
|
|
|
|
- Map<String, HotRankFeatureInfo> allCustomerFeatureMap = customerFeature.stream()
|
|
|
- .collect(Collectors.toMap(HotRankFeatureInfo::getLabel, Function.identity(), (o1, o2) -> o1));
|
|
|
+ Map<String, HotRankFeatureInfo> allCustomerFeatureMap = customerFeature.stream().collect(Collectors.toMap(HotRankFeatureInfo::getLabel, Function.identity(), (o1, o2) -> o1));
|
|
|
|
|
|
- Map<Long, HotRankFeatureInfo> allCreativeFeatureInfoMap = creativeFeature.stream()
|
|
|
- .collect(Collectors.toMap(i -> Long.parseLong(i.getLabel()), Function.identity(), (o1, o2) -> o1));
|
|
|
+ Map<Long, HotRankFeatureInfo> allCreativeFeatureInfoMap = creativeFeature.stream().collect(Collectors.toMap(i -> Long.parseLong(i.getLabel()), Function.identity(), (o1, o2) -> o1));
|
|
|
|
|
|
Map<String, String> sceneFeature = this.handleSceneFeature(System.currentTimeMillis() / 1000);
|
|
|
Map<String, String> reqFeature = this.getReqFeature(scoreParam, request);
|
|
@@ -119,18 +108,17 @@ public class RankStrategyBy687 extends RankStrategyBasic {
|
|
|
|
|
|
private String getUserLayer(RankRecommendRequestParam request) {
|
|
|
|
|
|
- String userLayer = "无曝光";
|
|
|
|
|
|
- String key = String.format("ad:engine:mid:layer:%s", request.getMid());
|
|
|
- String value = algRedisHelper.get(key);
|
|
|
- if (StringUtils.isNotEmpty(value)) {
|
|
|
- userLayer = value;
|
|
|
- }
|
|
|
+ Map<String, String> userLayer = this.getUserLayer(request.getMid());
|
|
|
+
|
|
|
+ String layer = userLayer.getOrDefault("layer", "无曝光");
|
|
|
+ String clazz = userLayer.getOrDefault("class", "其他");
|
|
|
+
|
|
|
if (request.getIsFilterUser()) {
|
|
|
- userLayer += "-炸";
|
|
|
+ return String.join("-", layer, "炸", clazz);
|
|
|
+ } else {
|
|
|
+ return String.join("-", layer, clazz);
|
|
|
}
|
|
|
-
|
|
|
- return userLayer;
|
|
|
}
|
|
|
|
|
|
private List<HotRankFeatureInfo> multiGetFeature(List<String> customers, String keyFormat) {
|