package com.zsElectric.boot.config.property; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; import java.util.Arrays; import java.util.Collections; import java.util.Set; import java.util.stream.Collectors; /** * 充电站经纬度同步黑名单配置 * *

配置在黑名单中的充电站,同步时不会覆盖其经纬度信息

*/ @Data @Component @ConfigurationProperties(prefix = "black-charging-stations") public class BlackChargingStationsProperties { /** * 不同步经纬度的充电站ID列表(逗号分隔) */ private String stationList = ""; /** * 判断指定stationId是否在黑名单中 */ public boolean isBlacklisted(String stationId) { if (stationId == null || stationList == null || stationList.isBlank()) { return false; } return getStationSet().contains(stationId); } /** * 获取黑名单Station ID集合 */ public Set getStationSet() { if (stationList == null || stationList.isBlank()) { return Collections.emptySet(); } return Arrays.stream(stationList.split(",")) .map(String::trim) .filter(s -> !s.isEmpty()) .collect(Collectors.toSet()); } }