Parcourir la source

Merge branch 'feature_20240531_zhaohaipeng_log' of algorithm/ad-engine into master

zhaohaipeng il y a 10 mois
Parent
commit
82ebd45e88

+ 19 - 7
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/log/impl/LogHubServiceImpl.java

@@ -14,10 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 import java.util.concurrent.LinkedBlockingDeque;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
@@ -58,11 +55,26 @@ public class LogHubServiceImpl implements LogHubService {
                         }
                     }
                 }
+                logMap.put("abExpCode", abExpCode);
 
-                logMap.put("scoreResult", JSON.toJSONString(rankItems));
-                logMap.put("creativeList", JSON.toJSONString(adIdList));
+                List<JSONObject> scoreResult = new ArrayList<>();
+                for (AdRankItem rankItem : rankItems) {
+                    JSONObject json = new JSONObject();
+                    json.put("adId", rankItem.getAdId());
+                    json.put("score", rankItem.getScore());
+                    json.put("ext", rankItem.getExt());
+                    json.put("weight", rankItem.getWeight());
+                    scoreResult.add(json);
+                }
+                logMap.put("scoreResult", JSON.toJSONString(scoreResult));
 
-                logMap.put("abExpCode", abExpCode);
+                AdRankItem top1 = rankItems.get(0);
+                logMap.put("top1_adId", top1.getAdId());
+                logMap.put("top1_score", top1.getScore());
+                logMap.put("top1_ext", JSON.toJSONString(top1.getExt()));
+                logMap.put("top1_weight", top1.getWeight());
+
+                logMap.put("creativeList", JSON.toJSONString(adIdList));
                 logMap.put("adAbGroup", requestParam.getAdAbGroup());
                 logMap.put("scoreStrategy", scoreStrategy);
                 logMap.put("appType", requestParam.getAppType());

+ 14 - 0
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/VideoAdThompsonScorerV2.java

@@ -140,6 +140,8 @@ public class VideoAdThompsonScorerV2 {
             item.setScore_type(663);
             item.setBid1(dto.getBid1());
             item.setBid2(dto.getBid2());
+            item.setWeight(dto.getWeight());
+            item.setCreativeCode(dto.getCreativeCode());
             result.add(item);
         }
 
@@ -182,6 +184,8 @@ public class VideoAdThompsonScorerV2 {
                 Map<String, Object> ext = this.extMap(statistic, "664", dto.getCpa(), null,
                         exp664Param.getOrDefault("alpha", 1d), exp664Param.getOrDefault("beta", 10000d), null);
                 ext.put("s1", s1);
+                item.setCreativeCode(dto.getCreativeCode());
+                item.setWeight(dto.getWeight());
                 item.setExt(ext);
                 item.setScore_type(664);
             } catch (Exception e) {
@@ -225,10 +229,12 @@ public class VideoAdThompsonScorerV2 {
                 score = score * dto.getCpa() * dto.getBid1() * dto.getBid2();
                 item.setScore(score);
                 item.setScore_type(665);
+                item.setWeight(dto.getWeight());
 
                 Map<String, Object> ext = this.extMap(statistic, "665", dto.getCpa(), null,
                         exp665Param.getOrDefault("alpha", 1d), exp665Param.getOrDefault("beta", 10000d), null);
                 ext.put("s1", s1);
+                item.setCreativeCode(dto.getCreativeCode());
                 item.setExt(ext);
             } catch (Exception e) {
                 log.error("svc=thompsonScorerByExp665 {}", gson.toJson(e.getStackTrace()));
@@ -373,6 +379,8 @@ public class VideoAdThompsonScorerV2 {
             item.setScore_type(666);
             item.setBid2(dto.getBid2());
             item.setBid1(dto.getBid1());
+            item.setWeight(dto.getWeight());
+            item.setCreativeCode(dto.getCreativeCode());
             result.add(item);
         }
 
@@ -443,6 +451,8 @@ public class VideoAdThompsonScorerV2 {
             ext.put("vidCidA", alpha);
             ext.put("cidB", cidBeta);
             ext.put("vidCidB", vidCidBeta);
+            ext.put("bid1", dto.getBid1());
+            ext.put("bid2", dto.getBid2());
             ext.put("cidStatistic", JSON.toJSONString(cidStatistic));
             ext.put("vidCidStatistic", JSON.toJSONString(vidCidStatistic));
             ext.put("cpa", dto.getCpa());
@@ -453,8 +463,12 @@ public class VideoAdThompsonScorerV2 {
             AdRankItem item = new AdRankItem();
             item.setCpa(dto.getCpa());
             item.setAdId(dto.getCreativeId());
+            item.setWeight(dto.getWeight());
             item.setScore(score);
             item.setExt(ext);
+            item.setBid1(dto.getBid1());
+            item.setBid2(dto.getBid2());
+            item.setCreativeCode(dto.getCreativeCode());
 
             result.add(item);
         }

+ 2 - 0
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/dto/AdPlatformCreativeDTO.java

@@ -30,6 +30,8 @@ public class AdPlatformCreativeDTO {
 
     private Double ecpm2;
 
+    private double weight;
+
     public static void main(String[] args) {
         System.out.println(JSON.toJSONString(AdPlatformCreativeDTO.builder()
                 .creativeId(3366L)