package com.xisc.pm.infra.enums;

import io.choerodon.core.exception.CommonException;

public enum PdEventType {
    HP01("HP01", "组板合同收池事件"), HP02("HP02", "组板合同退池事件"), HP03("HP03", "组板合同超投事件"),

    HP04("HP04", "合同组板事件"), HP05("HP05", "合同组板释放事件"), HP06("HP06", "组板合同取消超投事件"),

    HP10("HP10", "余材板坯组板完成事件"), HP11("HP11", "余材板坯组板删除事件"), HP14("HP14", "余材钢板组板完成事件"), HP15("HP15", "余材钢板组板删除事件"),
    HP16("HP16", "连铸出钢材组板完成事件"), HP17("HP17", "连铸出钢材组板删除事件"), HP26("HP26", "连铸出钢材预组炉完成事件"),
    HP27("HP27", "连铸出钢材预组炉删除事件"), HP30("HP30", "启动试样添加事件"), HP31("HP31", "余材板坯组板二次设计事件"), HP33("HP33", "余材钢板组板二次设计事件"),
    HP34("HP34", "连铸出钢材组板二次设计事件"), HP40("HP40", "余材板坯组板命令作成事件"), HP42("HP42", "余材钢板组板命令作成事件"),
    HP43("HP43", "连铸出钢材组板命令作成事件"),

    HP45("HP45", ""),

    HP46("HP46", "成品充当挂/脱合同事件"), HPZ1("HPZ1", "产线转换-SM封锁"), HPZ2("HPZ2", "产线转换-HP封锁"), HPZ3("HPZ3", "产线转换-规格检查 板坯"),
    HPZ4("HPZ4", "产线转换-规格检查 钢板"), HPZ5("HPZ5", "产线转换-SM规则检查未通过，解封"), HPZ6("HPZ6", "产线转换-HP规则检查未通过，解封"),
    HPZ7("HPZ7", "产线转换-SM插入合同表(无LOTKEY)"), HPZ8("HPZ8", "产线转换-SM插入合同表(有LOTKEY)"),
    HPZ9("HPZ9", "产线转换-SM插入余材板坯表(传LOTKEY)"), HPZA("HPZA", "产线转换-SM插入余材板坯表(不传LOTKEY)"),
    HPZB("HPZB", "产线转换-HP插入合同表(无LOTKEY)"), HPZC("HPZC", "产线转换-HP插入余材钢板表(传LOTKEY)"),
    HPZD("HPZD", "产线转换-HP插入余材钢板表(不传LOTKEY)"), HPZE("HPZE", "产线转换-试样添加 板坯(传LOTKEY)"),
    HPZF("HPZF", "产线转换-试样添加 板坯(不传LOTKEY)"), HPZG("HPZG", "产线转换-试样添加 钢板(传LOTKEY)"),
    HPZH("HPZH", "产线转换-试样添加 钢板(不传LOTKEY)"), HPZI("HPZI", "产线转换-余材板坯二次设计(传LOTKEY)"),
    HPZJ("HPZJ", "产线转换-余材板坯二次设计(不传LOTKEY)"), HPZK("HPZK", "产线转换-余材钢板二次设计(传LOTKEY)"),
    HPZL("HPZL", "产线转换-余材钢板二次设计(不传LOTKEY)"), HPZM("HPZM", "产线转换-板坯命令作成(传LOTKEY)"),
    HPZN("HPZN", "产线转换-板坯命令作成(不传LOTKEY)"), HPZO("HPZO", "产线转换-钢板命令作成(传LOTKEY)"), HPZP("HPZP", "产线转换-钢板命令作成(不传LOTKEY)"),
    HPZQ("HPZQ", "产线转换-板坯命令释放(传LOTKEY)"), HPZR("HPZR", "产线转换-板坯命令释放(不传LOTKEY)"), HPZS("HPZS", "产线转换-钢板命令释放(传LOTKEY)"),
    HPZT("HPZT", "产线转换-钢板命令释放(不传LOTKEY)"),

    HPTH("HPTH", "外部脱合同删除组板信息"),
    HP_FHB_FINSHED("HP_FHB_FINSHED", "复合板组板完成", false), HP_FHB_DELETED("HP_FHB_FINSHED", "复合板组板解散", false), 
    HP49("HP49", "二次开坯组板", true);

    private final String code;
    private final String desc;
    private final boolean createEventRec;

    // 私有构造函数
    PdEventType(String code, String desc, boolean createEventRec) {
        this.code = code;
        this.desc = desc;
        this.createEventRec = createEventRec;
    }

    // 私有构造函数
    PdEventType(String code, String desc) {
        this.code = code;
        this.desc = desc;
        this.createEventRec = true;
    }

    // Getter 方法
    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    // 根据code查找枚举项（可选）
    public static PdEventType getByCode(String code) {
        for (PdEventType type : PdEventType.values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        throw new CommonException("pm.pm_pd_rec_002", code);
    }

    public boolean isCreateEventRec() {
        return createEventRec;
    }
}
