Merge branch 'develop' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into master-jdk17
This commit is contained in:
@@ -19,6 +19,7 @@ public enum BpmReasonEnum {
|
||||
CANCEL_PROCESS_INSTANCE_BY_START_USER("用户主动取消流程,原因:{}"), // 场景:用户主动取消流程
|
||||
CANCEL_PROCESS_INSTANCE_BY_ADMIN("管理员【{}】取消流程,原因:{}"), // 场景:管理员取消流程
|
||||
CANCEL_CHILD_PROCESS_INSTANCE_BY_MAIN_PROCESS("子流程自动取消,原因:主流程已取消"),
|
||||
REJECT_CHILD_PROCESS("子流程审批不通过"),
|
||||
|
||||
// ========== 流程任务的独有原因 ==========
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ import org.flowable.engine.history.HistoricActivityInstance;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.history.HistoricProcessInstanceQuery;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.flowable.engine.runtime.Execution;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.flowable.engine.runtime.ProcessInstanceBuilder;
|
||||
import org.flowable.task.api.Task;
|
||||
@@ -69,6 +70,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
import static cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmApprovalDetailRespVO.ActivityNode;
|
||||
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.bpm.enums.task.BpmReasonEnum.REJECT_CHILD_PROCESS;
|
||||
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.START_USER_NODE_ID;
|
||||
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.parseNodeType;
|
||||
import static java.util.Arrays.asList;
|
||||
@@ -949,6 +951,29 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||
status);
|
||||
}
|
||||
|
||||
// 1.3 如果子流程拒绝,设置其父流程也为拒绝状态,且结束父流程
|
||||
// 相关问题链接:https://t.zsxq.com/kZhyb
|
||||
if (Objects.equals(status, BpmProcessInstanceStatusEnum.REJECT.getStatus())
|
||||
&& StrUtil.isNotBlank(instance.getSuperExecutionId())) {
|
||||
// 1.3.1 获取父流程实例 并标记为不通过
|
||||
Execution execution = runtimeService.createExecutionQuery().executionId(instance.getSuperExecutionId()).singleResult();
|
||||
ProcessInstance parentProcessInstance = getProcessInstance(execution.getProcessInstanceId());
|
||||
updateProcessInstanceReject(parentProcessInstance, REJECT_CHILD_PROCESS.getReason());
|
||||
|
||||
// 1.3.2 结束父流程。需要在子流程结束事务提交后执行
|
||||
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
||||
|
||||
@Override
|
||||
public void afterCompletion(int transactionStatus) {
|
||||
// 回滚情况,直接返回
|
||||
if (ObjectUtil.equal(transactionStatus, TransactionSynchronization.STATUS_ROLLED_BACK)) {
|
||||
return;
|
||||
}
|
||||
taskService.moveTaskToEnd(parentProcessInstance.getId(),REJECT_CHILD_PROCESS.getReason());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 2. 发送对应的消息通知
|
||||
if (Objects.equals(status, BpmProcessInstanceStatusEnum.APPROVE.getStatus())) {
|
||||
messageService.sendMessageWhenProcessInstanceApprove(
|
||||
@@ -996,17 +1021,18 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||
if (ObjUtil.notEqual(instance.getName(), name)) {
|
||||
runtimeService.setProcessInstanceName(instance.getProcessInstanceId(), name);
|
||||
}
|
||||
|
||||
// 流程前置通知:需要在流程启动后(事务提交后),保证 variables 已设置
|
||||
// 相关问题链接:https://t.zsxq.com/DF7Kq
|
||||
if (ObjUtil.isNull(processDefinitionInfo.getProcessBeforeTriggerSetting())) {
|
||||
return;
|
||||
}
|
||||
BpmModelMetaInfoVO.HttpRequestSetting setting = processDefinitionInfo.getProcessBeforeTriggerSetting();
|
||||
BpmHttpRequestUtils.executeBpmHttpRequest(instance,
|
||||
setting.getUrl(), setting.getHeader(), setting.getBody(), true, setting.getResponse());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// 流程前置通知
|
||||
if (ObjUtil.isNull(processDefinitionInfo.getProcessBeforeTriggerSetting())) {
|
||||
return;
|
||||
}
|
||||
BpmModelMetaInfoVO.HttpRequestSetting setting = processDefinitionInfo.getProcessBeforeTriggerSetting();
|
||||
BpmHttpRequestUtils.executeBpmHttpRequest(instance,
|
||||
setting.getUrl(), setting.getHeader(), setting.getBody(), true, setting.getResponse());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -804,7 +804,8 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
.setTargetTaskDefinitionKey(returnTaskId).setReason(reqVO.getReason()));
|
||||
return;
|
||||
}
|
||||
// 3.2 情况二:直接结束,审批不通过
|
||||
|
||||
// 3.2 情况二: 标记流程为不通过并结束流程
|
||||
processInstanceService.updateProcessInstanceReject(instance, reqVO.getReason()); // 标记不通过
|
||||
moveTaskToEnd(task.getProcessInstanceId(), BpmCommentTypeEnum.REJECT.formatComment(reqVO.getReason())); // 结束流程
|
||||
}
|
||||
@@ -986,6 +987,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void moveTaskToEnd(String processInstanceId, String reason) {
|
||||
List<Task> taskList = getRunningTaskListByProcessInstanceId(processInstanceId, null, null);
|
||||
if (CollUtil.isEmpty(taskList)) {
|
||||
|
||||
Reference in New Issue
Block a user