Эх сурвалжийг харах

feat: Simple设计器-userTask-添加是否需要签名字段

Lesan 7 сар өмнө
parent
commit
fd4b6ef9e4

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

@@ -60,6 +60,9 @@ public class BpmSimpleModelNodeVO {
     @Schema(description = "操作按钮设置", example = "[]")
     private List<OperationButtonSetting> buttonsSetting;  // 用于审批节点
 
+    @Schema(description = "是否需要签名", example = "false")
+    private Boolean signEnable;
+
     /**
      * 审批节点拒绝处理
      */

+ 3 - 0
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java

@@ -78,6 +78,9 @@ public class BpmTaskRespVO {
     @Schema(description = "操作按钮设置值")
     private Map<Integer, OperationButtonSetting> buttonsSetting;
 
+    @Schema(description = "是否需要签名")
+    private Boolean signEnable;
+
     @Data
     @Schema(description = "流程实例")
     public static class ProcessInstance {

+ 5 - 0
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnModelConstants.java

@@ -110,4 +110,9 @@ public interface BpmnModelConstants {
      */
     String START_USER_NODE_ID = "StartUserNode";
 
+    /**
+     * 是否需要签名
+     */
+    String SIGN_ENABLE = "signEnable";
+
 }

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

@@ -1,6 +1,7 @@
 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;
@@ -367,6 +368,26 @@ public class BpmnModelUtils {
         return Optional.ofNullable(extensionElement).map(ExtensionElement::getElementText).orElse(null);
     }
 
+    public static void addSignEnable(Boolean signEnable, FlowElement userTask) {
+        if (ObjUtil.isNotNull(signEnable)) {
+            addExtensionElement(userTask, SIGN_ENABLE, signEnable.toString());
+        } else {
+            addExtensionElement(userTask, SIGN_ENABLE, "false");
+        }
+    }
+
+    public static Boolean parseSignEnable(BpmnModel bpmnModel, String flowElementId) {
+        FlowElement flowElement = getFlowElementById(bpmnModel, flowElementId);
+        if (flowElement == null) {
+            return false;
+        }
+        List<ExtensionElement> extensionElements = flowElement.getExtensionElements().get(SIGN_ENABLE);
+        if (CollUtil.isEmpty(extensionElements)) {
+            return false;
+        }
+        return Convert.toBool(extensionElements.get(0).getElementText(), false);
+    }
+
     // ========== BPM 简单查找相关的方法 ==========
 
     /**

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

@@ -440,6 +440,8 @@ public class SimpleModelUtils {
             }
             // 设置监听器
             addUserTaskListener(node, userTask);
+            // 添加是否需要签名
+            addSignEnable(node.getSignEnable(), userTask);
             return userTask;
         }
 

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

@@ -64,6 +64,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
 import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
 import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*;
 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG;
+import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.parseSignEnable;
 
 /**
  * 流程任务实例 Service 实现类
@@ -161,13 +162,17 @@ public class BpmTaskServiceImpl implements BpmTaskService {
         BpmnModel bpmnModel = bpmProcessDefinitionService.getProcessDefinitionBpmnModel(todoTask.getProcessDefinitionId());
         Map<Integer, BpmTaskRespVO.OperationButtonSetting> buttonsSetting = BpmnModelUtils.parseButtonsSetting(
                 bpmnModel, todoTask.getTaskDefinitionKey());
+        Boolean signEnable = parseSignEnable(bpmnModel, todoTask.getTaskDefinitionKey());
 
         // 4. 任务表单
         BpmFormDO taskForm = null;
         if (StrUtil.isNotBlank(todoTask.getFormKey())){
             taskForm = formService.getForm(NumberUtils.parseLong(todoTask.getFormKey()));
         }
-        return BpmTaskConvert.INSTANCE.buildTodoTask(todoTask, childrenTasks, buttonsSetting, taskForm);
+
+        BpmTaskRespVO bpmTaskRespVO = BpmTaskConvert.INSTANCE.buildTodoTask(todoTask, childrenTasks, buttonsSetting, taskForm);
+        bpmTaskRespVO.setSignEnable(signEnable);
+        return bpmTaskRespVO;
     }
 
     @Override