Commit 62cc2ad2 by shenjunjie

Merge branch 'feature' into 'dev'

品见项目预警模块上测试环境2

See merge request !79
parents 8c51a0f7 31bed0e8
...@@ -72,6 +72,19 @@ public class ProjectWarnServiceImpl implements ProjectWarnService { ...@@ -72,6 +72,19 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
@Resource(name = "redisUtil") @Resource(name = "redisUtil")
RedisUtil redisUtil; RedisUtil redisUtil;
private static final Map<String, String> TYPE_SEARCH = new HashMap<>();
static {
TYPE_SEARCH.put("微博热搜", "weibo");
TYPE_SEARCH.put("微博话题", "weibo-topic");
TYPE_SEARCH.put("微博预热", "weibo-rise");
TYPE_SEARCH.put("头条热搜", "toutiao");
TYPE_SEARCH.put("抖音热搜", "douyin");
TYPE_SEARCH.put("知乎热搜", "zhihu");
TYPE_SEARCH.put("B站热搜", "bilibili-ranking");
TYPE_SEARCH.put("快手热搜", "kuaishou");
}
@Override @Override
public ResponseResult getProjectWarnCriteria(String projectId, String type) { public ResponseResult getProjectWarnCriteria(String projectId, String type) {
Map<String, Object> res = new HashMap<>(); Map<String, Object> res = new HashMap<>();
...@@ -242,7 +255,7 @@ public class ProjectWarnServiceImpl implements ProjectWarnService { ...@@ -242,7 +255,7 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
} }
int firstCount = datas.size(); int firstCount = datas.size();
// key1 // key1
String key1 = "【品见】舆情动态" + project.getProjectName(); String key1 = "【品见】舆情动态-" + project.getProjectName();
// key2 // key2
String key2Header = "全部"; String key2Header = "全部";
StringBuilder mediaChannel = new StringBuilder(); StringBuilder mediaChannel = new StringBuilder();
...@@ -360,7 +373,7 @@ public class ProjectWarnServiceImpl implements ProjectWarnService { ...@@ -360,7 +373,7 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
} }
int firstCount = datas.size(); int firstCount = datas.size();
// key1 // key1
String key1 = "【品见】渠道参与" + project.getProjectName(); String key1 = "【品见】渠道参与-" + project.getProjectName();
// key2 // key2
String key2 = "自定义渠道"; String key2 = "自定义渠道";
if (Boolean.TRUE.equals(config.getFriendlyChannel())) { if (Boolean.TRUE.equals(config.getFriendlyChannel())) {
...@@ -441,7 +454,7 @@ public class ProjectWarnServiceImpl implements ProjectWarnService { ...@@ -441,7 +454,7 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
if (firstCount == 0) { if (firstCount == 0) {
return null; return null;
} }
String key1 = "【品见】热点事件" + project.getProjectName(); String key1 = "【品见】热点事件-" + project.getProjectName();
// key2 // key2
String key2 = null; String key2 = null;
// key3 // key3
...@@ -474,27 +487,81 @@ public class ProjectWarnServiceImpl implements ProjectWarnService { ...@@ -474,27 +487,81 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
long start = end - config.getPushInterval(); long start = end - config.getPushInterval();
try { try {
log.info("获取上榜热搜预警开始,project:{}", project.getProjectName()); log.info("获取上榜热搜预警开始,project:{}", project.getProjectName());
// 根据配置榜单类型 if (null == config.getListType()) {
List<String> listType = config.getListType(); return ResponseResult.success();
if (listType.contains("微博热搜")) {
//获取当前微博热搜数据
List<JSONObject> wbRankList = getRankListByType("weibo");
getHotTopList(config, projectId, wbRankList, "微博热搜");
} }
// 根据配置榜单类型
List<BrandkbsHotTopWarn.HotTop> resList = new ArrayList<>();
config.getListType().forEach(type -> resList.addAll(getHotTopList(config, projectId, getRankListByType(type), type)));
log.info("获取上榜热搜预警结束,project:{}", project.getProjectName()); log.info("获取上榜热搜预警结束,project:{}", project.getProjectName());
return ResponseResult.success(); return ResponseResult.success(brandkbsWarnTemplate4HotTop(config, resList, start, end, project));
} catch (Exception e) { } catch (Exception e) {
log.info("获取上榜热搜预警失败,project:{}", project.getProjectName(), e); log.info("获取上榜热搜预警失败,project:{}", project.getProjectName(), e);
} }
return ResponseResult.failure("获取上榜热搜预警失败"); return ResponseResult.failure("获取上榜热搜预警失败");
} }
private BrandkbsWarnTemplate brandkbsWarnTemplate4HotTop(BrandkbsHotTopConfig config, List<BrandkbsHotTopWarn.HotTop> datas, long start, long end,
AbstractProject project) {
if (CollectionUtils.isEmpty(datas)) {
return null;
}
String key1 = "【品见】上榜热搜-" + project.getProjectName();
// key2
String key2 = "";
List<String> key2Element = new ArrayList<>();
config.getListType().forEach(type -> {
if (config.getFirstTop()) {
key2Element.add(type + "榜-首次上榜");
}
if (config.getNewHeight()) {
key2Element.add(type + "榜-排名新高");
}
if (config.getTopOnceAgain()) {
key2Element.add(type + "榜-掉榜和再次上榜");
}
if ((type.equals("微博话题") || type.equals("微博热搜")) && config.getIntroduction()) {
key2Element.add(type + "榜-导语");
}
});
if (key2Element.size() > 2) {
key2 = key2Element.get(0) + "、" + key2Element.get(1) + "...";
} else if (1 == key2Element.size()) {
key2 = key2Element.get(0);
} else if (2 == key2Element.size()) {
key2 = key2Element.get(0) + "、" + key2Element.get(1);
}
// key3
String key3 = Constant.SPEC_MINUTE_FORMAT.format(start) + " ~ " + Constant.SPEC_MINUTE_FORMAT.format(end);
// key4
String key4;
StringBuilder keyBuilder4 = new StringBuilder();
for (int i = 0; i < 2; i++) {
BrandkbsHotTopWarn.HotTop hotTop = datas.get(i);
String topName = hotTop.getTopName() + "榜";
String title = hotTop.getTitle();
keyBuilder4.append(topName).append("/r/n");
keyBuilder4.append(i + 1).append("、").append(title).append("/r/n");
}
if (datas.size() > 2) {
key4 = keyBuilder4.append("...").toString();
} else {
key4 = keyBuilder4.substring(0, keyBuilder4.length() - 4);
}
return new BrandkbsWarnTemplate(datas.size(), key1, key2, key3, key4, new BrandkbsHotTopWarn(config.getWarnKeyword(), config.getFilterKeyword(), datas));
}
private List<JSONObject> getRankListByType(String type) { private List<JSONObject> getRankListByType(String type) {
String search = TYPE_SEARCH.get(type);
if (null == search) {
log.error("getRankListByType,search-null,type:{}", type);
return Collections.emptyList();
}
try { try {
ResponseEntity<String> response = restTemplate.getForEntity(hotSearchUrl, String.class, type); ResponseEntity<String> response = restTemplate.getForEntity(hotSearchUrl, String.class, search);
return JSON.parseObject(response.getBody()).getJSONArray("data").toJavaList(JSONObject.class); return JSON.parseObject(response.getBody()).getJSONArray("data").toJavaList(JSONObject.class);
} catch (Exception e) { } catch (Exception e) {
log.error("{} 热搜获取失败:", type, e); log.error("{} 热搜获取失败:", search, e);
} }
return Collections.emptyList(); return Collections.emptyList();
} }
...@@ -603,7 +670,7 @@ public class ProjectWarnServiceImpl implements ProjectWarnService { ...@@ -603,7 +670,7 @@ public class ProjectWarnServiceImpl implements ProjectWarnService {
hotTops.addAll(dropList.stream().map(json -> BrandkbsHotTopWarn.HotTop.createFromJSON(json, "掉榜", type)).collect(Collectors.toList())); hotTops.addAll(dropList.stream().map(json -> BrandkbsHotTopWarn.HotTop.createFromJSON(json, "掉榜", type)).collect(Collectors.toList()));
hotTops.addAll(reappearList.stream().map(json -> BrandkbsHotTopWarn.HotTop.createFromJSON(json, "再次上榜", type)).collect(Collectors.toList())); hotTops.addAll(reappearList.stream().map(json -> BrandkbsHotTopWarn.HotTop.createFromJSON(json, "再次上榜", type)).collect(Collectors.toList()));
} }
if (Boolean.TRUE.equals(config.getIntroduction())) { if (((type.equals("微博话题") || type.equals("微博热搜")) && Boolean.TRUE.equals(config.getIntroduction()))) {
List<JSONObject> topLeads = rankList.stream().filter(wbRank -> { List<JSONObject> topLeads = rankList.stream().filter(wbRank -> {
if (wbRank.getString("topicLead") == null) { if (wbRank.getString("topicLead") == null) {
return false; return false;
......
...@@ -92,4 +92,5 @@ warn.hotTop.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/bra ...@@ -92,4 +92,5 @@ warn.hotTop.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/bra
warn.yuQing.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/config/yuQing/{1} warn.yuQing.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/config/yuQing/{1}
warn.taskSwitch.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/enable/used warn.taskSwitch.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/enable/used
#\u9884\u8B66\u5916\u90E8\u63A5\u53E3 #\u9884\u8B66\u5916\u90E8\u63A5\u53E3
ef.external.filterNew.url=https://ef.zhiweidata.com/external/filterNew.do?firstTypes={1}&start={2}&end={3} ef.external.filterNew.url=https://ef.zhiweidata.com/external/filterNew.do?firstTypes={1}&start={2}&end={3}
\ No newline at end of file hot.search.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findNewHotSearch?type={1}
\ No newline at end of file
...@@ -94,4 +94,5 @@ warn.hotTop.url=http://192.168.0.225:11003/qbjc/brandkbsPush/interface/brandkbs/ ...@@ -94,4 +94,5 @@ warn.hotTop.url=http://192.168.0.225:11003/qbjc/brandkbsPush/interface/brandkbs/
warn.yuQing.url=http://192.168.0.225:11003/qbjc/brandkbsPush/interface/brandkbs/config/yuQing/{1} warn.yuQing.url=http://192.168.0.225:11003/qbjc/brandkbsPush/interface/brandkbs/config/yuQing/{1}
warn.taskSwitch.url=http://192.168.0.225:11003/qbjc/brandkbsPush/interface/brandkbs/enable/used warn.taskSwitch.url=http://192.168.0.225:11003/qbjc/brandkbsPush/interface/brandkbs/enable/used
#\u9884\u8B66\u5916\u90E8\u63A5\u53E3 #\u9884\u8B66\u5916\u90E8\u63A5\u53E3
ef.external.filterNew.url=https://ef.zhiweidata.com/external/filterNew.do?firstTypes={1}&start={2}&end={3} ef.external.filterNew.url=https://ef.zhiweidata.com/external/filterNew.do?firstTypes={1}&start={2}&end={3}
\ No newline at end of file hot.search.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findNewHotSearch?type={1}
\ No newline at end of file
...@@ -92,4 +92,5 @@ warn.hotTop.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/bra ...@@ -92,4 +92,5 @@ warn.hotTop.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/bra
warn.yuQing.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/config/yuQing/{1} warn.yuQing.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/config/yuQing/{1}
warn.taskSwitch.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/enable/used warn.taskSwitch.url=https://auto-push.zhiweidata.com/qbjc/brandkbsPush/interface/brandkbs/enable/used
#\u9884\u8B66\u5916\u90E8\u63A5\u53E3 #\u9884\u8B66\u5916\u90E8\u63A5\u53E3
ef.external.filterNew.url=https://ef.zhiweidata.com/external/filterNew.do?firstTypes={1}&start={2}&end={3} ef.external.filterNew.url=https://ef.zhiweidata.com/external/filterNew.do?firstTypes={1}&start={2}&end={3}
\ No newline at end of file hot.search.url=https://hotsearch-manage.zhiweidata.com/hotsearch/hotSearch/findNewHotSearch?type={1}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment