Commit 6722c11c by Future

添加定时器

parent f1d1382b
......@@ -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);
......
......@@ -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 InboxScheduled {
public class MessageScheduled {
@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));
}
}
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