Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cust-api
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李伟
cust-api
Commits
942bd075
Commit
942bd075
authored
Feb 25, 2025
by
liwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增了刷新话题动态数的定时任务
parent
11b26e11
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
2 deletions
+76
-2
OpmTopicRepository.java
...org/rcisoft/business/opmTopic/dao/OpmTopicRepository.java
+7
-0
OpmTopicServiceImpl.java
...t/business/opmTopic/service/impl/OpmTopicServiceImpl.java
+38
-2
ScheduleTasks.java
src/main/java/org/rcisoft/core/schedule/ScheduleTasks.java
+11
-0
OpmTopicMapper.xml
...ources/mapper/business/opmTopic.mapper/OpmTopicMapper.xml
+20
-0
No files found.
src/main/java/org/rcisoft/business/opmTopic/dao/OpmTopicRepository.java
View file @
942bd075
...
...
@@ -36,5 +36,12 @@ public interface OpmTopicRepository extends CyBaseMapper<OpmTopic> {
//权重验重
OpmTopic
checkWeight
(
@Param
(
"weight"
)
Integer
weight
);
//查询所有话题
List
<
OpmTopic
>
selectAllTopic
();
//查询某个话题下的动态数
Integer
selectArticleCountByTopicId
(
Integer
businessId
);
int
updateArticleCountById
(
@Param
(
"entity"
)
OpmTopic
topic
);
}
src/main/java/org/rcisoft/business/opmTopic/service/impl/OpmTopicServiceImpl.java
View file @
942bd075
...
...
@@ -4,9 +4,13 @@ import cn.hutool.core.util.ObjectUtil;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
import
org.rcisoft.business.opmArticle.dao.OpmArticleRepository
;
import
org.rcisoft.business.opmArticle.entity.OpmArticle
;
import
org.rcisoft.business.opmTopic.dao.OpmTopicRepository
;
import
org.rcisoft.business.opmTopic.entity.OpmTopic
;
import
org.rcisoft.business.opmTopic.service.OpmTopicService
;
import
org.rcisoft.business.sysScheduledTaskLog.entity.SysScheduledTaskLog
;
import
org.rcisoft.business.sysScheduledTaskLog.service.SysScheduledTaskLogService
;
import
org.rcisoft.core.exception.CyServiceException
;
import
org.rcisoft.core.model.CyPageInfo
;
import
org.rcisoft.core.model.CyPersistModel
;
...
...
@@ -17,6 +21,7 @@ import org.springframework.transaction.annotation.Isolation;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Date
;
import
java.util.List
;
/**
...
...
@@ -28,8 +33,10 @@ import java.util.List;
@Slf4j
public
class
OpmTopicServiceImpl
extends
ServiceImpl
<
OpmTopicRepository
,
OpmTopic
>
implements
OpmTopicService
{
@Autowired
private
OpmArticleRepository
opmArticleRepository
;
@Autowired
private
SysScheduledTaskLogService
sysScheduledTaskLogServiceImpl
;
/**
* 保存 话题
...
...
@@ -164,4 +171,33 @@ public class OpmTopicServiceImpl extends ServiceImpl<OpmTopicRepository, OpmTopi
return
new
CyPersistModel
(
line
);
}
/**
* 定时更新话题表的动态数
*/
public
void
opmTopicSchedule
()
{
try
{
//查询所有话题
List
<
OpmTopic
>
allTopicList
=
baseMapper
.
selectAllTopic
();
allTopicList
.
forEach
(
topic
->
{
Integer
articleCount
=
baseMapper
.
selectArticleCountByTopicId
(
topic
.
getBusinessId
());
topic
.
setArticleCount
(
articleCount
);
baseMapper
.
updateArticleCountById
(
topic
);
});
SysScheduledTaskLog
sysScheduledTaskLog
=
new
SysScheduledTaskLog
();
sysScheduledTaskLog
.
setTaskName
(
"定时更新话题表动态数定时任务"
);
sysScheduledTaskLog
.
setTaskState
(
"成功"
);
sysScheduledTaskLog
.
setTaskTime
(
"每2小时执行一次"
);
sysScheduledTaskLog
.
setCreateDate
(
new
Date
());
sysScheduledTaskLogServiceImpl
.
persist
(
sysScheduledTaskLog
);
}
catch
(
Exception
e
)
{
SysScheduledTaskLog
sysScheduledTaskLog
=
new
SysScheduledTaskLog
();
sysScheduledTaskLog
.
setTaskName
(
"定时更新话题表动态数定时任务"
);
sysScheduledTaskLog
.
setTaskState
(
"失败"
);
sysScheduledTaskLog
.
setTaskTime
(
"每2小时执行一次"
);
sysScheduledTaskLog
.
setCreateDate
(
new
Date
());
sysScheduledTaskLogServiceImpl
.
persist
(
sysScheduledTaskLog
);
}
}
}
src/main/java/org/rcisoft/core/schedule/ScheduleTasks.java
View file @
942bd075
...
...
@@ -11,6 +11,7 @@ import org.rcisoft.business.memInfo.service.impl.MemInfoServiceImpl;
import
org.rcisoft.business.memLeaveMessage.service.impl.MemLeaveMessageServiceImpl
;
import
org.rcisoft.business.memTraffic.service.MemTrafficService
;
import
org.rcisoft.business.memTraffic.service.impl.MemTrafficServiceImpl
;
import
org.rcisoft.business.opmTopic.service.impl.OpmTopicServiceImpl
;
import
org.rcisoft.core.service.CyRedisService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
...
...
@@ -36,6 +37,8 @@ public class ScheduleTasks {
private
MemLeaveMessageServiceImpl
memLeaveMessageService
;
@Autowired
private
MemTrafficServiceImpl
memTrafficService
;
@Autowired
private
OpmTopicServiceImpl
opmTopicServiceImpl
;
/**
* 每俩小时 执行一次点赞数据定时任务 将点赞数据同步到点赞表表中
...
...
@@ -103,5 +106,13 @@ public class ScheduleTasks {
memTrafficService
.
memTrafficSchedule
();
}
/**
* 定时更新话题表 刷新话题表的动态数
* 每俩小时执行一次
*/
@Scheduled
(
cron
=
"0 0 */2 * * ?"
)
public
void
opmTopicSchedule
()
{
opmTopicServiceImpl
.
opmTopicSchedule
();
}
}
src/main/resources/mapper/business/opmTopic.mapper/OpmTopicMapper.xml
View file @
942bd075
...
...
@@ -142,4 +142,24 @@
and del_flag = '0'
and weight = #{weight}
</select>
<select
id=
"selectAllTopic"
resultType=
"org.rcisoft.business.opmTopic.entity.OpmTopic"
>
select *
from opm_topic
where 1=1
and del_flag = '0'
</select>
<select
id=
"selectArticleCountByTopicId"
resultType=
"java.lang.Integer"
>
select COUNT(*)
from opm_article
where 1=1
and del_flag = '0'
and flag = '1'
and exam_status = '1'
and topic_id = #{topicId}
</select>
<update
id=
"updateArticleCountById"
>
update opm_topic
set article_count = #{entity.articleCount}
where business_id = #{entity.businessId}
</update>
</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