陈昶聿
8 天以前 655d01040d8c658091e978851961464b91be3506
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.smartor.service;
 
import com.smartor.domain.ServiceTaskSchedule;
import com.smartor.domain.ServiceTaskScheduleDetail;
import com.smartor.domain.ServiceTaskScheduleVO;
 
import java.util.List;
 
/**
 * 随访任务计划 Service 接口
 *
 * @author smartor
 * @date 2026-06-30
 */
public interface IServiceTaskScheduleService {
 
    /**
     * 保存计划(含明细)。
     * 若 taskid 已有计划:先软删旧的,再新建。
     *
     * @param vo 主计划 + 明细
     * @return 保存后的主计划(含主键)
     */
    ServiceTaskSchedule saveScheduleWithDetail(ServiceTaskScheduleVO vo);
 
    /**
     * 按 taskid 查询计划详情(含明细)
     */
    ServiceTaskScheduleVO getScheduleByTaskid(Long taskid);
 
    /**
     * 通过 taskid 查询主计划
     */
    ServiceTaskSchedule selectByTaskid(Long taskid);
 
    /**
     * 通过 scheduleid 查询明细
     */
    List<ServiceTaskScheduleDetail> selectDetailByScheduleid(Long scheduleid);
 
    /**
     * 按 taskid 软删主计划 + 明细
     */
    int removeByTaskid(Long taskid);
 
    /**
     * 循环任务滚动调度:
     * <p>
     * 扫描所有 schedule_style=1 的有效计划,若 current_loop_count 已达上限则跳过;
     * 否则判定本轮(current_loop_count)是否已全部 finalize(sendstate ∉ 1/2/3)。
     * 是 -> 生成下一轮 subtask(克隆本轮的患者,visit_time = 本轮 visit_time + N天/周/月/年),
     *      current_loop_count + 1,next_execute_time 推进。
     * 否 -> 跳过等待下次扫描。
     * <p>
     * 由 RyTask 定时调用,单次扫描限制 200 条避免长事务。
     *
     * @return 实际推进了多少个计划
     */
    int rollCycleTasks();
}