浏览代码

Merge branch '20251024_feature_fjy_673_update' of algorithm/ad-engine into master

fanjinyang 1 天之前
父节点
当前提交
66e1d2dd31

+ 12 - 2
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/predict/v2/PredictStrategyBy673.java

@@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.MapUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
@@ -13,6 +14,9 @@ import java.util.*;
 @Slf4j
 @Service
 public class PredictStrategyBy673 extends ThresholdPredictStrategy {
+
+    @Value("${filter.with.region:1}")
+    private String filterWithRegion;
     @Override
     Map<String, Double> thresholdConfig(PredictContext ctx) {
 
@@ -22,7 +26,14 @@ public class PredictStrategyBy673 extends ThresholdPredictStrategy {
 
         try {
             JSONObject json = ctx.getExpConfigMap().getOrDefault("673", new JSONObject());
-            JSONObject configJson = json.getJSONObject(String.format("%s:%s", ctx.getUserExternalSource(), ctx.getShareLayer()));
+            String configKey = String.format("%s:%s", ctx.getUserExternalSource(), ctx.getShareLayer());
+            if("1".equals(filterWithRegion) && StringUtils.isNotBlank(configKey)) {
+                String region = StringUtils.isBlank(ctx.getRegion()) ? "未知地区" : ctx.getRegion();
+                String city = StringUtils.isBlank(ctx.getCity()) ? "未知地区" : ctx.getCity();
+                configKey = configKey + ":" + region + "_" + city;
+                log.info( "PredictStrategyBy673 configKey: {}", configKey);
+            }
+            JSONObject configJson = json.getJSONObject(configKey);
             if (MapUtils.isEmpty(configJson)) {
                 return Collections.emptyMap();
             }
@@ -57,7 +68,6 @@ public class PredictStrategyBy673 extends ThresholdPredictStrategy {
                 break;
             }
         }
-
         Map<String, Object> rtnMap = new HashMap<>();
         if (score < threshold) {
             rtnMap.putAll(rtnAdPredict(ctx));