Browse Source

新增驳回直接终止

hubin 1 year ago
parent
commit
8e78d1db69

+ 3 - 0
src/main/java/com/aizuda/boot/modules/flw/entity/dto/RejectTaskDTO.java

@@ -29,4 +29,7 @@ public class RejectTaskDTO {
     @Schema(description = "原因")
     private String reason;
 
+    @Schema(description = "终止流程")
+    private boolean termination;
+
 }

+ 2 - 6
src/main/java/com/aizuda/boot/modules/flw/flow/FlowTaskListener.java

@@ -29,11 +29,6 @@ public class FlowTaskListener implements TaskListener {
     public boolean notify(EventType eventType, Supplier<FlwTask> supplier, NodeModel nodeModel, FlowCreator flowCreator) {
         FlwTask flwTask = supplier.get();
 
-        // 延迟触发器
-        if (EventType.autoComplete.eq(eventType) && TaskType.trigger.eq(flwTask.getTaskType())) {
-            return true;
-        }
-
         // 不进行二次执行自动跳转逻辑,防止出现taskId不存在,退回需要发起人手动审批
         if (EventType.create.eq(eventType)) {
             // 获取当前节点信息
@@ -111,7 +106,8 @@ public class FlowTaskListener implements TaskListener {
             fpa.setTaskKey(flwTask.getTaskKey());
         }
 
-        if (EventType.autoComplete.equals(eventType) || EventType.autoReject.equals(eventType)) {
+        if (EventType.autoComplete.eq(eventType) || EventType.autoReject.eq(eventType)
+                || EventType.trigger.eq(eventType)) {
             // 自动审批情况,设置默认处理人信息
             fpa.setCreateId(0L);
             fpa.setCreateBy("admin");

+ 7 - 4
src/main/java/com/aizuda/boot/modules/flw/service/impl/ProcessTaskServiceImpl.java

@@ -10,10 +10,7 @@ import com.aizuda.boot.modules.flw.flow.FlowForm;
 import com.aizuda.boot.modules.flw.flow.FlowHelper;
 import com.aizuda.boot.modules.flw.mapper.FlowlongMapper;
 import com.aizuda.boot.modules.flw.service.*;
-import com.aizuda.bpm.engine.FlowDataTransfer;
-import com.aizuda.bpm.engine.FlowLongEngine;
-import com.aizuda.bpm.engine.ProcessService;
-import com.aizuda.bpm.engine.TaskService;
+import com.aizuda.bpm.engine.*;
 import com.aizuda.bpm.engine.core.FlowCreator;
 import com.aizuda.bpm.engine.core.enums.PerformType;
 import com.aizuda.bpm.engine.core.enums.ProcessType;
@@ -47,6 +44,7 @@ import java.util.stream.Collectors;
 @Service
 @AllArgsConstructor
 public class ProcessTaskServiceImpl implements IProcessTaskService {
+    private final RuntimeService runtimeService;
     private FlowlongMapper flowlongMapper;
     private FlwExtInstanceMapper extInstanceMapper;
     private FlowLongEngine flowLongEngine;
@@ -297,6 +295,11 @@ public class ProcessTaskServiceImpl implements IProcessTaskService {
         ApiAssert.isEmpty(flwTask, "当前ID执行任务不存在");
         TaskService taskService = flowLongEngine.taskService();
         this.processApprovalOpinion(dto.getReason());
+        if (dto.isTermination()) {
+            // 驳回并终止流程
+            runtimeService.reject(flwTask.getInstanceId(), FlowHelper.getFlowCreator());
+            return true;
+        }
         return taskService.rejectTask(flwTask, FlowHelper.getFlowCreator(), dto.getArgs()).isPresent();
     }