package org.linlinjava.jz.core.system;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * 系统设置
 */
public class SystemConfig {
    // 电访相关配置
    public final static String jz_CALL_NO_ANSWER = "jz_call_noanswer";//无应答
    public final static String jz_CALL_BUSY = "jz_call_busy";//通话中 几个小时候拨打
    public final static String jz_CALL_POWER_OFF = "jz_call_power_off";//关机 几个小时候拨打
    public final static String jz_CALL_OVERUDE = "jz_call_overdue";//停机 几个小时候拨打
    public final static String Jz_CALL_NO_CONNECTED = "jz_call_no_connected";//无法拨通 几个小时候拨打


    public final static String jz_CALL_NO_CONNECT_TIMES = "jz_call_no_connnect_times";//未接通 拨打几次



    //所有的配置均保存在该 HashMap 中
    private static Map<String, String> SYSTEM_CONFIGS = new HashMap<>();

    private static String getConfig(String keyName) {
        return SYSTEM_CONFIGS.get(keyName);
    }

    private static Integer getConfigInt(String keyName) {
        return Integer.parseInt(SYSTEM_CONFIGS.get(keyName));
    }

    private static Boolean getConfigBoolean(String keyName) {
        return Boolean.valueOf(SYSTEM_CONFIGS.get(keyName));
    }

    private static BigDecimal getConfigBigDec(String keyName) {
        return new BigDecimal(SYSTEM_CONFIGS.get(keyName));
    }

    public static Integer getCallNoAnswer() {
        return getConfigInt(jz_CALL_NO_ANSWER);
    }

    public static Integer getCallBusy() {        return getConfigInt(jz_CALL_BUSY);    }

    public static Integer getCallPowerOff() {
        return getConfigInt(jz_CALL_POWER_OFF);
    }

    public static Integer getCallOverdue() {
        return getConfigInt(jz_CALL_OVERUDE);
    }

    public static Integer getCallNoConnected() {
        return getConfigInt(Jz_CALL_NO_CONNECTED);
    }

    public static Integer getCallNoConnectedTimes() {
        return getConfigInt(jz_CALL_NO_CONNECT_TIMES);
    }


    public static void setConfigs(Map<String, String> configs) {
        SYSTEM_CONFIGS = configs;
    }

    public static void updateConfigs(Map<String, String> data) {
        for (Map.Entry<String, String> entry : data.entrySet()) {
            SYSTEM_CONFIGS.put(entry.getKey(), entry.getValue());
        }
    }
}