Commit ff6bee964b5622e2e0184726f1aa59efc58b6b73
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 | 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 | 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 | 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 | 15 | import cn.iocoder.yudao.module.bpm.service.definition.BpmFormService; |
| 16 | 16 | import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService; |
| 17 | 17 | import cn.iocoder.yudao.module.bpm.service.definition.BpmProcessDefinitionService; |
| 18 | -import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmModelMetaInfoRespDTO; | |
| 19 | 18 | import io.swagger.v3.oas.annotations.Operation; |
| 20 | 19 | import io.swagger.v3.oas.annotations.Parameter; |
| 21 | 20 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -63,7 +62,7 @@ public class BpmModelController { |
| 63 | 62 | // 拼接数据 |
| 64 | 63 | // 获得 Form 表单 |
| 65 | 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 | 66 | return metaInfo != null ? metaInfo.getFormId() : null; |
| 68 | 67 | }); |
| 69 | 68 | Map<Long, BpmFormDO> formMap = formService.getFormMap(formIds); |
| ... | ... | @@ -96,14 +95,14 @@ public class BpmModelController { |
| 96 | 95 | @PostMapping("/create") |
| 97 | 96 | @Operation(summary = "新建模型") |
| 98 | 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 | 99 | return success(modelService.createModel(createRetVO)); |
| 101 | 100 | } |
| 102 | 101 | |
| 103 | 102 | @PutMapping("/update") |
| 104 | 103 | @Operation(summary = "修改模型") |
| 105 | 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 | 106 | modelService.updateModel(modelVO); |
| 108 | 107 | return success(true); |
| 109 | 108 | } |
| ... | ... | @@ -125,6 +124,14 @@ public class BpmModelController { |
| 125 | 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 | 135 | @DeleteMapping("/delete") |
| 129 | 136 | @Operation(summary = "删除模型") |
| 130 | 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 | 79 | @Parameter(name = "suspensionState", description = "挂起状态", required = true, example = "1") // 参见 Flowable SuspensionState 枚举 |
| 80 | 80 | public CommonResult<List<BpmProcessDefinitionRespVO>> getProcessDefinitionList( |
| 81 | 81 | @RequestParam("suspensionState") Integer suspensionState) { |
| 82 | + // 1.1 获得开启的流程定义 | |
| 82 | 83 | List<ProcessDefinition> list = processDefinitionService.getProcessDefinitionListBySuspensionState(suspensionState); |
| 83 | 84 | if (CollUtil.isEmpty(list)) { |
| 84 | 85 | return success(Collections.emptyList()); |
| 85 | 86 | } |
| 86 | - | |
| 87 | - // 获得 BpmProcessDefinitionInfoDO Map | |
| 87 | + // 1.2 移除不可见的流程定义 | |
| 88 | 88 | Map<String, BpmProcessDefinitionInfoDO> processDefinitionMap = processDefinitionService.getProcessDefinitionInfoMap( |
| 89 | 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 | 96 | return success(BpmProcessDefinitionConvert.INSTANCE.buildProcessDefinitionList( |
| 91 | 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 | 8 | |
| 9 | 9 | @Schema(description = "管理后台 - 流程模型 Response VO") |
| 10 | 10 | @Data |
| 11 | -public class BpmModelRespVO { | |
| 11 | +public class BpmModelRespVO extends BpmModelMetaInfoVO { | |
| 12 | 12 | |
| 13 | 13 | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 14 | 14 | private String id; |
| ... | ... | @@ -22,27 +22,14 @@ public class BpmModelRespVO { |
| 22 | 22 | @Schema(description = "流程图标", example = "https://www.iocoder.cn/yudao.jpg") |
| 23 | 23 | private String icon; |
| 24 | 24 | |
| 25 | - @Schema(description = "流程描述", example = "我是描述") | |
| 26 | - private String description; | |
| 27 | - | |
| 28 | 25 | @Schema(description = "流程分类编码", example = "1") |
| 29 | 26 | private String category; |
| 30 | 27 | @Schema(description = "流程分类名字", example = "请假") |
| 31 | 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 | 30 | @Schema(description = "表单名字", example = "请假表单") |
| 39 | 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 | 33 | @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 47 | 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 | 1 | package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model; |
| 2 | 2 | |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | -import lombok.Data; | |
| 5 | -import lombok.EqualsAndHashCode; | |
| 6 | -import lombok.ToString; | |
| 7 | - | |
| 8 | 4 | import jakarta.validation.constraints.NotEmpty; |
| 5 | +import lombok.Data; | |
| 9 | 6 | |
| 10 | -@Schema(description = "管理后台 - 流程模型的创建 Request VO") | |
| 7 | +@Schema(description = "管理后台 - 流程模型的保存 Request VO") | |
| 11 | 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 | 14 | @Schema(description = "流程标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "process_yudao") |
| 15 | 15 | @NotEmpty(message = "流程标识不能为空") |
| ... | ... | @@ -19,7 +19,7 @@ public class BpmModelCreateReqVO { |
| 19 | 19 | @NotEmpty(message = "流程名称不能为空") |
| 20 | 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 | 1 | package cn.iocoder.yudao.module.bpm.convert.definition; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.util.ArrayUtil; |
| 4 | -import cn.hutool.core.util.StrUtil; | |
| 5 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 5 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 7 | 6 | import cn.iocoder.yudao.framework.common.util.date.DateUtils; |
| 8 | 7 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 9 | 8 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 10 | -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelCreateReqVO; | |
| 11 | 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 | 11 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionRespVO; |
| 14 | 12 | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmCategoryDO; |
| 15 | 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 | 15 | import org.flowable.common.engine.impl.db.SuspensionState; |
| 18 | 16 | import org.flowable.engine.repository.Deployment; |
| 19 | 17 | import org.flowable.engine.repository.Model; |
| ... | ... | @@ -23,7 +21,6 @@ import org.mapstruct.factory.Mappers; |
| 23 | 21 | |
| 24 | 22 | import java.util.List; |
| 25 | 23 | import java.util.Map; |
| 26 | -import java.util.Objects; | |
| 27 | 24 | |
| 28 | 25 | /** |
| 29 | 26 | * 流程模型 Convert |
| ... | ... | @@ -40,7 +37,7 @@ public interface BpmModelConvert { |
| 40 | 37 | Map<String, BpmCategoryDO> categoryMap, Map<String, Deployment> deploymentMap, |
| 41 | 38 | Map<String, ProcessDefinition> processDefinitionMap) { |
| 42 | 39 | List<BpmModelRespVO> list = CollectionUtils.convertList(pageResult.getList(), model -> { |
| 43 | - BpmModelMetaInfoRespDTO metaInfo = buildMetaInfo(model); | |
| 40 | + BpmModelMetaInfoVO metaInfo = buildMetaInfo(model); | |
| 44 | 41 | BpmFormDO form = metaInfo != null ? formMap.get(metaInfo.getFormId()) : null; |
| 45 | 42 | BpmCategoryDO category = categoryMap.get(model.getCategory()); |
| 46 | 43 | Deployment deployment = model.getDeploymentId() != null ? deploymentMap.get(model.getDeploymentId()) : null; |
| ... | ... | @@ -52,7 +49,7 @@ public interface BpmModelConvert { |
| 52 | 49 | |
| 53 | 50 | default BpmModelRespVO buildModel(Model model, |
| 54 | 51 | byte[] bpmnBytes) { |
| 55 | - BpmModelMetaInfoRespDTO metaInfo = buildMetaInfo(model); | |
| 52 | + BpmModelMetaInfoVO metaInfo = buildMetaInfo(model); | |
| 56 | 53 | BpmModelRespVO modelVO = buildModel0(model, metaInfo, null, null, null, null); |
| 57 | 54 | if (ArrayUtil.isNotEmpty(bpmnBytes)) { |
| 58 | 55 | modelVO.setBpmnXml(new String(bpmnBytes)); |
| ... | ... | @@ -61,20 +58,15 @@ public interface BpmModelConvert { |
| 61 | 58 | } |
| 62 | 59 | |
| 63 | 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 | 63 | BpmModelRespVO modelRespVO = new BpmModelRespVO().setId(model.getId()).setName(model.getName()) |
| 67 | 64 | .setKey(model.getKey()).setCategory(model.getCategory()) |
| 68 | 65 | .setCreateTime(DateUtils.of(model.getCreateTime())); |
| 69 | 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 | 68 | if (form != null) { |
| 77 | - modelRespVO.setFormId(form.getId()).setFormName(form.getName()); | |
| 69 | + modelRespVO.setFormName(form.getName()); | |
| 78 | 70 | } |
| 79 | 71 | // Category |
| 80 | 72 | if (category != null) { |
| ... | ... | @@ -92,46 +84,15 @@ public interface BpmModelConvert { |
| 92 | 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 | 6 | import com.baomidou.mybatisplus.annotation.TableId; |
| 7 | 7 | import com.baomidou.mybatisplus.annotation.TableName; |
| 8 | 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 | 16 | import java.util.List; |
| 12 | 17 | |
| ... | ... | @@ -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 | 41 | private String processDefinitionId; |
| 37 | 42 | /** |
| 38 | 43 | * 流程模型的编号 |
| 39 | 44 | * |
| 40 | - * 关联 Model 的 id 属性 | |
| 45 | + * 关联 {@link Model#getId()} 属性 | |
| 41 | 46 | */ |
| 42 | 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 | 64 | /** |
| 54 | 65 | * 表单类型 |
| 55 | 66 | * |
| 56 | - * 关联 {@link BpmModelFormTypeEnum} | |
| 67 | + * 枚举 {@link BpmModelFormTypeEnum} | |
| 57 | 68 | */ |
| 58 | 69 | private Integer formType; |
| 59 | 70 | /** |
| 60 | 71 | * 动态表单编号 |
| 72 | + * | |
| 61 | 73 | * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 |
| 62 | 74 | * |
| 63 | 75 | * 关联 {@link BpmFormDO#getId()} |
| ... | ... | @@ -65,6 +77,7 @@ public class BpmProcessDefinitionInfoDO extends BaseDO { |
| 65 | 77 | private Long formId; |
| 66 | 78 | /** |
| 67 | 79 | * 表单的配置 |
| 80 | + * | |
| 68 | 81 | * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 |
| 69 | 82 | * |
| 70 | 83 | * 冗余 {@link BpmFormDO#getConf()} |
| ... | ... | @@ -72,21 +85,31 @@ public class BpmProcessDefinitionInfoDO extends BaseDO { |
| 72 | 85 | private String formConf; |
| 73 | 86 | /** |
| 74 | 87 | * 表单项的数组 |
| 88 | + * | |
| 75 | 89 | * 在表单类型为 {@link BpmModelFormTypeEnum#NORMAL} 时 |
| 76 | 90 | * |
| 77 | - * 冗余 {@link BpmFormDO#getFields()} ()} | |
| 91 | + * 冗余 {@link BpmFormDO#getFields()} | |
| 78 | 92 | */ |
| 79 | 93 | @TableField(typeHandler = JacksonTypeHandler.class) |
| 80 | 94 | private List<String> formFields; |
| 81 | 95 | /** |
| 82 | 96 | * 自定义表单的提交路径,使用 Vue 的路由地址 |
| 97 | + * | |
| 83 | 98 | * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 |
| 84 | 99 | */ |
| 85 | 100 | private String formCustomCreatePath; |
| 86 | 101 | /** |
| 87 | 102 | * 自定义表单的查看路径,使用 Vue 的路由地址 |
| 103 | + * | |
| 88 | 104 | * 在表单类型为 {@link BpmModelFormTypeEnum#CUSTOM} 时 |
| 89 | 105 | */ |
| 90 | 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 | 1 | package cn.iocoder.yudao.module.bpm.service.definition; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelCreateReqVO; | |
| 5 | 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 | 6 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO; |
| 8 | 7 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelUpdateReqVO; |
| 9 | 8 | import jakarta.validation.Valid; |
| ... | ... | @@ -31,7 +30,7 @@ public interface BpmModelService { |
| 31 | 30 | * @param modelVO 创建信息 |
| 32 | 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 | 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 | 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 | 6 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.object.PageUtils; |
| 8 | 8 | import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; |
| 9 | -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.BpmModelCreateReqVO; | |
| 10 | 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 | 11 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO; |
| 13 | 12 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelUpdateReqVO; |
| 14 | 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 | 17 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils; |
| 19 | 18 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.FlowableUtils; |
| 20 | 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 | 21 | import jakarta.annotation.Resource; |
| 23 | 22 | import jakarta.validation.Valid; |
| 24 | 23 | import lombok.extern.slf4j.Slf4j; |
| ... | ... | @@ -32,7 +31,6 @@ import org.flowable.engine.repository.ModelQuery; |
| 32 | 31 | import org.flowable.engine.repository.ProcessDefinition; |
| 33 | 32 | import org.springframework.stereotype.Service; |
| 34 | 33 | import org.springframework.transaction.annotation.Transactional; |
| 35 | -import org.springframework.util.ObjectUtils; | |
| 36 | 34 | import org.springframework.validation.annotation.Validated; |
| 37 | 35 | |
| 38 | 36 | import java.util.List; |
| ... | ... | @@ -90,55 +88,58 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 90 | 88 | |
| 91 | 89 | @Override |
| 92 | 90 | @Transactional(rollbackFor = Exception.class) |
| 93 | - public String createModel(@Valid BpmModelCreateReqVO createReqVO) { | |
| 91 | + public String createModel(@Valid BpmModelSaveReqVO createReqVO) { | |
| 94 | 92 | if (!ValidationUtils.isXmlNCName(createReqVO.getKey())) { |
| 95 | 93 | throw exception(MODEL_KEY_VALID); |
| 96 | 94 | } |
| 97 | - // 校验流程标识已经存在 | |
| 95 | + // 1. 校验流程标识已经存在 | |
| 98 | 96 | Model keyModel = getModelByKey(createReqVO.getKey()); |
| 99 | 97 | if (keyModel != null) { |
| 100 | 98 | throw exception(MODEL_KEY_EXISTS, createReqVO.getKey()); |
| 101 | 99 | } |
| 102 | 100 | |
| 103 | - // 创建流程定义 | |
| 101 | + // 2.1 创建流程定义 | |
| 104 | 102 | Model model = repositoryService.newModel(); |
| 105 | - BpmModelConvert.INSTANCE.copyToCreateModel(model, createReqVO); | |
| 103 | + BpmModelConvert.INSTANCE.copyToModel(model, createReqVO); | |
| 106 | 104 | model.setTenantId(FlowableUtils.getTenantId()); |
| 107 | - // 保存流程定义 | |
| 105 | + // 2.2 保存流程定义 | |
| 108 | 106 | repositoryService.saveModel(model); |
| 109 | 107 | return model.getId(); |
| 110 | 108 | } |
| 111 | 109 | |
| 112 | 110 | @Override |
| 113 | 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 | 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 | 133 | @Override |
| 130 | 134 | @Transactional(rollbackFor = Exception.class) // 因为进行多个操作,所以开启事务 |
| 131 | 135 | public void deployModel(String id) { |
| 132 | 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 | 138 | // 1.2 校验流程图 |
| 138 | 139 | byte[] bpmnBytes = getModelBpmnXML(model.getId()); |
| 139 | 140 | validateBpmnXml(bpmnBytes); |
| 140 | 141 | // 1.3 校验表单已配 |
| 141 | - BpmModelMetaInfoRespDTO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoRespDTO.class); | |
| 142 | + BpmModelMetaInfoVO metaInfo = JsonUtils.parseObject(model.getMetaInfo(), BpmModelMetaInfoVO.class); | |
| 142 | 143 | BpmFormDO form = validateFormConfig(metaInfo); |
| 143 | 144 | // 1.4 校验任务分配规则已配置 |
| 144 | 145 | taskCandidateInvoker.validateBpmnConfig(bpmnBytes); |
| ... | ... | @@ -178,10 +179,8 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 178 | 179 | @Transactional(rollbackFor = Exception.class) |
| 179 | 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 | 185 | repositoryService.deleteModel(id); |
| 187 | 186 | // 禁用流程定义 |
| ... | ... | @@ -191,10 +190,7 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 191 | 190 | @Override |
| 192 | 191 | public void updateModelState(String id, Integer state) { |
| 193 | 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 | 194 | // 1.2 校验流程定义存在 |
| 199 | 195 | ProcessDefinition definition = processDefinitionService.getProcessDefinitionByDeploymentId(model.getDeploymentId()); |
| 200 | 196 | if (definition == null) { |
| ... | ... | @@ -212,10 +208,7 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 212 | 208 | |
| 213 | 209 | @Override |
| 214 | 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 | 212 | // 通过 ACT_RE_MODEL 表 EDITOR_SOURCE_EXTRA_VALUE_ID_ ,获取仿钉钉快搭模型的 JSON 数据 |
| 220 | 213 | byte[] jsonBytes = getModelSimpleJson(model.getId()); |
| 221 | 214 | return JsonUtils.parseObject(jsonBytes, BpmSimpleModelNodeVO.class); |
| ... | ... | @@ -224,15 +217,12 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 224 | 217 | @Override |
| 225 | 218 | public void updateSimpleModel(BpmSimpleModelUpdateReqVO reqVO) { |
| 226 | 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 | 222 | // 2.1 JSON 转换成 bpmnModel |
| 233 | 223 | BpmnModel bpmnModel = SimpleModelUtils.buildBpmnModel(model.getKey(), model.getName(), reqVO.getSimpleModel()); |
| 234 | 224 | // 2.2 保存 Bpmn XML |
| 235 | - saveModelBpmnXml(model.getId(), BpmnModelUtils.getBpmnXml(bpmnModel)); | |
| 225 | + updateModelBpmnXml(model.getId(), BpmnModelUtils.getBpmnXml(bpmnModel)); | |
| 236 | 226 | // 2.3 保存 JSON 数据 |
| 237 | 227 | saveModelSimpleJson(model.getId(), JsonUtils.toJsonByte(reqVO.getSimpleModel())); |
| 238 | 228 | } |
| ... | ... | @@ -243,7 +233,7 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 243 | 233 | * @param metaInfo 流程模型元数据 |
| 244 | 234 | * @return 表单配置 |
| 245 | 235 | */ |
| 246 | - private BpmFormDO validateFormConfig(BpmModelMetaInfoRespDTO metaInfo) { | |
| 236 | + private BpmFormDO validateFormConfig(BpmModelMetaInfoVO metaInfo) { | |
| 247 | 237 | if (metaInfo == null || metaInfo.getFormType() == null) { |
| 248 | 238 | throw exception(MODEL_DEPLOY_FAIL_FORM_NOT_CONFIG); |
| 249 | 239 | } |
| ... | ... | @@ -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 | 260 | if (StrUtil.isEmpty(bpmnXml)) { |
| 270 | 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 | 4 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageReqVO; |
| 5 | 5 | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; |
| 6 | 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 | 8 | import org.flowable.bpmn.model.BpmnModel; |
| 9 | 9 | import org.flowable.engine.repository.Deployment; |
| 10 | 10 | import org.flowable.engine.repository.Model; |
| ... | ... | @@ -51,7 +51,7 @@ public interface BpmProcessDefinitionService { |
| 51 | 51 | * @param form 表单 |
| 52 | 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 | 11 | import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessDefinitionInfoMapper; |
| 12 | 12 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants; |
| 13 | 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 | 15 | import jakarta.annotation.Resource; |
| 16 | 16 | import lombok.extern.slf4j.Slf4j; |
| 17 | 17 | import org.flowable.bpmn.model.BpmnModel; |
| ... | ... | @@ -105,7 +105,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | @Override |
| 108 | - public String createProcessDefinition(Model model, BpmModelMetaInfoRespDTO modelMetaInfo, | |
| 108 | + public String createProcessDefinition(Model model, BpmModelMetaInfoVO modelMetaInfo, | |
| 109 | 109 | byte[] bpmnBytes, BpmFormDO form) { |
| 110 | 110 | // 创建 Deployment 部署 |
| 111 | 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 | -} |