add - 添加取消实例的接口

This commit is contained in:
wangli 2023-07-17 09:46:24 +08:00
parent 3a5091a5d9
commit 813b2d0045
4 changed files with 83 additions and 3 deletions

View File

@ -1,5 +1,6 @@
package cn.axzo.workflow.core.service;
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceCancelDTO;
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceCreateDTO;
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceMyPageReqVO;
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceWithdrawDTO;
@ -16,10 +17,17 @@ import javax.validation.Valid;
public interface BpmProcessInstanceService {
/**
* 发起审核
* */
* 发起审核
*/
String createProcessInstance(BpmProcessInstanceCreateDTO processInstanceCreateDTO);
/**
* 取消流程实例
*
* @return
*/
Boolean cancelProcessInstance(BpmProcessInstanceCancelDTO processInstanceCancelDTO);
/**
* 我发起的审批列表
* */

View File

@ -0,0 +1,44 @@
package cn.axzo.workflow.core.service.dto.request.process;
import lombok.Data;
/**
* 取消流程实例的入参模型
*
* @author wangli
* @since 2023/7/17 09:34
*/
@Data
public class BpmProcessInstanceCancelDTO {
/**
* 流程实例的编号
*/
private String id;
/**
* 流程实例对应的 businessKey
*/
private String businessKey;
/**
* 取消原因
*/
private String reason;
/**
* 租户 ID
*/
private String tenantId;
/**
* 用户 ID
*/
private String userId;
/**
* 用户姓名
*/
private String userName;
}

View File

@ -10,6 +10,7 @@ import cn.axzo.workflow.core.repository.mapper.BpmProcessInstanceExtMapper;
import cn.axzo.workflow.core.service.BpmProcessDefinitionService;
import cn.axzo.workflow.core.service.BpmProcessInstanceService;
import cn.axzo.workflow.core.service.converter.BpmProcessInstanceConvert;
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceCancelDTO;
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceCreateDTO;
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceMyPageReqVO;
import cn.axzo.workflow.core.service.dto.request.process.BpmProcessInstanceWithdrawDTO;
@ -41,7 +42,7 @@ import javax.annotation.Nullable;
import javax.validation.Valid;
import java.util.*;
import static cn.axzo.workflow.core.common.BpmConstants.INTERNAL_START_USER_NAME;
import static cn.axzo.workflow.core.common.BpmConstants.*;
import static cn.axzo.workflow.core.common.enums.BpmErrorCode.*;
import static cn.axzo.workflow.core.common.utils.BpmCollectionUtils.convertList;
@ -180,6 +181,28 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
return instance.getId();
}
@Override
public Boolean cancelProcessInstance(BpmProcessInstanceCancelDTO dto) {
ProcessInstance instance = null;
if (StringUtils.isNotBlank(dto.getId())) {
instance = getProcessInstance(dto.getId(), dto.getTenantId(), false);
} else if (StringUtils.isNotBlank(dto.getBusinessKey())) {
instance = getProcessInstanceByBusinessKey(dto.getBusinessKey(), dto.getTenantId(), false);
} else {
throw new WorkflowEngineException("未找到指定的流程实例");
}
Map<String, Object> variables = new HashMap<>();
variables.put(INTERNAL_END_USER_WORKSPACE_ID, dto.getTenantId());
variables.put(INTERNAL_END_USER_IDENTITY_ID, dto.getUserId());
variables.put(INTERNAL_END_USER_NAME, dto.getUserName());
runtimeService.setVariables(instance.getProcessInstanceId(), variables);
deleteProcessInstance(instance.getProcessInstanceId(),
BpmProcessInstanceDeleteReasonEnum.CANCEL_TASK.format(dto.getReason()));
return true;
}
@Override
public HistoricProcessInstance getHistoricProcessInstance(String id, String tenantId) {
return historyService.createHistoricProcessInstanceQuery().processInstanceId(id)

View File

@ -45,6 +45,11 @@ public class BpmProcessInstanceController {
return CommonResponse.success(result);
}
public CommonResponse<Boolean> cancelProcessInstant(@Valid @RequestBody BpmProcessInstanceCancelDTO dto) {
log.info("取消审核cancelProcessInstant===>>>参数:{}", JSON.toJSONString(dto));
return CommonResponse.success(bpmProcessInstanceService.cancelProcessInstance(dto));
}
/**
* 获得流程实例
*