|
@@ -1,6 +1,7 @@
|
|
package com.flow.listener;
|
|
package com.flow.listener;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
|
+import com.flow.common.redis.service.RedisService;
|
|
import com.flow.entity.FlowDefine;
|
|
import com.flow.entity.FlowDefine;
|
|
import com.flow.entity.FlowInstance;
|
|
import com.flow.entity.FlowInstance;
|
|
import com.flow.entity.FlowTask;
|
|
import com.flow.entity.FlowTask;
|
|
@@ -23,7 +24,6 @@ import org.flowable.bpmn.model.UserTask;
|
|
import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent;
|
|
import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent;
|
|
import org.flowable.common.engine.api.delegate.event.FlowableEngineEvent;
|
|
import org.flowable.common.engine.api.delegate.event.FlowableEngineEvent;
|
|
import org.flowable.engine.ManagementService;
|
|
import org.flowable.engine.ManagementService;
|
|
-import org.flowable.engine.RuntimeService;
|
|
|
|
import org.flowable.engine.TaskService;
|
|
import org.flowable.engine.TaskService;
|
|
import org.flowable.engine.delegate.DelegateExecution;
|
|
import org.flowable.engine.delegate.DelegateExecution;
|
|
import org.flowable.engine.delegate.event.AbstractFlowableEngineEventListener;
|
|
import org.flowable.engine.delegate.event.AbstractFlowableEngineEventListener;
|
|
@@ -31,7 +31,6 @@ import org.flowable.engine.delegate.event.FlowableCancelledEvent;
|
|
import org.flowable.engine.delegate.event.FlowableProcessStartedEvent;
|
|
import org.flowable.engine.delegate.event.FlowableProcessStartedEvent;
|
|
import org.flowable.engine.delegate.event.impl.FlowableProcessCancelledEventImpl;
|
|
import org.flowable.engine.delegate.event.impl.FlowableProcessCancelledEventImpl;
|
|
import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl;
|
|
import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl;
|
|
-import org.flowable.spring.SpringProcessEngineConfiguration;
|
|
|
|
import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl;
|
|
import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
@@ -52,15 +51,13 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
|
|
@Autowired
|
|
@Autowired
|
|
private TaskService taskService;
|
|
private TaskService taskService;
|
|
@Autowired
|
|
@Autowired
|
|
- private RuntimeService runtimeService;
|
|
|
|
- @Autowired
|
|
|
|
private ManagementService managementService;
|
|
private ManagementService managementService;
|
|
@Autowired
|
|
@Autowired
|
|
private NotifyService notifyService;
|
|
private NotifyService notifyService;
|
|
@Autowired
|
|
@Autowired
|
|
private FlowInstanceService flowInstanceService;
|
|
private FlowInstanceService flowInstanceService;
|
|
@Autowired
|
|
@Autowired
|
|
- private SpringProcessEngineConfiguration springProcessEngineConfiguration;
|
|
|
|
|
|
+ private RedisService redisService;
|
|
|
|
|
|
// 任务创建监听器
|
|
// 任务创建监听器
|
|
@Override
|
|
@Override
|
|
@@ -103,7 +100,7 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
|
|
// 审批人重复处理
|
|
// 审批人重复处理
|
|
String duplicate = execution.getVariable("_DUPLICATE_APPROVAL", String.class);
|
|
String duplicate = execution.getVariable("_DUPLICATE_APPROVAL", String.class);
|
|
if (StringUtils.isNotBlank(duplicate)) {
|
|
if (StringUtils.isNotBlank(duplicate)) {
|
|
- String taskDefinitionKey = runtimeService.getVariable(event.getProcessInstanceId(), String.format("_%s_", entity.getAssignee()), String.class);
|
|
|
|
|
|
+ String taskDefinitionKey = redisService.hget(event.getProcessInstanceId(), entity.getAssignee(), String.class);
|
|
if (duplicate.equals(DuplicateApprovalEnum.ONCE.getType())) {
|
|
if (duplicate.equals(DuplicateApprovalEnum.ONCE.getType())) {
|
|
if (StringUtils.isNotBlank(taskDefinitionKey)) {
|
|
if (StringUtils.isNotBlank(taskDefinitionKey)) {
|
|
flowTaskService.autoComplete(entity.getId(), " 审批人重复");
|
|
flowTaskService.autoComplete(entity.getId(), " 审批人重复");
|
|
@@ -169,6 +166,7 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
|
|
// 更新流程实例状态
|
|
// 更新流程实例状态
|
|
FlowInstance flowInstance = FlowInstance.buildStatus(entity.getProcessInstanceId(), ProcessStatus.COMPLETED);
|
|
FlowInstance flowInstance = FlowInstance.buildStatus(entity.getProcessInstanceId(), ProcessStatus.COMPLETED);
|
|
flowInstanceService.updateById(flowInstance);
|
|
flowInstanceService.updateById(flowInstance);
|
|
|
|
+ redisService.del(event.getProcessInstanceId());
|
|
// 消息通知
|
|
// 消息通知
|
|
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
|
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
|
@Override
|
|
@Override
|
|
@@ -189,6 +187,7 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
|
|
// 流程取消监听器
|
|
// 流程取消监听器
|
|
@Override
|
|
@Override
|
|
protected void processCancelled(FlowableCancelledEvent event) {
|
|
protected void processCancelled(FlowableCancelledEvent event) {
|
|
|
|
+ redisService.del(event.getProcessInstanceId());
|
|
FlowableProcessCancelledEventImpl flowableProcessCancelledEvent = (FlowableProcessCancelledEventImpl) event;
|
|
FlowableProcessCancelledEventImpl flowableProcessCancelledEvent = (FlowableProcessCancelledEventImpl) event;
|
|
DelegateExecution execution = flowableProcessCancelledEvent.getExecution();
|
|
DelegateExecution execution = flowableProcessCancelledEvent.getExecution();
|
|
Map<String, Object> variables = execution.getVariables();
|
|
Map<String, Object> variables = execution.getVariables();
|
|
@@ -224,6 +223,7 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
|
|
Node target = flowDefine.findFlowNodeOfType(Node.class, targetNode);
|
|
Node target = flowDefine.findFlowNodeOfType(Node.class, targetNode);
|
|
String deleteReason = String.format("<span>跳转至 <span class='color-primary'>%s</span></span>", target.getName());
|
|
String deleteReason = String.format("<span>跳转至 <span class='color-primary'>%s</span></span>", target.getName());
|
|
managementService.executeCommand(new RecordActivityDeleteReasonCmd(event.getExecutionId(), entity.getActivityId(), deleteReason));
|
|
managementService.executeCommand(new RecordActivityDeleteReasonCmd(event.getExecutionId(), entity.getActivityId(), deleteReason));
|
|
|
|
+ redisService.del(event.getProcessInstanceId());
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|