package com.usky.vpp.config; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; /** * 运管平台 UN/DN 对接配置 */ @Data @Component @ConfigurationProperties(prefix = "vpp.un") public class VppUnProperties { /** 运管平台 UN 基地址 */ private String baseUrl; /** 虚拟电厂运营商 DN ID */ private String dnId; /** DN 名称 */ private String dnName; /** DN 对外服务地址(供 UN 回调) */ private String transportAddress; /** UN 公钥 Base64 */ private String unPublicKey; /** DN 公钥 Base64 */ private String dnPublicKey; /** DN 私钥 Base64 */ private String dnPrivateKey; /** Poll 轮询间隔秒,默认 10 */ private Integer pollIntervalSec = 10; /** 是否启用 DN 主动调用 UN(Poll/申报/出清等) */ private Boolean outboundEnabled = false; /** 是否启用 Poll 定时任务 */ private Boolean pollEnabled = false; /** 是否启用 SM2/SM3 加解密(未配置密钥时自动降级为明文) */ private Boolean cryptoEnabled = false; /** 申报价格下调系数,默认 0.8 */ private String priceDownCoeff = "0.8"; /** 已保存的 registrationID(首次注册后需持久化) */ private String registrationId; /** Token 请求头,默认 Authorization */ private String tokenHeader = "Authorization"; /** Token 前缀,默认 Bearer */ private String tokenPrefix = "Bearer "; /** Token 有效期分钟(文档默认 30),用于本地缓存刷新 */ private Integer tokenTtlMinutes = 25; /** 收到出清公示后是否自动向 UN 发送 CreateEventResponse */ private Boolean autoAckClearing = false; /** 启动时自动注册 UN(需 outbound-enabled=true) */ private Boolean autoRegisterOnStartup = false; /** HTTP 连接超时毫秒 */ private Integer connectTimeoutMs = 10000; /** HTTP 读超时毫秒 */ private Integer readTimeoutMs = 30000; public boolean isOutboundActive() { return Boolean.TRUE.equals(outboundEnabled) && baseUrl != null && !baseUrl.trim().isEmpty(); } public boolean isPollActive() { return Boolean.TRUE.equals(pollEnabled) && isOutboundActive(); } }