【代码评审】BPM:Simple 设计器 - 签名实现
This commit is contained in:
parent
adc05cad66
commit
62aabc633c
|
@ -119,6 +119,7 @@ public class BpmSimpleModelNodeVO {
|
||||||
@Schema(description = "路由分支组", example = "[]")
|
@Schema(description = "路由分支组", example = "[]")
|
||||||
private List<RouteCondition> routerGroups;
|
private List<RouteCondition> routerGroups;
|
||||||
|
|
||||||
|
// TODO @lesan:这个目前前端是随机生成的。可以后端来随机么?
|
||||||
@Schema(description = "默认分支 ID", example = "Flow_xxx")
|
@Schema(description = "默认分支 ID", example = "Flow_xxx")
|
||||||
private String defaultFlowId; // 仅用于路由分支节点 BpmSimpleModelNodeType.ROUTE_BRANCH_NODE
|
private String defaultFlowId; // 仅用于路由分支节点 BpmSimpleModelNodeType.ROUTE_BRANCH_NODE
|
||||||
|
|
||||||
|
@ -289,6 +290,7 @@ public class BpmSimpleModelNodeVO {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO @lesan:还有相关的也要改下哈。route 到 router
|
||||||
@Schema(description = "路由分支")
|
@Schema(description = "路由分支")
|
||||||
@Data
|
@Data
|
||||||
@Valid
|
@Valid
|
||||||
|
|
|
@ -3,11 +3,8 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.util;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
import cn.hutool.core.util.ArrayUtil;
|
import cn.hutool.core.util.*;
|
||||||
import cn.hutool.core.util.ObjUtil;
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
|
||||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||||
import cn.iocoder.yudao.framework.common.util.string.StrUtils;
|
import cn.iocoder.yudao.framework.common.util.string.StrUtils;
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO;
|
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO;
|
||||||
|
@ -58,18 +55,6 @@ public class BpmnModelUtils {
|
||||||
element.addExtensionElement(extensionElement);
|
element.addExtensionElement(extensionElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addExtensionElementJson(FlowElement element, String name, Object value) {
|
|
||||||
if (value == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ExtensionElement extensionElement = new ExtensionElement();
|
|
||||||
extensionElement.setNamespace(FLOWABLE_EXTENSIONS_NAMESPACE);
|
|
||||||
extensionElement.setNamespacePrefix(FLOWABLE_EXTENSIONS_PREFIX);
|
|
||||||
extensionElement.setElementText(JsonUtils.toJsonString(value));
|
|
||||||
extensionElement.setName(name);
|
|
||||||
element.addExtensionElement(extensionElement);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addExtensionElement(FlowElement element, String name, Integer value) {
|
public static void addExtensionElement(FlowElement element, String name, Integer value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
return;
|
return;
|
||||||
|
@ -107,14 +92,6 @@ public class BpmnModelUtils {
|
||||||
return element != null ? element.getElementText() : null;
|
return element != null ? element.getElementText() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> T parseExtensionElementJson(FlowElement flowElement, String elementName, Class<T> clazz) {
|
|
||||||
if (flowElement == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
ExtensionElement element = CollUtil.getFirst(flowElement.getExtensionElements().get(elementName));
|
|
||||||
return element != null ? JsonUtils.parseObject(element.getElementText(), clazz) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 给节点添加候选人元素
|
* 给节点添加候选人元素
|
||||||
*
|
*
|
||||||
|
@ -369,6 +346,7 @@ public class BpmnModelUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addSignEnable(Boolean signEnable, FlowElement userTask) {
|
public static void addSignEnable(Boolean signEnable, FlowElement userTask) {
|
||||||
|
// TODO @lesan:是不是改成表达式会好点 addExtensionElement(userTask, SIGN_ENABLE, ObjUtil.isNotNull(signEnable) ? )
|
||||||
if (ObjUtil.isNotNull(signEnable)) {
|
if (ObjUtil.isNotNull(signEnable)) {
|
||||||
addExtensionElement(userTask, SIGN_ENABLE, signEnable.toString());
|
addExtensionElement(userTask, SIGN_ENABLE, signEnable.toString());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -465,6 +465,7 @@ public class SimpleModelUtils {
|
||||||
flowableListener.setEvent(TaskListener.EVENTNAME_ASSIGNMENT);
|
flowableListener.setEvent(TaskListener.EVENTNAME_ASSIGNMENT);
|
||||||
flowableListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
|
flowableListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
|
||||||
flowableListener.setImplementation(DELEGATE_EXPRESSION);
|
flowableListener.setImplementation(DELEGATE_EXPRESSION);
|
||||||
|
// TODO @lesan:可以在 BpmnModelUtils 搞个方法,类似 public static Integer parseCandidateStrategy。这样,就收敛啦!
|
||||||
FieldExtension fieldExtension = new FieldExtension();
|
FieldExtension fieldExtension = new FieldExtension();
|
||||||
fieldExtension.setFieldName("listenerConfig");
|
fieldExtension.setFieldName("listenerConfig");
|
||||||
fieldExtension.setStringValue(JsonUtils.toJsonString(node.getTaskAssignListener()));
|
fieldExtension.setStringValue(JsonUtils.toJsonString(node.getTaskAssignListener()));
|
||||||
|
|
|
@ -170,9 +170,8 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||||
taskForm = formService.getForm(NumberUtils.parseLong(todoTask.getFormKey()));
|
taskForm = formService.getForm(NumberUtils.parseLong(todoTask.getFormKey()));
|
||||||
}
|
}
|
||||||
|
|
||||||
BpmTaskRespVO bpmTaskRespVO = BpmTaskConvert.INSTANCE.buildTodoTask(todoTask, childrenTasks, buttonsSetting, taskForm);
|
return BpmTaskConvert.INSTANCE.buildTodoTask(todoTask, childrenTasks, buttonsSetting, taskForm)
|
||||||
bpmTaskRespVO.setSignEnable(signEnable);
|
.setSignEnable(signEnable);
|
||||||
return bpmTaskRespVO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class BpmUserTaskListener implements TaskListener {
|
||||||
headers.add(HEADER_TENANT_ID, delegateTask.getTenantId());
|
headers.add(HEADER_TENANT_ID, delegateTask.getTenantId());
|
||||||
}
|
}
|
||||||
// 2.2 请求体默认参数
|
// 2.2 请求体默认参数
|
||||||
// TODO @芋艿:哪些默认参数,后续再调研下;
|
// TODO @芋艿:哪些默认参数,后续再调研下;感觉可以搞个 task 字段,把整个 delegateTask 放进去;
|
||||||
body.add("processInstanceId", delegateTask.getProcessInstanceId());
|
body.add("processInstanceId", delegateTask.getProcessInstanceId());
|
||||||
body.add("assignee", delegateTask.getAssignee());
|
body.add("assignee", delegateTask.getAssignee());
|
||||||
body.add("taskDefinitionKey", delegateTask.getTaskDefinitionKey());
|
body.add("taskDefinitionKey", delegateTask.getTaskDefinitionKey());
|
||||||
|
@ -80,6 +80,7 @@ public class BpmUserTaskListener implements TaskListener {
|
||||||
// 3. 异步发起请求
|
// 3. 异步发起请求
|
||||||
// TODO @芋艿:确认要同步,还是异步
|
// TODO @芋艿:确认要同步,还是异步
|
||||||
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(body, headers);
|
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(body, headers);
|
||||||
|
// TODO @lesan:可能需要 try catch 哇? RestClientException
|
||||||
ResponseEntity<String> responseEntity = restTemplate.exchange(listenerHandler.getPath(), HttpMethod.POST,
|
ResponseEntity<String> responseEntity = restTemplate.exchange(listenerHandler.getPath(), HttpMethod.POST,
|
||||||
requestEntity, String.class);
|
requestEntity, String.class);
|
||||||
log.info("[notify][监听器:{},事件类型:{},请求头:{},请求体:{},响应结果:{}]",
|
log.info("[notify][监听器:{},事件类型:{},请求头:{},请求体:{},响应结果:{}]",
|
||||||
|
@ -111,6 +112,7 @@ public class BpmUserTaskListener implements TaskListener {
|
||||||
.filter(item -> item.getEvent().equals(eventName))
|
.filter(item -> item.getEvent().equals(eventName))
|
||||||
.findFirst().orElse(null);
|
.findFirst().orElse(null);
|
||||||
Assert.notNull(flowableListener, "监听器({})不能为空", flowableListener);
|
Assert.notNull(flowableListener, "监听器({})不能为空", flowableListener);
|
||||||
|
// TODO @lesan:BpmnModelUtils 提供一个 BpmSimpleModelNodeVO.ListenerHandler 解析方法,尽量收敛掉。
|
||||||
FieldExtension fieldExtension = flowableListener.getFieldExtensions().stream()
|
FieldExtension fieldExtension = flowableListener.getFieldExtensions().stream()
|
||||||
.filter(item -> item.getFieldName().equals("listenerConfig"))
|
.filter(item -> item.getFieldName().equals("listenerConfig"))
|
||||||
.findFirst().orElse(null);
|
.findFirst().orElse(null);
|
||||||
|
|
Loading…
Reference in New Issue