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
b81df074
Commit
b81df074
authored
Feb 22, 2022
by
刘基明
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v2.3.1' into 'dev'
V2.3.1 See merge request
!64
parents
5733cebf
69fca593
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
279 additions
and
44 deletions
+279
-44
ThemeMapper.java
...com/tanpu/community/dao/mapper/community/ThemeMapper.java
+4
-0
FeignClientForWxcp.java
...va/com/tanpu/community/feign/wxcp/FeignClientForWxcp.java
+25
-0
FeignbackForWxcp.java
...java/com/tanpu/community/feign/wxcp/FeignbackForWxcp.java
+31
-0
ThemeManager.java
...c/main/java/com/tanpu/community/manager/ThemeManager.java
+0
-3
TopicManager.java
...c/main/java/com/tanpu/community/manager/TopicManager.java
+2
-2
CommentService.java
...main/java/com/tanpu/community/service/CommentService.java
+15
-8
FeignService.java
...c/main/java/com/tanpu/community/service/FeignService.java
+3
-3
RankService.java
...rc/main/java/com/tanpu/community/service/RankService.java
+2
-5
ThemeService.java
...c/main/java/com/tanpu/community/service/ThemeService.java
+14
-14
TopicService.java
...c/main/java/com/tanpu/community/service/TopicService.java
+32
-8
TopicReportService.java
...om/tanpu/community/service/quartz/TopicReportService.java
+140
-0
ThemeEntityMapper.xml
...src/main/resources/mapper/community/ThemeEntityMapper.xml
+10
-0
VisitLogEntityMapper.xml
.../main/resources/mapper/community/VisitLogEntityMapper.xml
+1
-1
No files found.
community-service/src/main/java/com/tanpu/community/dao/mapper/community/ThemeMapper.java
View file @
b81df074
...
...
@@ -29,5 +29,9 @@ public interface ThemeMapper extends BaseMapper<ThemeEntity> {
Integer
countByTopicIdAndCreateTimeAfter
(
@Param
(
"topicId"
)
String
topicId
,
@Param
(
"minCreateTime"
)
LocalDateTime
minCreateTime
);
List
<
ThemeEntity
>
queryRecentdaysOrHasTopic
(
@Param
(
"deleteTag"
)
Integer
deleteTag
,
@Param
(
"minCreateTime"
)
LocalDateTime
minCreateTime
,
@Param
(
"notTopicId"
)
String
notTopicId
);
}
community-service/src/main/java/com/tanpu/community/feign/wxcp/FeignClientForWxcp.java
0 → 100644
View file @
b81df074
package
com
.
tanpu
.
community
.
feign
.
wxcp
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboDetailVO
;
import
com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboListResp
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
java.util.List
;
@FeignClient
(
value
=
"service-wxcp"
,
url
=
"${tanpu.wxcp.svc:}"
,
contextId
=
"wxcp"
,
fallbackFactory
=
FeignbackForWxcp
.
class
,
path
=
"/wxcp"
)
//@FeignClient(value = "service-product", contextId = "product", fallbackFactory = FeignBackClientForProducts.class, url = "http://127.0.0.1:8194/product")
public
interface
FeignClientForWxcp
{
@PostMapping
(
"/wx/kf/sendMessage/{agentId}/{corpId}"
)
@ApiOperation
(
"发送微信客服消息"
)
CommonResp
sendMessage
(
@PathVariable
(
"agentId"
)
Long
agentId
,
@PathVariable
(
"corpId"
)
String
corpId
,
@RequestBody
String
requestBody
);
}
community-service/src/main/java/com/tanpu/community/feign/wxcp/FeignbackForWxcp.java
0 → 100644
View file @
b81df074
package
com
.
tanpu
.
community
.
feign
.
wxcp
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboDetailVO
;
import
com.tanpu.community.api.beans.vo.feign.zhibo.ZhiboListResp
;
import
com.tanpu.community.feign.zhibo.FeignClientForZhibo
;
import
feign.hystrix.FallbackFactory
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
java.util.List
;
@Slf4j
@Component
public
class
FeignbackForWxcp
implements
FallbackFactory
<
FeignClientForWxcp
>
{
@Override
public
FeignClientForWxcp
create
(
Throwable
throwable
)
{
return
new
FeignClientForWxcp
()
{
@Override
public
CommonResp
sendMessage
(
Long
agentId
,
String
corpId
,
String
requestBody
)
{
log
.
error
(
"请求信息"
,
throwable
);
log
.
error
(
"FeignClientForWxcp.sendMessage-agentId:{}, corpId:{}, request:{}"
,
agentId
,
corpId
,
requestBody
);
return
CommonResp
.
error
();
}
};
}
}
community-service/src/main/java/com/tanpu/community/manager/ThemeManager.java
View file @
b81df074
...
...
@@ -477,10 +477,7 @@ public class ThemeManager {
});
firstThemeTime
=
themeService
.
queryByThemeIdIgnoreDelete
(
excludeIds
.
get
(
0
)).
getCreateTime
();
}
}
Integer
pageStart
=
(
req
.
page
.
pageNumber
-
1
)
*
req
.
page
.
pageSize
;
Integer
pageSize
=
req
.
page
.
pageSize
;
...
...
community-service/src/main/java/com/tanpu/community/manager/TopicManager.java
View file @
b81df074
...
...
@@ -110,11 +110,11 @@ public class TopicManager {
themeService
.
queryCommentForTopic
(
topicFollowQos
,
userId
);
// 排序
topicFollowQos
.
stream
().
filter
(
o
->
o
.
checkTopicName
(
keyword
)).
sorted
(
Comparator
.
comparing
(
TopicFollowQo:
:
getSpecialPermission
,
Comparator
.
reverseOrder
()).
List
<
TopicFollowQo
>
res
=
topicFollowQos
.
stream
().
filter
(
o
->
o
.
checkTopicName
(
keyword
)).
sorted
(
Comparator
.
comparing
(
TopicFollowQo:
:
getSpecialPermission
,
Comparator
.
reverseOrder
()).
thenComparing
(
TopicFollowQo:
:
getLastThemeTime
,
Comparator
.
nullsFirst
(
String:
:
compareTo
).
reversed
()))
.
collect
(
Collectors
.
toList
());
return
topicFollowQo
s
;
return
re
s
;
}
/**
...
...
community-service/src/main/java/com/tanpu/community/service/CommentService.java
View file @
b81df074
...
...
@@ -21,11 +21,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
static
com
.
tanpu
.
community
.
api
.
constants
.
RedisKeyConstant
.*;
...
...
@@ -72,10 +68,21 @@ public class CommentService {
//统计主题集合的评论量
public
Integer
getCommentCountByThemeId
(
String
themeId
)
{
return
commentMapper
.
select
Lis
t
((
new
LambdaQueryWrapper
<
CommentEntity
>()
return
commentMapper
.
select
Coun
t
((
new
LambdaQueryWrapper
<
CommentEntity
>()
.
eq
(
CommentEntity:
:
getThemeId
,
themeId
))
.
eq
(
CommentEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
))
.
size
();
.
eq
(
CommentEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
));
}
public
Integer
getCommentCountByThemeIds
(
List
<
String
>
themeIds
)
{
return
commentMapper
.
selectCount
((
new
LambdaQueryWrapper
<
CommentEntity
>()
.
in
(
CommentEntity:
:
getThemeId
,
themeIds
))
.
eq
(
CommentEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
));
}
public
Integer
getCommentCountByThemeIds
(
List
<
String
>
themeIds
,
Date
startDate
,
Date
endDate
)
{
return
commentMapper
.
selectCount
((
new
LambdaQueryWrapper
<
CommentEntity
>()
.
in
(
CommentEntity:
:
getThemeId
,
themeIds
))
.
gt
(
CommentEntity:
:
getCreateTime
,
startDate
)
.
lt
(
CommentEntity:
:
getCreateTime
,
endDate
)
.
eq
(
CommentEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
));
}
...
...
community-service/src/main/java/com/tanpu/community/service/FeignService.java
View file @
b81df074
package
com
.
tanpu
.
community
.
service
;
import
com.tanpu.common.api.CommonResp
;
import
com.tanpu.common.exception.BizException
;
import
com.tanpu.community.api.beans.resp.CoursePackageSimpleResp
;
import
com.tanpu.community.api.beans.vo.feign.activity.OfflineActivitySimpleResp
;
import
com.tanpu.community.api.beans.vo.feign.course.CourseSimpleResp
;
...
...
@@ -26,6 +25,7 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.function.Function
;
...
...
@@ -65,9 +65,9 @@ public class FeignService {
public
UserInfoResp
getUserInfoById
(
String
userId
)
{
List
<
UserInfoResp
>
userList
=
getUserList
(
Arrays
.
as
List
(
userId
));
List
<
UserInfoResp
>
userList
=
getUserList
(
Collections
.
singleton
List
(
userId
));
if
(
CollectionUtils
.
isEmpty
(
userList
))
{
throw
new
BizException
(
"内部接口调用失败"
)
;
return
null
;
}
return
userList
.
get
(
0
);
}
...
...
community-service/src/main/java/com/tanpu/community/service/RankService.java
View file @
b81df074
...
...
@@ -27,8 +27,6 @@ import java.util.List;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
static
com
.
tanpu
.
community
.
api
.
constants
.
RedisKeyConstant
.
CACHE_FEIGN_USER_INFO
;
@Service
public
class
RankService
{
...
...
@@ -97,7 +95,7 @@ public class RankService {
LocalDateTime
start
=
LocalDateTime
.
now
();
//7天内所有主题进行热度值排序
List
<
ThemeEntity
>
themeEntities
=
themeService
.
queryRecentdays
(
60
);
List
<
ThemeEntity
>
themeEntities
=
themeService
.
queryRecentdays
OrHasTopic
(
60
);
if
(
CollectionUtils
.
isEmpty
(
themeEntities
))
{
return
;
}
...
...
@@ -119,8 +117,7 @@ public class RankService {
theme
.
setViewCount
(
visitCountMap
.
getOrDefault
(
themeId
,
0
));
//查询用户质量
String
authorId
=
theme
.
getAuthorId
();
UserInfoResp
authorInfo
=
redisCache
.
getObject
(
StringUtils
.
joinWith
(
"_"
,
CACHE_FEIGN_USER_INFO
,
authorId
),
60
,
()
->
feignService
.
getUserInfoById
(
authorId
),
UserInfoResp
.
class
);
UserInfoResp
authorInfo
=
feignService
.
getUserInfoById
(
authorId
);
if
(
authorInfo
==
null
||
authorInfo
.
getLevelGrade
()
==
null
)
{
theme
.
setUserWeight
(
0.0
);
}
else
{
...
...
community-service/src/main/java/com/tanpu/community/service/ThemeService.java
View file @
b81df074
...
...
@@ -28,13 +28,7 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -68,13 +62,9 @@ public class ThemeService {
}
//n天内发表的所有主题
public
List
<
ThemeEntity
>
queryRecentdays
(
Integer
days
)
{
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
eq
(
ThemeEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
())
.
gt
(
ThemeEntity:
:
getCreateTime
,
TimeUtils
.
getDaysBefore
(
days
))
.
orderByDesc
(
ThemeEntity:
:
getId
);
public
List
<
ThemeEntity
>
queryRecentdaysOrHasTopic
(
Integer
days
)
{
return
themeMapper
.
selectList
(
queryWrapper
);
return
themeMapper
.
queryRecentdaysOrHasTopic
(
DeleteTagEnum
.
NOT_DELETED
.
getCode
(),
TimeUtils
.
getDaysBefore
(
days
),
""
);
}
//最新的n条主题
...
...
@@ -207,6 +197,16 @@ public class ThemeService {
return
themeMapper
.
selectList
(
queryWrapper
).
stream
().
map
(
ThemeEntity:
:
getThemeId
).
collect
(
Collectors
.
toList
());
}
public
List
<
String
>
queryThemeIdsByTopic
(
String
topidId
,
Date
startDate
,
Date
endDate
)
{
if
(
StringUtils
.
isEmpty
(
topidId
))
{
return
Collections
.
emptyList
();
}
LambdaQueryWrapper
<
ThemeEntity
>
queryWrapper
=
new
LambdaQueryWrapper
<
ThemeEntity
>()
.
eq
(
ThemeEntity:
:
getTopicId
,
topidId
).
gt
(
ThemeEntity:
:
getCreateTime
,
startDate
).
lt
(
ThemeEntity:
:
getCreateTime
,
endDate
);
queryWrapper
.
select
(
ThemeEntity:
:
getThemeId
);
return
themeMapper
.
selectList
(
queryWrapper
).
stream
().
map
(
ThemeEntity:
:
getThemeId
).
collect
(
Collectors
.
toList
());
}
/**
* 根据作者查询主题分页列表
*
...
...
@@ -362,7 +362,7 @@ public class ThemeService {
private
String
getUserName
(
String
authorId
)
{
UserInfoResp
userInfoById
=
feignService
.
getUserInfoById
(
authorId
);
if
(
StringUtils
.
isNotBlank
(
userInfoById
.
getNickName
())){
if
(
StringUtils
.
isNotBlank
(
userInfoById
.
getNickName
()))
{
return
userInfoById
.
getNickName
();
}
return
"理财师"
;
...
...
community-service/src/main/java/com/tanpu/community/service/TopicService.java
View file @
b81df074
...
...
@@ -34,12 +34,7 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.*
;
import
java.util.stream.Collectors
;
...
...
@@ -48,10 +43,10 @@ import java.util.stream.Collectors;
public
class
TopicService
{
@Resource
TopicFollowRelMapper
topicFollowRelMapper
;
private
TopicFollowRelMapper
topicFollowRelMapper
;
@Resource
TopicMapper
topicMapper
;
private
TopicMapper
topicMapper
;
@Resource
private
TopicManagerMapper
topicManagerMapper
;
...
...
@@ -76,6 +71,13 @@ public class TopicService {
return
retList
;
}
public
List
<
TopicEntity
>
queryTopicNeedReport
()
{
// 是否同步动态至管理员企业微信 0:否 1:是
return
topicMapper
.
selectList
(
new
LambdaQueryWrapper
<
TopicEntity
>()
.
eq
(
TopicEntity:
:
getSyncCorpWechat
,
1
)
.
eq
(
TopicEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()));
}
public
TopicEntity
queryOnlineTopicById
(
String
topicId
)
{
return
topicMapper
.
selectOne
(
new
LambdaQueryWrapper
<
TopicEntity
>()
...
...
@@ -98,6 +100,10 @@ public class TopicService {
return
topicMapper
.
selectList
(
new
LambdaQueryWrapper
<
TopicEntity
>().
in
(
TopicEntity:
:
getTopicId
,
topicIds
));
}
/**
* CRUD Topic_Follow
*/
public
List
<
TopicFollowQo
>
queryFollowTopic
(
String
keyword
,
String
userId
)
{
// 用户的关注列表(包括专属)
List
<
String
>
followTopicIds
=
topicFollowRelMapper
.
selectTopicIdByUserId
(
userId
);
...
...
@@ -108,7 +114,21 @@ public class TopicService {
List
<
TopicEntity
>
topicEntities
=
topicMapper
.
selectAllByTopicIdIn
(
followTopicIds
);
List
<
TopicFollowQo
>
topicFollowQos
=
ConvertUtil
.
topicEntityToFollowQos
(
topicEntities
);
return
topicFollowQos
;
}
// 根据关注事件 count
public
Integer
countTotalFollow
(
String
topicId
)
{
return
topicFollowRelMapper
.
selectCount
(
new
LambdaQueryWrapper
<
TopicFollowRelEntity
>()
.
eq
(
TopicFollowRelEntity:
:
getTopicId
,
topicId
)
.
eq
(
TopicFollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()));
}
public
Integer
countFollowByIdAndTime
(
String
topicId
,
Date
startDate
,
Date
endDate
)
{
return
topicFollowRelMapper
.
selectCount
(
new
LambdaQueryWrapper
<
TopicFollowRelEntity
>()
.
eq
(
TopicFollowRelEntity:
:
getTopicId
,
topicId
)
.
gt
(
TopicFollowRelEntity:
:
getFollowTime
,
startDate
)
.
lt
(
TopicFollowRelEntity:
:
getFollowTime
,
endDate
)
.
eq
(
TopicFollowRelEntity:
:
getDeleteTag
,
DeleteTagEnum
.
NOT_DELETED
.
getCode
()));
}
...
...
@@ -267,6 +287,10 @@ public class TopicService {
}
}
public
List
<
TopicManagerEntity
>
getManagersByTopic
(
String
topicId
)
{
return
topicManagerMapper
.
selectList
(
new
LambdaQueryWrapper
<
TopicManagerEntity
>().
eq
(
TopicManagerEntity:
:
getTopicId
,
topicId
));
}
public
Set
<
String
>
getManagerId
(
String
topicId
)
{
if
(
StringUtils
.
isBlank
(
topicId
))
{
return
new
HashSet
<>();
...
...
community-service/src/main/java/com/tanpu/community/service/quartz/TopicReportService.java
0 → 100644
View file @
b81df074
package
com
.
tanpu
.
community
.
service
.
quartz
;
import
com.alibaba.fastjson.JSON
;
import
com.tanpu.common.util.DateUtils
;
import
com.tanpu.community.api.beans.vo.feign.user.UserInfoVo
;
import
com.tanpu.community.dao.entity.community.TopicEntity
;
import
com.tanpu.community.dao.entity.community.TopicManagerEntity
;
import
com.tanpu.community.feign.fatools.FeignClientForFatools
;
import
com.tanpu.community.feign.wxcp.FeignClientForWxcp
;
import
com.tanpu.community.manager.TopicManager
;
import
com.tanpu.community.service.CommentService
;
import
com.tanpu.community.service.ThemeService
;
import
com.tanpu.community.service.TopicService
;
import
com.tanpu.community.service.VisitLogService
;
import
lombok.extern.log4j.Log4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
java.util.*
;
@Service
public
class
TopicReportService
{
@Value
(
"${wxcp.topicreport.agentId}"
)
private
Long
agentId
;
@Value
(
"${wxcp.topicreport.corpId}"
)
private
String
corpId
;
@Autowired
private
TopicService
topicService
;
@Autowired
private
ThemeService
themeService
;
@Autowired
private
CommentService
commentService
;
@Autowired
private
VisitLogService
visitLogService
;
@Autowired
private
FeignClientForWxcp
feignClientForWxcp
;
@Autowired
private
FeignClientForFatools
feignClientForFatools
;
// 每个工作日早上09:30汇报
public
static
String
content_report_topic_weekday
=
"话题(%s) 当前总成员: %s, 当前总阅读: %s, 当前总讨论: %s, 昨日新增成员: %s, 昨日新增讨论"
;
public
void
reportTopicWeekday
()
{
List
<
TopicEntity
>
topics
=
topicService
.
queryTopicNeedReport
();
for
(
TopicEntity
topic
:
topics
)
{
// 当前总成员
Integer
totalFollowNum
=
topicService
.
countTotalFollow
(
topic
.
getTopicId
());
// 阅读量
Integer
totalVisitNum
=
visitLogService
.
queryTopicDetailVisit
(
topic
.
getTopicId
());
// 讨论量 包括主题数量和评论数量 不算长文
List
<
String
>
totalThemeIds
=
themeService
.
queryThemeIdsByTopic
(
topic
.
getTopicId
());
Integer
totalCommentNum
=
commentService
.
getCommentCountByThemeIds
(
totalThemeIds
);
Integer
totalDiscussNum
=
totalCommentNum
+
totalThemeIds
.
size
();
Date
endDate
=
DateUtils
.
getDayStartTime
(
new
Date
());
Date
startDate
=
DateUtils
.
getAfterDay
(
endDate
,
-
1
);
// 昨日新增成员
Integer
newFollowNum
=
topicService
.
countFollowByIdAndTime
(
topic
.
getTopicId
(),
startDate
,
endDate
);
// 昨日新增讨论
List
<
String
>
newThemeIds
=
themeService
.
queryThemeIdsByTopic
(
topic
.
getTopicId
(),
startDate
,
endDate
);
Integer
newCommentNum
=
commentService
.
getCommentCountByThemeIds
(
totalThemeIds
,
startDate
,
endDate
);
Integer
newDiscussNum
=
newThemeIds
.
size
()
+
newCommentNum
;
String
content
=
String
.
format
(
content_report_topic_weekday
,
topic
.
getTopicTitle
(),
totalFollowNum
,
totalVisitNum
,
totalDiscussNum
,
newFollowNum
,
newDiscussNum
);
List
<
String
>
wxcpIds
=
getTopicManagerWxcpIds
(
topic
.
getTopicId
());
sendReportMessage
(
content
,
wxcpIds
);
}
}
// 每周六早上09:00汇报
public
static
String
content_report_topic_saturday
=
"话题(%s) 当前总成员: %s, 当前总阅读: %s, 当前总讨论: %s, 截至本周五新增成员: %s, 昨日新增讨论"
;
public
void
reportTopicSaturday
()
{
List
<
TopicEntity
>
topics
=
topicService
.
queryTopicNeedReport
();
for
(
TopicEntity
topic
:
topics
)
{
// 当前总成员
Integer
totalFollowNum
=
topicService
.
countTotalFollow
(
topic
.
getTopicId
());
// 阅读量
Integer
totalVisitNum
=
visitLogService
.
queryTopicDetailVisit
(
topic
.
getTopicId
());
// 讨论量 包括主题数量和评论数量 不算长文
List
<
String
>
totalThemeIds
=
themeService
.
queryThemeIdsByTopic
(
topic
.
getTopicId
());
Integer
totalCommentNum
=
commentService
.
getCommentCountByThemeIds
(
totalThemeIds
);
Integer
totalDiscussNum
=
totalCommentNum
+
totalThemeIds
.
size
();
Date
today
=
DateUtils
.
getDayStartTime
(
new
Date
());
Date
endDate
=
DateUtils
.
getAfterDay
(
today
,
-
1
);
Date
startDate
=
DateUtils
.
getAfterDay
(
endDate
,
-
5
);
// 昨日新增成员
Integer
newFollowNum
=
topicService
.
countFollowByIdAndTime
(
topic
.
getTopicId
(),
startDate
,
endDate
);
// 昨日新增讨论
List
<
String
>
newThemeIds
=
themeService
.
queryThemeIdsByTopic
(
topic
.
getTopicId
(),
startDate
,
endDate
);
Integer
newCommentNum
=
commentService
.
getCommentCountByThemeIds
(
totalThemeIds
,
startDate
,
endDate
);
Integer
newDiscussNum
=
newThemeIds
.
size
()
+
newCommentNum
;
String
content
=
String
.
format
(
content_report_topic_saturday
,
topic
.
getTopicTitle
(),
totalFollowNum
,
totalVisitNum
,
totalDiscussNum
,
newFollowNum
,
newDiscussNum
);
List
<
String
>
wxcpIds
=
getTopicManagerWxcpIds
(
topic
.
getTopicId
());
sendReportMessage
(
content
,
wxcpIds
);
}
}
public
void
sendReportMessage
(
String
content
,
List
<
String
>
wxcpIds
)
{
Map
<
String
,
Object
>
parmMap
=
new
HashMap
<>();
parmMap
.
put
(
"type"
,
"text"
);
parmMap
.
put
(
"content"
,
content
);
parmMap
.
put
(
"list"
,
wxcpIds
);
feignClientForWxcp
.
sendMessage
(
agentId
,
corpId
,
JSON
.
toJSONString
(
parmMap
));
}
public
List
<
String
>
getTopicManagerWxcpIds
(
String
topicId
)
{
List
<
String
>
retList
=
new
ArrayList
<>();
List
<
TopicManagerEntity
>
managers
=
topicService
.
getManagersByTopic
(
topicId
);
for
(
TopicManagerEntity
mgr
:
managers
)
{
UserInfoVo
user
=
feignClientForFatools
.
getUserInfoById
(
mgr
.
getUserId
());
if
(
user
!=
null
&&
user
.
getUiTelphone
()
!=
null
)
{
// todo 应该用企业微信 这里暂时用手机号代替
retList
.
add
(
user
.
getUiTelphone
());
}
}
return
retList
;
}
}
community-service/src/main/resources/mapper/community/ThemeEntityMapper.xml
View file @
b81df074
...
...
@@ -54,4 +54,14 @@
where topic_id = #{topicId}
and create_time
<![CDATA[>]]>
#{minCreateTime}
</select>
<!--auto generated by MybatisCodeHelper on 2022-02-22-->
<select
id=
"queryRecentdaysOrHasTopic"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from theme
where delete_tag=#{deleteTag}
and ( create_time
<![CDATA[>]]>
#{minCreateTime}
or topic_id
<![CDATA[<>]]>
#{notTopicId})
</select>
</mapper>
community-service/src/main/resources/mapper/community/VisitLogEntityMapper.xml
View file @
b81df074
...
...
@@ -34,6 +34,6 @@
<include
refid=
"Base_Column_List"
/>
from visit_log
where visitor_id=#{visitorId} and ref_id=#{refId}
order by update_time limit 1
order by update_time
desc
limit 1
</select>
</mapper>
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