Browse Source

feat:修改日志上报的存储结构

zhaohaipeng 10 months ago
parent
commit
2ac02282f0

+ 1 - 1
ad-engine-commons/pom.xml

@@ -25,7 +25,7 @@
         <dependency>
             <groupId>com.tzld.piaoquan</groupId>
             <artifactId>recommend-feature-client</artifactId>
-            <version>1.1.30</version>
+            <version>1.1.21</version>
         </dependency>
         <dependency>
             <groupId>com.tzld.piaoquan</groupId>

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

@@ -40,10 +40,10 @@ public class LogHubServiceImpl implements LogHubService {
             @Override
             public void run() {
                 JSONObject logMap = new JSONObject();
-                logMap.put("pqtId", param.getPqtId());
+                logMap.put("pqtid", param.getPqtId());
                 logMap.put("mid", param.getMid());
-                logMap.put("videoId", param.getVideoId());
-                logMap.put("abCode", abCode);
+                logMap.put("vid", param.getVideoId());
+                logMap.put("expid", abCode);
                 // 获取AB实验列表
                 Set<String> abExpCode = new HashSet<>();
                 if (CollectionUtils.isNotEmpty(requestParam.getAdAbExpArr())) {
@@ -53,41 +53,42 @@ public class LogHubServiceImpl implements LogHubService {
                         }
                     }
                 }
-                logMap.put("abExpCode", abExpCode);
+                logMap.put("expids", abExpCode);
 
                 List<JSONObject> scoreResult = new ArrayList<>();
                 for (AdRankItem rankItem : rankItems) {
                     JSONObject json = new JSONObject();
-                    json.put("adId", rankItem.getAdId());
                     json.put("cid", rankItem.getAdId());
                     json.put("score", rankItem.getScore());
-                    json.put("ext", rankItem.getExt());
-                    json.put("weight", rankItem.getWeight());
+                    rankItem.getFeature().put("weight", rankItem.getWeight());
+                    json.put("feature", rankItem.getFeature());
                     scoreResult.add(json);
                 }
                 logMap.put("scoreResult", JSON.toJSONString(scoreResult));
 
                 AdRankItem top1 = rankItems.get(0);
-                logMap.put("top1_adId", top1.getAdId());
-                logMap.put("top1_cid", top1.getAdId());
-                logMap.put("top1_score", top1.getScore());
-                logMap.put("top1_ext", JSON.toJSONString(top1.getExt()));
-                logMap.put("top1_weight", top1.getWeight());
+                logMap.put("cid", top1.getAdId());
+                logMap.put("score", top1.getScore());
+                JSONObject feature = new JSONObject(top1.getFeature());
+                feature.put("weight", top1.getWeight());
+                logMap.put("feature", feature.toJSONString());
 
-                logMap.put("creativeList", JSON.toJSONString(adIdList));
-                logMap.put("adAbGroup", requestParam.getAdAbGroup());
-                logMap.put("scoreStrategy", scoreStrategy);
-                logMap.put("appType", requestParam.getAppType());
+                logMap.put("abcode", requestParam.getAdAbGroup());
+                logMap.put("scorestrategy", scoreStrategy);
+                logMap.put("apptype", requestParam.getAppType());
 
-                if (Objects.nonNull(requestParam.getStatisticsLog())) {
-                    logMap.put("earlyAdIds", requestParam.getStatisticsLog().getEarlyAdIds());
-                    logMap.put("earlyCidList", requestParam.getStatisticsLog().getEarlyCreativeIds());
-                    logMap.put("finalCidList", requestParam.getStatisticsLog().getFinalCreativeIds());
-                    logMap.put("commonFilterAfterAdIds", requestParam.getStatisticsLog().getCommonFilterAfterAdIds());
-                    logMap.put("commonFilterAfterCidList", requestParam.getStatisticsLog().getCommonFilterAfterCreativeIds());
-                    logMap.put("tacticsFilterAfterAdIds", requestParam.getStatisticsLog().getTacticsFilterAfterAdIds());
-                    logMap.put("tacticsFilterAfterCidList", requestParam.getStatisticsLog().getTacticsFilterAfterCreativeIds());
-                }
+                // logMap.put("creativeList", JSON.toJSONString(adIdList));
+                // if (Objects.nonNull(requestParam.getStatisticsLog())) {
+                //     JSONObject extInfo = new JSONObject();
+                //     extInfo.put("earlyAdIds", requestParam.getStatisticsLog().getEarlyAdIds());
+                //     extInfo.put("earlyCidList", requestParam.getStatisticsLog().getEarlyCreativeIds());
+                //     extInfo.put("finalCidList", requestParam.getStatisticsLog().getFinalCreativeIds());
+                //     extInfo.put("commonFilterAfterAdIds", requestParam.getStatisticsLog().getCommonFilterAfterAdIds());
+                //     extInfo.put("commonFilterAfterCidList", requestParam.getStatisticsLog().getCommonFilterAfterCreativeIds());
+                //     extInfo.put("tacticsFilterAfterAdIds", requestParam.getStatisticsLog().getTacticsFilterAfterAdIds());
+                //     extInfo.put("tacticsFilterAfterCidList", requestParam.getStatisticsLog().getTacticsFilterAfterCreativeIds());
+                //     logMap.put("extinfo", extInfo);
+                // }
 
                 aliyunLogManager.sendLog(project, logStore, "", logMap);
             }

+ 3 - 3
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/impl/RankServiceImpl.java

@@ -78,14 +78,14 @@ public class RankServiceImpl implements RankService {
         Map<Long, List<AdPlatformCreativeDTO>> groupMap = request
                 .getAdIdList()
                 .stream()
-                .collect(Collectors.groupingBy(creativeDTO -> creativeDTO.getCreativeId()));
+                .collect(Collectors.groupingBy(AdPlatformCreativeDTO::getCreativeId));
         Map<Long, AdRankItem> cache = adCreativeFeatureContainer.getAll(new ArrayList<>(groupMap.keySet()));
         List<AdRankItem> rankItems = Collections.emptyList();
         if (!cache.isEmpty()) {
             rankItems = new LinkedList<>(cache.values());
         }
         // 避免recommend-feature出问题
-        if (rankItems == null || rankItems.size() == 0) {
+        if (CollectionUtils.isEmpty(rankItems)) {
             rankItems = new LinkedList<>();
             for (Long adId : groupMap.keySet()) {
                 AdRankItem item = new AdRankItem();
@@ -179,7 +179,7 @@ public class RankServiceImpl implements RankService {
             }
 
             for (AdRankItem adRankItem : rankResult) {
-                adRankItem.getExt().put("userAdFeature", JSON.toJSONString(userAdFeature));
+                adRankItem.getFeature().put("userAdFeature", JSON.toJSONString(userAdFeature));
             }
             // 日志上报
             logHubService.scoreLogUpload(param, request.getAdIdList(), rankResult, request,