Commit 231c2868 by shenjunjie

Merge branch 'feature' into 'release'

渠道榜单调整上线

See merge request !448
parents 81dedb79 0ba5c8e1
......@@ -277,7 +277,7 @@ public class AppChannelController extends BaseController {
@RequestParam(value = "endTime", required = false) Long endTime,
@RequestParam(value = "sorter", defaultValue = "{\"index\":\"descend\"}") String sorter,
@RequestParam(value = "pageSize", defaultValue = "50") int size) {
return ResponseResult.success(channelService.getPositiveChannelList(contendId, startTime, endTime, size, sorter, true));
return ResponseResult.success(channelService.getPositiveChannelList(contendId, startTime, endTime, size, null, true));
}
@ApiImplicitParams({@ApiImplicitParam(name = "contendId", value = "品牌id", defaultValue = "0", paramType = "query", dataType = "string"),
......@@ -294,7 +294,7 @@ public class AppChannelController extends BaseController {
@RequestParam(value = "endTime", required = false) Long endTime,
@RequestParam(value = "sorter", defaultValue = "{\"index\":\"descend\"}") String sorter,
@RequestParam(value = "pageSize", defaultValue = "50") int size) {
return ResponseResult.success(channelService.getNegativeChannelList(contendId, startTime, endTime, size, sorter, true));
return ResponseResult.success(channelService.getNegativeChannelList(contendId, startTime, endTime, size, null, true));
}
@ApiOperation("渠道库-渠道申请")
......
......@@ -200,11 +200,21 @@ public class ChannelIndex extends AbstractBaseMongo {
}
public static List<Article> filterArticles(Long startTime, Long endTime, List<Article> articles) {
return filterArticles(startTime, endTime, articles, null);
}
public static List<Article> filterArticles(Long startTime, Long endTime, List<Article> articles, Integer emotion) {
// 去除不符合时间段数据
articles = articles.stream().filter(article -> Tools.hitTimeRange(startTime, endTime, article.getTime())).collect(Collectors.toList());
// 去重并保留最近标注时间
Map<String, ChannelIndex.Article> setMap = new HashMap<>();
for (ChannelIndex.Article article : articles) {
if (null != emotion) {
// 文章类型与其不一致
if (emotion != EmotionEnum.ALL.getState() && emotion != article.getEmotion()) {
continue;
}
}
setMap.compute(article.getId(), (k, v) -> {
// 旧值为null或标注时间更新
if (null == v || article.getMtime() > v.getMtime()) {
......
......@@ -519,7 +519,10 @@ public class ChannelServiceImpl implements ChannelService {
// 情感过滤
if (emotion == EmotionEnum.ALL.getState() || emotion == channelRecord.getEmotion()) {
List<ChannelIndex.Article> articles = ChannelIndex.Record.filterArticles(startTime, endTime,
channelRecord.getRecord().getArticles());
channelRecord.getRecord().getArticles(), emotion);
if (0 == articles.size()) {
return null;
}
articles.sort(Comparator.comparingLong(ChannelIndex.Article::getTime).reversed());
channelRecord.getRecord().setArticles(articles);
return channelRecord;
......@@ -575,6 +578,7 @@ public class ChannelServiceImpl implements ChannelService {
return resList;
}
@Deprecated
private List<ChannelListVO> getEmotionList(String projectId, String contendId, String platform, String keyword, String sorter,
Long startTime, Long endTime, int size, int emotion, boolean cache) throws IOException {
List<ChannelListVO> resList = new ArrayList<>();
......
......@@ -378,8 +378,10 @@ public class IndexServiceImpl implements IndexService {
long normalCount = markDataService.getYuqingMarkCount(startTime, endTime, EmotionEnum.ALL.getName(), projectId, contendId);
//获取时间范围内总正面稿件数
long positiveCount = markDataService.getYuqingMarkCount(startTime, endTime, EmotionEnum.POSITIVE.getName(), projectId, contendId);
//获取时间范围内总中性稿件数
long neutralCount = markDataService.getYuqingMarkCount(startTime, endTime, EmotionEnum.NEUTRAL.getName(), projectId, contendId);
double reputation = normalCount == 0 ? 0d : 100 * positiveCount / (double) normalCount;
double neutralPercent = normalCount == 0 ? 0d : 100 * neutralCount / (double) normalCount;
SimpleDateFormat sdf;
if ("year".equals(type)) {
type = "年";
......@@ -393,9 +395,11 @@ public class IndexServiceImpl implements IndexService {
}
String date = spreadResult.stream().max(Comparator.comparing(json -> json.getIntValue("normalCount"))).map(json -> sdf.format(json.getDate("time"))).get();
if (!flag) {
return "近一月,传播高峰为" + date + ",全网品牌相关新闻传播总量达" + normalCount + "篇,正面内容占比为" + String.format("%.1f", reputation) + "%。";
return "近一月,传播高峰为" + date + ",全网品牌相关新闻传播总量达" + normalCount + "篇,正面内容占比为" + String.format("%.1f", reputation) + "%,中性内容占比为" + String.format("%.1f"
, neutralPercent) + "%。";
} else {
return "近" + spreadResult.size() + type + "内,传播高峰为" + date + ",全网品牌相关新闻传播总量达" + normalCount + "篇,正面内容占比为" + String.format("%.1f", reputation) + "%。";
return "近" + spreadResult.size() + type + "内,传播高峰为" + date + ",全网品牌相关新闻传播总量达" + normalCount + "篇,正面内容占比为" + String.format("%.1f", reputation) +
"%,中性内容占比为" + String.format("%.1f", neutralPercent) + "%。";
}
}
......
......@@ -155,10 +155,10 @@ public class TaskServiceImpl implements TaskService {
channelService.getActiveChannelList(Constant.PRIMARY_CONTEND_ID, times[0], times[1], 50, false);
// 友好渠道榜
channelService.getPositiveList(Constant.PRIMARY_CONTEND_ID, null, null, sorter, times[0], times[1], 50, false);
channelService.getPositiveChannelList(Constant.PRIMARY_CONTEND_ID, times[0], times[1], 50, sorter, false);
channelService.getPositiveChannelList(Constant.PRIMARY_CONTEND_ID, times[0], times[1], 50, null, false);
// 敏感渠道榜
channelService.getNegativeList(Constant.PRIMARY_CONTEND_ID, null, null, sorter, times[0], times[1], 50, false);
channelService.getNegativeChannelList(Constant.PRIMARY_CONTEND_ID, times[0], times[1], 50, sorter, false);
channelService.getNegativeChannelList(Constant.PRIMARY_CONTEND_ID, times[0], times[1], 50, null, false);
});
log.info("项目:{}-渠道榜单缓存已完成:{}个", project.getProjectName(), total.incrementAndGet());
return null;
......
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