| | |
| | | import org.dromara.workflow.domain.bo.*; |
| | | import org.dromara.workflow.domain.vo.MultiInstanceVo; |
| | | import org.dromara.workflow.domain.vo.TaskVo; |
| | | import org.dromara.workflow.domain.vo.VariableVo; |
| | | import org.dromara.workflow.domain.vo.WfCopy; |
| | | import org.dromara.workflow.flowable.cmd.*; |
| | | import org.dromara.workflow.flowable.strategy.FlowEventStrategy; |
| | |
| | | import org.flowable.task.api.history.HistoricTaskInstance; |
| | | import org.flowable.task.api.history.HistoricTaskInstanceQuery; |
| | | import org.flowable.task.service.impl.persistence.entity.TaskEntity; |
| | | import org.flowable.variable.api.persistence.entity.VariableInstance; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static org.dromara.workflow.common.constant.FlowConstant.FLOWABLE_SKIP_EXPRESSION_ENABLED; |
| | | import static org.dromara.workflow.common.constant.FlowConstant.INITIATOR; |
| | | import static org.dromara.workflow.common.constant.FlowConstant.*; |
| | | |
| | | /** |
| | | * 任务 服务层实现 |
| | |
| | | if (CollUtil.isNotEmpty(startProcessBo.getVariables())) { |
| | | taskService.setVariables(taskResult.get(0).getId(), startProcessBo.getVariables()); |
| | | } |
| | | map.put("processInstanceId", taskResult.get(0).getProcessInstanceId()); |
| | | map.put(PROCESS_INSTANCE_ID, taskResult.get(0).getProcessInstanceId()); |
| | | map.put("taskId", taskResult.get(0).getId()); |
| | | return map; |
| | | } |
| | |
| | | |
| | | runtimeService.updateBusinessStatus(pi.getProcessInstanceId(), BusinessStatusEnum.DRAFT.getStatus()); |
| | | taskService.setAssignee(taskList.get(0).getId(), LoginHelper.getUserId().toString()); |
| | | taskService.setVariable(taskList.get(0).getId(), "processInstanceId", pi.getProcessInstanceId()); |
| | | taskService.setVariable(taskList.get(0).getId(), PROCESS_INSTANCE_ID, pi.getProcessInstanceId()); |
| | | taskService.setVariable(taskList.get(0).getId(), BUSINESS_KEY, pi.getBusinessKey()); |
| | | map.put("processInstanceId", pi.getProcessInstanceId()); |
| | | map.put("taskId", taskList.get(0).getId()); |
| | | return map; |
| | |
| | | public TableDataInfo<TaskVo> getPageByTaskWait(TaskBo taskBo, PageQuery pageQuery) { |
| | | QueryWrapper<TaskVo> queryWrapper = new QueryWrapper<>(); |
| | | List<RoleDTO> roles = LoginHelper.getLoginUser().getRoles(); |
| | | List<String> roleIds = StreamUtils.toList(roles, e -> String.valueOf(e.getRoleId())); |
| | | String userId = String.valueOf(LoginHelper.getUserId()); |
| | | queryWrapper.eq("t.business_status_", BusinessStatusEnum.WAITING.getStatus()); |
| | | queryWrapper.eq(TenantHelper.isEnable(), "t.tenant_id_", TenantHelper.getTenantId()); |
| | | queryWrapper.and(w1 -> |
| | | w1.eq("t.assignee_", userId) |
| | | .or(w2 -> w2.isNull("t.assignee_") |
| | | .and(w3 -> w3.eq("t.user_id_", userId).or().in("t.group_id_", StreamUtils.toList(roles, RoleDTO::getRoleId)))) |
| | | .apply("exists ( select LINK.ID_ from ACT_RU_IDENTITYLINK LINK where LINK.TASK_ID_ = t.ID_ and LINK.TYPE_ = 'candidate' " + |
| | | "and (LINK.USER_ID_ = {0} or ( LINK.GROUP_ID_ IN " + getInParam(roleIds) + " ) ))", userId)) |
| | | ); |
| | | if (StringUtils.isNotBlank(taskBo.getName())) { |
| | | queryWrapper.like("t.name_", taskBo.getName()); |
| | |
| | | task.setMultiInstance(WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey()) != null); |
| | | } |
| | | return new TableDataInfo<>(taskList, page.getTotal()); |
| | | } |
| | | |
| | | private String getInParam(List<String> param) { |
| | | StringBuilder sb = new StringBuilder(); |
| | | sb.append("("); |
| | | for (int i = 0; i < param.size(); i++) { |
| | | sb.append("'").append(param.get(i)).append("'"); |
| | | if (i != param.size() - 1) { |
| | | sb.append(","); |
| | | } |
| | | } |
| | | sb.append(")"); |
| | | return sb.toString(); |
| | | } |
| | | |
| | | /** |
| | |
| | | throw new ServiceException(FlowConstant.MESSAGE_SUSPENDED); |
| | | } |
| | | HistoricProcessInstance historicProcessInstance = QueryUtils.hisInstanceQuery() |
| | | .processInstanceBusinessKey(task.getProcessInstanceId()).singleResult(); |
| | | .processInstanceId(task.getProcessInstanceId()).singleResult(); |
| | | BusinessStatusEnum.checkInvalidStatus(historicProcessInstance.getBusinessStatus()); |
| | | try { |
| | | if (StringUtils.isBlank(terminationBo.getComment())) { |
| | |
| | | if (CollectionUtil.isNotEmpty(subTasks)) { |
| | | subTasks.forEach(e -> taskService.deleteTask(e.getId())); |
| | | } |
| | | runtimeService.updateBusinessStatus(task.getProcessInstanceId(), BusinessStatusEnum.TERMINATION.getStatus()); |
| | | runtimeService.deleteProcessInstance(task.getProcessInstanceId(), StrUtil.EMPTY); |
| | | } |
| | | runtimeService.updateBusinessStatus(task.getProcessInstanceId(), BusinessStatusEnum.TERMINATION.getStatus()); |
| | | FlowProcessEventHandler processHandler = flowEventStrategy.getProcessHandler(historicProcessInstance.getProcessDefinitionKey()); |
| | | if (processHandler != null) { |
| | | processHandler.handleProcess(historicProcessInstance.getBusinessKey(), BusinessStatusEnum.TERMINATION.getStatus(), false); |
| | |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | | * 查询流程变量 |
| | | * |
| | | * @param taskId 任务id |
| | | */ |
| | | @Override |
| | | public List<VariableVo> getInstanceVariable(String taskId) { |
| | | List<VariableVo> variableVoList = new ArrayList<>(); |
| | | Map<String, VariableInstance> variableInstances = taskService.getVariableInstances(taskId); |
| | | if (CollectionUtil.isNotEmpty(variableInstances)) { |
| | | for (Map.Entry<String, VariableInstance> entry : variableInstances.entrySet()) { |
| | | VariableVo variableVo = new VariableVo(); |
| | | variableVo.setKey(entry.getKey()); |
| | | variableVo.setValue(entry.getValue().getValue().toString()); |
| | | variableVoList.add(variableVo); |
| | | } |
| | | } |
| | | return variableVoList; |
| | | } |
| | | } |