package com.mortals.xhx.common.utils;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

import java.text.ParseException;

/**
 * @Title: 证件类型转换
 * @Package: com.atm.affair.util
 * @Description: (用一句话描述该文件做什么)
 * @Author: tinker
 * @Date: 4/9/21
 * @Version: V1.0
 */
public class ExcelConvertCardType implements Converter<String> {
    @Override
    public Class supportJavaTypeKey() {
        return String.class;
    }

    @Override
    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.STRING;
    }

    @Override
    public String convertToJavaData(CellData cellData, ExcelContentProperty contentProperty,
                                     GlobalConfiguration globalConfiguration) throws ParseException {
        //        001 统一社会信用代码证件
//        099 其他法人或其他组织有效证件
//        111 居民身份证
//        112 临时居民身份证
//        113 户口簿
        if (cellData.getStringValue() == null) {
            return "";
        } else if (cellData.getStringValue().indexOf("统一社会信用代码")>=0) {
            return "001";
        } else if ("其他法人或其他组织有效证件".equals(cellData.getStringValue())) {
            return "099";
        } else if ("居民身份证".equals(cellData.getStringValue())) {
            return "111";
        } else if ("临时居民身份证".equals(cellData.getStringValue())) {
            return "112";
        } else if ("护照".equals(cellData.getStringValue())) {
        return "414";
    }
        else{
            return "111";
        }
    }

    @Override
    public CellData convertToExcelData(String value, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
    return null;
    }

}
