【代码评审】BPM:Simple 设计器 - 签名实现

This commit is contained in:
YunaiV 2025-01-08 22:11:52 +08:00
parent adc05cad66
commit 62aabc633c
5 changed files with 10 additions and 28 deletions

View File

@ -119,6 +119,7 @@ public class BpmSimpleModelNodeVO {
@Schema(description = "路由分支组", example = "[]")
private List<RouteCondition> routerGroups;
// TODO @lesan这个目前前端是随机生成的可以后端来随机么
@Schema(description = "默认分支 ID", example = "Flow_xxx")
private String defaultFlowId; // 仅用于路由分支节点 BpmSimpleModelNodeType.ROUTE_BRANCH_NODE
@ -289,6 +290,7 @@ public class BpmSimpleModelNodeVO {
}
// TODO @lesan还有相关的也要改下哈route router
@Schema(description = "路由分支")
@Data
@Valid

View File

@ -3,11 +3,8 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.util;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.*;
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.string.StrUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO;
@ -58,18 +55,6 @@ public class BpmnModelUtils {
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) {
if (value == null) {
return;
@ -107,14 +92,6 @@ public class BpmnModelUtils {
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) {
// TODO @lesan是不是改成表达式会好点 addExtensionElement(userTask, SIGN_ENABLE, ObjUtil.isNotNull(signEnable) ? )
if (ObjUtil.isNotNull(signEnable)) {
addExtensionElement(userTask, SIGN_ENABLE, signEnable.toString());
} else {

View File

@ -465,6 +465,7 @@ public class SimpleModelUtils {
flowableListener.setEvent(TaskListener.EVENTNAME_ASSIGNMENT);
flowableListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION);
flowableListener.setImplementation(DELEGATE_EXPRESSION);
// TODO @lesan可以在 BpmnModelUtils 搞个方法类似 public static Integer parseCandidateStrategy这样就收敛啦
FieldExtension fieldExtension = new FieldExtension();
fieldExtension.setFieldName("listenerConfig");
fieldExtension.setStringValue(JsonUtils.toJsonString(node.getTaskAssignListener()));

View File

@ -170,9 +170,8 @@ public class BpmTaskServiceImpl implements BpmTaskService {
taskForm = formService.getForm(NumberUtils.parseLong(todoTask.getFormKey()));
}
BpmTaskRespVO bpmTaskRespVO = BpmTaskConvert.INSTANCE.buildTodoTask(todoTask, childrenTasks, buttonsSetting, taskForm);
bpmTaskRespVO.setSignEnable(signEnable);
return bpmTaskRespVO;
return BpmTaskConvert.INSTANCE.buildTodoTask(todoTask, childrenTasks, buttonsSetting, taskForm)
.setSignEnable(signEnable);
}
@Override

View File

@ -71,7 +71,7 @@ public class BpmUserTaskListener implements TaskListener {
headers.add(HEADER_TENANT_ID, delegateTask.getTenantId());
}
// 2.2 请求体默认参数
// TODO @芋艿哪些默认参数后续再调研下
// TODO @芋艿哪些默认参数后续再调研下感觉可以搞个 task 字段把整个 delegateTask 放进去
body.add("processInstanceId", delegateTask.getProcessInstanceId());
body.add("assignee", delegateTask.getAssignee());
body.add("taskDefinitionKey", delegateTask.getTaskDefinitionKey());
@ -80,6 +80,7 @@ public class BpmUserTaskListener implements TaskListener {
// 3. 异步发起请求
// TODO @芋艿确认要同步还是异步
HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(body, headers);
// TODO @lesan可能需要 try catch RestClientException
ResponseEntity<String> responseEntity = restTemplate.exchange(listenerHandler.getPath(), HttpMethod.POST,
requestEntity, String.class);
log.info("[notify][监听器:{},事件类型:{},请求头:{},请求体:{},响应结果:{}]",
@ -111,6 +112,7 @@ public class BpmUserTaskListener implements TaskListener {
.filter(item -> item.getEvent().equals(eventName))
.findFirst().orElse(null);
Assert.notNull(flowableListener, "监听器({})不能为空", flowableListener);
// TODO @lesanBpmnModelUtils 提供一个 BpmSimpleModelNodeVO.ListenerHandler 解析方法尽量收敛掉
FieldExtension fieldExtension = flowableListener.getFieldExtensions().stream()
.filter(item -> item.getFieldName().equals("listenerConfig"))
.findFirst().orElse(null);