ny
昨天 b6f169fe43a2b13f351aefc152374fc7f0bc8cb7
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package jnpf.permission.constant;
 
import jnpf.model.ExcelColumnAttr;
import org.apache.poi.ss.usermodel.IndexedColors;
 
import java.util.*;
 
public class PosColumnMap {
 
    String excelName = "岗位信息";
 
    Map<String, String> keyMap = new LinkedHashMap() {{
        put("organizeId", "所属组织");
        put("parentId", "上级岗位");
        put("fullName", "岗位名称");
        put("enCode", "岗位编码");
        put("isCondition", "岗位约束");
        put("constraintType", "约束类型");
        put("mutualExclusion", "互斥岗位");
        put("userNum", "用户基数");
        put("permissionNum", "权限基数");
        put("prerequisite", "先决岗位");
        put("sortCode", "排序");
        put("description", "说明");
    }};
 
    //岗位约束类型
    public static Map<Integer, String> constraintType = new LinkedHashMap() {{
        put(0, "互斥约束");
        put(1, "基数约束");
        put(2, "先决约束");
    }};
 
    /**
     * 表格名称
     *
     * @return
     */
    public String getExcelName() {
        return excelName;
    }
 
    /**
     * 根据类型获取excel表头字段
     *
     * @param type
     * @return
     */
    public Map<String, String> getColumnByType(Integer type) {
        return keyMap;
    }
 
    /**
     * 获取字段列表
     *
     * @param isError
     * @return
     */
    public List<ExcelColumnAttr> getFieldsModel(boolean isError) {
        List<ExcelColumnAttr> models = new ArrayList<>();
        //异常原因
        if (isError) {
            ExcelColumnAttr attr = ExcelColumnAttr.builder().key("errorsInfo").name("异常原因").build();
            models.add(attr);
        }
        List<String> requireFields = Arrays.asList("organizeId", "fullName");
        for (String key : keyMap.keySet()) {
            ExcelColumnAttr attr = ExcelColumnAttr.builder().key(key).name(keyMap.get(key)).build();
            if (requireFields.contains(key)) {
                attr.setRequire(true);
                attr.setFontColor(IndexedColors.RED.getIndex());
            }
            models.add(attr);
        }
        return models;
    }
 
    /**
     * 获取默认值
     */
    public List<Map<String, Object>> getDefaultList() {
        List<Map<String, Object>> list = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
        //所属组织
        map.put("organizeId", "组织名称/编码");
        map.put("parentId", "岗位名称/编码");
        //约束类型
        Map<Integer, String> constraintTypeMap = PosColumnMap.constraintType;
        String constraintType = String.join(",", constraintTypeMap.values());
        map.put("constraintType", constraintType + ":多选组合");
        map.put("mutualExclusion", "岗位名称1/编码1,岗位名称2/编码2");
        map.put("prerequisite", "岗位名称1/编码1,岗位名称2/编码2");
        list.add(map);
        return list;
    }
 
}