camunda撤销流程

 /*** 撤销*/@Overridepublic void revoke(String processInstanceId, String businessId) {LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();HistoricProcessInstance instance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();if (processInstanceIsFinished(instance.getId())) {throw new JeecgBootException("流程已经结束,不允许撤销");}Task task = taskService.createTaskQuery().processInstanceId(processInstanceId).singleResult();if (!user.getUsername().equals(instance.getStartUserId())) {throw new JeecgBootException("您不是流程的发起人,不允许撤销");} else {//如果系统登录人是流程的发起人,并且当前任务办理人是流程的发起人,则允许撤回if (instance.getStartUserId().equals(task.getAssignee())) {revokeAndUpdateForm(instance, businessId);} else {List historicTaskInstanceList = historyService.createHistoricTaskInstanceQuery().processInstanceId(processInstanceId).finished().list();if (CollectionUtils.isEmpty(historicTaskInstanceList)) {//如果任务还没有被办理过,则允许撤回revokeAndUpdateForm(instance, businessId);} else {//获取办理人List assigneeList = historicTaskInstanceList.stream().map(HistoricTaskInstance::getAssignee).collect(Collectors.toList());long count = assigneeList.stream().filter(a -> !a.equals(instance.getStartUserId())).count();if (count == 0) {//已办的任务全部都是发起人自己办理的,则允许撤回revokeAndUpdateForm(instance, businessId);} else {throw new JeecgBootException("流程已被其他人办理过,不允许撤销");}}}}}/*** 撤销流程并更新表单** @param instance* @param businessId*/public void revokeAndUpdateForm(HistoricProcessInstance instance, String businessId) {runtimeService.deleteProcessInstance(instance.getId(), "撤销");//更新表单状态formDesignService.updateFormStatus(processDefinitionService.getStartFormKey(instance.getProcessDefinitionId()),businessId, FormStatusType.YCX.getCode());}


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部