Commit ff6bee964b5622e2e0184726f1aa59efc58b6b73

Authored by YunaiV
1 parent c26862f3

【功能新增】工作流:BPM Model 增加 type 标记是 BPMN 设计器,还是 SIMPLE 钉钉设计器

Showing 17 changed files with 229 additions and 248 deletions
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/object/BeanUtils.java
@@ -59,4 +59,11 @@ public class BeanUtils { @@ -59,4 +59,11 @@ public class BeanUtils {
59 return new PageResult<>(list, source.getTotal()); 59 return new PageResult<>(list, source.getTotal());
60 } 60 }
61 61
  62 + public static void copyProperties(Object source, Object target) {
  63 + if (source == null || target == null) {
  64 + return;
  65 + }
  66 + BeanUtil.copyProperties(source, target, false);
  67 + }
  68 +
62 } 69 }
63 \ No newline at end of file 70 \ No newline at end of file
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmModelTypeEnum.java 0 → 100644
  1 +package cn.iocoder.yudao.module.bpm.enums.definition;
  2 +
  3 +import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
  4 +import lombok.AllArgsConstructor;
  5 +import lombok.Getter;
  6 +
  7 +import java.util.Arrays;
  8 +
  9 +/**
  10 + * BPM 模型的类型的枚举
  11 + *
  12 + * @author 芋道源码
  13 + */
  14 +@Getter
  15 +@AllArgsConstructor
  16 +public enum BpmModelTypeEnum implements IntArrayValuable {
  17 +
  18 + BPMN(10, "BPMN 设计器"), // https://bpmn.io/toolkit/bpmn-js/
  19 + SIMPLE(20, "SIMPLE 设计器"); // 参考钉钉、飞书工作流的设计器
  20 +
  21 + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BpmModelTypeEnum::getType).toArray();
  22 +
  23 + private final Integer type;
  24 + private final String name;
  25 +
  26 + @Override
  27 + public int[] array() {
  28 + return ARRAYS;
  29 + }
  30 +
  31 +}
0 \ No newline at end of file 32 \ No newline at end of file
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmModelController.java
@@ -15,7 +15,6 @@ import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryService; @@ -15,7 +15,6 @@ import cn.iocoder.yudao.module.bpm.service.definition.BpmCategoryService;
15 import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService; 15 import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService;
16 import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService; 16 import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService;
17 import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; 17 import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService;
18 -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO;  
19 import io.swagger.v3.oas.annotations.Operation; 18 import io.swagger.v3.oas.annotations.Operation;
20 import io.swagger.v3.oas.annotations.Parameter; 19 import io.swagger.v3.oas.annotations.Parameter;
21 import io.swagger.v3.oas.annotations.tags.Tag; 20 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -63,7 +62,7 @@ public class BpmModelController { @@ -63,7 +62,7 @@ public class BpmModelController {
63 // 拼接数据 62 // 拼接数据
64 // 获得 Form 表单 63 // 获得 Form 表单
65 Set<Long> formIds = convertSet(pageResult.getList(), model -> { 64 Set<Long> formIds = convertSet(pageResult.getList(), model -> {
66 - BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); 65 + BpmModelMetaInfoVO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoVO.class);
67 return metaInfo != null ? metaInfo.getFormId() : null; 66 return metaInfo != null ? metaInfo.getFormId() : null;
68 }); 67 });
69 Map<Long, BpmFormDO> formMap = formService.getFormMap(formIds); 68 Map<Long, BpmFormDO> formMap = formService.getFormMap(formIds);
@@ -96,14 +95,14 @@ public class BpmModelController { @@ -96,14 +95,14 @@ public class BpmModelController {
96 @PostMapping("/create") 95 @PostMapping("/create")
97 @Operation(summary = "新建模型") 96 @Operation(summary = "新建模型")
98 @PreAuthorize("@ss.hasPermission('bpm:model:create')") 97 @PreAuthorize("@ss.hasPermission('bpm:model:create')")
99 - public CommonResult<String> createModel(@Valid @RequestBody BpmModelCreateReqVO createRetVO) { 98 + public CommonResult<String> createModel(@Valid @RequestBody BpmModelSaveReqVO createRetVO) {
100 return success(modelService.createModel(createRetVO)); 99 return success(modelService.createModel(createRetVO));
101 } 100 }
102 101
103 @PutMapping("/update") 102 @PutMapping("/update")
104 @Operation(summary = "修改模型") 103 @Operation(summary = "修改模型")
105 @PreAuthorize("@ss.hasPermission('bpm:model:update')") 104 @PreAuthorize("@ss.hasPermission('bpm:model:update')")
106 - public CommonResult<Boolean> updateModel(@Valid @RequestBody BpmModelUpdateReqVO modelVO) { 105 + public CommonResult<Boolean> updateModel(@Valid @RequestBody BpmModelSaveReqVO modelVO) {
107 modelService.updateModel(modelVO); 106 modelService.updateModel(modelVO);
108 return success(true); 107 return success(true);
109 } 108 }
@@ -125,6 +124,14 @@ public class BpmModelController { @@ -125,6 +124,14 @@ public class BpmModelController {
125 return success(true); 124 return success(true);
126 } 125 }
127 126
  127 + @PutMapping("/update-bpmn")
  128 + @Operation(summary = "修改模型的 BPMN")
  129 + @PreAuthorize("@ss.hasPermission('bpm:model:update')")
  130 + public CommonResult<Boolean> updateModelBpmn(@Valid @RequestBody BpmModeUpdateBpmnReqVO reqVO) {
  131 + modelService.updateModelBpmnXml(reqVO.getId(), reqVO.getBpmnXml());
  132 + return success(true);
  133 + }
  134 +
128 @DeleteMapping("/delete") 135 @DeleteMapping("/delete")
129 @Operation(summary = "删除模型") 136 @Operation(summary = "删除模型")
130 @Parameter(name = "id", description = "编号", required = true, example = "1024") 137 @Parameter(name = "id", description = "编号", required = true, example = "1024")
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmProcessDefinitionController.java
@@ -79,14 +79,20 @@ public class BpmProcessDefinitionController { @@ -79,14 +79,20 @@ public class BpmProcessDefinitionController {
79 @Parameter(name = "suspensionState", description = "挂起状态", required = true, example = "1") // 参见 Flowable SuspensionState 枚举 79 @Parameter(name = "suspensionState", description = "挂起状态", required = true, example = "1") // 参见 Flowable SuspensionState 枚举
80 public CommonResult<List<BpmProcessDefinitionRespVO>> getProcessDefinitionList( 80 public CommonResult<List<BpmProcessDefinitionRespVO>> getProcessDefinitionList(
81 @RequestParam("suspensionState") Integer suspensionState) { 81 @RequestParam("suspensionState") Integer suspensionState) {
  82 + // 1.1 获得开启的流程定义
82 List<ProcessDefinition> list = processDefinitionService.getProcessDefinitionListBySuspensionState(suspensionState); 83 List<ProcessDefinition> list = processDefinitionService.getProcessDefinitionListBySuspensionState(suspensionState);
83 if (CollUtil.isEmpty(list)) { 84 if (CollUtil.isEmpty(list)) {
84 return success(Collections.emptyList()); 85 return success(Collections.emptyList());
85 } 86 }
86 -  
87 - // 获得 BpmProcessDefinitionInfoDO Map 87 + // 1.2 移除不可见的流程定义
88 Map<String, BpmProcessDefinitionInfoDO> processDefinitionMap = processDefinitionService.getProcessDefinitionInfoMap( 88 Map<String, BpmProcessDefinitionInfoDO> processDefinitionMap = processDefinitionService.getProcessDefinitionInfoMap(
89 convertSet(list, ProcessDefinition::getId)); 89 convertSet(list, ProcessDefinition::getId));
  90 + list.removeIf(processDefinition -> {
  91 + BpmProcessDefinitionInfoDO processDefinitionInfo = processDefinitionMap.get(processDefinition.getId());
  92 + return processDefinitionInfo != null && Boolean.FALSE.equals(processDefinitionInfo.getVisible());
  93 + });
  94 +
  95 + // 2. 拼接 VO 返回
90 return success(BpmProcessDefinitionConvert.INSTANCE.buildProcessDefinitionList( 96 return success(BpmProcessDefinitionConvert.INSTANCE.buildProcessDefinitionList(
91 list, null, processDefinitionMap, null, null)); 97 list, null, processDefinitionMap, null, null));
92 } 98 }
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModeImportReqVO.java deleted
1 -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;  
2 -  
3 -import io.swagger.v3.oas.annotations.media.Schema;  
4 -import lombok.Data;  
5 -import lombok.EqualsAndHashCode;  
6 -import lombok.ToString;  
7 -import org.springframework.web.multipart.MultipartFile;  
8 -  
9 -import jakarta.validation.constraints.NotNull;  
10 -  
11 -@Schema(description = "管理后台 - 流程模型的导入 Request VO 相比流程模型的新建来说,只是多了一个 bpmnFile 文件")  
12 -@Data  
13 -public class BpmModeImportReqVO extends BpmModelCreateReqVO {  
14 -  
15 - @Schema(description = "BPMN 文件", requiredMode = Schema.RequiredMode.REQUIRED)  
16 - @NotNull(message = "BPMN 文件不能为空")  
17 - private MultipartFile bpmnFile;  
18 -  
19 -}  
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModeUpdateBpmnReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import jakarta.validation.constraints.NotEmpty;
  5 +import lombok.Data;
  6 +
  7 +@Schema(description = "管理后台 - 流程模型的更新 BPMN XML Request VO")
  8 +@Data
  9 +public class BpmModeUpdateBpmnReqVO {
  10 +
  11 + @Schema(description = "流程编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  12 + @NotEmpty(message = "流程编号不能为空")
  13 + private String id;
  14 +
  15 + @Schema(description = "BPMN XML", requiredMode = Schema.RequiredMode.REQUIRED)
  16 + @NotEmpty(message = "BPMN XML 不能为空")
  17 + private String bpmnXml;
  18 +
  19 +}
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelMetaInfoVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
  2 +
  3 +import cn.iocoder.yudao.framework.common.validation.InEnum;
  4 +import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum;
  5 +import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelTypeEnum;
  6 +import io.swagger.v3.oas.annotations.media.Schema;
  7 +import jakarta.validation.constraints.NotEmpty;
  8 +import jakarta.validation.constraints.NotNull;
  9 +import lombok.Data;
  10 +import org.hibernate.validator.constraints.URL;
  11 +
  12 +/**
  13 + * BPM 流程 MetaInfo Response DTO
  14 + * 主要用于 { Model#setMetaInfo(String)} 的存储
  15 + *
  16 + * 最终,它的字段和 {@link cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO} 是一致的
  17 + *
  18 + * @author 芋道源码
  19 + */
  20 +@Data
  21 +public class BpmModelMetaInfoVO {
  22 +
  23 + @Schema(description = "流程图标", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn/yudao.jpg")
  24 + @NotEmpty(message = "流程图标不能为空")
  25 + @URL(message = "流程图标格式不正确")
  26 + private String icon;
  27 +
  28 + @Schema(description = "流程描述", example = "我是描述")
  29 + private String description;
  30 +
  31 + @Schema(description = "流程类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
  32 + @InEnum(BpmModelTypeEnum.class)
  33 + @NotNull(message = "流程类型不能为空")
  34 + private Integer type;
  35 +
  36 + @Schema(description = "表单类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
  37 + @InEnum(BpmModelFormTypeEnum.class)
  38 + @NotNull(message = "表单类型不能为空")
  39 + private Integer formType;
  40 + @Schema(description = "表单编号", example = "1024")
  41 + private Long formId; // formType 为 NORMAL 使用,必须非空
  42 + @Schema(description = "自定义表单的提交路径,使用 Vue 的路由地址",
  43 + example = "/bpm/oa/leave/create")
  44 + private String formCustomCreatePath; // 表单类型为 CUSTOM 时,必须非空
  45 + @Schema(description = "自定义表单的查看路径,使用 Vue 的路由地址",
  46 + example = "/bpm/oa/leave/view")
  47 + private String formCustomViewPath; // 表单类型为 CUSTOM 时,必须非空
  48 +
  49 + @Schema(description = "是否可见", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
  50 + @NotNull(message = "是否可见不能为空")
  51 + private Boolean visible;
  52 +
  53 +}
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelRespVO.java
@@ -8,7 +8,7 @@ import java.time.LocalDateTime; @@ -8,7 +8,7 @@ import java.time.LocalDateTime;
8 8
9 @Schema(description = "管理后台 - 流程模型 Response VO") 9 @Schema(description = "管理后台 - 流程模型 Response VO")
10 @Data 10 @Data
11 -public class BpmModelRespVO { 11 +public class BpmModelRespVO extends BpmModelMetaInfoVO {
12 12
13 @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") 13 @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
14 private String id; 14 private String id;
@@ -22,27 +22,14 @@ public class BpmModelRespVO { @@ -22,27 +22,14 @@ public class BpmModelRespVO {
22 @Schema(description = "流程图标", example = "https://www.iocoder.cn/yudao.jpg") 22 @Schema(description = "流程图标", example = "https://www.iocoder.cn/yudao.jpg")
23 private String icon; 23 private String icon;
24 24
25 - @Schema(description = "流程描述", example = "我是描述")  
26 - private String description;  
27 -  
28 @Schema(description = "流程分类编码", example = "1") 25 @Schema(description = "流程分类编码", example = "1")
29 private String category; 26 private String category;
30 @Schema(description = "流程分类名字", example = "请假") 27 @Schema(description = "流程分类名字", example = "请假")
31 private String categoryName; 28 private String categoryName;
32 29
33 - @Schema(description = "表单类型-参见 bpm_model_form_type 数据字典", example = "1")  
34 - private Integer formType;  
35 -  
36 - @Schema(description = "表单编号", example = "1024")  
37 - private Long formId; // 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空  
38 @Schema(description = "表单名字", example = "请假表单") 30 @Schema(description = "表单名字", example = "请假表单")
39 private String formName; 31 private String formName;
40 32
41 - @Schema(description = "自定义表单的提交路径", example = "/bpm/oa/leave/create")  
42 - private String formCustomCreatePath; // 使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空  
43 - @Schema(description = "自定义表单的查看路径", example = "/bpm/oa/leave/view")  
44 - private String formCustomViewPath; // ,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空  
45 -  
46 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) 33 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
47 private LocalDateTime createTime; 34 private LocalDateTime createTime;
48 35
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelCreateReqVO.java renamed to yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelSaveReqVO.java
1 package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; 1 package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;
2 2
3 import io.swagger.v3.oas.annotations.media.Schema; 3 import io.swagger.v3.oas.annotations.media.Schema;
4 -import lombok.Data;  
5 -import lombok.EqualsAndHashCode;  
6 -import lombok.ToString;  
7 -  
8 import jakarta.validation.constraints.NotEmpty; 4 import jakarta.validation.constraints.NotEmpty;
  5 +import lombok.Data;
9 6
10 -@Schema(description = "管理后台 - 流程模型的创建 Request VO") 7 +@Schema(description = "管理后台 - 流程模型的保存 Request VO")
11 @Data 8 @Data
12 -public class BpmModelCreateReqVO { 9 +public class BpmModelSaveReqVO extends BpmModelMetaInfoVO {
  10 +
  11 + @Schema(description = "编号", example = "1024")
  12 + private String id;
13 13
14 @Schema(description = "流程标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "process_yudao") 14 @Schema(description = "流程标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "process_yudao")
15 @NotEmpty(message = "流程标识不能为空") 15 @NotEmpty(message = "流程标识不能为空")
@@ -19,7 +19,7 @@ public class BpmModelCreateReqVO { @@ -19,7 +19,7 @@ public class BpmModelCreateReqVO {
19 @NotEmpty(message = "流程名称不能为空") 19 @NotEmpty(message = "流程名称不能为空")
20 private String name; 20 private String name;
21 21
22 - @Schema(description = "流程描述", example = "我是描述")  
23 - private String description; 22 + @Schema(description = "流程分类", example = "1")
  23 + private String category;
24 24
25 } 25 }
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelUpdateReqVO.java deleted
1 -package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model;  
2 -  
3 -import cn.iocoder.yudao.framework.common.validation.InEnum;  
4 -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum;  
5 -import io.swagger.v3.oas.annotations.media.Schema;  
6 -import jakarta.validation.constraints.NotEmpty;  
7 -import lombok.Data;  
8 -import org.hibernate.validator.constraints.URL;  
9 -  
10 -@Schema(description = "管理后台 - 流程模型的更新 Request VO")  
11 -@Data  
12 -public class BpmModelUpdateReqVO {  
13 -  
14 - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")  
15 - @NotEmpty(message = "编号不能为空")  
16 - private String id;  
17 -  
18 - @Schema(description = "流程名称", example = "芋道")  
19 - private String name;  
20 -  
21 - @Schema(description = "流程图标", example = "https://www.iocoder.cn/yudao.jpg")  
22 - @URL(message = "流程图标格式不正确")  
23 - private String icon;  
24 -  
25 - @Schema(description = "流程描述", example = "我是描述")  
26 - private String description;  
27 -  
28 - @Schema(description = "流程分类", example = "1")  
29 - private String category;  
30 -  
31 - @Schema(description = "BPMN XML", requiredMode = Schema.RequiredMode.REQUIRED)  
32 - private String bpmnXml;  
33 -  
34 - @Schema(description = "表单类型-参见 bpm_model_form_type 数据字典", example = "1")  
35 - @InEnum(BpmModelFormTypeEnum.class)  
36 - private Integer formType;  
37 - @Schema(description = "表单编号-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空", example = "1024")  
38 - private Long formId;  
39 - @Schema(description = "自定义表单的提交路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空",  
40 - example = "/bpm/oa/leave/create")  
41 - private String formCustomCreatePath;  
42 - @Schema(description = "自定义表单的查看路径,使用 Vue 的路由地址-在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时,必须非空",  
43 - example = "/bpm/oa/leave/view")  
44 - private String formCustomViewPath;  
45 -  
46 -}  
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/definition/BpmModelConvert.java
1 package cn.iocoder.yudao.module.bpm.convert.definition; 1 package cn.iocoder.yudao.module.bpm.convert.definition;
2 2
3 import cn.hutool.core.util.ArrayUtil; 3 import cn.hutool.core.util.ArrayUtil;
4 -import cn.hutool.core.util.StrUtil;  
5 import cn.iocoder.yudao.framework.common.pojo.PageResult; 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; 5 import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
7 import cn.iocoder.yudao.framework.common.util.date.DateUtils; 6 import cn.iocoder.yudao.framework.common.util.date.DateUtils;
8 import cn.iocoder.yudao.framework.common.util.json.JsonUtils; 7 import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
9 import cn.iocoder.yudao.framework.common.util.object.BeanUtils; 8 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
10 -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelCreateReqVO;  
11 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelRespVO; 9 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelRespVO;
12 -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelUpdateReqVO; 10 +import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelSaveReqVO;
13 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; 11 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO;
14 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; 12 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO;
15 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; 13 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
16 -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; 14 +import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelMetaInfoVO;
17 import org.flowable.common.engine.impl.db.SuspensionState; 15 import org.flowable.common.engine.impl.db.SuspensionState;
18 import org.flowable.engine.repository.Deployment; 16 import org.flowable.engine.repository.Deployment;
19 import org.flowable.engine.repository.Model; 17 import org.flowable.engine.repository.Model;
@@ -23,7 +21,6 @@ import org.mapstruct.factory.Mappers; @@ -23,7 +21,6 @@ import org.mapstruct.factory.Mappers;
23 21
24 import java.util.List; 22 import java.util.List;
25 import java.util.Map; 23 import java.util.Map;
26 -import java.util.Objects;  
27 24
28 /** 25 /**
29 * 流程模型 Convert 26 * 流程模型 Convert
@@ -40,7 +37,7 @@ public interface BpmModelConvert { @@ -40,7 +37,7 @@ public interface BpmModelConvert {
40 Map<String, BpmCategoryDO> categoryMap, Map<String, Deployment> deploymentMap, 37 Map<String, BpmCategoryDO> categoryMap, Map<String, Deployment> deploymentMap,
41 Map<String, ProcessDefinition> processDefinitionMap) { 38 Map<String, ProcessDefinition> processDefinitionMap) {
42 List<BpmModelRespVO> list = CollectionUtils.convertList(pageResult.getList(), model -> { 39 List<BpmModelRespVO> list = CollectionUtils.convertList(pageResult.getList(), model -> {
43 - BpmModelMetaInfoRespDTO metaInfo = buildMetaInfo(model); 40 + BpmModelMetaInfoVO metaInfo = buildMetaInfo(model);
44 BpmFormDO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null; 41 BpmFormDO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null;
45 BpmCategoryDO category = categoryMap.get(model.getCategory()); 42 BpmCategoryDO category = categoryMap.get(model.getCategory());
46 Deployment deployment = model.getDeploymentId() != null ? deploymentMap.get(model.getDeploymentId()) : null; 43 Deployment deployment = model.getDeploymentId() != null ? deploymentMap.get(model.getDeploymentId()) : null;
@@ -52,7 +49,7 @@ public interface BpmModelConvert { @@ -52,7 +49,7 @@ public interface BpmModelConvert {
52 49
53 default BpmModelRespVO buildModel(Model model, 50 default BpmModelRespVO buildModel(Model model,
54 byte[] bpmnBytes) { 51 byte[] bpmnBytes) {
55 - BpmModelMetaInfoRespDTO metaInfo = buildMetaInfo(model); 52 + BpmModelMetaInfoVO metaInfo = buildMetaInfo(model);
56 BpmModelRespVO modelVO = buildModel0(model, metaInfo, null, null, null, null); 53 BpmModelRespVO modelVO = buildModel0(model, metaInfo, null, null, null, null);
57 if (ArrayUtil.isNotEmpty(bpmnBytes)) { 54 if (ArrayUtil.isNotEmpty(bpmnBytes)) {
58 modelVO.setBpmnXml(new String(bpmnBytes)); 55 modelVO.setBpmnXml(new String(bpmnBytes));
@@ -61,20 +58,15 @@ public interface BpmModelConvert { @@ -61,20 +58,15 @@ public interface BpmModelConvert {
61 } 58 }
62 59
63 default BpmModelRespVO buildModel0(Model model, 60 default BpmModelRespVO buildModel0(Model model,
64 - BpmModelMetaInfoRespDTO metaInfo, BpmFormDO form, BpmCategoryDO category,  
65 - Deployment deployment, ProcessDefinition processDefinition) { 61 + BpmModelMetaInfoVO metaInfo, BpmFormDO form, BpmCategoryDO category,
  62 + Deployment deployment, ProcessDefinition processDefinition) {
66 BpmModelRespVO modelRespVO = new BpmModelRespVO().setId(model.getId()).setName(model.getName()) 63 BpmModelRespVO modelRespVO = new BpmModelRespVO().setId(model.getId()).setName(model.getName())
67 .setKey(model.getKey()).setCategory(model.getCategory()) 64 .setKey(model.getKey()).setCategory(model.getCategory())
68 .setCreateTime(DateUtils.of(model.getCreateTime())); 65 .setCreateTime(DateUtils.of(model.getCreateTime()));
69 // Form 66 // Form
70 - if (metaInfo != null) {  
71 - modelRespVO.setFormType(metaInfo.getFormType()).setFormId(metaInfo.getFormId())  
72 - .setFormCustomCreatePath(metaInfo.getFormCustomCreatePath())  
73 - .setFormCustomViewPath(metaInfo.getFormCustomViewPath());  
74 - modelRespVO.setIcon(metaInfo.getIcon()).setDescription(metaInfo.getDescription());  
75 - } 67 + BeanUtils.copyProperties(metaInfo, modelRespVO);
76 if (form != null) { 68 if (form != null) {
77 - modelRespVO.setFormId(form.getId()).setFormName(form.getName()); 69 + modelRespVO.setFormName(form.getName());
78 } 70 }
79 // Category 71 // Category
80 if (category != null) { 72 if (category != null) {
@@ -92,46 +84,15 @@ public interface BpmModelConvert { @@ -92,46 +84,15 @@ public interface BpmModelConvert {
92 return modelRespVO; 84 return modelRespVO;
93 } 85 }
94 86
95 - default void copyToCreateModel(Model model, BpmModelCreateReqVO bean) {  
96 - model.setName(bean.getName());  
97 - model.setKey(bean.getKey());  
98 - model.setMetaInfo(buildMetaInfoStr(null,  
99 - null, bean.getDescription(),  
100 - null, null, null, null));  
101 - }  
102 -  
103 - default void copyToUpdateModel(Model model, BpmModelUpdateReqVO bean) {  
104 - model.setName(bean.getName());  
105 - model.setCategory(bean.getCategory());  
106 - model.setMetaInfo(buildMetaInfoStr(buildMetaInfo(model),  
107 - bean.getIcon(), bean.getDescription(),  
108 - bean.getFormType(), bean.getFormId(), bean.getFormCustomCreatePath(), bean.getFormCustomViewPath()));  
109 - }  
110 -  
111 - default String buildMetaInfoStr(BpmModelMetaInfoRespDTO metaInfo,  
112 - String icon, String description,  
113 - Integer formType, Long formId, String formCustomCreatePath, String formCustomViewPath) {  
114 - if (metaInfo == null) {  
115 - metaInfo = new BpmModelMetaInfoRespDTO();  
116 - }  
117 - // 只有非空,才进行设置,避免更新时的覆盖  
118 - if (StrUtil.isNotEmpty(icon)) {  
119 - metaInfo.setIcon(icon);  
120 - }  
121 - if (StrUtil.isNotEmpty(description)) {  
122 - metaInfo.setDescription(description);  
123 - }  
124 - if (Objects.nonNull(formType)) {  
125 - metaInfo.setFormType(formType);  
126 - metaInfo.setFormId(formId);  
127 - metaInfo.setFormCustomCreatePath(formCustomCreatePath);  
128 - metaInfo.setFormCustomViewPath(formCustomViewPath);  
129 - }  
130 - return JsonUtils.toJsonString(metaInfo); 87 + default void copyToModel(Model model, BpmModelSaveReqVO reqVO) {
  88 + model.setName(reqVO.getName());
  89 + model.setKey(reqVO.getKey());
  90 + model.setCategory(reqVO.getCategory());
  91 + model.setMetaInfo(JsonUtils.toJsonString(BeanUtils.toBean(reqVO, BpmModelMetaInfoVO.class)));
131 } 92 }
132 93
133 - default BpmModelMetaInfoRespDTO buildMetaInfo(Model model) {  
134 - return JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); 94 + default BpmModelMetaInfoVO buildMetaInfo(Model model) {
  95 + return JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoVO.class);
135 } 96 }
136 97
137 } 98 }
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionInfoDO.java
@@ -6,7 +6,12 @@ import com.baomidou.mybatisplus.annotation.TableField; @@ -6,7 +6,12 @@ import com.baomidou.mybatisplus.annotation.TableField;
6 import com.baomidou.mybatisplus.annotation.TableId; 6 import com.baomidou.mybatisplus.annotation.TableId;
7 import com.baomidou.mybatisplus.annotation.TableName; 7 import com.baomidou.mybatisplus.annotation.TableName;
8 import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; 8 import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
9 -import lombok.*; 9 +import lombok.AllArgsConstructor;
  10 +import lombok.Builder;
  11 +import lombok.Data;
  12 +import lombok.NoArgsConstructor;
  13 +import org.flowable.engine.repository.Model;
  14 +import org.flowable.engine.repository.ProcessDefinition;
10 15
11 import java.util.List; 16 import java.util.List;
12 17
@@ -31,15 +36,21 @@ public class BpmProcessDefinitionInfoDO extends BaseDO { @@ -31,15 +36,21 @@ public class BpmProcessDefinitionInfoDO extends BaseDO {
31 /** 36 /**
32 * 流程定义的编号 37 * 流程定义的编号
33 * 38 *
34 - * 关联 ProcessDefinition 的 id 属性 39 + * 关联 {@link ProcessDefinition#getId()} 属性
35 */ 40 */
36 private String processDefinitionId; 41 private String processDefinitionId;
37 /** 42 /**
38 * 流程模型的编号 43 * 流程模型的编号
39 * 44 *
40 - * 关联 Model 的 id 属性 45 + * 关联 {@link Model#getId()} 属性
41 */ 46 */
42 private String modelId; 47 private String modelId;
  48 + /**
  49 + * 流程模型的类型
  50 + *
  51 + * 枚举 {@link BpmModelFormTypeEnum}
  52 + */
  53 + private Integer modelType;
43 54
44 /** 55 /**
45 * 图标 56 * 图标
@@ -53,11 +64,12 @@ public class BpmProcessDefinitionInfoDO extends BaseDO { @@ -53,11 +64,12 @@ public class BpmProcessDefinitionInfoDO extends BaseDO {
53 /** 64 /**
54 * 表单类型 65 * 表单类型
55 * 66 *
56 - * 关联 {@link BpmModelFormTypeEnum} 67 + * 枚举 {@link BpmModelFormTypeEnum}
57 */ 68 */
58 private Integer formType; 69 private Integer formType;
59 /** 70 /**
60 * 动态表单编号 71 * 动态表单编号
  72 + *
61 * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 73 * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时
62 * 74 *
63 * 关联 {@link BpmFormDO#getId()} 75 * 关联 {@link BpmFormDO#getId()}
@@ -65,6 +77,7 @@ public class BpmProcessDefinitionInfoDO extends BaseDO { @@ -65,6 +77,7 @@ public class BpmProcessDefinitionInfoDO extends BaseDO {
65 private Long formId; 77 private Long formId;
66 /** 78 /**
67 * 表单的配置 79 * 表单的配置
  80 + *
68 * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 81 * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时
69 * 82 *
70 * 冗余 {@link BpmFormDO#getConf()} 83 * 冗余 {@link BpmFormDO#getConf()}
@@ -72,21 +85,31 @@ public class BpmProcessDefinitionInfoDO extends BaseDO { @@ -72,21 +85,31 @@ public class BpmProcessDefinitionInfoDO extends BaseDO {
72 private String formConf; 85 private String formConf;
73 /** 86 /**
74 * 表单项的数组 87 * 表单项的数组
  88 + *
75 * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 89 * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时
76 * 90 *
77 - * 冗余 {@link BpmFormDO#getFields()} ()} 91 + * 冗余 {@link BpmFormDO#getFields()}
78 */ 92 */
79 @TableField(typeHandler = JacksonTypeHandler.class) 93 @TableField(typeHandler = JacksonTypeHandler.class)
80 private List<String> formFields; 94 private List<String> formFields;
81 /** 95 /**
82 * 自定义表单的提交路径,使用 Vue 的路由地址 96 * 自定义表单的提交路径,使用 Vue 的路由地址
  97 + *
83 * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 98 * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时
84 */ 99 */
85 private String formCustomCreatePath; 100 private String formCustomCreatePath;
86 /** 101 /**
87 * 自定义表单的查看路径,使用 Vue 的路由地址 102 * 自定义表单的查看路径,使用 Vue 的路由地址
  103 + *
88 * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 104 * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时
89 */ 105 */
90 private String formCustomViewPath; 106 private String formCustomViewPath;
91 107
  108 + /**
  109 + * 是否可见
  110 + *
  111 + * 目的:如果 false 不可见,则不展示在“发起流程”的列表里
  112 + */
  113 + private Boolean visible;
  114 +
92 } 115 }
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java
1 package cn.iocoder.yudao.module.bpm.service.definition; 1 package cn.iocoder.yudao.module.bpm.service.definition;
2 2
3 import cn.iocoder.yudao.framework.common.pojo.PageResult; 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelCreateReqVO;  
5 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelPageReqVO; 4 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelPageReqVO;
6 -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelUpdateReqVO; 5 +import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelSaveReqVO;
7 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO; 6 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO;
8 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelUpdateReqVO; 7 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelUpdateReqVO;
9 import jakarta.validation.Valid; 8 import jakarta.validation.Valid;
@@ -31,7 +30,7 @@ public interface BpmModelService { @@ -31,7 +30,7 @@ public interface BpmModelService {
31 * @param modelVO 创建信息 30 * @param modelVO 创建信息
32 * @return 创建的流程模型的编号 31 * @return 创建的流程模型的编号
33 */ 32 */
34 - String createModel(@Valid BpmModelCreateReqVO modelVO); 33 + String createModel(@Valid BpmModelSaveReqVO modelVO);
35 34
36 /** 35 /**
37 * 获得流程模块 36 * 获得流程模块
@@ -50,11 +49,19 @@ public interface BpmModelService { @@ -50,11 +49,19 @@ public interface BpmModelService {
50 byte[] getModelBpmnXML(String id); 49 byte[] getModelBpmnXML(String id);
51 50
52 /** 51 /**
  52 + * 修改流程模型的 BPMN XML
  53 + *
  54 + * @param id 编号
  55 + * @param bpmnXml BPMN XML
  56 + */
  57 + void updateModelBpmnXml(String id, String bpmnXml);
  58 +
  59 + /**
53 * 修改流程模型 60 * 修改流程模型
54 * 61 *
55 * @param updateReqVO 更新信息 62 * @param updateReqVO 更新信息
56 */ 63 */
57 - void updateModel(@Valid BpmModelUpdateReqVO updateReqVO); 64 + void updateModel(@Valid BpmModelSaveReqVO updateReqVO);
58 65
59 /** 66 /**
60 * 将流程模型,部署成一个流程定义 67 * 将流程模型,部署成一个流程定义
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java
@@ -6,9 +6,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -6,9 +6,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 import cn.iocoder.yudao.framework.common.util.json.JsonUtils; 6 import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
7 import cn.iocoder.yudao.framework.common.util.object.PageUtils; 7 import cn.iocoder.yudao.framework.common.util.object.PageUtils;
8 import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; 8 import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils;
9 -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelCreateReqVO;  
10 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelPageReqVO; 9 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelPageReqVO;
11 -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelUpdateReqVO; 10 +import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelSaveReqVO;
12 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO; 11 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO;
13 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelUpdateReqVO; 12 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelUpdateReqVO;
14 import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert; 13 import cn.iocoder.yudao.module.bpm.convert.definition.BpmModelConvert;
@@ -18,7 +17,7 @@ import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCand @@ -18,7 +17,7 @@ import cn.iocoder.yudao.module.bpm.framework.flowable.core.candidate.BpmTaskCand
18 import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils; 17 import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils;
19 import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; 18 import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
20 import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.SimpleModelUtils; 19 import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.SimpleModelUtils;
21 -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; 20 +import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelMetaInfoVO;
22 import jakarta.annotation.Resource; 21 import jakarta.annotation.Resource;
23 import jakarta.validation.Valid; 22 import jakarta.validation.Valid;
24 import lombok.extern.slf4j.Slf4j; 23 import lombok.extern.slf4j.Slf4j;
@@ -32,7 +31,6 @@ import org.flowable.engine.repository.ModelQuery; @@ -32,7 +31,6 @@ import org.flowable.engine.repository.ModelQuery;
32 import org.flowable.engine.repository.ProcessDefinition; 31 import org.flowable.engine.repository.ProcessDefinition;
33 import org.springframework.stereotype.Service; 32 import org.springframework.stereotype.Service;
34 import org.springframework.transaction.annotation.Transactional; 33 import org.springframework.transaction.annotation.Transactional;
35 -import org.springframework.util.ObjectUtils;  
36 import org.springframework.validation.annotation.Validated; 34 import org.springframework.validation.annotation.Validated;
37 35
38 import java.util.List; 36 import java.util.List;
@@ -90,55 +88,58 @@ public class BpmModelServiceImpl implements BpmModelService { @@ -90,55 +88,58 @@ public class BpmModelServiceImpl implements BpmModelService {
90 88
91 @Override 89 @Override
92 @Transactional(rollbackFor = Exception.class) 90 @Transactional(rollbackFor = Exception.class)
93 - public String createModel(@Valid BpmModelCreateReqVO createReqVO) { 91 + public String createModel(@Valid BpmModelSaveReqVO createReqVO) {
94 if (!ValidationUtils.isXmlNCName(createReqVO.getKey())) { 92 if (!ValidationUtils.isXmlNCName(createReqVO.getKey())) {
95 throw exception(MODEL_KEY_VALID); 93 throw exception(MODEL_KEY_VALID);
96 } 94 }
97 - // 校验流程标识已经存在 95 + // 1. 校验流程标识已经存在
98 Model keyModel = getModelByKey(createReqVO.getKey()); 96 Model keyModel = getModelByKey(createReqVO.getKey());
99 if (keyModel != null) { 97 if (keyModel != null) {
100 throw exception(MODEL_KEY_EXISTS, createReqVO.getKey()); 98 throw exception(MODEL_KEY_EXISTS, createReqVO.getKey());
101 } 99 }
102 100
103 - // 创建流程定义 101 + // 2.1 创建流程定义
104 Model model = repositoryService.newModel(); 102 Model model = repositoryService.newModel();
105 - BpmModelConvert.INSTANCE.copyToCreateModel(model, createReqVO); 103 + BpmModelConvert.INSTANCE.copyToModel(model, createReqVO);
106 model.setTenantId(FlowableUtils.getTenantId()); 104 model.setTenantId(FlowableUtils.getTenantId());
107 - // 保存流程定义 105 + // 2.2 保存流程定义
108 repositoryService.saveModel(model); 106 repositoryService.saveModel(model);
109 return model.getId(); 107 return model.getId();
110 } 108 }
111 109
112 @Override 110 @Override
113 @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务 111 @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务
114 - public void updateModel(@Valid BpmModelUpdateReqVO updateReqVO) {  
115 - // 校验流程模型存在  
116 - Model model = getModel(updateReqVO.getId());  
117 - if (model == null) {  
118 - throw exception(MODEL_NOT_EXISTS);  
119 - } 112 + public void updateModel(@Valid BpmModelSaveReqVO updateReqVO) {
  113 + // 1. 校验流程模型存在
  114 + Model model = validateModelExists(updateReqVO.getId());
120 115
121 // 修改流程定义 116 // 修改流程定义
122 - BpmModelConvert.INSTANCE.copyToUpdateModel(model, updateReqVO); 117 + BpmModelConvert.INSTANCE.copyToModel(model, updateReqVO);
123 // 更新模型 118 // 更新模型
124 repositoryService.saveModel(model); 119 repositoryService.saveModel(model);
125 - // 更新 BPMN XML  
126 - saveModelBpmnXml(model.getId(), updateReqVO.getBpmnXml());  
127 } 120 }
128 121
  122 + private Model validateModelExists(String id) {
  123 + Model model = repositoryService.getModel(id);
  124 + if (model == null) {
  125 + throw exception(MODEL_NOT_EXISTS);
  126 + }
  127 + return model;
  128 + }
  129 +
  130 +// // 更新 BPMN XML
  131 +// saveModelBpmnXml(model.getId(), updateReqVO.getBpmnXml());
  132 +
129 @Override 133 @Override
130 @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务 134 @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务
131 public void deployModel(String id) { 135 public void deployModel(String id) {
132 // 1.1 校验流程模型存在 136 // 1.1 校验流程模型存在
133 - Model model = getModel(id);  
134 - if (ObjectUtils.isEmpty(model)) {  
135 - throw exception(MODEL_NOT_EXISTS);  
136 - } 137 + Model model = validateModelExists(id);
137 // 1.2 校验流程图 138 // 1.2 校验流程图
138 byte[] bpmnBytes = getModelBpmnXML(model.getId()); 139 byte[] bpmnBytes = getModelBpmnXML(model.getId());
139 validateBpmnXml(bpmnBytes); 140 validateBpmnXml(bpmnBytes);
140 // 1.3 校验表单已配 141 // 1.3 校验表单已配
141 - BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); 142 + BpmModelMetaInfoVO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoVO.class);
142 BpmFormDO form = validateFormConfig(metaInfo); 143 BpmFormDO form = validateFormConfig(metaInfo);
143 // 1.4 校验任务分配规则已配置 144 // 1.4 校验任务分配规则已配置
144 taskCandidateInvoker.validateBpmnConfig(bpmnBytes); 145 taskCandidateInvoker.validateBpmnConfig(bpmnBytes);
@@ -178,10 +179,8 @@ public class BpmModelServiceImpl implements BpmModelService { @@ -178,10 +179,8 @@ public class BpmModelServiceImpl implements BpmModelService {
178 @Transactional(rollbackFor = Exception.class) 179 @Transactional(rollbackFor = Exception.class)
179 public void deleteModel(String id) { 180 public void deleteModel(String id) {
180 // 校验流程模型存在 181 // 校验流程模型存在
181 - Model model = getModel(id);  
182 - if (model == null) {  
183 - throw exception(MODEL_NOT_EXISTS);  
184 - } 182 + Model model = validateModelExists(id);
  183 +
185 // 执行删除 184 // 执行删除
186 repositoryService.deleteModel(id); 185 repositoryService.deleteModel(id);
187 // 禁用流程定义 186 // 禁用流程定义
@@ -191,10 +190,7 @@ public class BpmModelServiceImpl implements BpmModelService { @@ -191,10 +190,7 @@ public class BpmModelServiceImpl implements BpmModelService {
191 @Override 190 @Override
192 public void updateModelState(String id, Integer state) { 191 public void updateModelState(String id, Integer state) {
193 // 1.1 校验流程模型存在 192 // 1.1 校验流程模型存在
194 - Model model = getModel(id);  
195 - if (model == null) {  
196 - throw exception(MODEL_NOT_EXISTS);  
197 - } 193 + Model model = validateModelExists(id);
198 // 1.2 校验流程定义存在 194 // 1.2 校验流程定义存在
199 ProcessDefinition definition = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId()); 195 ProcessDefinition definition = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId());
200 if (definition == null) { 196 if (definition == null) {
@@ -212,10 +208,7 @@ public class BpmModelServiceImpl implements BpmModelService { @@ -212,10 +208,7 @@ public class BpmModelServiceImpl implements BpmModelService {
212 208
213 @Override 209 @Override
214 public BpmSimpleModelNodeVO getSimpleModel(String modelId) { 210 public BpmSimpleModelNodeVO getSimpleModel(String modelId) {
215 - Model model = getModel(modelId);  
216 - if (model == null) {  
217 - throw exception(MODEL_NOT_EXISTS);  
218 - } 211 + Model model = validateModelExists(modelId);
219 // 通过 ACT_RE_MODEL 表 EDITOR_SOURCE_EXTRA_VALUE_ID_ ,获取仿钉钉快搭模型的 JSON 数据 212 // 通过 ACT_RE_MODEL 表 EDITOR_SOURCE_EXTRA_VALUE_ID_ ,获取仿钉钉快搭模型的 JSON 数据
220 byte[] jsonBytes = getModelSimpleJson(model.getId()); 213 byte[] jsonBytes = getModelSimpleJson(model.getId());
221 return JsonUtils.parseObject(jsonBytes, BpmSimpleModelNodeVO.class); 214 return JsonUtils.parseObject(jsonBytes, BpmSimpleModelNodeVO.class);
@@ -224,15 +217,12 @@ public class BpmModelServiceImpl implements BpmModelService { @@ -224,15 +217,12 @@ public class BpmModelServiceImpl implements BpmModelService {
224 @Override 217 @Override
225 public void updateSimpleModel(BpmSimpleModelUpdateReqVO reqVO) { 218 public void updateSimpleModel(BpmSimpleModelUpdateReqVO reqVO) {
226 // 1. 校验流程模型存在 219 // 1. 校验流程模型存在
227 - Model model = getModel(reqVO.getId());  
228 - if (model == null) {  
229 - throw exception(MODEL_NOT_EXISTS);  
230 - } 220 + Model model = validateModelExists(reqVO.getId());
231 221
232 // 2.1 JSON 转换成 bpmnModel 222 // 2.1 JSON 转换成 bpmnModel
233 BpmnModel bpmnModel = SimpleModelUtils.buildBpmnModel(model.getKey(), model.getName(), reqVO.getSimpleModel()); 223 BpmnModel bpmnModel = SimpleModelUtils.buildBpmnModel(model.getKey(), model.getName(), reqVO.getSimpleModel());
234 // 2.2 保存 Bpmn XML 224 // 2.2 保存 Bpmn XML
235 - saveModelBpmnXml(model.getId(), BpmnModelUtils.getBpmnXml(bpmnModel)); 225 + updateModelBpmnXml(model.getId(), BpmnModelUtils.getBpmnXml(bpmnModel));
236 // 2.3 保存 JSON 数据 226 // 2.3 保存 JSON 数据
237 saveModelSimpleJson(model.getId(), JsonUtils.toJsonByte(reqVO.getSimpleModel())); 227 saveModelSimpleJson(model.getId(), JsonUtils.toJsonByte(reqVO.getSimpleModel()));
238 } 228 }
@@ -243,7 +233,7 @@ public class BpmModelServiceImpl implements BpmModelService { @@ -243,7 +233,7 @@ public class BpmModelServiceImpl implements BpmModelService {
243 * @param metaInfo 流程模型元数据 233 * @param metaInfo 流程模型元数据
244 * @return 表单配置 234 * @return 表单配置
245 */ 235 */
246 - private BpmFormDO validateFormConfig(BpmModelMetaInfoRespDTO metaInfo) { 236 + private BpmFormDO validateFormConfig(BpmModelMetaInfoVO metaInfo) {
247 if (metaInfo == null || metaInfo.getFormType() == null) { 237 if (metaInfo == null || metaInfo.getFormType() == null) {
248 throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG); 238 throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG);
249 } 239 }
@@ -265,7 +255,8 @@ public class BpmModelServiceImpl implements BpmModelService { @@ -265,7 +255,8 @@ public class BpmModelServiceImpl implements BpmModelService {
265 } 255 }
266 } 256 }
267 257
268 - private void saveModelBpmnXml(String id, String bpmnXml) { 258 + @Override
  259 + public void updateModelBpmnXml(String id, String bpmnXml) {
269 if (StrUtil.isEmpty(bpmnXml)) { 260 if (StrUtil.isEmpty(bpmnXml)) {
270 return; 261 return;
271 } 262 }
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionService.java
@@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO; 4 import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO;
5 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; 5 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO;
6 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO; 6 import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO;
7 -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; 7 +import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelMetaInfoVO;
8 import org.flowable.bpmn.model.BpmnModel; 8 import org.flowable.bpmn.model.BpmnModel;
9 import org.flowable.engine.repository.Deployment; 9 import org.flowable.engine.repository.Deployment;
10 import org.flowable.engine.repository.Model; 10 import org.flowable.engine.repository.Model;
@@ -51,7 +51,7 @@ public interface BpmProcessDefinitionService { @@ -51,7 +51,7 @@ public interface BpmProcessDefinitionService {
51 * @param form 表单 51 * @param form 表单
52 * @return 流程编号 52 * @return 流程编号
53 */ 53 */
54 - String createProcessDefinition(Model model, BpmModelMetaInfoRespDTO modelMetaInfo, byte[] bpmnBytes, BpmFormDO form); 54 + String createProcessDefinition(Model model, BpmModelMetaInfoVO modelMetaInfo, byte[] bpmnBytes, BpmFormDO form);
55 55
56 /** 56 /**
57 * 更新流程定义状态 57 * 更新流程定义状态
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java
@@ -11,7 +11,7 @@ import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitio @@ -11,7 +11,7 @@ import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitio
11 import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessDefinitionInfoMapper; 11 import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessDefinitionInfoMapper;
12 import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants; 12 import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants;
13 import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; 13 import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils;
14 -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; 14 +import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelMetaInfoVO;
15 import jakarta.annotation.Resource; 15 import jakarta.annotation.Resource;
16 import lombok.extern.slf4j.Slf4j; 16 import lombok.extern.slf4j.Slf4j;
17 import org.flowable.bpmn.model.BpmnModel; 17 import org.flowable.bpmn.model.BpmnModel;
@@ -105,7 +105,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ @@ -105,7 +105,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ
105 } 105 }
106 106
107 @Override 107 @Override
108 - public String createProcessDefinition(Model model, BpmModelMetaInfoRespDTO modelMetaInfo, 108 + public String createProcessDefinition(Model model, BpmModelMetaInfoVO modelMetaInfo,
109 byte[] bpmnBytes, BpmFormDO form) { 109 byte[] bpmnBytes, BpmFormDO form) {
110 // 创建 Deployment 部署 110 // 创建 Deployment 部署
111 Deployment deploy = repositoryService.createDeployment() 111 Deployment deploy = repositoryService.createDeployment()
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/dto/BpmModelMetaInfoRespDTO.java deleted
1 -package cn.iocoder.yudao.module.bpm.service.definition.dto;  
2 -  
3 -import cn.iocoder.yudao.module.bpm.enums.definition.BpmModelFormTypeEnum;  
4 -import lombok.Data;  
5 -  
6 -/**  
7 - * BPM 流程 MetaInfo Response DTO  
8 - * 主要用于 { Model#setMetaInfo(String)} 的存储  
9 - *  
10 - * 最终,它的字段和 {@link cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionInfoDO} 是一致的  
11 - *  
12 - * @author 芋道源码  
13 - */  
14 -@Data  
15 -public class BpmModelMetaInfoRespDTO {  
16 -  
17 - /**  
18 - * 流程图标  
19 - */  
20 - private String icon;  
21 - /**  
22 - * 流程描述  
23 - */  
24 - private String description;  
25 -  
26 - /**  
27 - * 表单类型  
28 - */  
29 - private Integer formType;  
30 - /**  
31 - * 表单编号  
32 - * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时  
33 - */  
34 - private Long formId;  
35 - /**  
36 - * 自定义表单的提交路径,使用 Vue 的路由地址  
37 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时  
38 - */  
39 - private String formCustomCreatePath;  
40 - /**  
41 - * 自定义表单的查看路径,使用 Vue 的路由地址  
42 - * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时  
43 - */  
44 - private String formCustomViewPath;  
45 -  
46 -}