|
|
@@ -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));
|