刘光辉
3 小时以前 06f314545ac3514d7ce28939920866ae8188d31c
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
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;
    }
}