Преглед изворни кода

http节点异常默认处理人

caixiaofeng пре 7 месеци
родитељ
комит
5acc02c0ce

+ 17 - 3
flow-workflow/flow-workflow-biz/src/main/java/com/flow/behavior/CustomHttpServiceTaskActivityBehavior.java

@@ -1,12 +1,12 @@
 package com.flow.behavior;
 
-import com.flow.flowable.cmd.RecordActivityDeleteReasonCmd;
 import lombok.extern.slf4j.Slf4j;
 import org.flowable.common.engine.api.async.AsyncTaskInvoker;
-import org.flowable.engine.ManagementService;
+import org.flowable.common.engine.api.variable.VariableContainer;
 import org.flowable.engine.delegate.DelegateExecution;
 import org.flowable.engine.impl.bpmn.http.DefaultBpmnHttpActivityDelegate;
-import org.flowable.engine.impl.util.CommandContextUtil;
+import org.flowable.http.common.api.HttpHeaders;
+import org.flowable.http.common.api.HttpRequest;
 import org.flowable.http.common.api.HttpResponse;
 
 import java.util.concurrent.CompletableFuture;
@@ -19,6 +19,20 @@ public class CustomHttpServiceTaskActivityBehavior extends DefaultBpmnHttpActivi
         return super.execute(execution, taskInvoker);
     }
 
+    @Override
+    protected CompletableFuture<ExecutionData> prepareAndExecuteRequest(HttpRequest request, boolean parallelInSameTransaction, AsyncTaskInvoker taskInvoker) {
+        HttpHeaders httpHeaders = request.getHttpHeaders();
+        httpHeaders.add("Content-Type", "application/json");
+        request.setHttpHeaders(httpHeaders);
+        return super.prepareAndExecuteRequest(request, parallelInSameTransaction, taskInvoker);
+    }
+
+    @Override
+    protected HttpRequest createRequest(VariableContainer variableContainer, String prefix) {
+        return super.createRequest(variableContainer, prefix);
+    }
+
+
     @Override
     public void afterExecution(DelegateExecution execution, ExecutionData result) {
         HttpResponse response = result.getResponse();

+ 5 - 1
flow-workflow/flow-workflow-biz/src/main/java/com/flow/service/impl/FlowDefineServiceImpl.java

@@ -16,6 +16,7 @@ import com.flow.enums.ProcessStatus;
 import com.flow.model.FormInfo;
 import com.flow.model.StartProcess;
 import com.flow.service.FlowDefineService;
+import com.google.common.collect.Lists;
 import org.flowable.common.engine.impl.identity.Authentication;
 import org.flowable.engine.RepositoryService;
 import org.flowable.engine.RuntimeService;
@@ -88,7 +89,10 @@ public class FlowDefineServiceImpl extends BaseServiceImpl<FlowDefineDao, FlowDe
         for (HttpNode httpNode : httpNodes) {
             List<String> errorUsers = httpNode.getErrorUsers();
             if (CollectionUtils.isNotEmpty(errorUsers)) {
-                values.put(String.format("%sCollection", httpNode.getId()), errorUsers);
+                values.put(String.format("%sCollection", httpNode.getId()),
+                        CollectionUtils.isNotEmpty(errorUsers) ? errorUsers :
+                                Lists.newArrayList(SecurityContextUtil.getUserId())
+                );
             }
         }
         // 生成流程实例ID

+ 1 - 2
flow-workflow/flow-workflow-entity/src/main/java/com/flow/entity/node/HttpNode.java

@@ -79,10 +79,9 @@ public class HttpNode extends Node {
                     }
                 }
                 String body = objectMapper.writeValueAsString(map);
-                String requestBody = objectMapper.writeValueAsString(body);
                 FieldExtension bodyExtension = new FieldExtension();
                 bodyExtension.setFieldName("requestBody");
-                bodyExtension.setExpression(requestBody);
+                bodyExtension.setExpression(body);
                 fieldExtensions.add(bodyExtension);
             }
         } catch (JsonProcessingException ignored) {