|
|
@@ -0,0 +1,43 @@
|
|
|
+package com.kxs.user.biz.task;
|
|
|
+
|
|
|
+import cn.hutool.core.date.DatePattern;
|
|
|
+import cn.hutool.core.date.LocalDateTimeUtil;
|
|
|
+import com.kxs.common.mybatis.handler.MonthTableNameHandler;
|
|
|
+import com.kxs.user.biz.mapper.KxsUserAmountLogMapper;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
+import org.springframework.scheduling.annotation.EnableAsync;
|
|
|
+import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
+import org.springframework.scheduling.annotation.Scheduled;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import java.time.LocalDate;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 产品模块定时任务
|
|
|
+ *
|
|
|
+ * @author 没秃顶的码农
|
|
|
+ * @date 2024-03-13
|
|
|
+ */
|
|
|
+@Component
|
|
|
+@EnableAsync
|
|
|
+@EnableScheduling
|
|
|
+@RequiredArgsConstructor
|
|
|
+@Slf4j
|
|
|
+public class KxsUserTaskJob {
|
|
|
+
|
|
|
+ private final KxsUserAmountLogMapper kxsUserAmountLogMapper;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 自动表创建任务
|
|
|
+ * 每个月15号建立下个月的收支日志表
|
|
|
+ */
|
|
|
+ @Async(value = "getAsyncExecutor")
|
|
|
+ @Scheduled(cron = "0 15 10 15 * ?")
|
|
|
+ public void automaticTableCreationTasks() {
|
|
|
+ String thisMoth = LocalDateTimeUtil.format(LocalDate.now().plusMonths(1L), DatePattern.SIMPLE_MONTH_PATTERN);
|
|
|
+ kxsUserAmountLogMapper.automaticTableCreationTasks("kxs_user_amount_log_" +thisMoth);
|
|
|
+ }
|
|
|
+}
|