|
|
@@ -242,6 +242,9 @@ public class Task {
|
|
|
@Autowired
|
|
|
private IFsImMsgSendLogService fsImMsgSendLogService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private com.fs.store.mapper.FsUserCourseCountMapper fsUserCourseCountMapper;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 定时任务,处理ai禁止回复之后的消息
|
|
|
@@ -1900,6 +1903,30 @@ public class Task {
|
|
|
logger.info("删除fs_im_msg_send_log数据:{}条", logCount);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 定时清理 fs_user_course_count 表,只保留3个月的数据,1000条一批次删除
|
|
|
+ */
|
|
|
+ public void cleanFsUserCourseCount() {
|
|
|
+ logger.info("开始执行清理 fs_user_course_count 表数据任务");
|
|
|
+ Date thresholdTime = org.apache.commons.lang3.time.DateUtils.addMonths(new Date(), -3);
|
|
|
+ int totalDeleted = 0;
|
|
|
+ int batchCount;
|
|
|
+ do {
|
|
|
+ batchCount = fsUserCourseCountMapper.deleteByCreateTimeLimit(thresholdTime);
|
|
|
+ totalDeleted += batchCount;
|
|
|
+ if (batchCount > 0) {
|
|
|
+ logger.info("清理 fs_user_course_count 数据, 本批删除 {} 条, 累计已删除 {} 条", batchCount, totalDeleted);
|
|
|
+ try {
|
|
|
+ Thread.sleep(100);
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ Thread.currentThread().interrupt();
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } while (batchCount > 0);
|
|
|
+ logger.info("清理 fs_user_course_count 表数据完成, 总共删除 {} 条", totalDeleted);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|