| | |
| | | |
| | | import com.highdatas.mdm.entity.TUser; |
| | | import com.highdatas.mdm.pojo.NextTaskUserInfo; |
| | | import com.highdatas.mdm.util.DbUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.activiti.engine.*; |
| | | import org.activiti.engine.delegate.Expression; |
| | |
| | | RuntimeService runtimeService; |
| | | @Autowired |
| | | IdentityService identityService; |
| | | /** |
| | | * |
| | | * @description: 检验节点是否已经被接收 |
| | | * @param workflowId 流程id |
| | | * @return: 是否已被接收 |
| | | * |
| | | */ |
| | | |
| | | public boolean checkClaim(String workflowId) { |
| | | Task task = getTask(workflowId); |
| | | if (task == null) { |
| | |
| | | return false; |
| | | } |
| | | } |
| | | /** |
| | | * |
| | | * @description: 接收任务 |
| | | * @param workflowId 流程id |
| | | * @return: 任务id |
| | | * |
| | | */ |
| | | public String claimTask(String workflowId) { |
| | | Task task = getTask(workflowId); |
| | | if (task == null) { |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | public boolean completeTask(String taskId, boolean pass, String reason, Map<String,Object> other) { |
| | | /** |
| | | * |
| | | * @description: 完成节点任务 |
| | | * @param taskId 任务id |
| | | * @param pass 是否通过 true,false |
| | | * @param reason 原因 |
| | | * @param other 其他参数 |
| | | * @return: 是否完成成功 |
| | | * |
| | | */ |
| | | public boolean completeTask(String taskId, Object pass, String reason, Map<String,Object> other) { |
| | | Map<String, Object> variables = new LinkedHashMap<String, Object>(); |
| | | if(other != null){ |
| | | Set<String> keySet = other.keySet(); |
| | | for (String key : keySet) { |
| | | variables.put(key, other.get(key)); |
| | | } |
| | | variables.putAll(other); |
| | | } |
| | | variables.put("pass", pass); |
| | | variables.put("reason", reason); |
| | |
| | | log.debug("can not complete task(" + taskId + "): " + e.getMessage()); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | public boolean completeTask(String taskId, boolean pass, String reason) { |
| | | } |
| | | /** |
| | | * |
| | | * @description: 完成节点任务 |
| | | * @param taskId 任务id |
| | | * @param pass 是否通过 true,false |
| | | * @param reason 原因 |
| | | * @return: 是否完成成功 |
| | | * |
| | | */ |
| | | public boolean completeTask(String taskId, Object pass, String reason) { |
| | | return completeTask(taskId,pass,reason,null); |
| | | } |
| | | |
| | | } |
| | | /** |
| | | * |
| | | * @description: 获取待审批任务列表 |
| | | * @return: 待审批任务列表 |
| | | * |
| | | */ |
| | | public List<String> getTodoTask() { |
| | | TUser onlineUser = getOnlineUser(); |
| | | Set<String> result = new HashSet<>(); |
| | |
| | | |
| | | return new ArrayList<>(result); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @description: 通过流程获取当前任务节点 |
| | | * @param processId 流程id |
| | | * @return: 当前任务节点 |
| | | * |
| | | */ |
| | | public Task geTask(String processId) { |
| | | Task task = taskService.createTaskQuery().processInstanceId(processId).singleResult(); |
| | | return task; |
| | |
| | | TaskDefinition taskDef = (TaskDefinition)activityImpl.getProperties().get("taskDefinition"); |
| | | Set<Expression> userCodes = taskDef.getCandidateUserIdExpressions();//候选人 |
| | | Set<Expression> roleCodes = taskDef.getCandidateGroupIdExpressions();//候选组 |
| | | if (userCodes != null) { |
| | | Set<String> userList = userCodes.stream().map(expression -> expression.getExpressionText()).collect(Collectors.toSet()); |
| | | nextTaskUserInfo.addUserList(userList); |
| | | } |
| | | |
| | | if (roleCodes != null) { |
| | | Set<String> roleList = roleCodes.stream().map(expression -> expression.getExpressionText()).collect(Collectors.toSet()); |
| | | nextTaskUserInfo.addRoleList(roleList); |
| | | } |
| | | return nextTaskUserInfo; |
| | | Set<String> userList = new HashSet<>(); |
| | | if (userCodes != null) { |
| | | Set userSet = userCodes.stream().map(expression -> expression.getExpressionText()).collect(Collectors.toSet()); |
| | | userList.addAll(userSet); |
| | | } |
| | | List<String> roleIdList = nextTaskUserInfo.getRoleIdList(); |
| | | if (roleIdList == null || roleIdList.isEmpty()) { |
| | | nextTaskUserInfo.addUserList(userList); |
| | | return nextTaskUserInfo; |
| | | } |
| | | for (String roleId : roleIdList) { |
| | | Set<String> userByRole = DbUtils.getUserByRole(roleId); |
| | | userList.addAll(userByRole); |
| | | } |
| | | nextTaskUserInfo.addUserList(userList); |
| | | return nextTaskUserInfo; |
| | | |
| | | } |
| | | |
| | | } |