caixiaofeng 6 mesiacov pred
rodič
commit
863d818ad3

+ 3 - 2
flow-common/flow-common-flowable-starter/src/main/java/com/flow/flowable/behavior/JumpActivityBehavior.java

@@ -29,16 +29,17 @@ public class JumpActivityBehavior extends AbstractBpmnActivityBehavior {
             Expression expression = expressionManager.createExpression(skipExpression);
             Object result = expression.getValue(execution);
             if ((result instanceof Boolean && (Boolean) result)) {
+                leave(execution);
                 return;
             }
         }
+        ManagementService managementService = CommandContextUtil.getProcessEngineConfiguration().getManagementService();
+        managementService.executeCommand(new JumpActivityCmd(execution.getProcessInstanceId(), jumpServiceTask.getTargetNode()));
         FlowableEventDispatcher eventDispatcher = processEngineConfiguration.getEventDispatcher();
         if (Objects.nonNull(eventDispatcher) && eventDispatcher.isEnabled()) {
             CustomFlowableEngineEvent customFlowableEngineEvent = new CustomFlowableEngineEvent((ExecutionEntityImpl) execution, CustomFlowableEventType.ACTIVITY_JUMP);
             eventDispatcher.dispatchEvent(customFlowableEngineEvent, processEngineConfiguration.getEngineCfgKey());
         }
-        ManagementService managementService = CommandContextUtil.getProcessEngineConfiguration().getManagementService();
-        managementService.executeCommand(new JumpActivityCmd(execution.getProcessInstanceId(), jumpServiceTask.getTargetNode()));
         leave(execution);
     }
 }

+ 3 - 3
flow-common/flow-common-flowable-starter/src/main/java/com/flow/flowable/event/CustomFlowableEngineEvent.java

@@ -5,7 +5,7 @@ import org.flowable.common.engine.impl.event.FlowableEngineEventImpl;
 import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl;
 
 public class CustomFlowableEngineEvent extends FlowableEngineEventImpl {
-    protected Object entity;
+    protected ExecutionEntityImpl entity;
     protected CustomFlowableEventType customFlowableEventType;
 
     public CustomFlowableEngineEvent(ExecutionEntityImpl entity, CustomFlowableEventType type) {
@@ -17,11 +17,11 @@ public class CustomFlowableEngineEvent extends FlowableEngineEventImpl {
         super.setProcessDefinitionId(entity.getProcessDefinitionId());
     }
 
-    public Object getEntity() {
+    public ExecutionEntityImpl getEntity() {
         return entity;
     }
 
-    public void setEntity(Object entity) {
+    public void setEntity(ExecutionEntityImpl entity) {
         this.entity = entity;
     }
 

+ 0 - 5
flow-common/flow-common-flowable-starter/src/main/java/com/flow/flowable/event/CustomFlowableEventType.java

@@ -3,11 +3,6 @@ package com.flow.flowable.event;
 import org.flowable.common.engine.api.delegate.event.FlowableEventType;
 
 public enum CustomFlowableEventType implements FlowableEventType {
-    // 节点跳转
     ACTIVITY_JUMP,
-    // 节点跳转-取消
-    ACTIVITY_JUMP_CANCEL,
-    // 抄送流程
     PROCESS_COPY
-
 }

+ 25 - 2
flow-workflow/flow-workflow-biz/src/main/java/com/flow/listener/GlobalActivityEventListener.java

@@ -5,6 +5,7 @@ import com.flow.entity.FlowDefine;
 import com.flow.entity.FlowInstance;
 import com.flow.entity.FlowTask;
 import com.flow.entity.Notify;
+import com.flow.entity.node.Node;
 import com.flow.entity.settings.CancelConfig;
 import com.flow.entity.settings.Settings;
 import com.flow.enums.ApprovalNobodyEnum;
@@ -12,6 +13,7 @@ import com.flow.enums.AssigneeTypeEnum;
 import com.flow.enums.NotifyEnum;
 import com.flow.enums.ProcessStatus;
 import com.flow.flowable.event.CustomFlowableEngineEvent;
+import com.flow.flowable.model.JumpServiceTask;
 import com.flow.flowable.utils.ProcessElementUtil;
 import com.flow.service.FlowDefineService;
 import com.flow.service.FlowInstanceService;
@@ -27,7 +29,8 @@ import org.flowable.engine.delegate.event.AbstractFlowableEngineEventListener;
 import org.flowable.engine.delegate.event.FlowableCancelledEvent;
 import org.flowable.engine.delegate.event.FlowableProcessStartedEvent;
 import org.flowable.engine.delegate.event.impl.FlowableProcessCancelledEventImpl;
-import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl;
+import org.flowable.engine.impl.persistence.entity.*;
+import org.flowable.spring.SpringProcessEngineConfiguration;
 import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -35,6 +38,7 @@ import org.springframework.transaction.support.TransactionSynchronization;
 import org.springframework.transaction.support.TransactionSynchronizationManager;
 
 import java.time.LocalDateTime;
+import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 
@@ -51,6 +55,8 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
     private NotifyService notifyService;
     @Autowired
     private FlowInstanceService flowInstanceService;
+    @Autowired
+    private SpringProcessEngineConfiguration springProcessEngineConfiguration;
 
     // 任务创建监听器
     @Override
@@ -183,7 +189,24 @@ public class GlobalActivityEventListener extends AbstractFlowableEngineEventList
     }
 
     protected void activityJump(CustomFlowableEngineEvent event) {
-
+        ExecutionEntityImpl entity = event.getEntity();
+        JumpServiceTask jumpServiceTask = (JumpServiceTask) entity.getCurrentFlowElement();
+        String targetNode = jumpServiceTask.getTargetNode();
+        FlowDefine flowDefine = flowDefineService.getDefine(event.getProcessDefinitionId());
+        Node target = flowDefine.findFlowNodeOfType(Node.class, targetNode);
+        ActivityInstanceEntityManager activityInstanceEntityManager = springProcessEngineConfiguration.getActivityInstanceEntityManager();
+        List<ActivityInstanceEntity> activityInstanceEntityList = activityInstanceEntityManager.findActivityInstancesByExecutionAndActivityId(event.getExecutionId(), entity.getActivityId());
+        for (ActivityInstanceEntity activityInstanceEntity : activityInstanceEntityList) {
+            activityInstanceEntity.setDeleteReason(String.format("<span>跳转至 <span class='color-primary'>%s</span></span>", target.getName()));
+            activityInstanceEntityManager.update(activityInstanceEntity);
+        }
+        HistoricActivityInstanceEntityManager historicActivityInstanceEntityManager = springProcessEngineConfiguration.getHistoricActivityInstanceEntityManager();
+        List<HistoricActivityInstanceEntity> historicActivityInstanceEntities = historicActivityInstanceEntityManager.findHistoricActivityInstancesByExecutionAndActivityId(event.getExecutionId(), entity.getActivityId());
+        for (HistoricActivityInstanceEntity historicActivityInstanceEntity : historicActivityInstanceEntities) {
+            historicActivityInstanceEntity.setDeleteReason(String.format("<span>跳转至 <span class='color-primary'>%s</span></span>", target.getName()));
+            historicActivityInstanceEntityManager.update(historicActivityInstanceEntity);
+        }
     }
 
+
 }

+ 4 - 14
flow-workflow/flow-workflow-biz/src/main/java/com/flow/service/impl/FlowActivityServiceImpl.java

@@ -5,8 +5,6 @@ import com.flow.entity.Activity;
 import com.flow.entity.FlowDefine;
 import com.flow.entity.FlowTask;
 import com.flow.entity.node.ApprovalNode;
-import com.flow.entity.node.JumpNode;
-import com.flow.entity.node.Node;
 import com.flow.enums.ApprovalMultiEnum;
 import com.flow.service.FlowActivityService;
 import com.flow.service.FlowDefineService;
@@ -72,13 +70,9 @@ public class FlowActivityServiceImpl implements FlowActivityService {
                     } else if ("startEvent".equals(activity.getActivityType())) {
                         activity.setAssignee(processInstance.getStartUserId());
                     } else if ("jumpServiceTask".equals(activity.getActivityType())) {
-                        JumpNode jumpNode = flowDefine.findFlowNodeOfType(JumpNode.class, e.getActivityId());
-                        Node target = flowDefine.findFlowNodeOfType(Node.class, jumpNode.getTargetNode());
                         activity.setAssignee("admin");
-                        if (StringUtils.isNotBlank(activity.getDeleteReason())) {
-                            activity.setDeleteReason(String.format("<span>跳转至 <span class='color-primary'>%s</span></span>", target.getName()));
-                        } else {
-                            activity.setDeleteReason("<span>跳转失败 <span class='color-warning'>不满足跳转条件</span></span>");
+                        if (StringUtils.isBlank(activity.getDeleteReason())) {
+                            activity.setDeleteReason("<span>跳转失败 <span class='color-error'>不满足跳转条件</span></span>");
                         }
                     }
                     return activity;
@@ -121,13 +115,9 @@ public class FlowActivityServiceImpl implements FlowActivityService {
                     } else if ("startEvent".equals(activity.getActivityType())) {
                         activity.setAssignee(historicProcessInstance.getStartUserId());
                     } else if ("jumpServiceTask".equals(activity.getActivityType())) {
-                        JumpNode jumpNode = flowDefine.findFlowNodeOfType(JumpNode.class, e.getActivityId());
-                        Node target = flowDefine.findFlowNodeOfType(Node.class, jumpNode.getTargetNode());
                         activity.setAssignee("admin");
-                        if (StringUtils.isNotBlank(activity.getDeleteReason())) {
-                            activity.setDeleteReason(String.format("<span>跳转至 <span class='color-primary'>%s</span></span>", target.getName()));
-                        } else {
-                            activity.setDeleteReason("<span>跳转失败 <span class='color-warning'>不满足跳转条件</span></span>");
+                        if (StringUtils.isBlank(activity.getDeleteReason())) {
+                            activity.setDeleteReason("<span>跳转失败 <span class='color-error'>不满足跳转条件</span></span>");
                         }
                     }
                     return activity;