陈昶聿
9 天以前 8a73ac17d717c32aa8fd97f4c682094d7b1c0654
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
package com.smartor.service.mch;
 
import com.smartor.common.MchFollowupConstants;
import org.springframework.stereotype.Component;
 
import java.util.Date;
 
/**
 * 妇幼随访补发窗口判断。
 *
 * <p>只补发 1 天内到期的节点;超过 1 天标记过期,避免给患者发过时消息。</p>
 */
@Component
public class MchFollowupSendWindow {
 
    public MchFollowupDueDecision decide(Date sendTime, Date now) {
        if (sendTime == null) {
            return MchFollowupDueDecision.PENDING;
        }
        Date current = now == null ? new Date() : now;
        if (sendTime.after(current)) {
            return MchFollowupDueDecision.PENDING;
        }
        Date expireBefore = new Date(current.getTime() - MchFollowupConstants.CATCHUP_MILLIS);
        if (sendTime.before(expireBefore)) {
            return MchFollowupDueDecision.EXPIRED;
        }
        return MchFollowupDueDecision.SEND;
    }
}