EmpUtils 新增根据机构类型获取机构数据方法
This commit is contained in:
@@ -200,4 +200,4 @@ th[aria-selected=true] .ui-jqgrid-sortable {color:#1890ff;}
|
|||||||
.ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus {background:#f5f5f5;}
|
.ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus {background:#f5f5f5;}
|
||||||
.ui-jqgrid tr.ui-state-highlight.ui-row-ltr td {background-color:#e5f3ff;}
|
.ui-jqgrid tr.ui-state-highlight.ui-row-ltr td {background-color:#e5f3ff;}
|
||||||
/* .ui-jqgrid tr.ui-row-ltr td {border-right:0!important;} */
|
/* .ui-jqgrid tr.ui-row-ltr td {border-right:0!important;} */
|
||||||
.ui-jqgrid tr.ui-row-ltr td:last-child {border-right:1px solid #eaeaea!important;}
|
.ui-jqgrid tr.ui-row-ltr td:last-child {border-color:#eaeaea!important;}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import com.jeesite.modules.sys.service.OfficeService;
|
|||||||
*/
|
*/
|
||||||
public class EmpUtils {
|
public class EmpUtils {
|
||||||
|
|
||||||
// 部门和公司缓存常量
|
// 机构和公司缓存常量
|
||||||
public static final String CACHE_OFFICE_ALL_LIST = "officeAllList";
|
public static final String CACHE_OFFICE_ALL_LIST = "officeAllList";
|
||||||
public static final String CACHE_COMPANY_ALL_LIST = "companyAllList";
|
public static final String CACHE_COMPANY_ALL_LIST = "companyAllList";
|
||||||
public static final String CACHE_COMPANY_OFFICE_LIST = "employeeOfficeList";
|
public static final String CACHE_COMPANY_OFFICE_LIST = "employeeOfficeList";
|
||||||
@@ -91,7 +91,8 @@ public class EmpUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前附属部门对象列表
|
* 获取当前附属机构对象列表
|
||||||
|
* @author ThinkGem
|
||||||
*/
|
*/
|
||||||
public static List<EmployeeOffice> getEmployeeOfficeList(){
|
public static List<EmployeeOffice> getEmployeeOfficeList(){
|
||||||
List<EmployeeOffice> list = UserUtils.getCache(CACHE_COMPANY_OFFICE_LIST);
|
List<EmployeeOffice> list = UserUtils.getCache(CACHE_COMPANY_OFFICE_LIST);
|
||||||
@@ -103,37 +104,9 @@ public class EmpUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有部门编码,包括附属部门(数据权限用)
|
* 根据机构编码获取机构对象
|
||||||
* @return
|
|
||||||
* @author ThinkGem
|
|
||||||
*/
|
|
||||||
public static String[] getOfficeCodes(){
|
|
||||||
List<String> list = ListUtils.newArrayList();
|
|
||||||
list.add(getOffice().getOfficeCode());
|
|
||||||
getEmployeeOfficeList().forEach(e -> {
|
|
||||||
list.add(e.getOfficeCode());
|
|
||||||
});
|
|
||||||
return list.toArray(new String[list.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取所有部门编码,包括附属部门(数据权限用)
|
|
||||||
* @return
|
|
||||||
* @author ThinkGem
|
|
||||||
*/
|
|
||||||
public static String[] getOfficeParentCodess(){
|
|
||||||
List<String> list = ListUtils.newArrayList();
|
|
||||||
list.add(getOffice().getParentCodes());
|
|
||||||
getEmployeeOfficeList().forEach(e -> {
|
|
||||||
list.add(e.getParentCodes());
|
|
||||||
});
|
|
||||||
return list.toArray(new String[list.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取部门对象
|
|
||||||
* @param officeCode
|
* @param officeCode
|
||||||
* @return
|
* @author ThinkGem
|
||||||
*/
|
*/
|
||||||
public static Office getOffice(String officeCode){
|
public static Office getOffice(String officeCode){
|
||||||
List<Office> officeList = getOfficeAllList();
|
List<Office> officeList = getOfficeAllList();
|
||||||
@@ -146,15 +119,16 @@ public class EmpUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前员工附属部门
|
* 获取当前员工机构
|
||||||
|
* @author ThinkGem
|
||||||
*/
|
*/
|
||||||
public static Office getOffice(){
|
public static Office getOffice(){
|
||||||
return getEmployee().getOffice();
|
return getEmployee().getOffice();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有的机构
|
* 获取当前员工所有的机构
|
||||||
* @return
|
* @author ThinkGem
|
||||||
*/
|
*/
|
||||||
public static List<Office> getOfficeAllList(){
|
public static List<Office> getOfficeAllList(){
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -169,16 +143,93 @@ public class EmpUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前公司对象
|
* 获取当前员工所有机构编码,包括附属机构(数据权限用)
|
||||||
|
* @author ThinkGem
|
||||||
*/
|
*/
|
||||||
public static Company getCompany(){
|
public static String[] getOfficeCodes(){
|
||||||
return getEmployee().getCompany();
|
List<String> list = ListUtils.newArrayList();
|
||||||
|
list.add(getOffice().getOfficeCode());
|
||||||
|
getEmployeeOfficeList().forEach(e -> {
|
||||||
|
list.add(e.getOfficeCode());
|
||||||
|
});
|
||||||
|
return list.toArray(new String[list.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取公司对象
|
* 根据机构类型,获取当前员工所有机构编码,包括附属机构(数据权限用)
|
||||||
|
* @author ThinkGem
|
||||||
|
*/
|
||||||
|
public static String[] getOfficeCodesByType(String type){
|
||||||
|
List<String> list = ListUtils.newArrayList();
|
||||||
|
Office office = getOffice();
|
||||||
|
if (type.equals(office.getOfficeType())){
|
||||||
|
list.add(office.getOfficeCode());
|
||||||
|
}else{
|
||||||
|
Office parent = getOffice().getParentByType(type);
|
||||||
|
if (parent != null){
|
||||||
|
list.add(parent.getOfficeCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getEmployeeOfficeList().forEach(e -> {
|
||||||
|
Office office2 = getOffice(e.getOfficeCode());
|
||||||
|
if (type.equals(office2.getOfficeType())){
|
||||||
|
list.add(office2.getOfficeCode());
|
||||||
|
}else{
|
||||||
|
Office parent2 = office2.getParentByType(type);
|
||||||
|
if (parent2 != null){
|
||||||
|
list.add(parent2.getOfficeCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return list.toArray(new String[list.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前员工所有上级机构编码,包括附属机构(数据权限用)
|
||||||
|
* @author ThinkGem
|
||||||
|
*/
|
||||||
|
public static String[] getOfficeParentCodess(){
|
||||||
|
List<String> list = ListUtils.newArrayList();
|
||||||
|
list.add(getOffice().getParentCodes());
|
||||||
|
getEmployeeOfficeList().forEach(e -> {
|
||||||
|
list.add(e.getParentCodes());
|
||||||
|
});
|
||||||
|
return list.toArray(new String[list.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据机构类型,获取当前员工所有机构编码,包括附属机构(数据权限用)
|
||||||
|
* @author ThinkGem
|
||||||
|
*/
|
||||||
|
public static String[] getOfficeParentCodessByType(String type){
|
||||||
|
List<String> list = ListUtils.newArrayList();
|
||||||
|
Office office = getOffice();
|
||||||
|
if (type.equals(office.getOfficeType())){
|
||||||
|
list.add(office.getParentCodes());
|
||||||
|
}else{
|
||||||
|
Office parent = getOffice().getParentByType(type);
|
||||||
|
if (parent != null){
|
||||||
|
list.add(parent.getParentCodes());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
getEmployeeOfficeList().forEach(e -> {
|
||||||
|
Office office2 = getOffice(e.getOfficeCode());
|
||||||
|
if (type.equals(office2.getOfficeType())){
|
||||||
|
list.add(office2.getParentCodes());
|
||||||
|
}else{
|
||||||
|
Office parent2 = office2.getParentByType(type);
|
||||||
|
if (parent2 != null){
|
||||||
|
list.add(parent2.getParentCodes());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return list.toArray(new String[list.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据公司编码获取公司对象
|
||||||
* @param companyCode
|
* @param companyCode
|
||||||
* @return
|
* @author ThinkGem
|
||||||
*/
|
*/
|
||||||
public static Company getCompany(String companyCode){
|
public static Company getCompany(String companyCode){
|
||||||
List<Company> companyList = getCompanyAllList();
|
List<Company> companyList = getCompanyAllList();
|
||||||
@@ -191,8 +242,16 @@ public class EmpUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有的公司
|
* 获取当前员工公司对象
|
||||||
* @return
|
* @author ThinkGem
|
||||||
|
*/
|
||||||
|
public static Company getCompany(){
|
||||||
|
return getEmployee().getCompany();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前员工所有的公司
|
||||||
|
* @author ThinkGem
|
||||||
*/
|
*/
|
||||||
public static List<Company> getCompanyAllList(){
|
public static List<Company> getCompanyAllList(){
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -208,7 +267,7 @@ public class EmpUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 清除指定用户缓存,不包括改用的SESSION缓存
|
* 清除指定用户缓存,不包括改用的SESSION缓存
|
||||||
* @param user
|
* @author ThinkGem
|
||||||
*/
|
*/
|
||||||
public static void removeCache(String key){
|
public static void removeCache(String key){
|
||||||
if (StringUtils.inString(key, CACHE_OFFICE_ALL_LIST, CACHE_COMPANY_ALL_LIST)){
|
if (StringUtils.inString(key, CACHE_OFFICE_ALL_LIST, CACHE_COMPANY_ALL_LIST)){
|
||||||
|
|||||||
@@ -181,9 +181,9 @@ role:
|
|||||||
Office: {
|
Office: {
|
||||||
#控制类型的类名 : "用来获取控制表名和主键字段名,如果为 NONE,则代表是不控制该类型权限",
|
#控制类型的类名 : "用来获取控制表名和主键字段名,如果为 NONE,则代表是不控制该类型权限",
|
||||||
ctrlTypeClass: "com.jeesite.modules.sys.entity.Office",
|
ctrlTypeClass: "com.jeesite.modules.sys.entity.Office",
|
||||||
#控制数据的类名: "指定一个静态类名,方便 ctrlDataAttrName 得到权限数据,如:当前部门编码、公司编码",
|
#控制数据的类名: "指定一个静态类名,方便 ctrlDataAttrName 得到权限数据,如:当前机构编码、当前公司编码、当前行业编码等",
|
||||||
ctrlDataClass: "com.jeesite.modules.sys.utils.EmpUtils",
|
ctrlDataClass: "com.jeesite.modules.sys.utils.EmpUtils",
|
||||||
#控制数据的类名下的属性名 : "可看做类下的 get 方法,如:EmpUtils.getOffices(),支持返回字符串或字符串数组类型",
|
#控制数据的类名下的属性名 : "可看做 ctrlDataClass 下的 get 方法,如:EmpUtils.getOfficeCodes(),支持返回字符串或字符串数组类型",
|
||||||
ctrlDataAttrName: "officeCodes",
|
ctrlDataAttrName: "officeCodes",
|
||||||
#控制数据的所有上级编码 : "用于控制数据为树表的情况,为数组时,必须与 ctrlDataAttrName 返回的长度相同,不是树表设置为空",
|
#控制数据的所有上级编码 : "用于控制数据为树表的情况,为数组时,必须与 ctrlDataAttrName 返回的长度相同,不是树表设置为空",
|
||||||
ctrlDataParentCodesAttrName: "officeParentCodess"
|
ctrlDataParentCodesAttrName: "officeParentCodess"
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
模板名称=Template name
|
模板名称=Template name
|
||||||
归属模块=Module
|
归属模块=Module
|
||||||
模板内容=Template content
|
模板内容=Template content
|
||||||
模板内容语法格式=Template content syntax format
|
语法格式=Content syntax format
|
||||||
|
|
||||||
# =========== 消息相关字典 ===========
|
# =========== 消息相关字典 ===========
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user