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;
|
}
|
}
|