package com.pwt.common.config;

import com.pwt.common.constant.CacheConstants;
import com.pwt.common.utils.CacheMap;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * 读取项目相关配置
 *
 * @author ruoyi
 */
@Setter
@Component
@ConfigurationProperties(prefix = "pwt")
public class Config {

    /**
     * 上传路径
     */
    private static String profile;

    /**
     * 系统名称
     */
    private String systemName;

    /**
     * 站控系统
     */
    private String systemIp;

    /**
     * 站控系统端口
     */
    private Integer systemPort;

    /**
     * 管理员token有效期
     */
    private Long adminExpireTime;

    /**
     * 充电soc
     */
    private BigDecimal chargeSoc;

    /**
     * 云平台开关
     */
    private String cloudEnabled;

    /**
     * 云平台地址
     */
    private String cloudAddress;

    /**
     * 云平台账号
     */
    private String cloudAccount;

    /**
     * 云平台密码
     */
    private String cloudPassword;

    /**
     * 协议类型
     */
    private String agreementType;

    /**
     * 车载ip
     */
    private String vehicleCidr;

    /**
     * 换电机器人ip
     */
    private String robotIp;

    /**
     * 换电机器人端口
     */
    private Integer robotPort;

    /**
     * 扫码器ip
     */
    private String scannerIp;

    /**
     * 扫码器端口
     */
    private Integer scannerPort;

    /**
     * rfid ip
     */
    private String rfidIp;

    /**
     * rfid_port
     */
    private Integer rfidPort;

    /**
     * #1充电机ip
     */
    private String charger1Ip;

    /**
     * #2充电机ip
     */
    private String charger2Ip;

    /**
     * #3充电机ip
     */
    private String charger3Ip;

    /**
     * #4充电机ip
     */
    private String charger4Ip;

    /**
     * #5充电机ip
     */
    private String charger5Ip;

    /**
     * #6充电机ip
     */
    private String charger6Ip;

    /**
     * #7充电机ip
     */
    private String charger7Ip;

    /**
     * #8充电机ip
     */
    private String charger8Ip;

    public static String getProfile()
    {
        return profile;
    }

    public void setProfile(String profile)
    {
        Config.profile = profile;
    }

    public static String getSystemName()
    {
        return (String) getConfig("systemName");
    }

    public static String getSystemIp()
    {
        return (String) getConfig("systemIp");
    }

    public static Integer getSystemPort()
    {
        return (Integer) getConfig("systemPort");
    }

    public static Long getAdminExpireTime()
    {
        return (Long) getConfig("adminExpireTime");
    }

    public static BigDecimal getChargeSoc()
    {
        return (BigDecimal) getConfig("chargeSoc");
    }

    public static String getCloudEnabled()
    {
        return (String) getConfig("cloudEnabled");
    }

    public static String getCloudAddress()
    {
        return (String) getConfig("cloudAddress");
    }

    public static String getCloudAccount()
    {
        return (String) getConfig("cloudAccount");
    }

    public static String getCloudPassword()
    {
        return (String) getConfig("cloudPassword");
    }

    public static String getAgreementType()
    {
        return (String) getConfig("agreementType");
    }

    public static String getVehicleCidr()
    {
        return (String) getConfig("vehicleCidr");
    }

    public static String getRobotIp()
    {
        return (String) getConfig("robotIp");
    }

    public static Integer getRobotPort()
    {
        return (Integer) getConfig("robotPort");
    }

    public static String getScannerIp()
    {
        return (String) getConfig("scannerIp");
    }

    public static Integer getScannerPort()
    {
        return (Integer) getConfig("scannerPort");
    }

    public static String getRfidIp()
    {
        return (String) getConfig("rfidIp");
    }

    public static Integer getRfidPort()
    {
        return (Integer) getConfig("rfidPort");
    }

    public static String getCharger1Ip()
    {
        return (String) getConfig("charger1Ip");
    }

    public static String getCharger2Ip()
    {
        return (String) getConfig("charger2Ip");
    }

    public static String getCharger3Ip()
    {
        return (String) getConfig("charger3Ip");
    }

    public static String getCharger4Ip()
    {
        return (String) getConfig("charger4Ip");
    }

    public static String getCharger5Ip()
    {
        return (String) getConfig("charger5Ip");
    }

    public static String getCharger6Ip()
    {
        return (String) getConfig("charger6Ip");
    }

    public static String getCharger7Ip()
    {
        return (String) getConfig("charger7Ip");
    }

    public static String getCharger8Ip()
    {
        return (String) getConfig("charger8Ip");
    }

    /**
     * 获取导入上传路径
     */
    public static String getImportPath()
    {
        return getProfile() + "/import";
    }

    /**
     * 获取头像上传路径
     */
    public static String getAvatarPath()
    {
        return getProfile() + "/avatar";
    }

    /**
     * 获取下载路径
     */
    public static String getDownloadPath()
    {
        return getProfile() + "/download/";
    }

    /**
     * 获取上传路径
     */
    public static String getUploadPath()
    {
        return getProfile() + "/upload";
    }

    /**
     * 获取缓存参数
     */
    private static Object getConfig(String configKey)
    {
        return CacheMap.get(CacheConstants.PWT_CONFIG_KEY + configKey);
    }
}
