Преглед на файлове

【同步】BPM:合并 master-jdk17 代码

YunaiV преди 1 година
родител
ревизия
b65ccd769f

+ 1 - 1
pom.xml

@@ -16,7 +16,7 @@
         <module>yudao-module-system</module>
         <module>yudao-module-infra</module>
 <!--        <module>yudao-module-member</module>-->
-<!--        <module>yudao-module-bpm</module>-->
+        <module>yudao-module-bpm</module>
 <!--        <module>yudao-module-report</module>-->
 <!--        <module>yudao-module-mp</module>-->
 <!--        <module>yudao-module-pay</module>-->

+ 4 - 0
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java

@@ -75,4 +75,8 @@ public interface ErrorCodeConstants {
     // ========== BPM 流程表达式 1-009-014-000 ==========
     ErrorCode PROCESS_EXPRESSION_NOT_EXISTS = new ErrorCode(1_009_014_000, "流程表达式不存在");
 
+    // ========== BPM 仿钉钉流程设计器 1-009-015-000 ==========
+    // TODO @芋艿:这个错误码,需要关注下
+    ErrorCode CONVERT_TO_SIMPLE_MODEL_NOT_SUPPORT = new ErrorCode(1_009_015_000, "该流程模型不支持仿钉钉设计流程");
+
 }

+ 39 - 0
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmSimpleModelController.java

@@ -0,0 +1,39 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.simple.BpmSimpleModelNodeVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.simple.BpmSimpleModelSaveReqVO;
+import cn.iocoder.yudao.module.bpm.service.definition.BpmSimpleModelService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import jakarta.annotation.Resource;
+import jakarta.validation.Valid;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+// TODO @芋艿:后续考虑下,怎么放这个 Controller
+@Tag(name = "管理后台 - BPM 仿钉钉流程设计器")
+@RestController
+@RequestMapping("/bpm/simple")
+public class BpmSimpleModelController {
+    @Resource
+    private BpmSimpleModelService bpmSimpleModelService;
+
+    @PostMapping("/save")
+    @Operation(summary = "保存仿钉钉流程设计模型")
+    @PreAuthorize("@ss.hasPermission('bpm:model:update')")
+    public CommonResult<Boolean> saveSimpleModel(@Valid @RequestBody BpmSimpleModelSaveReqVO reqVO) {
+        return success(bpmSimpleModelService.saveSimpleModel(reqVO));
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得仿钉钉流程设计模型")
+    @Parameter(name = "modelId", description = "流程模型编号", required = true, example = "a2c5eee0-eb6c-11ee-abf4-0c37967c420a")
+    public CommonResult<BpmSimpleModelNodeVO> getSimpleModel(@RequestParam("modelId") String modelId){
+        return success(bpmSimpleModelService.getSimpleModel(modelId));
+    }
+
+}

+ 23 - 0
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/simple/BpmSimpleModelSaveReqVO.java

@@ -0,0 +1,23 @@
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.simple;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.Valid;
+import jakarta.validation.constraints.NotEmpty;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+// TODO @芋艿:或许挪到 model 里的 simple 包
+@Schema(description = "管理后台 - 仿钉钉流程设计模型的新增/修改 Request VO")
+@Data
+public class BpmSimpleModelSaveReqVO {
+
+    @Schema(description = "流程模型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
+    @NotEmpty(message = "流程模型编号不能为空")
+    private String modelId; // 对应 Flowable act_re_model 表 ID_ 字段
+
+    @Schema(description = "仿钉钉流程设计模型对象", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotNull(message = "仿钉钉流程设计模型对象不能为空")
+    @Valid
+    private BpmSimpleModelNodeVO simpleModelBody;
+
+}

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

@@ -1,5 +1,12 @@
 package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums;
 
+import com.google.common.collect.ImmutableSet;
+import org.flowable.bpmn.model.EndEvent;
+import org.flowable.bpmn.model.FlowNode;
+import org.flowable.bpmn.model.UserTask;
+
+import java.util.Set;
+
 /**
  * BPMN XML 常量信息
  *

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

@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.util;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.ArrayUtil;
+import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
 import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants;
 import org.flowable.bpmn.converter.BpmnXMLConverter;
@@ -14,7 +15,6 @@ import java.util.*;
 
 import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.*;
 import static org.flowable.bpmn.constants.BpmnXMLConstants.FLOWABLE_EXTENSIONS_NAMESPACE;
-import java.util.*;
 
 /**
  * 流程模型转操作工具类

+ 20 - 5
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.iocoder.yudao.module.bpm.service.definition;
 
+import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
 import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
@@ -103,7 +104,7 @@ public class BpmModelServiceImpl implements BpmModelService {
         // 保存流程定义
         repositoryService.saveModel(model);
         // 保存 BPMN XML
-        saveModelBpmnXml(model, bpmnXml);
+        saveModelBpmnXml(model.getId(), StrUtil.utf8Bytes(bpmnXml));
         return model.getId();
     }
 
@@ -121,7 +122,7 @@ public class BpmModelServiceImpl implements BpmModelService {
         // 更新模型
         repositoryService.saveModel(model);
         // 更新 BPMN XML
-        saveModelBpmnXml(model, updateReqVO.getBpmnXml());
+        saveModelBpmnXml(model.getId(), StrUtil.utf8Bytes(updateReqVO.getBpmnXml()));
     }
 
     @Override
@@ -236,11 +237,25 @@ public class BpmModelServiceImpl implements BpmModelService {
         }
     }
 
-    private void saveModelBpmnXml(Model model, String bpmnXml) {
-        if (StrUtil.isEmpty(bpmnXml)) {
+    @Override
+    public void saveModelBpmnXml(String id,  byte[] xmlBytes) {
+        if (ArrayUtil.isEmpty(xmlBytes)) {
+            return;
+        }
+        repositoryService.addModelEditorSource(id, xmlBytes);
+    }
+
+    @Override
+    public byte[] getModelSimpleJson(String id) {
+        return repositoryService.getModelEditorSourceExtra(id);
+    }
+
+    @Override
+    public void saveModelSimpleJson(String id, byte[] jsonBytes) {
+        if (ArrayUtil.isEmpty(jsonBytes)) {
             return;
         }
-        repositoryService.addModelEditorSource(model.getId(), StrUtil.utf8Bytes(bpmnXml));
+        repositoryService.addModelEditorSourceExtra(id, jsonBytes);
     }
 
     /**

+ 29 - 0
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmSimpleModelService.java

@@ -0,0 +1,29 @@
+package cn.iocoder.yudao.module.bpm.service.definition;
+
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.simple.BpmSimpleModelNodeVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.simple.BpmSimpleModelSaveReqVO;
+import jakarta.validation.Valid;
+
+/**
+ * 仿钉钉流程设计 Service 接口
+ *
+ * @author jason
+ */
+public interface BpmSimpleModelService {
+
+    /**
+     * 保存仿钉钉流程设计模型
+     *
+     * @param reqVO 请求信息
+     */
+    Boolean saveSimpleModel(@Valid BpmSimpleModelSaveReqVO reqVO);
+
+    /**
+     * 获取仿钉钉流程设计模型结构
+     *
+     * @param modelId 流程模型编号
+     * @return 仿钉钉流程设计模型结构
+     */
+    BpmSimpleModelNodeVO getSimpleModel(String modelId);
+
+}

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

@@ -17,9 +17,11 @@ public interface BpmProcessInstanceCopyService {
      * 流程实例的抄送
      *
      * @param userIds 抄送的用户编号
-     * @param taskId 流程任务编号
+     * @param processInstanceId 流程编号
+     * @param taskId 任务编号
+     * @param taskName 任务名称
      */
-    void createProcessInstanceCopy(Collection<Long> userIds, String taskId);
+    void createProcessInstanceCopy(Collection<Long> userIds, String processInstanceId, String taskId, String taskName);
 
     /**
      * 获得抄送的流程的分页

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

@@ -186,7 +186,8 @@ public class BpmTaskServiceImpl implements BpmTaskService {
 
         // 2. 抄送用户
         if (CollUtil.isNotEmpty(reqVO.getCopyUserIds())) {
-            processInstanceCopyService.createProcessInstanceCopy(reqVO.getCopyUserIds(), reqVO.getId());
+            processInstanceCopyService.createProcessInstanceCopy(reqVO.getCopyUserIds(), instance.getProcessInstanceId(),
+                    reqVO.getId(), task.getName());
         }
 
         // 情况一:被委派的任务,不调用 complete 去完成任务

+ 5 - 5
yudao-server/pom.xml

@@ -46,11 +46,11 @@
 <!--            <version>${revision}</version>-->
 <!--        </dependency>-->
         <!-- 工作流。默认注释,保证编译速度 -->
-<!--        <dependency>-->
-<!--            <groupId>cn.iocoder.boot</groupId>-->
-<!--            <artifactId>yudao-module-bpm-biz</artifactId>-->
-<!--            <version>${revision}</version>-->
-<!--        </dependency>-->
+        <dependency>
+            <groupId>cn.iocoder.boot</groupId>
+            <artifactId>yudao-module-bpm-biz</artifactId>
+            <version>${revision}</version>
+        </dependency>
         <!-- 支付服务。默认注释,保证编译速度 -->
 <!--        <dependency>-->
 <!--            <groupId>cn.iocoder.boot</groupId>-->