|
|
@@ -388,9 +388,9 @@ public class MaterialSearchServiceImpl implements MaterialSearchService {
|
|
|
ScoredMaterial item = new ScoredMaterial();
|
|
|
item.setConfigCode(configCode);
|
|
|
item.setModality(modality);
|
|
|
- item.setSim(round4(sim));
|
|
|
+ item.setSim(MaterialQualityCalculator.round4(sim));
|
|
|
item.setQualityScore(0.5);
|
|
|
- item.setFinalScore(round4(simNorm));
|
|
|
+ item.setFinalScore(MaterialQualityCalculator.round4(simNorm));
|
|
|
if (m instanceof VideoMatch) {
|
|
|
VideoMatch vm = (VideoMatch) m;
|
|
|
item.setVideoId(String.valueOf(vm.getVideoId()));
|
|
|
@@ -423,11 +423,11 @@ public class MaterialSearchServiceImpl implements MaterialSearchService {
|
|
|
for (String mid : materialIds) {
|
|
|
AdsMaterialTouliuAllChannel s = statsMap.get(mid);
|
|
|
if (s == null) continue;
|
|
|
- Double ctr = divide(s.getClicks(), s.getImpressions());
|
|
|
- Double cvr = divide(s.getConversions(), s.getImpressions());
|
|
|
- Double roi = divide(s.getIncome(), s.getCost());
|
|
|
- Double openRate = divide(s.getFirstUv(), s.getConversions());
|
|
|
- Double fissionRate = divide(s.getFission0Uv(), s.getFirstUv());
|
|
|
+ Double ctr = MaterialQualityCalculator.divide(s.getClicks(), s.getImpressions());
|
|
|
+ Double cvr = MaterialQualityCalculator.divide(s.getConversions(), s.getImpressions());
|
|
|
+ Double roi = MaterialQualityCalculator.divide(s.getIncome(), s.getCost());
|
|
|
+ Double openRate = MaterialQualityCalculator.divide(s.getFirstUv(), s.getConversions());
|
|
|
+ Double fissionRate = MaterialQualityCalculator.divide(s.getFission0Uv(), s.getFirstUv());
|
|
|
if (ctr != null || cvr != null || roi != null || openRate != null || fissionRate != null) {
|
|
|
effMap.put(mid, new double[]{
|
|
|
ctr != null ? ctr : 0, cvr != null ? cvr : 0,
|
|
|
@@ -462,9 +462,9 @@ public class MaterialSearchServiceImpl implements MaterialSearchService {
|
|
|
item.setSourceType(m.getSourceType());
|
|
|
item.setSource(mapSourceTypeLabel(m.getSourceType()));
|
|
|
item.setText(m.getText());
|
|
|
- item.setSim(round4(sim));
|
|
|
- item.setQualityScore(round4(qualityScore));
|
|
|
- item.setFinalScore(round4(finalScore));
|
|
|
+ item.setSim(MaterialQualityCalculator.round4(sim));
|
|
|
+ item.setQualityScore(MaterialQualityCalculator.round4(qualityScore));
|
|
|
+ item.setFinalScore(MaterialQualityCalculator.round4(finalScore));
|
|
|
|
|
|
// 元数据
|
|
|
JSONObject deconstructJson = deconstructMap.get(m.getMaterialId());
|
|
|
@@ -484,23 +484,23 @@ public class MaterialSearchServiceImpl implements MaterialSearchService {
|
|
|
item.setImpressions(s.getImpressions());
|
|
|
item.setClicks(s.getClicks());
|
|
|
item.setConversions(s.getConversions());
|
|
|
- item.setCost(round4(s.getCost()));
|
|
|
- item.setIncome(round4(s.getIncome()));
|
|
|
+ item.setCost(MaterialQualityCalculator.round4(s.getCost()));
|
|
|
+ item.setIncome(MaterialQualityCalculator.round4(s.getIncome()));
|
|
|
item.setFirstUv(s.getFirstUv());
|
|
|
item.setFission0Uv(s.getFission0Uv());
|
|
|
}
|
|
|
if (eff != null) {
|
|
|
- item.setCtr(round4(eff[0]));
|
|
|
- item.setCvr(round4(eff[1]));
|
|
|
- item.setRoi(round4(eff[2]));
|
|
|
- item.setOpenRate(round4(eff[3]));
|
|
|
- item.setFissionRate(round4(eff[4]));
|
|
|
+ item.setCtr(MaterialQualityCalculator.round4(eff[0]));
|
|
|
+ item.setCvr(MaterialQualityCalculator.round4(eff[1]));
|
|
|
+ item.setRoi(MaterialQualityCalculator.round4(eff[2]));
|
|
|
+ item.setOpenRate(MaterialQualityCalculator.round4(eff[3]));
|
|
|
+ item.setFissionRate(MaterialQualityCalculator.round4(eff[4]));
|
|
|
// 维度得分 = 原始比率
|
|
|
- item.setCtrScore(round4(eff[0]));
|
|
|
- item.setCvrScore(round4(eff[1]));
|
|
|
- item.setRoiScore(round4(eff[2]));
|
|
|
- item.setOpenRateScore(round4(eff[3]));
|
|
|
- item.setFissionRateScore(round4(eff[4]));
|
|
|
+ item.setCtrScore(MaterialQualityCalculator.round4(eff[0]));
|
|
|
+ item.setCvrScore(MaterialQualityCalculator.round4(eff[1]));
|
|
|
+ item.setRoiScore(MaterialQualityCalculator.round4(eff[2]));
|
|
|
+ item.setOpenRateScore(MaterialQualityCalculator.round4(eff[3]));
|
|
|
+ item.setFissionRateScore(MaterialQualityCalculator.round4(eff[4]));
|
|
|
}
|
|
|
list.add(item);
|
|
|
}
|
|
|
@@ -508,14 +508,6 @@ public class MaterialSearchServiceImpl implements MaterialSearchService {
|
|
|
return list.stream().limit(topN).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
- /** a / b,任一方为 null 或 b==0 时返回 null */
|
|
|
- private static Double divide(Number a, Number b) {
|
|
|
- if (a == null || b == null) return null;
|
|
|
- double bd = b.doubleValue();
|
|
|
- if (bd == 0) return null;
|
|
|
- return a.doubleValue() / bd;
|
|
|
- }
|
|
|
-
|
|
|
/** 从不同类型的 Match 中提取相似度分数 */
|
|
|
private double getMatchScore(Object match) {
|
|
|
if (match instanceof VideoMatch) return ((VideoMatch) match).getScore();
|
|
|
@@ -547,22 +539,22 @@ public class MaterialSearchServiceImpl implements MaterialSearchService {
|
|
|
vo.setImpressions(s.getImpressions());
|
|
|
vo.setClicks(s.getClicks());
|
|
|
vo.setConversions(s.getConversions());
|
|
|
- vo.setCost(round4(s.getCost()));
|
|
|
- vo.setIncome(round4(s.getIncome()));
|
|
|
+ vo.setCost(MaterialQualityCalculator.round4(s.getCost()));
|
|
|
+ vo.setIncome(MaterialQualityCalculator.round4(s.getIncome()));
|
|
|
vo.setFirstUv(s.getFirstUv());
|
|
|
vo.setFission0Uv(s.getFission0Uv());
|
|
|
|
|
|
// 效率指标
|
|
|
- Double ctr = divide(s.getClicks(), s.getImpressions());
|
|
|
- Double cvr = divide(s.getConversions(), s.getImpressions());
|
|
|
- Double roi = divide(s.getIncome(), s.getCost());
|
|
|
- Double openRate = divide(s.getFirstUv(), s.getConversions());
|
|
|
- Double fissionRate = divide(s.getFission0Uv(), s.getFirstUv());
|
|
|
- vo.setCtr(ctr != null ? round4(ctr) : null);
|
|
|
- vo.setCvr(cvr != null ? round4(cvr) : null);
|
|
|
- vo.setRoi(roi != null ? round4(roi) : null);
|
|
|
- vo.setOpenRate(openRate != null ? round4(openRate) : null);
|
|
|
- vo.setFissionRate(fissionRate != null ? round4(fissionRate) : null);
|
|
|
+ Double ctr = MaterialQualityCalculator.divide(s.getClicks(), s.getImpressions());
|
|
|
+ Double cvr = MaterialQualityCalculator.divide(s.getConversions(), s.getImpressions());
|
|
|
+ Double roi = MaterialQualityCalculator.divide(s.getIncome(), s.getCost());
|
|
|
+ Double openRate = MaterialQualityCalculator.divide(s.getFirstUv(), s.getConversions());
|
|
|
+ Double fissionRate = MaterialQualityCalculator.divide(s.getFission0Uv(), s.getFirstUv());
|
|
|
+ vo.setCtr(ctr != null ? MaterialQualityCalculator.round4(ctr) : null);
|
|
|
+ vo.setCvr(cvr != null ? MaterialQualityCalculator.round4(cvr) : null);
|
|
|
+ vo.setRoi(roi != null ? MaterialQualityCalculator.round4(roi) : null);
|
|
|
+ vo.setOpenRate(openRate != null ? MaterialQualityCalculator.round4(openRate) : null);
|
|
|
+ vo.setFissionRate(fissionRate != null ? MaterialQualityCalculator.round4(fissionRate) : null);
|
|
|
|
|
|
// 单素材查询无批内排名,维度得分置 null
|
|
|
return vo;
|
|
|
@@ -763,10 +755,6 @@ public class MaterialSearchServiceImpl implements MaterialSearchService {
|
|
|
return Math.max(0, Math.min(1, x));
|
|
|
}
|
|
|
|
|
|
- private static double round4(double v) {
|
|
|
- return Math.round(v * 10000.0) / 10000.0;
|
|
|
- }
|
|
|
-
|
|
|
private static String mapSourceTypeLabel(Short sourceType) {
|
|
|
if (sourceType == null) return null;
|
|
|
if (sourceType == 1) return "外部合作";
|