فهرست منبع

834随机实验

yaodaoseng 1 ماه پیش
والد
کامیت
bede81c1e3

+ 5 - 2
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/score/strategy/RankStrategyBy834.java

@@ -383,13 +383,16 @@ public class RankStrategyBy834 extends RankStrategyBasic {
 
 
             // 如果第一名不是保量广告,则随机取一条,并取消保量标记
             // 如果第一名不是保量广告,则随机取一条,并取消保量标记
             if (!top1IsGuaranteed && result.size() > 1) {
             if (!top1IsGuaranteed && result.size() > 1) {
-                int randomIndex = random.nextInt(result.size());
-                top1Item = result.get(randomIndex);
+                Collections.shuffle(result);
+                top1Item = result.get(0);
                 // 随机取出的广告取消保量标记
                 // 随机取出的广告取消保量标记
                 top1Item.getExt().put("isGuaranteed", false);
                 top1Item.getExt().put("isGuaranteed", false);
                 top1Item.getExt().put("guaranteeWeight", 1.0);
                 top1Item.getExt().put("guaranteeWeight", 1.0);
             }
             }
+        }
 
 
+        if (CollectionUtils.isNotEmpty(result)) {
+            AdRankItem top1Item = result.get(0);
             List<String> participateCompetitionType = new ArrayList<>();
             List<String> participateCompetitionType = new ArrayList<>();
             participateCompetitionType.add("engine");
             participateCompetitionType.add("engine");
             top1Item.getExt().put("isGuaranteeType", isGuaranteeType);
             top1Item.getExt().put("isGuaranteeType", isGuaranteeType);