ソースを参照

创意用户分层校准

jch 1 週間 前
コミット
0cddf4a066

+ 10 - 5
ad-engine-commons/src/main/java/com/tzld/piaoquan/ad/engine/commons/helper/CreativeUserLayerDataHelper.java

@@ -29,14 +29,18 @@ public class CreativeUserLayerDataHelper {
     @PostConstruct
     public void init() {
         Map<String, Double> map = readTextFromOss(filePath);
-        cidMap = Collections.unmodifiableMap(map);
+        if (null != map) {
+            cidMap = Collections.unmodifiableMap(map);
+        }
     }
 
     // 每5分钟更新一次数据
     @Scheduled(fixedRate = 5 * 60 * 1000)
     public void scheduledUpdate() {
         Map<String, Double> map = readTextFromOss(filePath);
-        cidMap = Collections.unmodifiableMap(map);
+        if (null != map) {
+            cidMap = Collections.unmodifiableMap(map);
+        }
     }
 
     public static Double getCopc(String model, String cid, String layer) {
@@ -64,8 +68,8 @@ public class CreativeUserLayerDataHelper {
     }
 
     private HashMap<String, Double> parseCidData(List<JSONObject> list) {
-        HashMap<String, Double> map = new HashMap<>();
         if (null != list) {
+            HashMap<String, Double> map = new HashMap<>();
             for (JSONObject json : list) {
                 String model = json.getString("model");
                 String cid = json.getString("cid");
@@ -74,13 +78,14 @@ public class CreativeUserLayerDataHelper {
                 String key = String.format(keyFormat, model, cid, layer);
                 map.put(key, copc);
             }
+            return map;
         }
-        return map;
+        return null;
     }
 
     private List<JSONObject> readOssFile(String ossFilePath) {
         if (!ossClient.doesObjectExist(BUCKET_NAME, ossFilePath)) {
-            log.error("ossFilePath not exist: {}", ossFilePath);
+            log.info("ossFilePath not exist: {}", ossFilePath);
             return null;
         }
         List<JSONObject> ossJson = new ArrayList<>();