| | |
| | | flowTaskVo.setTaskId(business.getTaskId()); |
| | | return findReturnTaskList(flowTaskVo); |
| | | } |
| | | |
| | | /** |
| | | * 结束流程 |
| | | * @param processInstanceId 流程实例 ID |
| | | * @param deleteReason 定义删除原因 |
| | | */ |
| | | public Result<?> end(String processInstanceId, String deleteReason) { |
| | | try { |
| | | // 强制结束流程实例 |
| | | runtimeService.deleteProcessInstance(processInstanceId, deleteReason); |
| | | // 删除关联流程的业务 |
| | | FlowMyBusiness flowMyBusiness=flowMyBusinessService.getFlowMyBusiness(processInstanceId); |
| | | flowMyBusinessService.removeById(flowMyBusiness.getId()); |
| | | System.out.println("Process instance with ID " + processInstanceId + " has been forcefully ended."); |
| | | } catch (Exception e) { |
| | | System.err.println("Failed to force end process instance: " + e.getMessage()); |
| | | } |
| | | |
| | | // 关闭流程引擎 |
| | | processEngine.close(); |
| | | return Result.OK("流程已结束"); |
| | | } |
| | | |
| | | /** |
| | | * 获取所有可回退的节点 |
| | | * |
| | |
| | | Page page = new Page(pageNum, pageSize); |
| | | String username = iFlowThirdService.getLoginUser().getUsername(); |
| | | flowMyBusinessDto.setCurrentUser(username); |
| | | IPage<FlowTaskDto> flowTaskDtoIPage = flowMyBusinessService.getPageListMyBusiness(page,flowMyBusinessDto); |
| | | flowTaskDtoIPage.getRecords().forEach(flowTaskDto -> { |
| | | // 流程定义信息 |
| | | ProcessDefinition pd = repositoryService.createProcessDefinitionQuery() |
| | | .processDefinitionId(flowTaskDto.getProcessDefinitionId()) |
| | | .singleResult(); |
| | | flowTaskDto.setDeployId(pd.getDeploymentId()); |
| | | flowTaskDto.setProcDefName(pd.getName()); |
| | | flowTaskDto.setProcDefVersion(pd.getVersion()); |
| | | flowTaskDto.setCategory(pd.getCategory()); |
| | | List<FlowTaskDto> list = flowMyBusinessService.ListMyBusiness(flowMyBusinessDto); |
| | | list.forEach(flowTaskDto -> { |
| | | // 流程发起人信息 |
| | | HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() |
| | | .processInstanceId(flowTaskDto.getProcInsId()) |
| | | .singleResult(); |
| | | SysUser startUser = iFlowThirdService.getUserByUsername(historicProcessInstance.getStartUserId()); |
| | | flowTaskDto.setStartUserId(startUser.getUsername()); |
| | | flowTaskDto.setStartUserName(startUser.getRealname()); |
| | | if (startUser!=null){ |
| | | flowTaskDto.setStartUserId(startUser.getUsername()); |
| | | flowTaskDto.setStartUserName(startUser.getRealname()); |
| | | } |
| | | List<String> departNamesByUsername = iFlowThirdService.getDepartNamesByUsername(historicProcessInstance.getStartUserId()); |
| | | flowTaskDto.setStartDeptName(CollUtil.join(departNamesByUsername,",")); |
| | | if (flowTaskDto.getTodoUsers() == null){ |
| | | flowTaskDto.setTodoUsers(""); |
| | | }else { |
| | | //去除[] |
| | | flowTaskDto.setTodoUsers(flowTaskDto.getTodoUsers().replaceAll("\\[", "").replaceAll("\\]", "")); |
| | | flowTaskDto.setTodoUsers(flowTaskDto.getTodoUsers().replaceAll("\"", "")); |
| | | } |
| | | }); |
| | | IPage<FlowTaskDto> flowTaskDtoIPage = new Page<>(); |
| | | flowTaskDtoIPage.setRecords(list); |
| | | flowTaskDtoIPage.setTotal(page.getTotal()); |
| | | return Result.OK(flowTaskDtoIPage); |
| | | } |
| | | |