Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wecloud_im_server
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hewei
wecloud_im_server
Commits
6722c11c
Commit
6722c11c
authored
Sep 27, 2022
by
Future
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加定时器
parent
f1d1382b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
7 deletions
+25
-7
core/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
+1
-2
scheduled/src/main/java/io/geekidea/springbootplus/scheduled/MessageScheduled.java
+24
-5
No files found.
core/src/main/java/com/wecloud/im/service/impl/ImConversationServiceImpl.java
View file @
6722c11c
...
...
@@ -858,9 +858,8 @@ public class ImConversationServiceImpl extends BaseServiceImpl<ImConversationMap
myconversationlistvo
.
setIsBeAt
(
Boolean
.
TRUE
);
}
myImConversationListAndMsgCountNew
.
add
(
myconversationlistvo
);
}
log
.
info
(
"{} 查询加入的会话列表结果
{}"
,
currentClient
.
getClientId
(),
JSON
.
toJSONString
(
myImConversationListAndMsgCountNew
));
log
.
info
(
"{} 查询加入的会话列表结果
条数 {}"
,
currentClient
.
getClientId
(),
myImConversationListAndMsgCountNew
.
size
(
));
return
myImConversationListAndMsgCountNew
;
}
catch
(
Exception
e
)
{
log
.
info
(
"查询所有会话异常 "
,
e
);
...
...
scheduled/src/main/java/io/geekidea/springbootplus/scheduled/
Inbox
Scheduled.java
→
scheduled/src/main/java/io/geekidea/springbootplus/scheduled/
Message
Scheduled.java
View file @
6722c11c
...
...
@@ -2,7 +2,9 @@ package io.geekidea.springbootplus.scheduled;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.wecloud.im.entity.ImInbox
;
import
com.wecloud.im.entity.ImMessage
;
import
com.wecloud.im.service.ImInboxService
;
import
com.wecloud.im.service.ImMessageService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.time.DateUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -18,22 +20,25 @@ import java.util.Date;
*/
@Slf4j
@Component
public
class
Inbox
Scheduled
{
public
class
Message
Scheduled
{
@Autowired
private
ImInboxService
imInboxService
;
@Autowired
private
ImMessageService
imMessageService
;
/**
* 离线消息处理定时器
*
一个月
之前的离线消息直接删除
*
15
之前的离线消息直接删除
* 一星期前的已读消息 删除
* 一天执行一次 凌晨3点执行
*/
@Scheduled
(
cron
=
"
* */10 *
* * ?"
)
public
void
callingTimeout
()
{
@Scheduled
(
cron
=
"
0 0 3
* * ?"
)
public
void
inboxDelete
()
{
log
.
info
(
"离线消息处理定时器处理开始..."
);
// 30天之前数据, 直接删除
Date
allDeleteTime
=
DateUtils
.
addDays
(
new
Date
(),
-
30
);
Date
allDeleteTime
=
DateUtils
.
addDays
(
new
Date
(),
-
15
);
imInboxService
.
remove
(
new
QueryWrapper
<
ImInbox
>().
lambda
()
.
lt
(
ImInbox:
:
getCreateTime
,
allDeleteTime
));
...
...
@@ -44,4 +49,18 @@ public class InboxScheduled {
.
lt
(
ImInbox:
:
getCreateTime
,
readTime
));
}
/**
* 离线消息处理定时器
* 一个月之前消息直接删除
* 一天执行一次 凌晨1点执行
*/
@Scheduled
(
cron
=
"0 0 1 * * ?"
)
public
void
messageDelete
()
{
log
.
info
(
"离线消息处理定时器处理开始..."
);
// 30天之前数据, 直接删除
Date
allDeleteTime
=
DateUtils
.
addDays
(
new
Date
(),
-
30
);
imMessageService
.
remove
(
new
QueryWrapper
<
ImMessage
>().
lambda
()
.
lt
(
ImMessage:
:
getCreateTime
,
allDeleteTime
));
}
}
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