Explorar el Código

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

YunaiV hace 7 meses
padre
commit
62aabc633c

+ 2 - 0
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java

@@ -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

+ 2 - 24
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java

@@ -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 {

+ 1 - 0
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java

@@ -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()));

+ 2 - 3
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java

@@ -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

+ 3 - 1
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/listener/BpmUserTaskListener.java

@@ -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 @lesan:BpmnModelUtils 提供一个 BpmSimpleModelNodeVO.ListenerHandler 解析方法,尽量收敛掉。
         FieldExtension fieldExtension = flowableListener.getFieldExtensions().stream()
                 .filter(item -> item.getFieldName().equals("listenerConfig"))
                 .findFirst().orElse(null);