SignInStatusConverter.java
1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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 SignInStatusConverter 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 {
String value = cellData.getStringValue();
if (SIGN_IN_SUCCESS_STRING.equals(value)){
return 1;
}
if (SIGN_IN_FAIL_STRING.equals(value)){
return 2;
}
return Integer.parseInt(value);
}
@Override
public CellData convertToExcelData(Integer integer, ExcelContentProperty excelContentProperty, GlobalConfiguration globalConfiguration) throws Exception {
String str = "";
if (SIGN_IN_SUCCESS.equals(integer)){
str = SIGN_IN_SUCCESS_STRING;
}
if (SIGN_IN_FAIL.equals(integer)){
str = SIGN_IN_FAIL_STRING;
}
return new CellData(str);
}
}