mirror of
https://github.com/dromara/RuoYi-Vue-Plus.git
synced 2025-09-30 15:16:41 +08:00
add 添加撤销流程申请
This commit is contained in:
parent
4c36f0afc2
commit
39acda09ec
@ -105,4 +105,15 @@ public class ActProcessInstanceController extends BaseController {
|
|||||||
public R<Void> deleteFinishProcessAndHisInst(@NotNull(message = "流程实例id不能为空") @PathVariable String[] processInstanceIds) {
|
public R<Void> deleteFinishProcessAndHisInst(@NotNull(message = "流程实例id不能为空") @PathVariable String[] processInstanceIds) {
|
||||||
return toAjax(iActProcessInstanceService.deleteFinishProcessAndHisInst(processInstanceIds));
|
return toAjax(iActProcessInstanceService.deleteFinishProcessAndHisInst(processInstanceIds));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 撤销流程申请
|
||||||
|
*
|
||||||
|
* @param processInstanceId 流程实例id
|
||||||
|
*/
|
||||||
|
@Log(title = "流程实例管理", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping("/cancelProcessApply/{processInstanceId}")
|
||||||
|
public R<Void> cancelProcessApply(@NotBlank(message = "流程实例id不能为空") @PathVariable String processInstanceId) {
|
||||||
|
return toAjax(iActProcessInstanceService.cancelProcessApply(processInstanceId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,4 +69,12 @@ public interface IActProcessInstanceService {
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
boolean deleteFinishProcessAndHisInst(String[] processInstanceIds);
|
boolean deleteFinishProcessAndHisInst(String[] processInstanceIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 撤销流程申请
|
||||||
|
*
|
||||||
|
* @param processInstanceId 流程实例id
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
boolean cancelProcessApply(String processInstanceId);
|
||||||
}
|
}
|
||||||
|
@ -401,4 +401,38 @@ public class ActProcessInstanceServiceImpl implements IActProcessInstanceService
|
|||||||
throw new ServiceException(e.getMessage());
|
throw new ServiceException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 撤销流程申请
|
||||||
|
*
|
||||||
|
* @param processInstanceId 流程实例id
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean cancelProcessApply(String processInstanceId) {
|
||||||
|
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
|
||||||
|
.processInstanceId(processInstanceId).processInstanceTenantId(TenantHelper.getTenantId()).startedBy(String.valueOf(LoginHelper.getUserId())).singleResult();
|
||||||
|
if (ObjectUtil.isNull(processInstance)) {
|
||||||
|
throw new ServiceException("您不是流程发起人,撤销失败!");
|
||||||
|
}
|
||||||
|
if (processInstance.isSuspended()) {
|
||||||
|
throw new ServiceException(FlowConstant.MESSAGE_SUSPENDED);
|
||||||
|
}
|
||||||
|
BusinessStatusEnum.checkStatus(processInstance.getBusinessStatus());
|
||||||
|
List<Task> taskList = taskService.createTaskQuery().taskTenantId(TenantHelper.getTenantId()).processInstanceId(processInstanceId).list();
|
||||||
|
for (Task task : taskList) {
|
||||||
|
taskService.addComment(task.getId(), processInstanceId, "申请人撤销申请");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().finished().orderByHistoricTaskInstanceEndTime().finished().list().get(0);
|
||||||
|
List<String> nodeIds = StreamUtils.toList(taskList, Task::getTaskDefinitionKey);
|
||||||
|
runtimeService.createChangeActivityStateBuilder()
|
||||||
|
.processInstanceId(processInstanceId)
|
||||||
|
.moveActivityIdsToSingleActivityId(nodeIds, historicTaskInstance.getTaskDefinitionKey()).changeState();
|
||||||
|
runtimeService.updateBusinessStatus(processInstanceId, BusinessStatusEnum.CANCEL.getStatus());
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
throw new ServiceException("撤销失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user