package jnpf.dmsService;
|
|
import jnpf.exception.DataException;
|
import java.time.ZoneId;
|
import java.util.Date;
|
|
/** Date-only form values use the business timezone; expiry is exclusive internally. */
|
public final class DmsApprovedFileDates {
|
public static final ZoneId ZONE = ZoneId.of("Asia/Shanghai");
|
private DmsApprovedFileDates() { }
|
/** Revocation and invalidation share one optional, per-file date rule. */
|
public static Date disableScheduled(Date requested, Date approvedAt) {
|
if (approvedAt == null) throw new DataException("文件停用必须先取得真实批准时间");
|
Date day = requested == null ? approvedAt : scheduled(requested);
|
return new Date(Math.max(day.getTime(), approvedAt.getTime()));
|
}
|
public static Date scheduled(Date effective) {
|
if (effective == null) throw new DataException("审核单正式生效日期必填");
|
return Date.from(effective.toInstant().atZone(ZONE).toLocalDate().atStartOfDay(ZONE).toInstant());
|
}
|
public static Date expires(Date through, Date scheduled) {
|
if (through == null) return null;
|
Date end = Date.from(through.toInstant().atZone(ZONE).toLocalDate().plusDays(1).atStartOfDay(ZONE).toInstant());
|
if (!end.after(scheduled)) throw new DataException("文件有效期已结束或早于生效日期");
|
return end;
|
}
|
}
|