📄 selectactorservice.java
字号:
if(org.getOrgId().equals(orgTemp.getOrgId())){
iTag=1;
break;
}
}
if(iTag!=1){
targetOrgList.add(org);
}
}
}
}
/**
* 将角色列表信息加入到目标角色列表信息中去
* @param targetOrgList 源角色列表信息
* @param srcOrgList 目标角色列表信息
*/
private void addToRoleList(List targetRoleList,List srcRoleList){
if(targetRoleList==null){
targetRoleList=new ArrayList();
}
if(srcRoleList!=null&&srcRoleList.size()>0){
for(int i=0;i<srcRoleList.size();i++){
WfRole role=(WfRole)srcRoleList.get(i);
int iTag=0;
for(int j=0;j<targetRoleList.size();j++){
WfRole roleTemp=(WfRole)targetRoleList.get(j);
if(role.getRoleId().equals(roleTemp.getRoleId())){
iTag=1;
break;
}
}
if(iTag!=1){
targetRoleList.add(role);
}
}
}
}
/**
* 将用户列表信息加入到目标用户列表信息中去
* @param targetOrgList 源用户列表信息
* @param srcOrgList 目标用户列表信息
*/
private void addToUserList(List targetUserList,List srcUserList){
if(targetUserList==null){
targetUserList=new ArrayList();
}
if(srcUserList!=null&&srcUserList.size()>0){
for(int i=0;i<srcUserList.size();i++){
WfUser user=(WfUser)srcUserList.get(i);
int iTag=0;
for(int j=0;j<targetUserList.size();j++){
WfUser userTemp=(WfUser)targetUserList.get(j);
String userId0=user.getUserId()==null?"":user.getUserId();
String userId1=userTemp.getUserId()==null?"":userTemp.getUserId();
String roleId0=user.getRoleId()==null?"":user.getRoleId();
String roleId1=userTemp.getRoleId()==null?"":userTemp.getRoleId();
String orgId0=user.getOrgId()==null?"":user.getOrgId();
String orgId1=userTemp.getOrgId()==null?"":userTemp.getOrgId();
if(userId0.equals(userId1)&&roleId0.equals(roleId1)&&
orgId0.equals(orgId1)){
iTag=1;
break;
}
}
if(iTag!=1){
targetUserList.add(user);
}
}
}
}
/**
* 根据用户的部门关系取得部门信息
* @param userId 用户id
* @param areaId 所属行政区,若为-1,则取得所有行政区内的部门信息
* @param orgRel 部门关系,若存在多种部门关系,则以“;”分隔,例如:“1;4”代表当前及下级部门
* @return List
*/
public List getOrgInfoByOrgRel(String userId,String areaId,String orgRel)
throws Exception{
List list=new ArrayList();
SelectActorDAO dao=new SelectActorDAO();
if(orgRel!=null&&!orgRel.equals("")){
String[] ids=orgRel.split(";");
for(int i=0;i<ids.length;i++){
List orgList=null;
if (!CommonUtil.isNumeric(ids[i]))
continue;
int iRel=Integer.parseInt(ids[i]);
switch(iRel){
default:
case 0: //任选
orgList=dao.getAllOrgInfo(areaId);
break;
case 1: //当前
orgList=dao.getCurrOrgInfo(userId,areaId);
break;
case 2: //平级
orgList=dao.getParallelOrgInfo(userId,areaId);
break;
case 3: //直接上级
orgList=dao.getParentOrgInfo(userId,areaId);
break;
case 30: //所有上级
orgList=dao.getAllParentOrgInfo(userId,areaId);
break;
case 4: //直接下级
orgList=dao.getChildOrgInfo(userId,areaId);
break;
case 40: //所有下级
orgList=dao.getAllChildOrgInfo(userId,areaId);
break;
}
addToOrgList(list,orgList);
}
}
return list;
}
/**
* 取得选择参与者树
* @param userId 用户id
* @param areaId 所属行政区id
* @param activityId 活动id
* @return 返回SelectActorTree列表
* @throws Exception
*/
public List getSelectActorTree(String userId,String areaId,long activityId)
throws Exception{
SelectActorDAO dao=new SelectActorDAO();
SelectActorParam actorParam=dao.getSelectActorParam(activityId);
return getSelectActorTree(userId,areaId,actorParam);
}
/**
* 取得选择参与者树
* @param userId 用户id
* @param areaId 所属行政区id
* @param actorParam 选择参与者设置参数
* @return 返回SelectActorTree列表
* @throws Exception
*/
public List getSelectActorTree(String userId,String areaId,
SelectActorParam actorParam)
throws Exception{
List list=new ArrayList();
if(actorParam!=null){
//选择用户
if(actorParam.getSelectType()!=null&&
actorParam.getSelectType().equals("user")){
list=this.getUserActorTree(userId,areaId,actorParam);
}
//选择部门
else if(actorParam.getSelectType()!=null&&
actorParam.getSelectType().equals("org")){
list=this.getOrgActorTree(userId,areaId,actorParam);
}
//选择角色
else if(actorParam.getSelectType()!=null&&
actorParam.getSelectType().equals("role")){
list=this.getRoleActorTree(userId,areaId,actorParam);
}
}
return list;
}
/**
* 取得选择用户类型参与者树
* @param userId 用户id
* @param areaId 所属行政区id
* @param actorParam 选择参与者设置参数
* @return 返回SelectActorTree列表
* @throws Exception
*/
private List getUserActorTree(String userId,String areaId,
SelectActorParam actorParam)
throws Exception{
List treeList=new ArrayList();
if(actorParam.getSelectType()!=null&&
actorParam.getSelectType().equals("user")){
List userList=new ArrayList();
List orgList=new ArrayList();
List roleList=new ArrayList();
SelectActorDAO dao=new SelectActorDAO();
String actorType=actorParam.getActorType()==null?"":
actorParam.getActorType();
String[] actorTypeArray=actorType.split(",");
if(actorTypeArray!=null&&actorTypeArray.length>0){
for(int i=0;i<actorTypeArray.length;i++){
////取得固定用户信息
if(actorTypeArray[i].toUpperCase().equals("fixed-user".toUpperCase())){
List tempUserList=this.getFixedUserInfo(actorParam.getActivityId());
this.addToUserList(userList,tempUserList);
}
//固定角色中的所有人员
if(actorTypeArray[i].toUpperCase().equals("all-fixed-role-user".
toUpperCase())){
//取得固定角色
List tempRoleList=this.getFixedRoleInfo(actorParam.getActivityId());
//取得符合条件的用户
List tempUserList=dao.getUserByRole(tempRoleList,areaId);
this.addToUserList(userList,tempUserList);
this.addToRoleList(roleList,tempRoleList);
}
//符合部门关系的部门中固定角色中的人员
if(actorTypeArray[i].toUpperCase().equals("rel-org-fixed-role-user".
toUpperCase())){
//取得固定角色
List tempRoleList=this.getFixedRoleInfo(actorParam.getActivityId());
//取得符合部门关系的部门
List tempOrgList=this.getOrgInfoByOrgRel(userId,areaId,
actorParam.getOrgRel());
//取得符合条件的用户
List tempUserList=dao.getUserByOrgRole(tempOrgList,tempRoleList);
this.addToUserList(userList,tempUserList);
this.addToOrgList(orgList,tempOrgList);
this.addToRoleList(roleList,tempRoleList);
}
//固定部门中固定角色的人员
if(actorTypeArray[i].toUpperCase().equals("fixed-org-fixed-role-user".
toUpperCase())){
//取得固定角色
List tempRoleList=this.getFixedRoleInfo(actorParam.getActivityId());
//取得固定部门
List tempOrgList=this.getFixedOrgInfo(actorParam.getActivityId());
//取得符合条件的用户
List tempUserList=dao.getUserByOrgRole(tempOrgList,tempRoleList);
this.addToUserList(userList,tempUserList);
this.addToOrgList(orgList,tempOrgList);
this.addToRoleList(roleList,tempRoleList);
}
//根据部门关系取出的部门中的所有人员
if(actorTypeArray[i].toUpperCase().equals("all-rel-org-user".
toUpperCase())){
//取得符合部门关系取出的部门
List tempOrgList=this.getOrgInfoByOrgRel(userId,areaId,
actorParam.getOrgRel());
//取得符合条件的用户
List tempUserList=dao.getUserByOrg(tempOrgList);
this.addToUserList(userList,tempUserList);
this.addToOrgList(orgList,tempOrgList);
}
//固定部门中的所有人员
if(actorTypeArray[i].toUpperCase().equals("all-fixed-org-user".
toUpperCase())){
//取得固定部门
List tempOrgList=this.getFixedOrgInfo(actorParam.getActivityId());
//取得符合条件的用户
List tempUserList=dao.getUserByOrg(tempOrgList);
this.addToUserList(userList,tempUserList);
this.addToOrgList(orgList,tempOrgList);
}
}
}
String dispalyType=actorParam.getDispalyType()==null?"":
actorParam.getDispalyType();
//直接选人员
if(dispalyType.equals("user")){
treeList=this.generateUserTree(userList);
}
//选择部门再选人员
if(dispalyType.equals("org")){
treeList=this.generateOrgUserTree(orgList,userList);
}
//选择角色再选人员
if(dispalyType.equals("role")){
treeList=this.generateRoleUserTree(roleList,userList);
}
}
return treeList;
}
/**
* 取得选择角色类型参与者树
* @param userId 用户id
* @param areaId 所属行政区id
* @param actorParam 选择参与者设置参数
* @return 返回SelectActorTree列表
* @throws Exception
*/
private List getRoleActorTree(String userId,String areaId,
SelectActorParam actorParam)
throws Exception{
List treeList=new ArrayList();
if(actorParam.getSelectType()!=null&&
actorParam.getSelectType().equals("role")){
List orgList=new ArrayList();
List roleList=new ArrayList();
String actorType=actorParam.getActorType()==null?"":
actorParam.getActorType();
String[] actorTypeArray=actorType.split(",");
if(actorTypeArray!=null&&actorTypeArray.length>0){
for(int i=0;i<actorTypeArray.length;i++){
//取得固定角色信息
if(actorTypeArray[i].toUpperCase().equals("fixed-role".toUpperCase())){
List tempRoleList=this.getFixedRoleInfo(actorParam.getActivityId());
this.addToRoleList(roleList,tempRoleList);
}
//固定角色的固定部门
if(actorTypeArray[i].toUpperCase().equals("fixed-org-fixed-role".
toUpperCase())){
//取得固定角色
List tempRoleList=this.getFixedRoleInfo(actorParam.getActivityId());
//取得固定部门
List tempOrgList=this.getFixedOrgInfo(actorParam.getActivityId());
this.addToOrgList(orgList,tempOrgList);
this.addToRoleList(roleList,tempRoleList);
}
//具有固定角色的根据部门关系取出的部门
if(actorTypeArray[i].toUpperCase().equals("rel-org-fixed-role".
toUpperCase())){
//取得固定角色
List tempRoleList=this.getFixedRoleInfo(actorParam.getActivityId());
//取得符合部门关系取出的部门
List tempOrgList=this.getOrgInfoByOrgRel(userId,areaId,
actorParam.getOrgRel());
this.addToOrgList(orgList,tempOrgList);
this.addToRoleList(roleList,tempRoleList);
}
}
}
String dispalyType=actorParam.getDispalyType()==null?"":
actorParam.getDispalyType();
//直接选角色
if(dispalyType.equals("role")){
treeList=this.generateRoleTree(roleList);
}
//选部门再选角色
if(dispalyType.equals("org")){
treeList=this.generateOrgRoleTree(orgList,roleList);
}
}
return treeList;
}
/**
* 取得选择部门类型参与者树
* @param userId 用户id
* @param areaId 所属行政区id
* @param actorParam 选择参与者设置参数
* @return 返回SelectActorTree列表
* @throws Exception
*/
private List getOrgActorTree(String userId,String areaId,
SelectActorParam actorParam)
throws Exception{
List treeList=new ArrayList();
if(actorParam.getSelectType()!=null&&
actorParam.getSelectType().equals("org")){
List orgList=new ArrayList();
List roleList=new ArrayList();
String actorType=actorParam.getActorType()==null?"":
actorParam.getActorType();
String[] actorTypeArray=actorType.split(",");
if(actorTypeArray!=null&&actorTypeArray.length>0){
for(int i=0;i<actorTypeArray.length;i++){
//取得固定部门
if(actorTypeArray[i].toUpperCase().equals("fixed-org".toUpperCase())){
List tempOrgList=this.getFixedOrgInfo(actorParam.getActivityId());
this.addToOrgList(orgList,tempOrgList);
}
//根据部门关系取出的部门
if(actorTypeArray[i].toUpperCase().equals("rel-org".toUpperCase())){
List tempOrgList=this.getOrgInfoByOrgRel(userId,areaId,
actorParam.getOrgRel());
this.addToOrgList(orgList,tempOrgList);
}
//固定角色的固定部门
if(actorTypeArray[i].toUpperCase().equals("fixed-org-fixed-role".
toUpperCase())){
//取得固定角色
List tempRoleList=this.getFixedRoleInfo(actorParam.getActivityId());
//取得固定部门
List tempOrgList=this.getFixedOrgInfo(actorParam.getActivityId());
this.addToOrgList(orgList,tempOrgList);
this.addToRoleList(roleList,tempRoleList);
}
//具有固定角色的根据部门关系取出的部门
if(actorTypeArray[i].toUpperCase().equals("rel-org-fixed-role".
toUpperCase())){
//取得固定角色
List tempRoleList=this.getFixedRoleInfo(actorParam.getActivityId());
//取得符合部门关系取出的部门
List tempOrgList=this.getOrgInfoByOrgRel(userId,areaId,
actorParam.getOrgRel());
this.addToOrgList(orgList,tempOrgList);
this.addToRoleList(roleList,tempRoleList);
}
}
}
String dispalyType=actorParam.getDispalyType()==null?"":
actorParam.getDispalyType();
//直接选部门
if(dispalyType.equals("org")){
treeList=this.generateOrgTree(orgList);
}
//选角色再选部门
if(dispalyType.equals("role")){
treeList=this.generateRoleOrgTree(roleList,orgList);
}
}
return treeList;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -