package com.tofly.gpsboot.common.business;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.StringUtils;

/**
 * @ClassName: ExcelExportFileTypeEnum
 * @Description: 导出文件枚举
 * @Author Zev
 * @Date 2021/3/25
 * @Version 1.0.0
 */
@Getter
@AllArgsConstructor
public enum ExcelExportFileTypeEnum {
    /**
     *
     */
    EXPORT_PDA("/人员终端台账.xlsx","人员终端台账","PdaDeviceService","1"),
    EXPORT_REPAIR_MATERIAL("/材料类型导入模板.xlsx","材料类型导入模板","repairmaterialService","1"),
    EXPORT_REPAIR_TYPE("/维修类型导入模板.xlsx","维修类型导入模板","repairtypeService","1"),
    EXPORT_REPAIR_PLAN_YEAR("/抢维修年详情导出.xlsx","抢维修年详情","repairplanyearService","0"),
    EXPORT_REPAIR_PLAN_MONTH("/抢维修月详情导出.xlsx","抢维修月详情","repairplanService","0"),
    EXPORT_REPAIR_ORDER("/工单详情导出.xlsx","工单详情","repairorderService","0"),
    EXPORT_INSPECTION_PLAN_YEAR("/巡检年详情导出.xlsx","巡检年详情","planyearService","0"),
    EXPORT_INSPECTION_PLAN_MONTH("/巡检月详情导出.xlsx","巡检月详情","planmouthService","0"),
    EXPORT_MAINTENANCE_LOG_LEDGER("/维修记录台账导出.xlsx","维修记录","statementService","0"),
    EXPORT_MAINTENANCE_MAINTAIN("/维修保养记录台账导出.xlsx","维修保养记录","statementService","1"),
    EXPORT_TERMINAL_RECORD("/终端记录台账导出.xlsx","终端记录","statementService","2"),
    ;
    /**
     * 导出模板文件
     */
    private String templateFile;
    /**
     * 导出表格名
     */
    private String sheetName;

    /**
     * 模板服务类型
     */
    private String templateServiceType;

    /**
     * 是否为示例模板
     */
    private String flag;

    /**
     * 根据模型类型和是否为示例模板获取对应枚举对象
     *
     * @param templateServiceType 模型类型
     * @param flag                是否为示例模板
     * @return 枚举对象
     */
    public static ExcelExportFileTypeEnum getExcelExportFileTypeEnum(String templateServiceType, String flag) {
        if (StringUtils.isEmpty(templateServiceType)) {
            return null;
        }

        for (ExcelExportFileTypeEnum e : ExcelExportFileTypeEnum.values()) {
            if (e.templateServiceType.equalsIgnoreCase(templateServiceType) && e.flag.equalsIgnoreCase(flag)) {
                return e;
            }
        }
        return null;
    }
}
