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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package jnpf.permission.constant;
 
import jnpf.model.ExcelColumnAttr;
import org.apache.poi.ss.usermodel.IndexedColors;
 
import java.util.*;
 
public class OrgColumnMap {
 
    String excelName = "组织信息";
    /**
     * 全部字段
     */
    private Map<String, String> allKeyMap = new LinkedHashMap() {{
        put("parentId", "上级组织");
        put("category", "组织类型");
        put("fullName", "组织名称");
        put("enCode", "组织编码");
        put("sortCode", "排序");
        put("description", "说明");
    }};
    /**
     * 组织map
     */
    private Map<String, String> orgMap = new LinkedHashMap() {{
        put("category", "类型");
        put("parentId", "上级公司");
        put("fullName", "公司名称");
        put("enCode", "公司编码");
        put("shortName", "公司简称");
        put("enterpriseNature", "公司性质");
        put("industry", "所属行业");
        put("foundedTime", "成立时间");
        put("telePhone", "公司电话");
        put("fax", "公司传真");
        put("webSite", "公司主页");
        put("address", "公司地址");
        put("managerName", "公司法人");
        put("managerTelePhone", "联系电话");
        put("managerMobilePhone", "联系手机");
        put("manageEmail", "联系邮箱");
        put("bankName", "开户银行");
        put("bankAccount", "银行账户");
        put("businessscope", "经营范围");
        put("managerId", "部门主管");
    }};
    /**
     * 部门map
     */
    private Map<String, String> depMap = new LinkedHashMap() {{
        put("category", "类型");
        put("parentId", "所属组织");
        put("fullName", "部门名称");
        put("enCode", "部门编码");
        put("managerId", "部门主管");
        put("sortCode", "排序");
        put("description", "说明");
    }};
 
    /**
     * 根据类型获取excel表头字段
     *
     * @param type
     * @return
     */
    public Map<String, String> getColumnByType(Integer type) {
        Map<String, String> map = new LinkedHashMap();
        switch (type) {
            case 2:
                map = new LinkedHashMap(depMap);
                break;
            case 1:
                map = new LinkedHashMap(orgMap);
                map.remove("managerId");
                break;
            default:
//                map = new LinkedHashMap(orgMap);
                map.putAll(allKeyMap);
                break;
        }
        return map;
    }
 
    public String getExcelName() {
        return excelName;
    }
 
 
    public List<ExcelColumnAttr> getFieldsModel(boolean isError, Integer type) {
        List<ExcelColumnAttr> models = new ArrayList<>();
        //异常原因
        if (isError) {
            ExcelColumnAttr attr = new ExcelColumnAttr().builder()
                    .key("errorsInfo")
                    .name("异常原因")
                    .build();
            models.add(attr);
        }
        List<String> requirelist = Arrays.asList("category", "fullName");
        // 遍历添加属性
        Map<String, String> keyMap = getColumnByType(type);
 
        for (String key : keyMap.keySet()) {
            ExcelColumnAttr attr = ExcelColumnAttr.builder()
                    .key(key)
                    .name(keyMap.get(key))
                    .build();
            if (requirelist.contains(key)) {
                attr.setRequire(true);
                attr.setFontColor(IndexedColors.RED.getIndex());
            }
            models.add(attr);
        }
        return models;
    }
 
    /**
     * 获取默认值
     */
    public List<Map<String, Object>> getDefaultList() {
//        Map<String, Object> orgMapDemo = new HashMap<>();
//        orgMapDemo.put("fullName", "公司名称/公司名称1");
//        orgMapDemo.put("foundedTime", "yyy-MM-dd");
        Map<String, Object> depMapDemo = new HashMap<>();
        depMapDemo.put("fullName", "组织名称");
        depMapDemo.put("parentId", "上级组织名称/编码(为空时则该组织添加为一级组织)");
//        depMapDemo.put("managerId", "姓名/账号");
        List<Map<String, Object>> list = new ArrayList<>();
//        list.add(orgMapDemo);
        list.add(depMapDemo);
        return list;
    }
}