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