fix - 完善自动驳回功能处理
This commit is contained in:
parent
182174e70d
commit
90a3c0cf71
@ -50,8 +50,7 @@ public class CustomRejectionTaskAsyncCmd extends AbstractCommand<String> impleme
|
||||
|
||||
validTask(historicTaskInstance, (TaskEntity) task, dto.getApprover(), null);
|
||||
|
||||
startAsync(processEngineConfiguration, task);
|
||||
return null;
|
||||
return startAsync(processEngineConfiguration, task);
|
||||
}
|
||||
|
||||
private String startAsync(ProcessEngineConfigurationImpl processEngineConfiguration, Task task) {
|
||||
|
||||
@ -6,6 +6,7 @@ import cn.axzo.workflow.core.engine.cmd.CustomApproveTaskAsyncCmd;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.common.engine.impl.cfg.TransactionListener;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandConfig;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandExecutor;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
@ -17,6 +18,7 @@ import org.flowable.task.service.delegate.DelegateTask;
|
||||
import java.util.Collections;
|
||||
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_TASK_RELATION_ASSIGNEE_INFO;
|
||||
import static org.flowable.common.engine.impl.interceptor.EngineConfigurationConstants.KEY_PROCESS_ENGINE_CONFIG;
|
||||
|
||||
/**
|
||||
* 自动过审的事务监听器
|
||||
@ -37,7 +39,6 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_TASK_RELAT
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class AutoPassTransactionListener implements TransactionListener {
|
||||
private final SpringProcessEngineConfiguration springProcessEngineConfiguration;
|
||||
private final DelegateTask delegateTask;
|
||||
private final String advice;
|
||||
|
||||
@ -45,21 +46,25 @@ public class AutoPassTransactionListener implements TransactionListener {
|
||||
public void execute(CommandContext commandContext) {
|
||||
log.info("exec auto pass transaction listener start, processInstanceId: {}, taskId: {}", delegateTask.getProcessInstanceId(), delegateTask.getId());
|
||||
|
||||
SpringProcessEngineConfiguration springProcessEngineConfiguration = (SpringProcessEngineConfiguration) commandContext
|
||||
.getEngineConfigurations().get(KEY_PROCESS_ENGINE_CONFIG);
|
||||
|
||||
RuntimeService runtimeService = springProcessEngineConfiguration.getRuntimeService();
|
||||
BpmnTaskDelegateAssigner assigner = BpmnTaskDelegateAssigner.toObjectCompatible(
|
||||
runtimeService.getVariable(delegateTask.getProcessInstanceId(), INTERNAL_TASK_RELATION_ASSIGNEE_INFO + delegateTask.getId()));
|
||||
|
||||
CommandConfig commandConfig = new CommandConfig().transactionRequired();
|
||||
CommandExecutor commandExecutor = springProcessEngineConfiguration.getCommandExecutor();
|
||||
BpmnTaskAuditDTO pass = new BpmnTaskAuditDTO();
|
||||
pass.setTaskId(delegateTask.getId());
|
||||
pass.setAdvice(advice);
|
||||
pass.setApprover(assigner);
|
||||
pass.setOperationDesc("自动通过");
|
||||
String jobId = commandExecutor.execute(new CustomApproveTaskAsyncCmd(pass));
|
||||
String jobId = commandExecutor.execute(commandConfig, new CustomApproveTaskAsyncCmd(pass));
|
||||
|
||||
// 重置任务,因为上面的 cmd 和这个 cmd 的 lock 对象不一致
|
||||
JobServiceConfiguration jobServiceConfiguration = springProcessEngineConfiguration.getJobServiceConfiguration();
|
||||
commandExecutor.execute(new ResetExpiredJobsCmd(Collections.singletonList(jobId), jobServiceConfiguration.getJobEntityManager(), jobServiceConfiguration));
|
||||
commandExecutor.execute(commandConfig, new ResetExpiredJobsCmd(Collections.singletonList(jobId), jobServiceConfiguration.getJobEntityManager(), jobServiceConfiguration));
|
||||
|
||||
log.info("exec auto pass transaction listener end");
|
||||
}
|
||||
|
||||
@ -3,10 +3,10 @@ package cn.axzo.workflow.core.engine.tx.listener;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskAuditDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
|
||||
import cn.axzo.workflow.core.engine.cmd.CustomRejectionTaskAsyncCmd;
|
||||
import cn.axzo.workflow.core.service.ExtAxHiTaskInstService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.common.engine.impl.cfg.TransactionListener;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandConfig;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandExecutor;
|
||||
import org.flowable.job.service.JobServiceConfiguration;
|
||||
@ -16,6 +16,8 @@ import org.flowable.task.service.delegate.DelegateTask;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import static org.flowable.common.engine.impl.interceptor.EngineConfigurationConstants.KEY_PROCESS_ENGINE_CONFIG;
|
||||
|
||||
/**
|
||||
* 自动拒绝的事务监听
|
||||
*
|
||||
@ -30,25 +32,28 @@ import java.util.Collections;
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
public class AutoRejectTransactionListener implements TransactionListener {
|
||||
private final SpringProcessEngineConfiguration springProcessEngineConfiguration;
|
||||
private final DelegateTask delegateTask;
|
||||
private final ExtAxHiTaskInstService extAxHiTaskInstService;
|
||||
|
||||
@Override
|
||||
public void execute(CommandContext commandContext) {
|
||||
log.info("exec auto reject transaction listener start, processInstanceId: {}, taskId: {}",
|
||||
delegateTask.getProcessInstanceId(), delegateTask.getId());
|
||||
|
||||
SpringProcessEngineConfiguration springProcessEngineConfiguration = (SpringProcessEngineConfiguration) commandContext
|
||||
.getEngineConfigurations().get(KEY_PROCESS_ENGINE_CONFIG);
|
||||
CommandConfig commandConfig = new CommandConfig().transactionRequired();
|
||||
|
||||
CommandExecutor commandExecutor = springProcessEngineConfiguration.getCommandExecutor();
|
||||
BpmnTaskAuditDTO reject = new BpmnTaskAuditDTO();
|
||||
reject.setTaskId(delegateTask.getId());
|
||||
reject.setApprover(new BpmnTaskDelegateAssigner("系统", "system", delegateTask.getTenantId()));
|
||||
reject.setOperationDesc("自动驳回");
|
||||
String jobId = commandExecutor.execute(new CustomRejectionTaskAsyncCmd(reject));
|
||||
String jobId = commandExecutor.execute(commandConfig, new CustomRejectionTaskAsyncCmd(reject));
|
||||
|
||||
// 重置任务,因为上面的 cmd 和这个 cmd 的 lock 对象不一致
|
||||
JobServiceConfiguration jobServiceConfiguration = springProcessEngineConfiguration.getJobServiceConfiguration();
|
||||
commandExecutor.execute(new ResetExpiredJobsCmd(Collections.singletonList(jobId), jobServiceConfiguration.getJobEntityManager(), jobServiceConfiguration));
|
||||
commandExecutor.execute(commandConfig,
|
||||
new ResetExpiredJobsCmd(Collections.singletonList(jobId), jobServiceConfiguration.getJobEntityManager(), jobServiceConfiguration));
|
||||
|
||||
log.info("exec auto reject transaction listener end");
|
||||
}
|
||||
|
||||
@ -190,7 +190,7 @@ public class AutoOperatorEvent_101_Listener extends AbstractBpmnEventListener<Ta
|
||||
*/
|
||||
private void autoReject(DelegateTask delegateTask, TransactionState transactionState) {
|
||||
Context.getTransactionContext().addTransactionListener(transactionState,
|
||||
new AutoRejectTransactionListener(processEngineConfiguration, delegateTask, extAxHiTaskInstService));
|
||||
new AutoRejectTransactionListener(delegateTask));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -203,7 +203,7 @@ public class AutoOperatorEvent_101_Listener extends AbstractBpmnEventListener<Ta
|
||||
*/
|
||||
private void autoPass(DelegateTask delegateTask, TransactionState transactionState, @Nullable String advice) {
|
||||
Context.getTransactionContext().addTransactionListener(transactionState,
|
||||
new AutoPassTransactionListener(processEngineConfiguration, delegateTask, advice));
|
||||
new AutoPassTransactionListener(delegateTask, advice));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user