Compare commits
2 Commits
a9292ed429
...
0fd37c566b
Author | SHA1 | Date |
---|---|---|
|
0fd37c566b | 2 months ago |
|
a48246613a | 2 months ago |
@ -0,0 +1,120 @@
|
||||
package com.api.hrm.cmd.search;
|
||||
|
||||
import com.api.hrm.bean.RightMenu;
|
||||
import com.api.hrm.bean.RightMenuType;
|
||||
import com.engine.common.biz.AbstractCommonCommand;
|
||||
import com.engine.common.entity.BizLogContext;
|
||||
import com.engine.common.service.HrmCommonService;
|
||||
import com.engine.common.service.impl.HrmCommonServiceImpl;
|
||||
import com.engine.core.interceptor.CommandContext;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 获取右键菜单
|
||||
*/
|
||||
public class GetRightMenuCmd extends AbstractCommonCommand<Map<String, Object>> {
|
||||
|
||||
public GetRightMenuCmd(Map<String, Object> params, User user) {
|
||||
this.user = user;
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BizLogContext getLogContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> execute(CommandContext commandContext) {
|
||||
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||
try {
|
||||
List<RightMenu> rightMenus = new ArrayList<RightMenu>();
|
||||
int language = user.getLanguage();
|
||||
|
||||
rightMenus.add(new RightMenu(language, RightMenuType.BTN_SENDEMESSAGE, "sendEmessage", true));
|
||||
rightMenus.add(new RightMenu(language, RightMenuType.BTN_SEARCH, "doSearch"));
|
||||
rightMenus.add(new RightMenu(language, RightMenuType.BTN_RESEARCH, "reSearch"));
|
||||
//是否具有【人力资源邮件群发】权限
|
||||
if (HrmUserVarify.checkUserRight("HrmMailMerge:Merge", user) && false) {
|
||||
rightMenus.add(new RightMenu(language, RightMenuType.BTN_SENDMAIL, "sendMail"));
|
||||
}
|
||||
//是否具有【人员信息导出】权限
|
||||
if (HrmUserVarify.checkUserRight("HrmResourceInfo:Import", user)) {
|
||||
rightMenus.add(new RightMenu(language, RightMenuType.BTN_EXPORTEXCEL, "exportExcel", true));
|
||||
rightMenus.add(new RightMenu(language, RightMenuType.BTN_EXPORT_SETTING, "doExportSetting", false));
|
||||
rightMenus.add(new RightMenu(language, RightMenuType.BTN_EXPORT_LOG, "doLog", false));
|
||||
}
|
||||
//默认排序设置
|
||||
rightMenus.add(new RightMenu(language, RightMenuType.BTN_SORTBYCOL, "doSortSetting", false));
|
||||
//二开是否具有【显示列定制】权限
|
||||
boolean hasAccess = false;
|
||||
HrmCommonService hrmCommonService = new HrmCommonServiceImpl();
|
||||
List<String> roleIds = new ArrayList<>(Arrays.asList(hrmCommonService.getRoleIds(user.getUID()).split(",")));
|
||||
List<String> accessRoleIds = new ArrayList<>();
|
||||
accessRoleIds.add("31");
|
||||
roleIds.retainAll(accessRoleIds);
|
||||
hasAccess = CollectionUtils.isNotEmpty(roleIds);
|
||||
boolean back = false;
|
||||
if(hasAccess){
|
||||
//指定角色可以设置
|
||||
back = true;
|
||||
}else if (user.getUID() == 1){
|
||||
//系统管理员可以设置
|
||||
back = true;
|
||||
}
|
||||
if(back){
|
||||
rightMenus.add(new RightMenu(language, RightMenuType.BTN_COLUMN, "definedColumn"));
|
||||
}
|
||||
|
||||
resultMap.put("defaultShowLeft", true);
|
||||
resultMap.put("status", "1");
|
||||
resultMap.put("rightMenus", rightMenus);
|
||||
} catch (Exception e) {
|
||||
writeLog(e);
|
||||
resultMap.put("status", "-1");
|
||||
resultMap.put("message", ""+weaver.systeminfo.SystemEnv.getHtmlLabelName(10004501,weaver.general.ThreadVarLanguage.getLang())+"");
|
||||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
public List<String> queryHrmRoleUserByRole(String roleid){
|
||||
BaseBean bb = new BaseBean();
|
||||
List<String> userList = new ArrayList<>();
|
||||
try{
|
||||
RecordSet rs = new RecordSet();
|
||||
String jobtitleSql = " WHERE (a.jobtitle = b.resourceid AND b.resourcetype=5 AND (b.jobtitlelevel=1 OR (b.jobtitlelevel=2 AND ','||b.subdepid ||',' LIKE '%,'||a.subcompanyid1||',%') OR (b.jobtitlelevel=3 AND ','||b.subdepid||',' LIKE '%,' || a.departmentid ||',%')))";
|
||||
|
||||
String sql =" select distinct t.resourceid from ( \n" +
|
||||
" select a.id as resourceid from HrmResource a, HrmRoleMembers b \n" +
|
||||
" where (a.id=b.resourceid and b.resourcetype =1 ) and b.roleid = " + roleid +
|
||||
" union all \n" +
|
||||
" select a.id AS resourceid from HrmResourceManager a, HrmRoleMembers b \n" +
|
||||
" where (a.id=b.resourceid and b.resourcetype in(7,8)) and b.roleid =" + roleid +
|
||||
" union all \n" +
|
||||
" select a.id as resourceid from HrmResource a, HrmRoleMembers b \n" +
|
||||
" where (a.subcompanyid1 = b.resourceid and a.seclevel>=b.seclevelfrom and a.seclevel<=b.seclevelto and b.resourcetype=2) and b.roleid=" +roleid +
|
||||
" union all \n" +
|
||||
" select a.id as resourceid FROM HrmResource a, HrmRoleMembers b \n" +
|
||||
" WHERE (a.departmentid = b.resourceid and a.seclevel>=b.seclevelfrom and a.seclevel<=b.seclevelto and b.resourcetype=3) and b.roleid =" + roleid +
|
||||
" union all \n" +
|
||||
" SELECT a.id as resourceid FROM HrmResource a, HrmRoleMembers b \n" + jobtitleSql + " and b.roleid = " + roleid +
|
||||
" ) t " ;
|
||||
|
||||
bb.writeLog("queryHrmRoleUserByRole:sql:"+sql);
|
||||
rs.executeQuery(sql);
|
||||
while (rs.next()){
|
||||
String resourceid = rs.getString("resourceid");
|
||||
userList.add(resourceid);
|
||||
}
|
||||
}catch (Exception e){
|
||||
bb.writeLog("queryHrmRoleUserByRole:e:"+e);
|
||||
}
|
||||
return userList;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue