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;
|
}
|
|
}
|