Commit 1b708ccd5567b29b659ca101c5c5720f4bb8e2ce

Authored by YunaiV
1 parent b504d984

BPM:code review 快搭的实现

yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/ErrorCodeConstants.java
@@ -76,5 +76,7 @@ public interface ErrorCodeConstants { @@ -76,5 +76,7 @@ public interface ErrorCodeConstants {
76 ErrorCode PROCESS_EXPRESSION_NOT_EXISTS = new ErrorCode(1_009_014_000, "流程表达式不存在"); 76 ErrorCode PROCESS_EXPRESSION_NOT_EXISTS = new ErrorCode(1_009_014_000, "流程表达式不存在");
77 77
78 // ========== BPM 仿钉钉流程设计器 1-009-015-000 ========== 78 // ========== BPM 仿钉钉流程设计器 1-009-015-000 ==========
  79 + // TODO @芋艿:这个错误码,需要关注下
79 ErrorCode CONVERT_TO_SIMPLE_MODEL_NOT_SUPPORT = new ErrorCode(1_009_015_000, "该流程模型不支持仿钉钉设计流程"); 80 ErrorCode CONVERT_TO_SIMPLE_MODEL_NOT_SUPPORT = new ErrorCode(1_009_015_000, "该流程模型不支持仿钉钉设计流程");
  81 +
80 } 82 }
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmSimpleModelNodeType.java
@@ -17,6 +17,7 @@ import java.util.Objects; @@ -17,6 +17,7 @@ import java.util.Objects;
17 @AllArgsConstructor 17 @AllArgsConstructor
18 public enum BpmSimpleModelNodeType implements IntArrayValuable { 18 public enum BpmSimpleModelNodeType implements IntArrayValuable {
19 19
  20 + // TODO @jaosn:-1、0、1、4、-2 是前端已经定义好的么?感觉未来可以考虑搞成和 BPMN 尽量一致的单词哈;类似 usertask 用户审批;
20 START_NODE(-1, "开始节点"), 21 START_NODE(-1, "开始节点"),
21 START_USER_NODE(0, "发起人结点"), 22 START_USER_NODE(0, "发起人结点"),
22 APPROVE_USER_NODE (1, "审批人节点"), 23 APPROVE_USER_NODE (1, "审批人节点"),
@@ -41,4 +42,5 @@ public enum BpmSimpleModelNodeType implements IntArrayValuable { @@ -41,4 +42,5 @@ public enum BpmSimpleModelNodeType implements IntArrayValuable {
41 public int[] array() { 42 public int[] array() {
42 return ARRAYS; 43 return ARRAYS;
43 } 44 }
  45 +
44 } 46 }
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/BpmSimpleModelController.java
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*; @@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
14 14
15 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 15 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
16 16
  17 +// TODO @芋艿:后续考虑下,怎么放这个 Controller
17 @Tag(name = "管理后台 - BPM 仿钉钉流程设计器") 18 @Tag(name = "管理后台 - BPM 仿钉钉流程设计器")
18 @RestController 19 @RestController
19 @RequestMapping("/bpm/simple") 20 @RequestMapping("/bpm/simple")
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/simple/BpmSimpleModelNodeVO.java
@@ -16,7 +16,7 @@ public class BpmSimpleModelNodeVO { @@ -16,7 +16,7 @@ public class BpmSimpleModelNodeVO {
16 16
17 @Schema(description = "模型节点编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "StartEvent_1") 17 @Schema(description = "模型节点编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "StartEvent_1")
18 @NotEmpty(message = "模型节点编号不能为空") 18 @NotEmpty(message = "模型节点编号不能为空")
19 - private String id; 19 + private String id;
20 20
21 @Schema(description = "模型节点类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") 21 @Schema(description = "模型节点类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
22 @NotNull(message = "模型节点类型不能为空") 22 @NotNull(message = "模型节点类型不能为空")
@@ -33,5 +33,6 @@ public class BpmSimpleModelNodeVO { @@ -33,5 +33,6 @@ public class BpmSimpleModelNodeVO {
33 private List<BpmSimpleModelNodeVO> conditionNodes; 33 private List<BpmSimpleModelNodeVO> conditionNodes;
34 34
35 @Schema(description = "节点的属性") 35 @Schema(description = "节点的属性")
36 - private Map<String, Object> attributes; 36 + private Map<String, Object> attributes;
  37 +
37 } 38 }
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/simple/BpmSimpleModelSaveReqVO.java
@@ -6,6 +6,7 @@ import jakarta.validation.constraints.NotEmpty; @@ -6,6 +6,7 @@ import jakarta.validation.constraints.NotEmpty;
6 import jakarta.validation.constraints.NotNull; 6 import jakarta.validation.constraints.NotNull;
7 import lombok.Data; 7 import lombok.Data;
8 8
  9 +// TODO @芋艿:或许挪到 model 里的 simple 包
9 @Schema(description = "管理后台 - 仿钉钉流程设计模型的新增/修改 Request VO") 10 @Schema(description = "管理后台 - 仿钉钉流程设计模型的新增/修改 Request VO")
10 @Data 11 @Data
11 public class BpmSimpleModelSaveReqVO { 12 public class BpmSimpleModelSaveReqVO {
@@ -18,4 +19,5 @@ public class BpmSimpleModelSaveReqVO { @@ -18,4 +19,5 @@ public class BpmSimpleModelSaveReqVO {
18 @NotNull(message = "仿钉钉流程设计模型对象不能为空") 19 @NotNull(message = "仿钉钉流程设计模型对象不能为空")
19 @Valid 20 @Valid
20 private BpmSimpleModelNodeVO simpleModelBody; 21 private BpmSimpleModelNodeVO simpleModelBody;
  22 +
21 } 23 }
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnModelConstants.java
@@ -28,6 +28,7 @@ public interface BpmnModelConstants { @@ -28,6 +28,7 @@ public interface BpmnModelConstants {
28 */ 28 */
29 String USER_TASK_CANDIDATE_PARAM = "candidateParam"; 29 String USER_TASK_CANDIDATE_PARAM = "candidateParam";
30 30
  31 + // TODO @芋艿:这里后面得关注下;
31 /** 32 /**
32 * BPMN End Event 节点 Id, 用于后端生成 End Event 节点 33 * BPMN End Event 节点 Id, 用于后端生成 End Event 节点
33 */ 34 */
@@ -36,6 +37,6 @@ public interface BpmnModelConstants { @@ -36,6 +37,6 @@ public interface BpmnModelConstants {
36 /** 37 /**
37 * 支持转仿钉钉设计模型的 Bpmn 节点 38 * 支持转仿钉钉设计模型的 Bpmn 节点
38 */ 39 */
39 - Set<Class<? extends FlowNode>> SUPPORT_CONVERT_SIMPLE_FlOW_NODES = ImmutableSet.of(UserTask.class, EndEvent.class); 40 + Set<Class<? extends FlowNode>> SUPPORT_CONVERT_SIMPLE_FlOW_NODES = ImmutableSet.of(UserTask.class, EndEvent.class);
40 41
41 } 42 }
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java
@@ -335,6 +335,8 @@ public class BpmnModelUtils { @@ -335,6 +335,8 @@ public class BpmnModelUtils {
335 return userTaskList; 335 return userTaskList;
336 } 336 }
337 337
  338 + // ========== TODO 芋艿:这里得捉摸下; ==========
  339 +
338 /** 340 /**
339 * 仿钉钉流程设计模型数据结构(json) 转换成 Bpmn Model (待完善) 341 * 仿钉钉流程设计模型数据结构(json) 转换成 Bpmn Model (待完善)
340 * 342 *
@@ -359,7 +361,6 @@ public class BpmnModelUtils { @@ -359,7 +361,6 @@ public class BpmnModelUtils {
359 addBpmnSequenceFlow(mainProcess, simpleModelNode); 361 addBpmnSequenceFlow(mainProcess, simpleModelNode);
360 // 自动布局 362 // 自动布局
361 new BpmnAutoLayout(bpmnModel).execute(); 363 new BpmnAutoLayout(bpmnModel).execute();
362 -  
363 return bpmnModel; 364 return bpmnModel;
364 } 365 }
365 366
@@ -396,7 +397,6 @@ public class BpmnModelUtils { @@ -396,7 +397,6 @@ public class BpmnModelUtils {
396 sequenceFlow.setConditionExpression(conditionExpression); 397 sequenceFlow.setConditionExpression(conditionExpression);
397 } 398 }
398 mainProcess.addFlowElement(sequenceFlow); 399 mainProcess.addFlowElement(sequenceFlow);
399 -  
400 } 400 }
401 401
402 private static void addBpmnFlowNode(Process mainProcess, BpmSimpleModelNodeVO simpleModelNode) { 402 private static void addBpmnFlowNode(Process mainProcess, BpmSimpleModelNodeVO simpleModelNode) {
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmModelService.java
@@ -53,6 +53,7 @@ public interface BpmModelService { @@ -53,6 +53,7 @@ public interface BpmModelService {
53 * @param id 编号 53 * @param id 编号
54 * @param bpmnXml BPMN XML 54 * @param bpmnXml BPMN XML
55 */ 55 */
  56 + // TODO @芋艿:可能要关注下;
56 void saveModelBpmnXml(String id, String bpmnXml); 57 void saveModelBpmnXml(String id, String bpmnXml);
57 58
58 /** 59 /**
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmSimpleModelService.java
@@ -13,14 +13,17 @@ public interface BpmSimpleModelService { @@ -13,14 +13,17 @@ public interface BpmSimpleModelService {
13 13
14 /** 14 /**
15 * 保存仿钉钉流程设计模型 15 * 保存仿钉钉流程设计模型
  16 + *
16 * @param reqVO 请求信息 17 * @param reqVO 请求信息
17 */ 18 */
18 Boolean saveSimpleModel(@Valid BpmSimpleModelSaveReqVO reqVO); 19 Boolean saveSimpleModel(@Valid BpmSimpleModelSaveReqVO reqVO);
19 20
20 /** 21 /**
21 * 获取仿钉钉流程设计模型结构 22 * 获取仿钉钉流程设计模型结构
  23 + *
22 * @param modelId 流程模型编号 24 * @param modelId 流程模型编号
23 * @return 仿钉钉流程设计模型结构 25 * @return 仿钉钉流程设计模型结构
24 */ 26 */
25 BpmSimpleModelNodeVO getSimpleModel(String modelId); 27 BpmSimpleModelNodeVO getSimpleModel(String modelId);
  28 +
26 } 29 }
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmSimpleModelServiceImpl.java
@@ -32,6 +32,7 @@ import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnMode @@ -32,6 +32,7 @@ import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnMode
32 @Service 32 @Service
33 @Validated 33 @Validated
34 public class BpmSimpleModelServiceImpl implements BpmSimpleModelService { 34 public class BpmSimpleModelServiceImpl implements BpmSimpleModelService {
  35 +
35 @Resource 36 @Resource
36 private BpmModelService bpmModelService; 37 private BpmModelService bpmModelService;
37 38
@@ -48,7 +49,7 @@ public class BpmSimpleModelServiceImpl implements BpmSimpleModelService { @@ -48,7 +49,7 @@ public class BpmSimpleModelServiceImpl implements BpmSimpleModelService {
48 // bpmModelService.saveModelBpmnXml(model.getId(), BpmnModelUtils.getBpmnXml(bpmnModel)); 49 // bpmModelService.saveModelBpmnXml(model.getId(), BpmnModelUtils.getBpmnXml(bpmnModel));
49 // return Boolean.TRUE; 50 // return Boolean.TRUE;
50 // } else { 51 // } else {
51 -// // TODO BPMN XML 已经存在。如何修改 ?? 52 +// // TODO BPMN XML 已经存在。如何修改 ?? TODO add by 芋艿:感觉一个流程,只能二选一,要么 bpmn、要么 simple
52 // return Boolean.FALSE; 53 // return Boolean.FALSE;
53 // } 54 // }
54 // 暂时直接修改 55 // 暂时直接修改
@@ -66,9 +67,9 @@ public class BpmSimpleModelServiceImpl implements BpmSimpleModelService { @@ -66,9 +67,9 @@ public class BpmSimpleModelServiceImpl implements BpmSimpleModelService {
66 byte[] bpmnBytes = bpmModelService.getModelBpmnXML(modelId); 67 byte[] bpmnBytes = bpmModelService.getModelBpmnXML(modelId);
67 BpmnModel bpmnModel = BpmnModelUtils.getBpmnModel(bpmnBytes); 68 BpmnModel bpmnModel = BpmnModelUtils.getBpmnModel(bpmnBytes);
68 return convertBpmnModelToSimpleModel(bpmnModel); 69 return convertBpmnModelToSimpleModel(bpmnModel);
69 -  
70 } 70 }
71 71
  72 + // TODO @jason:一般要支持这个么?感觉 bpmn 转 json 支持会不会太复杂。可以优先级低一点,做下调研~
72 /** 73 /**
73 * Bpmn Model 转换成 仿钉钉流程设计模型数据结构(json) 待完善 74 * Bpmn Model 转换成 仿钉钉流程设计模型数据结构(json) 待完善
74 * 75 *
@@ -89,7 +90,6 @@ public class BpmSimpleModelServiceImpl implements BpmSimpleModelService { @@ -89,7 +90,6 @@ public class BpmSimpleModelServiceImpl implements BpmSimpleModelService {
89 rootNode.setName(startEvent.getName()); 90 rootNode.setName(startEvent.getName());
90 recursiveBuildSimpleModelNode(startEvent, rootNode); 91 recursiveBuildSimpleModelNode(startEvent, rootNode);
91 return rootNode; 92 return rootNode;
92 -  
93 } 93 }
94 94
95 private void recursiveBuildSimpleModelNode(FlowNode currentFlowNode, BpmSimpleModelNodeVO currentSimpleModeNode) { 95 private void recursiveBuildSimpleModelNode(FlowNode currentFlowNode, BpmSimpleModelNodeVO currentSimpleModeNode) {
@@ -113,7 +113,6 @@ public class BpmSimpleModelServiceImpl implements BpmSimpleModelService { @@ -113,7 +113,6 @@ public class BpmSimpleModelServiceImpl implements BpmSimpleModelService {
113 // TODO 其它节点类型待实现 113 // TODO 其它节点类型待实现
114 } 114 }
115 115
116 -  
117 private BpmSimpleModelNodeVO convertUserTaskToSimpleModelNode(UserTask userTask) { 116 private BpmSimpleModelNodeVO convertUserTaskToSimpleModelNode(UserTask userTask) {
118 BpmSimpleModelNodeVO simpleModelNodeVO = new BpmSimpleModelNodeVO(); 117 BpmSimpleModelNodeVO simpleModelNodeVO = new BpmSimpleModelNodeVO();
119 simpleModelNodeVO.setType(BpmSimpleModelNodeType.APPROVE_USER_NODE.getType()); 118 simpleModelNodeVO.setType(BpmSimpleModelNodeType.APPROVE_USER_NODE.getType());