Commit d8234bd3 authored by tianbo's avatar tianbo

工作流节点执行角色匹配修改

parent c85b0e72
...@@ -6,7 +6,9 @@ import java.util.Date; ...@@ -6,7 +6,9 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.Set;
import com.google.common.collect.Sets;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -55,7 +57,13 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService { ...@@ -55,7 +57,13 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService {
@Override @Override
public Map<String, Object> checkTaskAuthMap(String processInstanceId, ReginParams userInfo) { public Map<String, Object> checkTaskAuthMap(String processInstanceId, ReginParams userInfo) {
// 获取当前登录用户的角色 // 获取当前登录用户的角色
String currentLoginUserRole = userInfo.getRole().getRoleName(); // String currentLoginUserRole = userInfo.getRole().getRoleName();
Set<String> roleNameSet = Sets.newHashSet();
userInfo.getUserModel().getOrgRoles().values().forEach(i -> {
i.forEach(e -> {
roleNameSet.add(e.getRoleName());
});
});
String currentLoginUserName = userInfo.getUserModel().getUserName(); String currentLoginUserName = userInfo.getUserModel().getUserName();
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
map.put(WorkFlowEnum.CHECKFLAG.getCode(), false); map.put(WorkFlowEnum.CHECKFLAG.getCode(), false);
...@@ -67,7 +75,7 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService { ...@@ -67,7 +75,7 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService {
if (WorkFlowEnum.制定计划内容.getCode().equals(detail.getString(WorkFlowEnum.NAME.getCode())) if (WorkFlowEnum.制定计划内容.getCode().equals(detail.getString(WorkFlowEnum.NAME.getCode()))
|| WorkFlowEnum.现场确认.getCode().equals(detail.getString(WorkFlowEnum.NAME.getCode()))) { || WorkFlowEnum.现场确认.getCode().equals(detail.getString(WorkFlowEnum.NAME.getCode()))) {
String groupName = getFristFlowDetail(processInstanceId); String groupName = getFristFlowDetail(processInstanceId);
if (StringUtils.isNotBlank(groupName) && currentLoginUserRole.equals(groupName)) { if (StringUtils.isNotBlank(groupName) && roleNameSet.contains(groupName)) {
map.put(WorkFlowEnum.TASKID.getCode(), detail.getString(WorkFlowEnum.ID.getCode())); map.put(WorkFlowEnum.TASKID.getCode(), detail.getString(WorkFlowEnum.ID.getCode()));
map.put(WorkFlowEnum.CHECKFLAG.getCode(), true); map.put(WorkFlowEnum.CHECKFLAG.getCode(), true);
map.put(WorkFlowEnum.NAME.getCode(), detail.getString(WorkFlowEnum.NAME.getCode())); map.put(WorkFlowEnum.NAME.getCode(), detail.getString(WorkFlowEnum.NAME.getCode()));
...@@ -104,13 +112,13 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService { ...@@ -104,13 +112,13 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService {
continue; continue;
} }
// 判断当前登录人的角色是不是与流程中设置的当前任务节点权限一致,一致则执行,不一致则退出 // 判断当前登录人的角色是不是与流程中设置的当前任务节点权限一致,一致则执行,不一致则退出
if (!defaultExecutionRoleProcess.equals(currentLoginUserRole)) { if (!roleNameSet.contains(defaultExecutionRoleProcess)) {
continue; continue;
} }
map.put(WorkFlowEnum.TASKID.getCode(), detail.getString(WorkFlowEnum.ID.getCode())); map.put(WorkFlowEnum.TASKID.getCode(), detail.getString(WorkFlowEnum.ID.getCode()));
map.put(WorkFlowEnum.CHECKFLAG.getCode(), true); map.put(WorkFlowEnum.CHECKFLAG.getCode(), true);
map.put(WorkFlowEnum.NAME.getCode(), detail.getString(WorkFlowEnum.NAME.getCode())); map.put(WorkFlowEnum.NAME.getCode(), detail.getString(WorkFlowEnum.NAME.getCode()));
map.put(WorkFlowEnum.GROUPNAME.getCode(), currentLoginUserRole); map.put(WorkFlowEnum.GROUPNAME.getCode(), defaultExecutionRoleProcess);
} }
} }
return map; return map;
...@@ -224,7 +232,13 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService { ...@@ -224,7 +232,13 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService {
* @throws Exception * @throws Exception
*/ */
public Object getCurrentUserAllTaskList(String key, ReginParams userInfo) throws Exception { public Object getCurrentUserAllTaskList(String key, ReginParams userInfo) throws Exception {
String currentLoginUserRole = userInfo.getRole().getRoleName(); Set<String> roleNameSet = Sets.newHashSet();
userInfo.getUserModel().getOrgRoles().values().forEach(i -> {
i.forEach(e -> {
roleNameSet.add(e.getRoleName());
});
});
// String currentLoginUserRole = userInfo.getRole().getRoleName();
JSONObject CurrentUserAllTaskResult = null; JSONObject CurrentUserAllTaskResult = null;
try { try {
//获取该登录用户已经分配到他名下和他对应的角色权限所能执行的任务组 //获取该登录用户已经分配到他名下和他对应的角色权限所能执行的任务组
...@@ -240,7 +254,7 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService { ...@@ -240,7 +254,7 @@ public class WorkflowExcuteServiceImpl implements IWorkflowExcuteService {
SpecifyTaskArray.stream().forEach(i -> { SpecifyTaskArray.stream().forEach(i -> {
JSONObject json = JSONObject.parseObject(JSONObject.toJSONString(i)); JSONObject json = JSONObject.parseObject(JSONObject.toJSONString(i));
String groupName = getFristFlowDetail(json.getString(WorkFlowEnum.PROCESSINSTANCEID.getCode())); String groupName = getFristFlowDetail(json.getString(WorkFlowEnum.PROCESSINSTANCEID.getCode()));
if (StringUtils.isNotBlank(groupName) && currentLoginUserRole.equals(groupName)) { if (StringUtils.isNotBlank(groupName) && roleNameSet.contains(groupName)) {
allTaskResultList.add(i); allTaskResultList.add(i);
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment