陈昶聿
2 天以前 67d0eef6ef56713345e03afdfd7e5badf4d4ad3d
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package com.smartor.mapper;
 
import com.smartor.domain.MchFollowupArchiveCandidate;
import com.smartor.domain.MchFollowupArchiveCursor;
import com.ruoyi.task.domain.ServiceSubtask;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
 
import java.util.Date;
import java.util.List;
 
/**
 * 妇幼随访任务(service_subtask)专用 Mapper。
 *
 * <p>妇幼节点不再使用独立计划表,节点快照落在 service_subtask 的
 * mch_archive_detail_id / mch_node_seq / mch_plan_hash / mch_node_json 上。</p>
 */
@Mapper
public interface MchFollowupSubtaskMapper {
 
    /**
     * 扫描已确认、且拟随访日期和随访周期都有值的妇幼档案。
     */
    List<MchFollowupArchiveCandidate> selectCandidates(@Param("orgid") String orgid,
                                                       @Param("dueBefore") Date dueBefore,
                                                       @Param("limit") int limit);
 
    /**
     * 查询某档案详情下已生成的妇幼 subtask。
     */
    List<ServiceSubtask> selectByArchiveDetailId(@Param("detailId") Long detailId);
 
    /**
     * 插入一条妇幼随访 subtask。
     */
    int insertMchSubtask(ServiceSubtask subtask);
 
    /**
     * 计划变更时取消旧计划版本下未发送的妇幼 subtask。
     */
    int cancelPendingByArchiveDetailId(@Param("detailId") Long detailId,
                                       @Param("planHash") String planHash,
                                       @Param("now") Date now);
 
    /**
     * 查询档案详情的懒生成游标。
     */
    MchFollowupArchiveCursor selectMchCursor(@Param("archiveType") String archiveType,
                                            @Param("detailId") Long detailId);
 
    /**
     * 更新档案详情的懒生成游标。
     */
    int updateMchCursor(@Param("archiveType") String archiveType,
                        @Param("detailId") Long detailId,
                        @Param("planHash") String planHash,
                        @Param("nextDueTime") Date nextDueTime);
 
    /**
     * 读取节点 JSON,供发送时使用。
     */
    String selectNodeJsonById(@Param("id") Long id);
 
    /**
     * 抢占待发送任务,避免并发重复发送。
     */
    int claimMchSubtask(@Param("id") Long id, @Param("now") Date now);
 
    /**
     * 回写妇幼 subtask 发送结果。
     */
    int updateMchSendResult(@Param("id") Long id,
                            @Param("sendstate") Long sendstate,
                            @Param("result") String result,
                            @Param("remark") String remark,
                            @Param("finishtime") Date finishtime,
                            @Param("now") Date now);
}