提交 2e315112 编写于 作者: zhouweidong's avatar zhouweidong

下一步条件(清除role其余用户待办)

上级 9825bc5e
......@@ -1577,23 +1577,6 @@ public class WFCoreService
return false;
}
}
/**
* 判断是否需要挂起
* @param execution
* @return
*/
public boolean accessClaim(DelegateExecution execution) {
Object sequenceFlowId = execution.getVariable("sequenceFlowId");
String flowAccessCond = getNextCondition(execution, sequenceFlowId); // role : any || all
if(!ObjectUtils.isEmpty(flowAccessCond) && "ANY".equalsIgnoreCase(flowAccessCond)){
return true;
}
else if (!ObjectUtils.isEmpty(flowAccessCond) && "ALL|ROLE:ANY".equalsIgnoreCase(flowAccessCond)) {
return true;
} else {
return false;
}
}
/**
* 获取连接线条件 (all/any/all|role:any)
......@@ -1602,7 +1585,7 @@ public class WFCoreService
* @param sequenceFlowId
* @return
*/
private String getNextCondition(DelegateExecution execution, Object sequenceFlowId) {
public String getNextCondition(DelegateExecution execution, Object sequenceFlowId) {
if (!ObjectUtils.isEmpty(execution.getCurrentFlowElement()) && execution.getCurrentFlowElement() instanceof UserTask) {
UserTask userTask = (UserTask) execution.getCurrentFlowElement();
for (SequenceFlow flow : userTask.getOutgoingFlows()) {
......@@ -1625,13 +1608,6 @@ public class WFCoreService
return null;
}
/**
* role:any 认领当前任务,挂起将role中其他人任务
*/
public void ClaimTask(String taskId,String userId) {
taskService.claim(taskId,userId);
}
/**
* 获取用户所属的工作流角色
* @param userId
......@@ -1726,4 +1702,114 @@ public class WFCoreService
}
return task;
}
/**
* 清除角色中其他成员待办任务
* @param userRoles
* @param execution
*/
public void deleteRoleTask(Set userRoles, DelegateExecution execution) {
Object processInstanceId = execution.getProcessInstanceId();
if(ObjectUtils.isEmpty(processInstanceId)){
throw new BadRequestAlertException("无法获取流程实例","","");
}
Set<String> roleUserIds = getUsersByRole(userRoles,execution);
if(roleUserIds.size()>0){
Map param = new HashMap();
param.put("userids",roleUserIds);
param.put("processinstanceid",processInstanceId);
List<Map> tasks = wfCoreMapper.searchUserTask(param);
if(tasks.size()>0){
for(Map task : tasks){
Object executionId = task.get("execution");
if(!StringUtils.isEmpty(executionId)){
runtimeService.deleteMultiInstanceExecution(String.valueOf(executionId),false);
}
}
}
}
}
/**
* 获取角色成员
* @param roles
* @param execution
* @return
*/
public Set<String> getUsersByRole(Set roles, DelegateExecution execution) {
Set userIds = new HashSet();
if (!ObjectUtils.isEmpty(roles)) {
String candidateUsers = getCandidateUsers(execution);
if (!StringUtils.isEmpty(candidateUsers)) {
LinkedHashMap executionMap = (LinkedHashMap) execution.getVariable("activedata");
String[] groups = candidateUsers.split("\\|\\|");
if (groups.length > 0) {
for (String group : groups) {
if (group.contains("activedata") && roles.contains(group)) {
for (String elUserId : group.split("\\|")) {
ExpressionParser parser = new SpelExpressionParser();
StandardEvaluationContext context = new StandardEvaluationContext();
Expression exp = parser.parseExpression(elUserId);
context.addPropertyAccessor(new MapAccessor());
context.setVariable("activedata", executionMap);
String processUserId = exp.getValue(context, String.class);
if (StringUtils.isEmpty(processUserId)) {
userIds.add(processUserId);
}
}
}
if (group.contains("wfCoreService.getGroupUsers")) {
EvaluationContext oldContext = new StandardEvaluationContext();
oldContext.setVariable("wfCoreService", this);
oldContext.setVariable("execution", execution);
Expression oldExp = parser.parseExpression(group);
List<WFMember> users = oldExp.getValue(oldContext, List.class);
if (!StringUtils.isEmpty(users)) {
users.forEach(groupMember -> {
if (!ObjectUtils.isEmpty(groupMember.getUserid())) {
String roleId;
if (!ObjectUtils.isEmpty(groupMember.getMdeptid())) {
roleId = String.format("%s_%s", groupMember.getGroupid(), groupMember.getMdeptid());
} else {
roleId = groupMember.getGroupid();
}
if (roles.contains(roleId)) {
userIds.add(groupMember.getUserid());
}
}
});
}
}
}
}
}
}
return userIds;
}
/**
* 获取步骤审批用户
* @param execution
* @return
*/
private String getCandidateUsers(DelegateExecution execution){
String strCandidateUsers ="";
UserTask task = (UserTask) execution.getCurrentFlowElement();
List fieldList = task.getExtensionElements().get("field");
if(!ObjectUtils.isEmpty(fieldList)){
for (Object field : fieldList) {
if(!ObjectUtils.isEmpty(((ExtensionElement) field).getAttributes())){
List<ExtensionAttribute> attributes = ((ExtensionElement) field).getAttributes().get("name");
if(attributes.size() > 0){
if(attributes.get(0).getValue().equals("candidateUsersList")){
strCandidateUsers = ((ExtensionElement) field).getChildElements().get("string").get(0).getElementText();
break;
}
}
}
}
}
return strCandidateUsers;
}
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册