|
@@ -41,7 +41,6 @@ public abstract class RankStrategyBasic implements RankStrategy {
|
|
|
String key = "ad:platform:guarantee:data:{date}:{adrId}";
|
|
|
|
|
|
|
|
|
-
|
|
|
protected Feature getFeature(ScoreParam param, RankRecommendRequestParam request) {
|
|
|
List<AdPlatformCreativeDTO> adIdList = request.getAdIdList();
|
|
|
List<String> cidList = adIdList.stream()
|
|
@@ -113,23 +112,28 @@ public abstract class RankStrategyBasic implements RankStrategy {
|
|
|
|
|
|
protected Map<String, GuaranteeView> getGuaranteeViewMap(RankRecommendRequestParam request, ScoreParam scoreParam) {
|
|
|
Map<String, GuaranteeView> map = new HashMap<>();
|
|
|
- if (scoreParam.getExpCodeSet().contains(guaranteeExp)) {
|
|
|
- String thatDayDateString = DateUtils.getThatDayDateString();
|
|
|
- String redisKey = key.replace("{date}", thatDayDateString);
|
|
|
- List<String> adVerIds = request.getAdIdList().stream().map(AdPlatformCreativeDTO::getAdVerId).distinct()
|
|
|
- .filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
- List<String> redisKeys = adVerIds.stream().map(e -> redisKey.replace("{adrId}", e)).collect(Collectors.toList());
|
|
|
- List<String> values = adRedisHelper.mget(redisKeys);
|
|
|
- if (CollectionUtils.isNotEmpty(values)) {
|
|
|
- for (int i = 0; i < redisKeys.size(); i++) {
|
|
|
- String value = values.get(i);
|
|
|
- if (value != null) {
|
|
|
- GuaranteeView guaranteeView = JSONObject.parseObject(value, GuaranteeView.class);
|
|
|
- map.put(adVerIds.get(i), guaranteeView);
|
|
|
+ try {
|
|
|
+ if (scoreParam.getExpCodeSet().contains(guaranteeExp)) {
|
|
|
+ String thatDayDateString = DateUtils.getThatDayDateString();
|
|
|
+ String redisKey = key.replace("{date}", thatDayDateString);
|
|
|
+ List<String> adVerIds = request.getAdIdList().stream().map(AdPlatformCreativeDTO::getAdVerId).distinct()
|
|
|
+ .filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ List<String> redisKeys = adVerIds.stream().map(e -> redisKey.replace("{adrId}", e)).collect(Collectors.toList());
|
|
|
+ List<String> values = adRedisHelper.mget(redisKeys);
|
|
|
+ if (CollectionUtils.isNotEmpty(values)) {
|
|
|
+ for (int i = 0; i < redisKeys.size(); i++) {
|
|
|
+ String value = values.get(i);
|
|
|
+ if (value != null) {
|
|
|
+ GuaranteeView guaranteeView = JSONObject.parseObject(value, GuaranteeView.class);
|
|
|
+ map.put(adVerIds.get(i), guaranteeView);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("getGuaranteeViewMap error", e);
|
|
|
}
|
|
|
+
|
|
|
return map;
|
|
|
}
|
|
|
|
|
@@ -143,9 +147,11 @@ public abstract class RankStrategyBasic implements RankStrategy {
|
|
|
guaranteeView.getGuaranteeNum() <= guaranteeView.getAdrAlgoViewNum()) {
|
|
|
guaranteeWeight = 0.0;
|
|
|
} else {
|
|
|
- int allViewNum = guaranteeView.getAllAlgoViewNum() == null || guaranteeView.getAllAlgoViewNum() == 0 ? 1 : guaranteeView.getAllAlgoViewNum();
|
|
|
- int adrAlogViewNum = guaranteeView.getAdrAlgoViewNum() == null || guaranteeView.getAdrAlgoViewNum() == 0 ? 1 : guaranteeView.getAdrAlgoViewNum();
|
|
|
- //guaranteeView.getGuaranteeRate() 是百分之几 要成0.01
|
|
|
+ int allViewNum = guaranteeView.getAllAlgoViewNum() == null || guaranteeView.getAllAlgoViewNum() == 0 ?
|
|
|
+ 1 : guaranteeView.getAllAlgoViewNum();
|
|
|
+ int adrAlogViewNum = guaranteeView.getAdrAlgoViewNum() == null || guaranteeView.getAdrAlgoViewNum() == 0 ?
|
|
|
+ 1 : guaranteeView.getAdrAlgoViewNum();
|
|
|
+ //guaranteeView.getGuaranteeRate() 是百分之几 要乘0.01
|
|
|
guaranteeWeight = guaranteeView.getGuaranteeRate() * 0.01 * allViewNum / adrAlogViewNum;
|
|
|
if (guaranteeWeight < 0.5) {
|
|
|
guaranteeWeight = 0.5;
|