流程触发器http的list参数改成json

This commit is contained in:
guoshengxiong 2024-12-19 15:26:06 +08:00
parent 829d120344
commit 8e8bee8b13

View File

@ -2,6 +2,7 @@ package com.wflow.workflow.task;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.wflow.utils.BeanUtil;
import com.wflow.utils.EmailUtil;
@ -15,6 +16,7 @@ import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.JavaDelegate;
import javax.mail.MessagingException;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.regex.Matcher;
@ -115,9 +117,18 @@ public class TriggerServiceTask implements JavaDelegate {
//处理请求体
if ("FORM".equals(http.getContentType())) {
http.getParams().stream().filter(o -> o != null && o.getName() != null && !"".equals(o.getName())).forEach(hd -> {
request.form(hd.getName(), hd.getIsField() ?
String.valueOf(variables.getOrDefault(String.valueOf(hd.getValue()), ""))
: getStrByRegex(String.valueOf(hd.getValue()), variables));
String v;
if (hd.getIsField()) {
Object orDefault = variables.getOrDefault(String.valueOf(hd.getValue()), "");
if (orDefault instanceof List) {
v = JSON.toJSONString(orDefault);
} else {
v = String.valueOf(orDefault);
}
} else {
v = getStrByRegex(String.valueOf(hd.getValue()), variables);
}
request.form(hd.getName(), v);
});
request.form("dfInstanceId", execution.getProcessInstanceId());
request.form("dfNodeId", execution.getCurrentActivityId());