|
|
@@ -2,12 +2,15 @@ package com.etotem.cfc.task;
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.etotem.cfc.entity.FamilyMember;
|
|
|
import com.etotem.cfc.entity.Task;
|
|
|
+import com.etotem.cfc.mapper.FamilyMemberMapper;
|
|
|
import com.etotem.cfc.mapper.TaskMapper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Calendar;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
@@ -22,6 +25,7 @@ import com.etotem.cfc.config.DatabaseInitializer;
|
|
|
* - weekly: 每周生成(按模板 deadline 的星期几)
|
|
|
* - monthly: 每月生成(按模板 deadline 的日)
|
|
|
* 兼容旧版 repeat_type (none/daily/weekly):repeat_type=daily 等价 frequency=daily,weekly 等价 weekly
|
|
|
+ * 额外:每日为能登录用户生成 3 条内置健康打卡任务([DIET]/[SLEEP]/[EXERCISE],is_daily_progress=1)
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Component
|
|
|
@@ -30,6 +34,16 @@ public class RepeatTaskGenerator {
|
|
|
@Resource
|
|
|
private TaskMapper taskMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private FamilyMemberMapper familyMemberMapper;
|
|
|
+
|
|
|
+ /** 内置健康打卡任务模板定义(title 前缀约定与 TaskService.updateProgress 的 taskKey 匹配一致) */
|
|
|
+ private static final List<String[]> CHECKIN_TEMPLATES = Arrays.asList(
|
|
|
+ new String[]{"[DIET]饮食打卡", "diet"},
|
|
|
+ new String[]{"[SLEEP]睡眠打卡", "sleep"},
|
|
|
+ new String[]{"[EXERCISE]运动打卡", "exercise"}
|
|
|
+ );
|
|
|
+
|
|
|
/**
|
|
|
* 每小时第5分执行,按频率分派生成重复任务
|
|
|
*/
|