Commit 32809c3edb78b52df98970887ca03be5a1af7855
1 parent
d9758636
仿钉钉流程设计-仿钉钉快搭模型 JSON数据的保存
Showing
4 changed files
with
49 additions
and
12 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/simple/BpmSimpleModelNodeVO.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.simple; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.validation.InEnum; |
| 4 | 4 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModelNodeType; |
| 5 | +import com.fasterxml.jackson.annotation.JsonInclude; | |
| 5 | 6 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | 7 | import jakarta.validation.constraints.NotEmpty; |
| 7 | 8 | import jakarta.validation.constraints.NotNull; |
| ... | ... | @@ -12,6 +13,7 @@ import java.util.Map; |
| 12 | 13 | |
| 13 | 14 | @Schema(description = "管理后台 - 仿钉钉流程设计模型节点 VO") |
| 14 | 15 | @Data |
| 16 | +@JsonInclude(JsonInclude.Include.NON_NULL) | |
| 15 | 17 | public class BpmSimpleModelNodeVO { |
| 16 | 18 | |
| 17 | 19 | @Schema(description = "模型节点编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "StartEvent_1") | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java
| ... | ... | @@ -51,10 +51,24 @@ public interface BpmModelService { |
| 51 | 51 | * 保存流程模型的 BPMN XML |
| 52 | 52 | * |
| 53 | 53 | * @param id 编号 |
| 54 | - * @param bpmnXml BPMN XML | |
| 54 | + * @param xmlBytes BPMN XML bytes | |
| 55 | 55 | */ |
| 56 | 56 | // TODO @芋艿:可能要关注下; |
| 57 | - void saveModelBpmnXml(String id, String bpmnXml); | |
| 57 | + void saveModelBpmnXml(String id, byte[] xmlBytes); | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * 获得仿钉钉快搭模型的 JSON 数据 | |
| 61 | + * @param id 编号 | |
| 62 | + * @return JSON bytes | |
| 63 | + */ | |
| 64 | + byte[] getModelSimpleJson(String id); | |
| 65 | + | |
| 66 | + /** | |
| 67 | + * 保存仿钉钉快搭模型的 JSON 数据 | |
| 68 | + * @param id 编号 | |
| 69 | + * @param jsonBytes JSON bytes | |
| 70 | + */ | |
| 71 | + void saveModelSimpleJson(String id, byte[] jsonBytes); | |
| 58 | 72 | |
| 59 | 73 | /** |
| 60 | 74 | * 修改流程模型 | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.bpm.service.definition; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.util.ArrayUtil; | |
| 3 | 4 | import cn.hutool.core.util.StrUtil; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 6 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| ... | ... | @@ -103,7 +104,7 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 103 | 104 | // 保存流程定义 |
| 104 | 105 | repositoryService.saveModel(model); |
| 105 | 106 | // 保存 BPMN XML |
| 106 | - saveModelBpmnXml(model.getId(), bpmnXml); | |
| 107 | + saveModelBpmnXml(model.getId(), StrUtil.utf8Bytes(bpmnXml)); | |
| 107 | 108 | return model.getId(); |
| 108 | 109 | } |
| 109 | 110 | |
| ... | ... | @@ -121,7 +122,7 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 121 | 122 | // 更新模型 |
| 122 | 123 | repositoryService.saveModel(model); |
| 123 | 124 | // 更新 BPMN XML |
| 124 | - saveModelBpmnXml(model.getId(), updateReqVO.getBpmnXml()); | |
| 125 | + saveModelBpmnXml(model.getId(), StrUtil.utf8Bytes(updateReqVO.getBpmnXml())); | |
| 125 | 126 | } |
| 126 | 127 | |
| 127 | 128 | @Override |
| ... | ... | @@ -237,11 +238,24 @@ public class BpmModelServiceImpl implements BpmModelService { |
| 237 | 238 | } |
| 238 | 239 | |
| 239 | 240 | @Override |
| 240 | - public void saveModelBpmnXml(String id, String bpmnXml) { | |
| 241 | - if (StrUtil.isEmpty(bpmnXml)) { | |
| 241 | + public void saveModelBpmnXml(String id, byte[] xmlBytes) { | |
| 242 | + if (ArrayUtil.isEmpty(xmlBytes)) { | |
| 242 | 243 | return; |
| 243 | 244 | } |
| 244 | - repositoryService.addModelEditorSource(id, StrUtil.utf8Bytes(bpmnXml)); | |
| 245 | + repositoryService.addModelEditorSource(id, xmlBytes); | |
| 246 | + } | |
| 247 | + | |
| 248 | + @Override | |
| 249 | + public byte[] getModelSimpleJson(String id) { | |
| 250 | + return repositoryService.getModelEditorSourceExtra(id); | |
| 251 | + } | |
| 252 | + | |
| 253 | + @Override | |
| 254 | + public void saveModelSimpleJson(String id, byte[] jsonBytes) { | |
| 255 | + if (ArrayUtil.isEmpty(jsonBytes)) { | |
| 256 | + return; | |
| 257 | + } | |
| 258 | + repositoryService.addModelEditorSourceExtra(id, jsonBytes); | |
| 245 | 259 | } |
| 246 | 260 | |
| 247 | 261 | /** | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmSimpleModelServiceImpl.java
| ... | ... | @@ -3,6 +3,8 @@ package cn.iocoder.yudao.module.bpm.service.definition; |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.lang.Assert; |
| 5 | 5 | import cn.hutool.core.map.MapUtil; |
| 6 | +import cn.hutool.core.util.StrUtil; | |
| 7 | +import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | |
| 6 | 8 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.simple.BpmSimpleModelNodeVO; |
| 7 | 9 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.simple.BpmSimpleModelSaveReqVO; |
| 8 | 10 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModelNodeType; |
| ... | ... | @@ -52,9 +54,12 @@ public class BpmSimpleModelServiceImpl implements BpmSimpleModelService { |
| 52 | 54 | // // TODO BPMN XML 已经存在。如何修改 ?? TODO add by 芋艿:感觉一个流程,只能二选一,要么 bpmn、要么 simple |
| 53 | 55 | // return Boolean.FALSE; |
| 54 | 56 | // } |
| 55 | - // 暂时直接修改 | |
| 57 | + // 1. JSON 转换成 bpmnModel | |
| 56 | 58 | BpmnModel bpmnModel = BpmnModelUtils.convertSimpleModelToBpmnModel(model.getKey(), model.getName(), reqVO.getSimpleModelBody()); |
| 57 | - bpmModelService.saveModelBpmnXml(model.getId(), BpmnModelUtils.getBpmnXml(bpmnModel)); | |
| 59 | + // 2.1 保存 Bpmn XML | |
| 60 | + bpmModelService.saveModelBpmnXml(model.getId(), StrUtil.utf8Bytes(BpmnModelUtils.getBpmnXml(bpmnModel))); | |
| 61 | + // 2.2 保存 JSON 数据 | |
| 62 | + bpmModelService.saveModelSimpleJson(model.getId(), JsonUtils.toJsonByte(reqVO.getSimpleModelBody())); | |
| 58 | 63 | return Boolean.TRUE; |
| 59 | 64 | } |
| 60 | 65 | |
| ... | ... | @@ -64,12 +69,14 @@ public class BpmSimpleModelServiceImpl implements BpmSimpleModelService { |
| 64 | 69 | if (model == null) { |
| 65 | 70 | throw exception(MODEL_NOT_EXISTS); |
| 66 | 71 | } |
| 67 | - byte[] bpmnBytes = bpmModelService.getModelBpmnXML(modelId); | |
| 68 | - BpmnModel bpmnModel = BpmnModelUtils.getBpmnModel(bpmnBytes); | |
| 69 | - return convertBpmnModelToSimpleModel(bpmnModel); | |
| 72 | + // 暂时不用 bpmn 转 json, 有点复杂, | |
| 73 | + // 通过 ACT_RE_MODEL 表 EDITOR_SOURCE_EXTRA_VALUE_ID_ 获取 仿钉钉快搭模型的JSON 数据 | |
| 74 | + byte[] jsonBytes = bpmModelService.getModelSimpleJson(model.getId()); | |
| 75 | + return JsonUtils.parseObject(jsonBytes, BpmSimpleModelNodeVO.class); | |
| 70 | 76 | } |
| 71 | 77 | |
| 72 | 78 | // TODO @jason:一般要支持这个么?感觉 bpmn 转 json 支持会不会太复杂。可以优先级低一点,做下调研~ |
| 79 | + | |
| 73 | 80 | /** |
| 74 | 81 | * Bpmn Model 转换成 仿钉钉流程设计模型数据结构(json) 待完善 |
| 75 | 82 | * | ... | ... |