Commit 85fac016 by shenjunjie

Merge branch 'release' into 'master'

Release

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