|
@@ -11,6 +11,7 @@ import com.tzld.piaoquan.ad.engine.commons.redis.AdRedisHelper;
|
|
|
import com.tzld.piaoquan.ad.engine.commons.score.ScoreParam;
|
|
|
import com.tzld.piaoquan.ad.engine.service.feature.Feature;
|
|
|
import com.tzld.piaoquan.ad.engine.service.feature.FeatureService;
|
|
|
+import com.tzld.piaoquan.recommend.feature.domain.ad.base.AdRankItem;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
@@ -263,4 +264,58 @@ public abstract class RankStrategyBasic implements RankStrategy {
|
|
|
return 1.0;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ protected void putMetaFeature(AdRankItem adRankItem, Feature feature, Map<String, String> reqFeature,
|
|
|
+ Map<String, String> sceneFeatureMap, RankRecommendRequestParam request) {
|
|
|
+ Map<String, Map<String, String>> userFeature = feature.getUserFeature();
|
|
|
+ Map<String, Map<String, String>> videoFeature = feature.getVideoFeature();
|
|
|
+ Map<String, Map<String, Map<String, String>>> allAdVerFeature = feature.getAdVerFeature();
|
|
|
+ Map<String, Map<String, Map<String, String>>> allCidFeature = feature.getCidFeature();
|
|
|
+ Map<String, Map<String, Map<String, String>>> allSkuFeature = feature.getSkuFeature();
|
|
|
+ for (Map.Entry<String, Map<String, String>> entry : videoFeature.entrySet()) {
|
|
|
+ if (MapUtils.isNotEmpty(entry.getValue())) {
|
|
|
+ adRankItem.getMetaFeatureMap().put(entry.getKey(), entry.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (Map.Entry<String, Map<String, String>> entry : userFeature.entrySet()) {
|
|
|
+ if (MapUtils.isNotEmpty(entry.getValue())) {
|
|
|
+ adRankItem.getMetaFeatureMap().put(entry.getKey(), entry.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Map<String, String>> adVerFeature = allAdVerFeature.getOrDefault(adRankItem.getAdVerId(), new HashMap<>());
|
|
|
+ for (Map.Entry<String, Map<String, String>> entry : adVerFeature.entrySet()) {
|
|
|
+ if (MapUtils.isNotEmpty(entry.getValue())) {
|
|
|
+ adRankItem.getMetaFeatureMap().put(entry.getKey(), entry.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Map<String, String>> cidFeature = allCidFeature.getOrDefault(String.valueOf(adRankItem.getAdId()), new HashMap<>());
|
|
|
+ for (Map.Entry<String, Map<String, String>> entry : cidFeature.entrySet()) {
|
|
|
+ if (MapUtils.isNotEmpty(entry.getValue())) {
|
|
|
+ adRankItem.getMetaFeatureMap().put(entry.getKey(), entry.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Map<String, String>> skuFeature = allSkuFeature.getOrDefault(String.valueOf(adRankItem.getSkuId()), new HashMap<>());
|
|
|
+ for (Map.Entry<String, Map<String, String>> entry : skuFeature.entrySet()) {
|
|
|
+ if (MapUtils.isNotEmpty(entry.getValue())) {
|
|
|
+ adRankItem.getMetaFeatureMap().put(entry.getKey(), entry.getValue());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ long cid = adRankItem.getAdId();
|
|
|
+ List<AdPlatformCreativeDTO> adIdList = request.getAdIdList();
|
|
|
+ AdPlatformCreativeDTO adPlatformCreativeDTO = adIdList.stream()
|
|
|
+ .filter(dto -> cid == dto.getCreativeId())
|
|
|
+ .findFirst().orElse(null);
|
|
|
+ if (adPlatformCreativeDTO != null) {
|
|
|
+ reqFeature.put("cid", String.valueOf(adPlatformCreativeDTO.getCreativeId()));
|
|
|
+ reqFeature.put("adid", String.valueOf(adPlatformCreativeDTO.getAdId()));
|
|
|
+ reqFeature.put("adverid", String.valueOf(adPlatformCreativeDTO.getAdVerId()));
|
|
|
+ reqFeature.put("profession", adPlatformCreativeDTO.getProfession());
|
|
|
+ }
|
|
|
+ adRankItem.getMetaFeatureMap().put("reqFeature", reqFeature);
|
|
|
+ adRankItem.getMetaFeatureMap().put("sceneFeature", sceneFeatureMap);
|
|
|
+ }
|
|
|
}
|