package com.xhpc.common.enums;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author yuyang
 * @date 2022/8/5 16:44
 */
public enum StopReasonEnum {

    FORTY("40", "APP 远程停止(0X40)"),
    FORTY_ONE("41", "SOC 达到 100%(0X41)"),
    FORTY_TWO("42", "充电电量满足设定条件(0X42)"),
    FORTY_THREE("43", "充电金额满足设定条件(0X43)"),
    FORTY_FOUR("44", "充电时间满足设定条件(0X44)"),
    FORTY_FIVE("45", "手动停止充电(0X45)"),
    FORTY_A("4A", "充电桩控制系统故障(需要重启或自动恢复)(0X4A)"),
    FORTY_B("4B", "控制导引断开(0X4B)"),
    FORTY_C("4C", "断路器跳位(0X4C)"),
    FORTY_D("4D", "电表通信中断(0X4D)"),
    FORTY_E("4E", "余额不足(0X4E)"),
    FORTY_F("4F", "充电模块故障(0X4F)"),
    FIVE("50", "急停开入(0X50)"),
    FIVE_ONE("51", "防雷器异常(0X5)"),
    FIVE_TWO("52", "BMS 未就绪(0X52)"),
    FIVE_THREE("53", "温度异常(0X53)"),
    FIVE_FOUR("54", "电池反接故障(0X54)"),
    FIVE_FIVE("55", "电子锁异常(0X55)"),
    FIVE_SIX("56", "合闸失败(0X56)"),
    FIVE_SEVEN("57", "绝缘异常(0X57)"),
    FIVE_NINE("59", "接收 BMS 握手报文 BHM 超时(0X59)"),
    FIVE_A("5A", "接收 BMS 和车辆的辨识报文超时 BRM(0X5A)"),
    FIVE_B("5B", "接收电池充电参数报文超时 BCP(0X5B)"),
    FIVE_C("5C", "接收 BMS 完成充电准备报文超时 BRO AA(0X5C)"),
    FIVE_D("5D", "接收电池充电总状态报文超时 BCS(0X5D)"),
    FIVE_E("5E", "接收电池充电要求报文超时 BCL(0X5E)"),
    FIVE_F("5F", "接收电池状态信息报文超时 BSM(0X5F)"),
    SIXTY("60", "GB2015 电池在BHM 阶段有电压不允许充电(0X60)"),
    SIXTY_ONE("61", "GB2015 辨识阶段在 BRO_AA 时候电池实际电压与 BCP 报文电池电压差距大于 5%(0X61)"),
    SIXTY_TWO("62", "B2015 充电机在预充电阶段从 BRO_AA 变成BRO_00 状态(0X62)"),
    SIXTY_THREE("63", "接收主机配置报文超时(0X63)"),
    SIXTY_FOUR("64", "充电机未准备就绪,我们没有回 CRO AA，对应老国标(0X64)"),
    SIXTY_A("6A", "系统闭锁(0X6A)"),
    SIXTY_B("6B", "导引断开(0X6B)"),
    SIXTY_C("6C", "断路器跳位(0X6C)"),
    SIXTY_D("6D", "电表通信中断(0X6D)"),
    SIXTY_E("6E", "余额不足(0X6E)"),
    SIXTY_F("6F", "交流保护动作(0X6F)"),
    SEVENTY("70", "直流保护动作(0X70)"),
    SEVENTY_ONE("71", "充电模块故障(0X71)"),
    SEVENTY_TWO("72", "急停按钮停止充电(0X72)"),
    SEVENTY_THREE("73", "防雷器异常(0X73)"),
    SEVENTY_FOUR("74", "温度异常(0X74)"),
    SEVENTY_FIVE("75", "输出异常(0X75)"),
    SEVENTY_SIX("76", "充电无流(0X76)"),
    SEVENTY_SEVEN("77", "电子锁异常(0X77)"),
    SEVENTY_EIGHY("78", "预留(0X78)"),
    SEVENTY_NINE("79", "总充电电压异常(0X79)"),
    SEVENTY_A("7A", "总充电电流异常(0X7A)"),
    SEVENTY_B("7B", "单体充电电压异常(0X7B)"),
    SEVENTY_C("7C", "电池组过温(0X7C)"),
    SEVENTY_D("7D", "最高单体充电电压异常(0X7D)"),
    SEVENTY_E("7E", "最高电池组过温(0X7E)"),
    SEVENTY_F("7F", "BMV 单体充电电压异常(0X7F)"),
    EIGHTY("80", "BMT 电池组过温(0X80)"),
    EIGHTY_ONE("81", "电池状态异常停止充电(0X81)"),
    EIGHTY_TWO("82", "车辆发报文禁止充电(0X82)"),
    EIGHTY_THREE("83", "充电桩断电(0X83)"),
    EIGHTY_FOUE("84", "接收电池充电总状态报文超时(0X84)"),
    EIGHTY_FIVE("85", "接收电池充电要求报文超时(0X85)"),
    EIGHTY_SIX("86", "接收电池状态信息报文超时(0X86)"),
    EIGHTY_SEVEN("87", "接收 BMS 中止充电报文超时(0X87)"),
    EIGHTY_EIGHY("88", "接收 BMS 充电统计报文超时(0X88)"),
    EIGHTY_NINE("89", "接收对侧 CCS 报文超时(0X89)"),
    NINETY("90", "未知原因中止(0X90)"),
    NINETY_ONE("91", "平台结算(0X91)"),
    NINETY_TWO("92", "远程重启(0X92)"),
    NINETY_THREE("93", "远程更新应答(0X93)"),
    NINETY_FOUE("94", "远程更新(0X94)"),
    ONE_HUNDRED_NINETY_NINE("199", "平台空订单(0X199)");
    private final String code;
    private final String name;


    public String getCode(){
        return code;
    }

    public String getName(){
        return name;
    }

    StopReasonEnum(String code, String name){
        this.code = code;
        this.name = name;
    }

    public static String getNameByCode(String code) {
        for (StopReasonEnum typeEnum : StopReasonEnum.values()) {
            //移除交办
            if (typeEnum.code.equals(code)) {
                return typeEnum.name;
            }
        }
        return "";
    }


    public static Map<String, String> getMap(){
        return Arrays.stream(StopReasonEnum.values()).collect(Collectors.toMap(StopReasonEnum::getCode, StopReasonEnum::getName));
    }

}
