Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in
Toggle navigation
T
tanpu-community
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
探普后端
tanpu-community
Commits
486792be
Commit
486792be
authored
Aug 11, 2021
by
刘基明
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into 'master'
Dev See merge request
!11
parents
f0f2842f
d86eebbe
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
16 deletions
+48
-16
TopicRankQo.java
...in/java/com/tanpu/community/api/beans/qo/TopicRankQo.java
+5
-0
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+8
-2
RankService.java
...rc/main/java/com/tanpu/community/service/RankService.java
+32
-11
ConvertUtil.java
...e/src/main/java/com/tanpu/community/util/ConvertUtil.java
+3
-3
No files found.
community-api/src/main/java/com/tanpu/community/api/beans/qo/TopicRankQo.java
View file @
486792be
package
com
.
tanpu
.
community
.
api
.
beans
.
qo
;
package
com
.
tanpu
.
community
.
api
.
beans
.
qo
;
import
com.tanpu.biz.common.enums.community.TopicStatusEnum
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -41,4 +42,8 @@ public class TopicRankQo {
...
@@ -41,4 +42,8 @@ public class TopicRankQo {
private
Integer
minutesTillNow
;
private
Integer
minutesTillNow
;
private
Double
score
;
private
Double
score
;
public
boolean
judgeNewTopic
(){
return
TopicStatusEnum
.
NEWEST
.
getCode
().
equals
(
type
);
}
}
}
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
486792be
...
@@ -8,6 +8,7 @@ import com.tanpu.biz.common.enums.community.CollectionTypeEnum;
...
@@ -8,6 +8,7 @@ import com.tanpu.biz.common.enums.community.CollectionTypeEnum;
import
com.tanpu.biz.common.enums.community.ReportTypeEnum
;
import
com.tanpu.biz.common.enums.community.ReportTypeEnum
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.constant.ErrorCodeConstant
;
import
com.tanpu.common.constant.ErrorCodeConstant
;
import
com.tanpu.common.enums.fund.ProductTypeEnum
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.common.util.JsonUtil
;
import
com.tanpu.community.api.CommunityConstant
;
import
com.tanpu.community.api.CommunityConstant
;
...
@@ -50,7 +51,6 @@ import com.tanpu.community.util.BizUtils;
...
@@ -50,7 +51,6 @@ import com.tanpu.community.util.BizUtils;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.ConvertUtil
;
import
com.tanpu.community.util.RankUtils
;
import
com.tanpu.community.util.RankUtils
;
import
com.tanpu.community.util.TencentcloudUtils
;
import
com.tanpu.community.util.TencentcloudUtils
;
import
com.tanpu.community.util.TimeUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.ListUtils
;
import
org.apache.commons.collections4.ListUtils
;
...
@@ -384,6 +384,12 @@ public class ThemeManager {
...
@@ -384,6 +384,12 @@ public class ThemeManager {
if
(
content
.
getProductType
()
==
null
)
{
if
(
content
.
getProductType
()
==
null
)
{
throw
new
BizException
(
ErrorCodeConstant
.
ILLEGAL_ARGEMENT
.
getCode
(),
"附件产品FUND缺少类型"
);
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 {
...
@@ -729,7 +735,7 @@ public class ThemeManager {
// 校验参数
// 校验参数
checkAttachment
(
req
.
getContent
());
checkAttachment
(
req
.
getContent
());
//
转播
权限校验
// 权限校验
// liveRelayCheck(userId, req.getContent());
// liveRelayCheck(userId, req.getContent());
// 保存主题表
// 保存主题表
...
...
community-service/src/main/java/com/tanpu/community/service/RankService.java
View file @
486792be
...
@@ -131,11 +131,10 @@ public class RankService {
...
@@ -131,11 +131,10 @@ public class RankService {
this
.
calculateThemeScore
(
theme
);
this
.
calculateThemeScore
(
theme
);
}
}
//排序
//排序
Map
<
ThemeAnalysDO
,
Double
>
map
=
themeAnalysDOS
.
stream
().
collect
(
Collectors
.
toMap
(
o
->
o
,
ThemeAnalysDO:
:
getScore
));
hotestThemes
=
map
.
entrySet
()
.
stream
()
hotestThemes
=
themeAnalysDOS
.
stream
()
.
sorted
(
Map
.
Entry
.
comparingByValue
(
Comparator
.
reverseOrder
()
))
.
sorted
(
Comparator
.
comparing
(
ThemeAnalysDO:
:
getScore
).
reversed
(
))
.
map
(
Map
.
Entry
::
getKey
).
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
//落库
//落库
rankLogService
.
logThemeRank
(
hotestThemes
,
start
,
TimeUtils
.
calMillisTillNow
(
start
));
rankLogService
.
logThemeRank
(
hotestThemes
,
start
,
TimeUtils
.
calMillisTillNow
(
start
));
}
}
...
@@ -154,12 +153,15 @@ public class RankService {
...
@@ -154,12 +153,15 @@ public class RankService {
this
.
rankTopicListTop4
=
new
ArrayList
<>();
this
.
rankTopicListTop4
=
new
ArrayList
<>();
return
;
return
;
}
}
List
<
TopicRankQo
>
topicRankQos
=
ConvertUtil
.
topicEntityToHotQos
(
topicEntities
);
List
<
TopicRankQo
>
topicRankQos
=
ConvertUtil
.
topicEntityToRankQos
(
topicEntities
);
// 统计话题下的所有主题数据
List
<
String
>
topicIds
=
topicRankQos
.
stream
().
map
(
TopicRankQo:
:
getTopicId
).
collect
(
Collectors
.
toList
());
List
<
String
>
topicIds
=
topicRankQos
.
stream
().
map
(
TopicRankQo:
:
getTopicId
).
collect
(
Collectors
.
toList
());
Map
<
String
,
Integer
>
topicViewMap
=
visitLogService
.
getCountMapByTargetIds
(
topicIds
,
PageEnum
.
COMM_VISIT_TOPIC_DETAIL
.
getId
());
Map
<
String
,
Integer
>
topicViewMap
=
visitLogService
.
getCountMapByTargetIds
(
topicIds
,
PageEnum
.
COMM_VISIT_TOPIC_DETAIL
.
getId
());
for
(
TopicRankQo
topic
:
topicRankQos
)
{
for
(
TopicRankQo
topic
:
topicRankQos
)
{
List
<
String
>
themeIds
=
themeService
.
queryThemeIdsByTopic
(
topic
.
getTopicId
());
List
<
String
>
themeIds
=
themeService
.
queryThemeIdsByTopic
(
topic
.
getTopicId
());
if
(
CollectionUtils
.
isEmpty
(
themeIds
))
{
if
(
CollectionUtils
.
isEmpty
(
themeIds
))
{
topic
.
setViewCount
(
topicViewMap
.
getOrDefault
(
topic
.
getTopicId
(),
0
));
topic
.
setViewCount
(
topicViewMap
.
getOrDefault
(
topic
.
getTopicId
(),
0
));
topic
.
setDisscussCount
(
0
);
topic
.
setDisscussCount
(
0
);
topic
.
setThemeWeight
(
0.0
);
topic
.
setThemeWeight
(
0.0
);
...
@@ -184,15 +186,33 @@ public class RankService {
...
@@ -184,15 +186,33 @@ public class RankService {
topic
.
setFormatDisscussCount
(
BizUtils
.
formatCountNumber
(
topic
.
getDisscussCount
()));
topic
.
setFormatDisscussCount
(
BizUtils
.
formatCountNumber
(
topic
.
getDisscussCount
()));
}
}
// 排序
// 排序
Map
<
TopicRankQo
,
Double
>
map
=
topicRankQos
.
stream
().
collect
(
Collectors
.
toMap
(
o
->
o
,
TopicRankQo:
:
getScore
));
List
<
TopicRankQo
>
rankList
=
topicRankQos
.
stream
()
List
<
TopicRankQo
>
rankList
=
map
.
entrySet
().
stream
()
.
sorted
(
Comparator
.
comparing
(
TopicRankQo:
:
getScore
).
reversed
())
.
sorted
(
Map
.
Entry
.
comparingByValue
(
Comparator
.
reverseOrder
()))
.
map
(
Map
.
Entry
::
getKey
)
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
rankList
.
get
(
0
).
setType
(
TopicStatusEnum
.
HOTTEST
.
getCode
());
// 非“新”话题才能添加“热”标签
if
(!
TopicStatusEnum
.
NEWEST
.
getCode
().
equals
(
rankList
.
get
(
0
).
getType
()))
{
rankList
.
get
(
0
).
setType
(
TopicStatusEnum
.
HOTTEST
.
getCode
());
}
this
.
rankTopicList
=
rankList
;
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
));
rankLogService
.
logTopicRank
(
rankList
,
start
,
TimeUtils
.
calMillisTillNow
(
start
));
...
@@ -272,6 +292,7 @@ public class RankService {
...
@@ -272,6 +292,7 @@ public class RankService {
//顶置话题
//顶置话题
if
(
topic
.
getIsTop
()
>
0
)
{
if
(
topic
.
getIsTop
()
>
0
)
{
topic
.
setScore
(
Double
.
MAX_VALUE
);
topic
.
setScore
(
Double
.
MAX_VALUE
);
return
;
}
}
Double
socre
=
((
topic
.
getDisscussCount
()
*
topicDiscussRate
+
topic
.
getViewCount
()
*
topicViewRate
)
Double
socre
=
((
topic
.
getDisscussCount
()
*
topicDiscussRate
+
topic
.
getViewCount
()
*
topicViewRate
)
/
Math
.
pow
(
topic
.
getMinutesTillNow
()
+
1
,
topicTimeRate
))
/
Math
.
pow
(
topic
.
getMinutesTillNow
()
+
1
,
topicTimeRate
))
...
...
community-service/src/main/java/com/tanpu/community/util/ConvertUtil.java
View file @
486792be
...
@@ -101,15 +101,15 @@ public class ConvertUtil {
...
@@ -101,15 +101,15 @@ public class ConvertUtil {
public
static
TopicRankQo
topicEntityToHotQo
(
TopicEntity
topicEntity
)
{
public
static
TopicRankQo
topicEntityToHotQo
(
TopicEntity
topicEntity
)
{
TopicRankQo
topicRankQo
=
new
TopicRankQo
();
TopicRankQo
topicRankQo
=
new
TopicRankQo
();
BeanUtils
.
copyProperties
(
topicEntity
,
topicRankQo
);
BeanUtils
.
copyProperties
(
topicEntity
,
topicRankQo
);
//
2
小时内发帖,添加新话题标签
//
24
小时内发帖,添加新话题标签
if
(
TimeUtils
.
calMinuteTillNow
(
topicEntity
.
getCreateTime
())
<
120
)
{
if
(
TimeUtils
.
calMinuteTillNow
(
topicEntity
.
getCreateTime
())
<
60
*
24
)
{
topicRankQo
.
setType
(
TopicStatusEnum
.
NEWEST
.
getCode
());
topicRankQo
.
setType
(
TopicStatusEnum
.
NEWEST
.
getCode
());
}
}
topicRankQo
.
setMinutesTillNow
((
int
)
TimeUtils
.
calMinuteTillNow
(
topicEntity
.
getCreateTime
()));
topicRankQo
.
setMinutesTillNow
((
int
)
TimeUtils
.
calMinuteTillNow
(
topicEntity
.
getCreateTime
()));
return
topicRankQo
;
return
topicRankQo
;
}
}
public
static
List
<
TopicRankQo
>
topicEntityTo
Hot
Qos
(
List
<
TopicEntity
>
topicEntities
)
{
public
static
List
<
TopicRankQo
>
topicEntityTo
Rank
Qos
(
List
<
TopicEntity
>
topicEntities
)
{
if
(
topicEntities
==
null
)
{
if
(
topicEntities
==
null
)
{
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment