skyouc
2025-04-09 faa2a5d8d3cba12ff98c261713bff4d9cea99b79
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
package com.vincent.rsf.server.common.handler;
 
import cn.afterturn.easypoi.handler.inter.IExcelDictHandler;
import com.vincent.rsf.framework.common.SpringUtils;
import com.vincent.rsf.server.common.handler.global.GlobalDictService;
 
/**
 * @Description: excel 字典处理类
 * @Author: Ryan
 * @CreateDate: 2019/10/29 17:42
 * @Version: 1.0
 */
public class ExcelDictHandlerImpl implements IExcelDictHandler {
 
    private ExcelDictHandlerImpl() {
    }
 
    private volatile static ExcelDictHandlerImpl INSTANCE;
 
    public static ExcelDictHandlerImpl getInstance() {
        if (INSTANCE == null) {
            synchronized (ExcelDictHandlerImpl.class) {
                INSTANCE = new ExcelDictHandlerImpl();
            }
        }
        return INSTANCE;
    }
 
    @Override
    public String toName(String dict, Object obj, String name, Object value) {
        return getGlobalDictService().getDictLabel(dict, (value != null ? value.toString() : null), (value != null ? value.toString() : null));
    }
 
    @Override
    public String toValue(String dict, Object obj, String name, Object value) {
        return getGlobalDictService().getDictValue(dict, (value != null ? value.toString() : null), (value != null ? value.toString() : null));
    }
 
    private GlobalDictService getGlobalDictService() {
        try {
            return SpringUtils.getBean(GlobalDictService.class);
        } catch (Exception e) {
            return null;
        }
    }
 
 
}