Procházet zdrojové kódy

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

zhaohaipeng před 10 měsíci
rodič
revize
f7fc567a39

+ 30 - 7
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/predict/impl/PredictModelServiceImpl.java

@@ -66,6 +66,10 @@ public class PredictModelServiceImpl implements PredictModelService {
     private String withoutAdVideoIds;
     @Value("${ad.predict.old.exp.appId:0,3,4,5,6,17,18,19,21,22}")
     private String oldExpGroupAppId = "";
+
+    @Value("${user.source.layer.ad.rate.exp.ids:673,676}")
+    private String userSourceLayerAdRateExpIds;
+
     List<Integer> appIdArr = Arrays.asList(new Integer[]{0, 3, 4, 5, 6, 17, 18, 19, 21, 22});
 
 
@@ -225,9 +229,9 @@ public class PredictModelServiceImpl implements PredictModelService {
 
             String appTypeStr = requestParam.getAppType().toString();
 
-            boolean in676Exp = expCodes.contains("673")
-                    || NewExpInfoHelper.checkInNewExpGroupAndSetParamIfIn(expCodes, appTypeStr, requestParam.getNewExpGroup(), "673", modelParam);
-            if (in676Exp) {
+            List<String> userSourceAndLayerAdRateExpIds = Arrays.asList(userSourceLayerAdRateExpIds.split(","));
+            boolean inAdRateExp = this.checkInAnyExpIdsAndNewAb(expCodes, userSourceAndLayerAdRateExpIds, appTypeStr, requestParam.getNewExpGroup(), modelParam);
+            if (inAdRateExp) {
                 result = ThresholdModelContainer.getThresholdPredictModel("random673").predict(modelParam);
                 // 如果676实验返回结果,表示未命中规则即对应的用户来源和所属层存在配置,使用676实验的结果,否则继续走599实验
                 if (Objects.nonNull(result)) {
@@ -305,10 +309,9 @@ public class PredictModelServiceImpl implements PredictModelService {
     }
 
     public void setExtraParam(ThresholdPredictModelParam modelParam) {
-        String[] ids = testIds.split(",");
-        List<String> idList = Arrays.asList(ids);
+        List<String> idList = Arrays.asList(testIds.split(","));
         List<Map<String, Object>> mapList = (List) modelParam.getAbExpInfo().get("ab_test002");
-        Collections.sort(mapList, new Comparator<Map<String, Object>>() {
+        mapList.sort(new Comparator<Map<String, Object>>() {
             @Override
             public int compare(Map<String, Object> map1, Map<String, Object> map2) {
                 int abExpCode1 = Integer.parseInt(map1.get("abExpCode").toString());
@@ -331,7 +334,7 @@ public class PredictModelServiceImpl implements PredictModelService {
     }
 
 
-    boolean inExpList(Set<String> set, String expCodes) {
+    private boolean inExpList(Set<String> set, String expCodes) {
         String[] expArr = expCodes.split(",");
         for (String str : expArr) {
             if (set.contains(str)) {
@@ -340,4 +343,24 @@ public class PredictModelServiceImpl implements PredictModelService {
         }
         return false;
     }
+
+    /**
+     * 判断用户是否处于某些实验中
+     *
+     * @param userExpIdSet 用户所在的实验
+     * @param expIds       需要判断的实验
+     */
+    private boolean checkInAnyExpIdsAndNewAb(Collection<String> userExpIdSet, Collection<String> expIds, String appId, int groupNumber, ThresholdPredictModelParam modelParam) {
+        for (String expId : expIds) {
+            // 如果包含,返回true
+            if (userExpIdSet.contains(expId)) {
+                return true;
+            }
+            // 在新实验系统中有配置
+            if (NewExpInfoHelper.checkInNewExpGroupAndSetParamIfIn(userExpIdSet, appId, groupNumber, expId, modelParam)) {
+                return true;
+            }
+        }
+        return false;
+    }
 }