AlcoholFlagConverter.java 1.33 KB
package com.ruoyi.pojo.converter;

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 static com.ruoyi.common.ConstSignInConstSignInProperties.*;

/**
 * 酒精测试
 * @author 20412
 */
@SuppressWarnings(value = {"unchecked", "rawtypes"})
public class AlcoholFlagConverter implements Converter<Integer> {
    @Override
    public Class supportJavaTypeKey() {
        return Integer.class;
    }

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

    @Override
    public Integer convertToJavaData(CellData cellData, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return null;
    }

    @Override
    public CellData convertToExcelData(Integer integer, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        String str = "";
        if (ALCOHOL_FLAG_YES.equals(integer)){
            str = ALCOHOL_FLAG_YES_STRING;
        }
        if (ALCOHOL_FLAG_NO.equals(integer)){
            str = ALCOHOL_FLAG_NO_STRING;
        }
        return new CellData(str);
    }
}