|
@@ -18,8 +18,10 @@ import com.flow.service.FlowTaskService;
|
|
|
import com.flow.service.NotifyService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.flowable.bpmn.model.FlowElement;
|
|
|
+import org.flowable.bpmn.model.UserTask;
|
|
|
import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent;
|
|
|
import org.flowable.common.engine.api.delegate.event.FlowableEngineEvent;
|
|
|
+import org.flowable.engine.HistoryService;
|
|
|
import org.flowable.engine.RuntimeService;
|
|
|
import org.flowable.engine.TaskService;
|
|
|
import org.flowable.engine.delegate.DelegateExecution;
|
|
@@ -52,6 +54,8 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
|
|
|
@Autowired
|
|
|
private RuntimeService runtimeService;
|
|
|
@Autowired
|
|
|
+ private HistoryService historyService;
|
|
|
+ @Autowired
|
|
|
private NotifyService notifyService;
|
|
|
@Autowired
|
|
|
private FlowInstanceService flowInstanceService;
|
|
@@ -95,6 +99,28 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ // 审批人重复处理
|
|
|
+ String duplicate = execution.getVariable("_DUPLICATE_APPROVAL", String.class);
|
|
|
+ if (StringUtils.isNotBlank(duplicate)) {
|
|
|
+ String taskDefinitionKey = runtimeService.getVariable(event.getProcessInstanceId(), String.format("_%s_", entity.getAssignee()), String.class);
|
|
|
+ if (duplicate.equals(DuplicateApprovalEnum.ONCE.getType())) {
|
|
|
+ if (StringUtils.isNotBlank(taskDefinitionKey)) {
|
|
|
+ flowTaskService.autoComplete(entity.getId(), " 审批人重复");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else if (duplicate.equals(DuplicateApprovalEnum.ADJACENT.getType())) {
|
|
|
+ if (StringUtils.isNotBlank(taskDefinitionKey)) {
|
|
|
+ UserTask userTask = ProcessElementUtil.findParentElement(currentFlowElement, UserTask.class);
|
|
|
+ if (Objects.nonNull(userTask)) {
|
|
|
+ if (userTask.getId().equals(taskDefinitionKey)) {
|
|
|
+ flowTaskService.autoComplete(entity.getId(), " 审批人重复");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
// 消息通知
|
|
|
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
|
|
|
@Override
|