package enumeration.converter;
|
|
import com.alibaba.excel.converters.Converter;
|
import com.alibaba.excel.enums.CellDataTypeEnum;
|
import com.alibaba.excel.metadata.GlobalConfiguration;
|
import com.alibaba.excel.metadata.data.ReadCellData;
|
import com.alibaba.excel.metadata.data.WriteCellData;
|
import com.alibaba.excel.metadata.property.ExcelContentProperty;
|
import enumeration.general.RuleDeductCategoryEnum;
|
|
/**
|
* 扣分类型枚举装换器
|
*
|
* @author gonghl
|
*/
|
public class RuleDeductCategoryConverter implements Converter<RuleDeductCategoryEnum> {
|
|
@Override
|
public Class supportJavaTypeKey() {
|
return null;
|
}
|
|
@Override
|
public CellDataTypeEnum supportExcelTypeKey() {
|
return null;
|
}
|
|
@Override
|
public RuleDeductCategoryEnum convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
if (cellData.getStringValue().equals(RuleDeductCategoryEnum.DEDUCT_POINTS.getDesc())) {
|
return RuleDeductCategoryEnum.DEDUCT_POINTS;
|
} else if (cellData.getStringValue().equals(RuleDeductCategoryEnum.MULTIPLY_POINTS_BY_QUANTITY.getDesc())) {
|
return RuleDeductCategoryEnum.MULTIPLY_POINTS_BY_QUANTITY;
|
} else if (cellData.getStringValue().equals(RuleDeductCategoryEnum.MULTIPLY_POINTS_AFTER_DIVIDING_QUANTITY.getDesc())) {
|
return RuleDeductCategoryEnum.MULTIPLY_POINTS_AFTER_DIVIDING_QUANTITY;
|
} else {
|
return null;
|
}
|
}
|
|
@Override
|
public WriteCellData<RuleDeductCategoryEnum> convertToExcelData(RuleDeductCategoryEnum value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) {
|
return new WriteCellData<>(value.getDesc());
|
}
|
}
|