丁云鹏 1 rok temu
rodzic
commit
349279d4db

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

@@ -55,18 +55,27 @@ public class PredictModelServiceImpl implements PredictModelService {
     private String adPredictBreakExpCode;
 
     public Map<String, Object> adPredict(ThresholdPredictModelRequestParam requestParam) {
-        JSONObject object = requestParam.getAbExpInfo();
+
         boolean isHit = false;
-        if (object != null) {
-            List<Map<String, String>> abExps = JSONUtils.fromJson(object.getString("ab_test002"),
-                    new TypeToken<List<Map<String, String>>>() {
-                    }, Collections.emptyList());
-            for (Map<String, String> abExpMap : abExps) {
-                if (StringUtils.equals(abExpMap.get("abExpCode"), adPredictBreakExpCode)) {
-                    isHit = true;
-                    break;
+
+        try {
+            JSONObject object = requestParam.getAbExpInfo();
+            if (object != null) {
+                JSONArray array = object.getJSONArray("ab_test002");
+                if (array != null) {
+                    List<Map<String, String>> abExps = JSONUtils.fromJson(array.toJSONString(),
+                            new TypeToken<List<Map<String, String>>>() {
+                            }, Collections.emptyList());
+                    for (Map<String, String> abExpMap : abExps) {
+                        if (StringUtils.equals(abExpMap.get("abExpCode"), adPredictBreakExpCode)) {
+                            isHit = true;
+                            break;
+                        }
+                    }
                 }
             }
+        } catch (Exception e) {
+            log.error("adPredict hit error", e);
         }
 
         if (adPredictBreakSwitch || isHit) {