|
@@ -21,13 +21,13 @@ import com.tzld.piaoquan.ad.engine.service.score.param.RankRecommendRequestParam
|
|
import com.tzld.piaoquan.recommend.feature.domain.ad.base.AdItemFeature;
|
|
import com.tzld.piaoquan.recommend.feature.domain.ad.base.AdItemFeature;
|
|
import com.tzld.piaoquan.recommend.feature.domain.ad.base.AdRankItem;
|
|
import com.tzld.piaoquan.recommend.feature.domain.ad.base.AdRankItem;
|
|
import com.tzld.piaoquan.recommend.feature.domain.ad.base.UserAdFeature;
|
|
import com.tzld.piaoquan.recommend.feature.domain.ad.base.UserAdFeature;
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
@@ -60,16 +60,12 @@ public class RankServiceImpl implements RankService {
|
|
@Value("${ad.cvr.adjusting.exp:652}")
|
|
@Value("${ad.cvr.adjusting.exp:652}")
|
|
private String cvrAdjustingExpCode;
|
|
private String cvrAdjustingExpCode;
|
|
|
|
|
|
- public AdRankItem adItemRank(RankRecommendRequestParam request) {
|
|
|
|
|
|
+ public AdRankItem adItemRank(RankRecommendRequestParam requestParam) {
|
|
|
|
+ return adItemRankOld(requestParam);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public AdRankItem adItemRankOld(RankRecommendRequestParam request) {
|
|
ScoreParam param = RequestConvert.requestConvert(request);
|
|
ScoreParam param = RequestConvert.requestConvert(request);
|
|
- LocalDateTime currentTime = LocalDateTime.now();
|
|
|
|
- int currentHour = currentTime.getHour();
|
|
|
|
- int dayOfWeek = currentTime.getDayOfWeek().getValue();
|
|
|
|
- param.getRequestContext().setHour(currentHour + "");
|
|
|
|
- param.getRequestContext().setWeek(dayOfWeek + "");
|
|
|
|
- param.getRequestContext().setRegion(request.getRegion().replace("省", ""));
|
|
|
|
- param.getRequestContext().setCity(request.getCity().replace("市", ""));
|
|
|
|
- param.getRequestContext().setDay(currentTime.format(dateFormatter));
|
|
|
|
|
|
|
|
UserAdFeature userAdFeature = featureRemoteService.getUserAdFeature(request.getMid());
|
|
UserAdFeature userAdFeature = featureRemoteService.getUserAdFeature(request.getMid());
|
|
if (userAdFeature == null) {
|
|
if (userAdFeature == null) {
|
|
@@ -96,15 +92,24 @@ public class RankServiceImpl implements RankService {
|
|
}
|
|
}
|
|
boolean inCpcPidExp = false;
|
|
boolean inCpcPidExp = false;
|
|
boolean inCvrAdjustingExp = false;
|
|
boolean inCvrAdjustingExp = false;
|
|
- if (request.getAdAbExpArr() != null && request.getAdAbExpArr().size() != 0) {
|
|
|
|
- for (Map<String, Object> map : request.getAdAbExpArr()) {
|
|
|
|
- if (map.getOrDefault("abExpCode", "").equals(cpcPidExpCode)) {
|
|
|
|
- inCpcPidExp = true;
|
|
|
|
- }
|
|
|
|
- if (map.getOrDefault("abExpCode", "").equals(cvrAdjustingExpCode)) {
|
|
|
|
- inCvrAdjustingExp = true;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ // if (request.getAdAbExpArr() != null && request.getAdAbExpArr().size() != 0) {
|
|
|
|
+ // for (Map<String, Object> map : request.getAdAbExpArr()) {
|
|
|
|
+ // if (map.getOrDefault("abExpCode", "").equals(cpcPidExpCode)) {
|
|
|
|
+ // inCpcPidExp = true;
|
|
|
|
+ // }
|
|
|
|
+ // if (map.getOrDefault("abExpCode", "").equals(cvrAdjustingExpCode)) {
|
|
|
|
+ // inCvrAdjustingExp = true;
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ if (CollectionUtils.isNotEmpty(request.getAdAbExpArr())) {
|
|
|
|
+ Set<String> abExpCode = request.getAdAbExpArr().stream()
|
|
|
|
+ .map(map -> map.get("abExpCode"))
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
+ .map(Object::toString)
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
|
+ inCpcPidExp = abExpCode.contains(cpcPidExpCode);
|
|
|
|
+ inCvrAdjustingExp = abExpCode.contains(cvrAdjustingExpCode);
|
|
}
|
|
}
|
|
double lambda = -1d;
|
|
double lambda = -1d;
|
|
if (inCpcPidExp) {
|
|
if (inCpcPidExp) {
|
|
@@ -162,7 +167,7 @@ public class RankServiceImpl implements RankService {
|
|
object.put("score", rankResult.get(0).getScore());
|
|
object.put("score", rankResult.get(0).getScore());
|
|
object.put("pidLambda", rankResult.get(0).getPidLambda());
|
|
object.put("pidLambda", rankResult.get(0).getPidLambda());
|
|
object.put("lrsamples", rankResult.get(0).getLrSampleString());
|
|
object.put("lrsamples", rankResult.get(0).getLrSampleString());
|
|
- object.put("dataTime", currentTime.format(timeFormatter));
|
|
|
|
|
|
+ object.put("dataTime", LocalDateTime.now().format(timeFormatter));
|
|
object.put("creativeId", rankResult.get(0).getAdId());
|
|
object.put("creativeId", rankResult.get(0).getAdId());
|
|
object.put("videoId", request.getVideoId());
|
|
object.put("videoId", request.getVideoId());
|
|
object.put("pqtId", request.getPqtId());
|
|
object.put("pqtId", request.getPqtId());
|
|
@@ -179,7 +184,7 @@ public class RankServiceImpl implements RankService {
|
|
}
|
|
}
|
|
|
|
|
|
for (AdRankItem adRankItem : rankResult) {
|
|
for (AdRankItem adRankItem : rankResult) {
|
|
- adRankItem.getFeature().put("userAdFeature", JSON.toJSONString(userAdFeature));
|
|
|
|
|
|
+ adRankItem.getExt().put("userAdFeature", JSON.toJSONString(userAdFeature));
|
|
}
|
|
}
|
|
// 日志上报
|
|
// 日志上报
|
|
logHubService.scoreLogUpload(param, request.getAdIdList(), rankResult, request,
|
|
logHubService.scoreLogUpload(param, request.getAdIdList(), rankResult, request,
|
|
@@ -204,12 +209,21 @@ public class RankServiceImpl implements RankService {
|
|
param.getRequestContext().setDay(currentTime.format(dateFormatter));
|
|
param.getRequestContext().setDay(currentTime.format(dateFormatter));
|
|
|
|
|
|
Set<String> expCodes = new HashSet<>();
|
|
Set<String> expCodes = new HashSet<>();
|
|
- if (request.getAdAbExpArr() != null && request.getAdAbExpArr().size() != 0) {
|
|
|
|
- for (Map<String, Object> map : request.getAdAbExpArr()) {
|
|
|
|
- String expCode = map.getOrDefault("abExpCode", "").toString();
|
|
|
|
- expCodes.add(expCode);
|
|
|
|
- }
|
|
|
|
|
|
+ // if (request.getAdAbExpArr() != null && request.getAdAbExpArr().size() != 0) {
|
|
|
|
+ // for (Map<String, Object> map : request.getAdAbExpArr()) {
|
|
|
|
+ // String expCode = map.getOrDefault("abExpCode", "").toString();
|
|
|
|
+ // expCodes.add(expCode);
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ if (CollectionUtils.isNotEmpty(request.getAdAbExpArr())) {
|
|
|
|
+ expCodes = request.getAdAbExpArr().stream()
|
|
|
|
+ .map(m -> m.get("abExpCode"))
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
+ .map(Object::toString)
|
|
|
|
+ .collect(Collectors.toSet());
|
|
}
|
|
}
|
|
|
|
+
|
|
ThresholdPredictModelParam modelParam = ThresholdPredictModelParam.builder()
|
|
ThresholdPredictModelParam modelParam = ThresholdPredictModelParam.builder()
|
|
.build();
|
|
.build();
|
|
// 兜底方案
|
|
// 兜底方案
|