Commit 486792be authored by 刘基明's avatar 刘基明

Merge branch 'dev' into 'master'

Dev

See merge request !11
parents f0f2842f d86eebbe
package com.tanpu.community.api.beans.qo;
import com.tanpu.biz.common.enums.community.TopicStatusEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -41,4 +42,8 @@ public class TopicRankQo {
private Integer minutesTillNow;
private Double score;
public boolean judgeNewTopic(){
return TopicStatusEnum.NEWEST.getCode().equals(type);
}
}
......@@ -8,6 +8,7 @@ import com.tanpu.biz.common.enums.community.CollectionTypeEnum;
import com.tanpu.biz.common.enums.community.ReportTypeEnum;
import com.tanpu.common.api.CommonResp;
import com.tanpu.common.constant.ErrorCodeConstant;
import com.tanpu.common.enums.fund.ProductTypeEnum;
import com.tanpu.common.exception.BizException;
import com.tanpu.common.util.JsonUtil;
import com.tanpu.community.api.CommunityConstant;
......@@ -50,7 +51,6 @@ import com.tanpu.community.util.BizUtils;
import com.tanpu.community.util.ConvertUtil;
import com.tanpu.community.util.RankUtils;
import com.tanpu.community.util.TencentcloudUtils;
import com.tanpu.community.util.TimeUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.ListUtils;
......@@ -384,6 +384,12 @@ public class ThemeManager {
if (content.getProductType() == null) {
throw new BizException(ErrorCodeConstant.ILLEGAL_ARGEMENT.getCode(), "附件产品FUND缺少类型");
}
if ( content.getProductType() == ProductTypeEnum.CUSTOMER_IMPORT.type){
throw new BizException(ErrorCodeConstant.LIMIT_CONTENT.getCode(), "圈子暂不支持私有基金");
}
if ( content.getProductType() == ProductTypeEnum.NOT_NET_PRODUCT.type){
throw new BizException(ErrorCodeConstant.LIMIT_CONTENT.getCode(), "圈子暂不支持无净值私有基金");
}
}
}
}
......@@ -729,7 +735,7 @@ public class ThemeManager {
// 校验参数
checkAttachment(req.getContent());
// 转播权限校验
// 权限校验
// liveRelayCheck(userId, req.getContent());
// 保存主题表
......
......@@ -131,11 +131,10 @@ public class RankService {
this.calculateThemeScore(theme);
}
//排序
Map<ThemeAnalysDO, Double> map = themeAnalysDOS.stream().collect(Collectors.toMap(o -> o, ThemeAnalysDO::getScore));
hotestThemes = map.entrySet().stream()
.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
.map(Map.Entry::getKey).collect(Collectors.toList());
hotestThemes = themeAnalysDOS.stream()
.sorted(Comparator.comparing(ThemeAnalysDO::getScore).reversed())
.collect(Collectors.toList());
//落库
rankLogService.logThemeRank(hotestThemes, start, TimeUtils.calMillisTillNow(start));
}
......@@ -154,12 +153,15 @@ public class RankService {
this.rankTopicListTop4 = new ArrayList<>();
return;
}
List<TopicRankQo> topicRankQos = ConvertUtil.topicEntityToHotQos(topicEntities);
List<TopicRankQo> topicRankQos = ConvertUtil.topicEntityToRankQos(topicEntities);
// 统计话题下的所有主题数据
List<String> topicIds = topicRankQos.stream().map(TopicRankQo::getTopicId).collect(Collectors.toList());
Map<String, Integer> topicViewMap = visitLogService.getCountMapByTargetIds(topicIds, PageEnum.COMM_VISIT_TOPIC_DETAIL.getId());
for (TopicRankQo topic : topicRankQos) {
List<String> themeIds = themeService.queryThemeIdsByTopic(topic.getTopicId());
if (CollectionUtils.isEmpty(themeIds)) {
topic.setViewCount(topicViewMap.getOrDefault(topic.getTopicId(), 0));
topic.setDisscussCount(0);
topic.setThemeWeight(0.0);
......@@ -184,15 +186,33 @@ public class RankService {
topic.setFormatDisscussCount(BizUtils.formatCountNumber(topic.getDisscussCount()));
}
// 排序
Map<TopicRankQo, Double> map = topicRankQos.stream().collect(Collectors.toMap(o -> o, TopicRankQo::getScore));
List<TopicRankQo> rankList = map.entrySet().stream()
.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
.map(Map.Entry::getKey)
List<TopicRankQo> rankList = topicRankQos.stream()
.sorted(Comparator.comparing(TopicRankQo::getScore).reversed())
.collect(Collectors.toList());
// 非“新”话题才能添加“热”标签
if (!TopicStatusEnum.NEWEST.getCode().equals(rankList.get(0).getType())) {
rankList.get(0).setType(TopicStatusEnum.HOTTEST.getCode());
}
this.rankTopicList = rankList;
this.rankTopicListTop4 = rankList.stream().limit(4).collect(Collectors.toList());
// 首页推荐话题
// 记录排序前最新的2个话题
List<TopicRankQo> newest2Topic = topicRankQos.stream().filter(TopicRankQo::judgeNewTopic)
.sorted(Comparator.comparing(TopicRankQo::getMinutesTillNow)).limit(2).collect(Collectors.toList());
List<TopicRankQo> top4Topic = rankList.stream()
.limit(6)
.filter(o -> !newest2Topic.contains(o))
.limit(4 - newest2Topic.size())
.collect(Collectors.toList());
top4Topic.addAll(newest2Topic);
this.rankTopicListTop4 = top4Topic.stream()
.sorted(Comparator.comparing(TopicRankQo::getScore).reversed())
.collect(Collectors.toList());
//落库
rankLogService.logTopicRank(rankList, start, TimeUtils.calMillisTillNow(start));
......@@ -272,6 +292,7 @@ public class RankService {
//顶置话题
if (topic.getIsTop() > 0) {
topic.setScore(Double.MAX_VALUE);
return;
}
Double socre = ((topic.getDisscussCount() * topicDiscussRate + topic.getViewCount() * topicViewRate)
/ Math.pow(topic.getMinutesTillNow() + 1, topicTimeRate))
......
......@@ -101,15 +101,15 @@ public class ConvertUtil {
public static TopicRankQo topicEntityToHotQo(TopicEntity topicEntity) {
TopicRankQo topicRankQo = new TopicRankQo();
BeanUtils.copyProperties(topicEntity, topicRankQo);
//2小时内发帖,添加新话题标签
if (TimeUtils.calMinuteTillNow(topicEntity.getCreateTime()) < 120) {
// 24小时内发帖,添加新话题标签
if (TimeUtils.calMinuteTillNow(topicEntity.getCreateTime()) < 60 * 24) {
topicRankQo.setType(TopicStatusEnum.NEWEST.getCode());
}
topicRankQo.setMinutesTillNow((int) TimeUtils.calMinuteTillNow(topicEntity.getCreateTime()));
return topicRankQo;
}
public static List<TopicRankQo> topicEntityToHotQos(List<TopicEntity> topicEntities) {
public static List<TopicRankQo> topicEntityToRankQos(List<TopicEntity> topicEntities) {
if (topicEntities == null) {
return Collections.emptyList();
}
......
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