package com.m2pool.lease.constant;

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

/**
 * @Description 单位换算
 * @Date 2025/8/18 16:19
 * @Author yyb
 */
public class PowerUnit {

    public static final String KH_UNIT = "KH/S";

    public static final String MH_UNIT = "MH/S";

    public static final String GH_UNIT = "GH/S";

    public static final String TH_UNIT = "TH/S";

    public static final String PH_UNIT = "PH/S";

    private static final Map<String, BigDecimal> UNIT_MAP;

    static {
        HashMap<String, BigDecimal> map = new HashMap<>();
        map.put(KH_UNIT, BigDecimal.valueOf(1000));
        map.put(MH_UNIT, BigDecimal.valueOf(1000 * 1000));
        map.put(GH_UNIT,  BigDecimal.valueOf(1000L * 1000 * 1000));
        map.put(TH_UNIT,  BigDecimal.valueOf(1000L * 1000 * 1000 * 1000 ));
        map.put(PH_UNIT,  BigDecimal.valueOf(1000L * 1000 * 1000 * 1000 * 1000));
        UNIT_MAP = Collections.unmodifiableMap(map);
    }


    public static BigDecimal getPower(String unit) {
        if (unit == null) {
            return BigDecimal.ZERO;
        }
        return UNIT_MAP.get(unit);
    }
}
