Browse Source

Merge remote-tracking branch 'origin/feature/bpm' into feature/bpm

# Conflicts:
#	yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java
YunaiV 1 year ago
parent
commit
4d176c8494

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

@@ -8,6 +8,8 @@ import cn.iocoder.yudao.framework.common.util.io.IoUtils;
 import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*;
+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.BpmSimpleModelUpdateReqVO;
 import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert;
 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO;
 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
@@ -145,4 +147,21 @@ public class BpmModelController {
         return success(true);
     }
 
+    // ========== 仿钉钉/飞书的精简模型 =========
+
+    @GetMapping("/simple/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(modelService.getSimpleModel(modelId));
+    }
+
+    @PostMapping("/simple/update")
+    @Operation(summary = "保存仿钉钉流程设计模型")
+    @PreAuthorize("@ss.hasPermission('bpm:model:update')")
+    public CommonResult<Boolean> updateSimpleModel(@Valid @RequestBody BpmSimpleModelUpdateReqVO reqVO) {
+        modelService.updateSimpleModel(reqVO);
+        return success(Boolean.TRUE);
+    }
+
 }

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

@@ -1,39 +0,0 @@
-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 @jason:融合到 BpmModelController 中,url 是 /bpm/model/simple/... 这样,通过一个子目录区分;目的是:逻辑更聚焦!
-@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));
-    }
-
-}

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

@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.simple;
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple;
 
 import cn.iocoder.yudao.framework.common.validation.InEnum;
 import cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModelNodeType;

+ 2 - 3
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/simple/BpmSimpleModelSaveReqVO.java → yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelUpdateReqVO.java

@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.simple;
+package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple;
 
 import io.swagger.v3.oas.annotations.media.Schema;
 import jakarta.validation.Valid;
@@ -6,10 +6,9 @@ import jakarta.validation.constraints.NotEmpty;
 import jakarta.validation.constraints.NotNull;
 import lombok.Data;
 
-// TODO @芋艿:或许挪到 model 里的 simple 包
 @Schema(description = "管理后台 - 仿钉钉流程设计模型的新增/修改 Request VO")
 @Data
-public class BpmSimpleModelSaveReqVO {
+public class BpmSimpleModelUpdateReqVO {
 
     @Schema(description = "流程模型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
     @NotEmpty(message = "流程模型编号不能为空")

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

@@ -7,7 +7,7 @@ import cn.hutool.core.lang.TypeReference;
 import cn.hutool.core.map.MapUtil;
 import cn.hutool.core.util.*;
 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
-import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.simple.BpmSimpleModelNodeVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO;
 import cn.iocoder.yudao.module.bpm.enums.definition.BpmApproveMethodEnum;
 import cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModeConditionType;
 import cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModelNodeType;

+ 22 - 6
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java

@@ -1,7 +1,11 @@
 package cn.iocoder.yudao.module.bpm.service.definition;
 
 import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.*;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelCreateReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelPageReqVO;
+import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelUpdateReqVO;
+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.BpmSimpleModelUpdateReqVO;
 import jakarta.validation.Valid;
 import org.flowable.bpmn.model.BpmnModel;
 import org.flowable.engine.repository.Model;
@@ -49,7 +53,7 @@ public interface BpmModelService {
     /**
      * 保存流程模型的 BPMN XML
      *
-     * @param id 编号
+     * @param id       编号
      * @param xmlBytes BPMN XML bytes
      */
     // TODO @芋艿:感觉可以不修改这个方法,而是额外加一个方法;传入 id,bpmn,json;
@@ -57,6 +61,7 @@ public interface BpmModelService {
 
     /**
      * 获得仿钉钉快搭模型的 JSON 数据
+     *
      * @param id 编号
      * @return JSON bytes
      */
@@ -64,7 +69,8 @@ public interface BpmModelService {
 
     /**
      * 保存仿钉钉快搭模型的 JSON 数据
-     * @param id 编号
+     *
+     * @param id        编号
      * @param jsonBytes JSON bytes
      */
     void saveModelSimpleJson(String id, byte[] jsonBytes);
@@ -108,10 +114,20 @@ public interface BpmModelService {
 
     // ========== 仿钉钉/飞书的精简模型 =========
 
-    // TODO @jason:使用 ========== 仿钉钉/飞书的精简模型 ========= 分隔下;把相关的 controller、service 懂合并了;另外,vo 可以挪到 model/simple 这样的形式;
+    /**
+     * 获取仿钉钉流程设计模型结构
+     *
+     * @param modelId 流程模型编号
+     * @return 仿钉钉流程设计模型结构
+     */
+    BpmSimpleModelNodeVO getSimpleModel(String modelId);
 
-    // TODO @jason:BpmSimpleModelServiceImpl 迁移到这里,搞成 updateSimpleModel(BpmSimpleModelUpdateReqVO reqVO)
-    // TODO @jason:BpmSimpleModelServiceImpl 迁移到这里,搞成 getSimpleModel;
+    /**
+     * 更新仿钉钉流程设计模型
+     *
+     * @param reqVO 请求信息
+     */
+    void updateSimpleModel(@Valid BpmSimpleModelUpdateReqVO reqVO);
 
     // TODO @jason:另外个问题,因为是存储到 modelExtra 里,那需要 deploy 存储出快照。和 bpmn xml 一样。目前我想到的,就是存储到 BpmProcessDefinitionInfoDO 加一个 simple_model 字段,text 类型。可以看看还有啥方案?
 

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

@@ -9,12 +9,15 @@ import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelCreateReqVO;
 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelPageReqVO;
 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelUpdateReqVO;
+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.BpmSimpleModelUpdateReqVO;
 import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert;
 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
 import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum;
 import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCandidateInvoker;
 import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
 import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
+import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.SimpleModelUtils;
 import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO;
 import jakarta.annotation.Resource;
 import jakarta.validation.Valid;
@@ -209,6 +212,33 @@ public class BpmModelServiceImpl implements BpmModelService {
         return repositoryService.getBpmnModel(processDefinitionId);
     }
 
+    @Override
+    public BpmSimpleModelNodeVO getSimpleModel(String modelId) {
+        Model model = getModel(modelId);
+        if (model == null) {
+            throw exception(MODEL_NOT_EXISTS);
+        }
+        // 通过 ACT_RE_MODEL 表 EDITOR_SOURCE_EXTRA_VALUE_ID_  获取 仿钉钉快搭模型的JSON 数据
+        byte[] jsonBytes = getModelSimpleJson(model.getId());
+        return JsonUtils.parseObject(jsonBytes, BpmSimpleModelNodeVO.class);
+    }
+
+    @Override
+    public void updateSimpleModel(BpmSimpleModelUpdateReqVO reqVO) {
+        // 1.1 校验流程模型存在
+        Model model = getModel(reqVO.getModelId());
+        if (model == null) {
+            throw exception(MODEL_NOT_EXISTS);
+        }
+        // 1.2 JSON 转换成 bpmnModel
+        BpmnModel bpmnModel = SimpleModelUtils.convertSimpleModelToBpmnModel(model.getKey(), model.getName(), reqVO.getSimpleModelBody());
+        // 2.1 保存 Bpmn XML
+        saveModelBpmnXml(model.getId(), StrUtil.utf8Bytes(BpmnModelUtils.getBpmnXml(bpmnModel)));
+        // 2.2 保存 JSON 数据
+        saveModelSimpleJson(model.getId(), JsonUtils.toJsonByte(reqVO.getSimpleModelBody()));
+    }
+
+
     /**
      * 校验流程表单已配置
      *

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

@@ -1,29 +0,0 @@
-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);
-
-}

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

@@ -1,60 +0,0 @@
-package cn.iocoder.yudao.module.bpm.service.definition;
-
-import cn.hutool.core.util.StrUtil;
-import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
-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.framework.flowable.core.util.BpmnModelUtils;
-import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.SimpleModelUtils;
-import jakarta.annotation.Resource;
-import org.flowable.bpmn.model.BpmnModel;
-import org.flowable.engine.repository.Model;
-import org.springframework.stereotype.Service;
-import org.springframework.validation.annotation.Validated;
-
-import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
-import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.MODEL_NOT_EXISTS;
-
-// TODO @jason:这块可以讨论下,是不是合并成一个 BpmnModelServiceImpl
-/**
- * 仿钉钉流程设计 Service 实现类
- *
- * @author jason
- */
-@Service
-@Validated
-public class BpmSimpleModelServiceImpl implements BpmSimpleModelService {
-
-    @Resource
-    private BpmModelService bpmModelService;
-
-    @Override
-    public Boolean saveSimpleModel(BpmSimpleModelSaveReqVO reqVO) {
-        // 1.1 校验流程模型存在
-        Model model = bpmModelService.getModel(reqVO.getModelId());
-        if (model == null) {
-            throw exception(MODEL_NOT_EXISTS);
-        }
-
-        // 1. JSON 转换成 bpmnModel
-        BpmnModel bpmnModel = SimpleModelUtils.convertSimpleModelToBpmnModel(model.getKey(), model.getName(), reqVO.getSimpleModelBody());
-        // 2.1 保存 Bpmn XML
-        bpmModelService.saveModelBpmnXml(model.getId(), StrUtil.utf8Bytes(BpmnModelUtils.getBpmnXml(bpmnModel)));
-        // 2.2 保存 JSON 数据
-        bpmModelService.saveModelSimpleJson(model.getId(), JsonUtils.toJsonByte(reqVO.getSimpleModelBody()));
-        return Boolean.TRUE;
-    }
-
-    @Override
-    public BpmSimpleModelNodeVO getSimpleModel(String modelId) {
-        Model model = bpmModelService.getModel(modelId);
-        if (model == null) {
-            throw exception(MODEL_NOT_EXISTS);
-        }
-        // 暂时不用 bpmn 转 json, 有点复杂,
-        // 通过 ACT_RE_MODEL 表 EDITOR_SOURCE_EXTRA_VALUE_ID_  获取 仿钉钉快搭模型的JSON 数据
-        byte[] jsonBytes = bpmModelService.getModelSimpleJson(model.getId());
-        return JsonUtils.parseObject(jsonBytes, BpmSimpleModelNodeVO.class);
-    }
-
-}