mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-06-20 07:22:00 +08:00
【代码评审】BPM:review simple 字段、seq 连线
This commit is contained in:
parent
4bd399cd32
commit
d9ca52a478
@ -30,6 +30,7 @@ public enum BpmSimpleModelNodeType implements IntArrayValuable {
|
|||||||
PARALLEL_BRANCH_JOIN_NODE(6, "并行分支聚合节点"),
|
PARALLEL_BRANCH_JOIN_NODE(6, "并行分支聚合节点"),
|
||||||
INCLUSIVE_BRANCH_FORK_NODE(7, "包容网关分叉节点"),
|
INCLUSIVE_BRANCH_FORK_NODE(7, "包容网关分叉节点"),
|
||||||
INCLUSIVE_BRANCH_JOIN_NODE(8, "包容网关聚合节点"),
|
INCLUSIVE_BRANCH_JOIN_NODE(8, "包容网关聚合节点"),
|
||||||
|
// TODO @jason:建议整合 join,最终只有 条件分支、并行分支、包容分支,三种~
|
||||||
;
|
;
|
||||||
|
|
||||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BpmSimpleModelNodeType::getType).toArray();
|
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BpmSimpleModelNodeType::getType).toArray();
|
||||||
@ -43,7 +44,8 @@ public enum BpmSimpleModelNodeType implements IntArrayValuable {
|
|||||||
* @param type 节点类型
|
* @param type 节点类型
|
||||||
*/
|
*/
|
||||||
public static boolean isBranchNode(Integer type) {
|
public static boolean isBranchNode(Integer type) {
|
||||||
return Objects.equals(CONDITION_BRANCH_NODE.getType(), type) || Objects.equals(PARALLEL_BRANCH_FORK_NODE.getType(), type)
|
return Objects.equals(CONDITION_BRANCH_NODE.getType(), type)
|
||||||
|
|| Objects.equals(PARALLEL_BRANCH_FORK_NODE.getType(), type)
|
||||||
|| Objects.equals(INCLUSIVE_BRANCH_FORK_NODE.getType(), type) ;
|
|| Objects.equals(INCLUSIVE_BRANCH_FORK_NODE.getType(), type) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,16 +28,25 @@ public class BpmSimpleModelNodeVO {
|
|||||||
@Schema(description = "模型节点名称", example = "领导审批")
|
@Schema(description = "模型节点名称", example = "领导审批")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
// TODO @jason:要不改成 placeholder 和一般 Element-Plus 组件一致。占位符,用于展示。
|
||||||
@Schema(description = "节点展示内容", example = "指定成员: 芋道源码")
|
@Schema(description = "节点展示内容", example = "指定成员: 芋道源码")
|
||||||
private String showText;
|
private String showText;
|
||||||
|
|
||||||
@Schema(description = "孩子节点")
|
@Schema(description = "子节点")
|
||||||
private BpmSimpleModelNodeVO childNode;
|
private BpmSimpleModelNodeVO childNode; // 补充说明:在该模型下,子节点有且仅有一个,不会有多个
|
||||||
|
|
||||||
@Schema(description = "网关节点的条件节点")
|
@Schema(description = "条件节点")
|
||||||
private List<BpmSimpleModelNodeVO> conditionNodes;
|
private List<BpmSimpleModelNodeVO> conditionNodes; // 补充说明:有且仅有条件、并行、包容等分支会使用
|
||||||
|
|
||||||
@Schema(description = "节点的属性")
|
@Schema(description = "节点的属性")
|
||||||
private Map<String, Object> attributes;
|
private Map<String, Object> attributes; // TODO @jason:建议是字段分拆下;类似说:
|
||||||
|
// Map<String, Integer> formPermissions; 表单权限;仅发起、审批、抄送节点会使用
|
||||||
|
// Integer approveMethod; 审批方式;仅审批节点会使用
|
||||||
|
// TODO @芋艿:审批人的选择;
|
||||||
|
// TODO @芋艿:没有人的策略?
|
||||||
|
// TODO @芋艿:审批拒绝的策略?
|
||||||
|
// TODO @芋艿:配置的可操作列表?
|
||||||
|
// TODO @芋艿:超时配置;要支持指定时间点、指定时间间隔;
|
||||||
|
// TODO @芋艿:条件;建议可以固化的一些选项;然后有个表达式兜底;要支持
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import jakarta.validation.constraints.NotEmpty;
|
|||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
// TODO @jason:需要考虑,如果某个节点的配置不正确,需要有提示;具体怎么实现,可以讨论下;
|
||||||
@Schema(description = "管理后台 - 仿钉钉流程设计模型的新增/修改 Request VO")
|
@Schema(description = "管理后台 - 仿钉钉流程设计模型的新增/修改 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class BpmSimpleModelUpdateReqVO {
|
public class BpmSimpleModelUpdateReqVO {
|
||||||
@ -14,6 +15,7 @@ public class BpmSimpleModelUpdateReqVO {
|
|||||||
@NotEmpty(message = "流程模型编号不能为空")
|
@NotEmpty(message = "流程模型编号不能为空")
|
||||||
private String modelId; // 对应 Flowable act_re_model 表 ID_ 字段
|
private String modelId; // 对应 Flowable act_re_model 表 ID_ 字段
|
||||||
|
|
||||||
|
// TODO @jason:simpleModel 要不?
|
||||||
@Schema(description = "仿钉钉流程设计模型对象", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "仿钉钉流程设计模型对象", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@NotNull(message = "仿钉钉流程设计模型对象不能为空")
|
@NotNull(message = "仿钉钉流程设计模型对象不能为空")
|
||||||
@Valid
|
@Valid
|
||||||
|
@ -92,11 +92,13 @@ public class SimpleModelUtils {
|
|||||||
|
|
||||||
private static void buildAndAddBpmnSequenceFlow(Process mainProcess, BpmSimpleModelNodeVO node, String targetId) {
|
private static void buildAndAddBpmnSequenceFlow(Process mainProcess, BpmSimpleModelNodeVO node, String targetId) {
|
||||||
// 节点为 null 或者 为END_EVENT 退出
|
// 节点为 null 或者 为END_EVENT 退出
|
||||||
|
// TODO @jason:isValidNode;然后把 END_NODE 是不是拿到 switch (nodeType) { 那 return 哈?这样出口更统一一点?
|
||||||
if (node == null || node.getId() == null || END_NODE.getType().equals(node.getType())) {
|
if (node == null || node.getId() == null || END_NODE.getType().equals(node.getType())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BpmSimpleModelNodeVO childNode = node.getChildNode();
|
BpmSimpleModelNodeVO childNode = node.getChildNode();
|
||||||
// 如果是网关分支节点. 后续节点可能为 null。但不是 END_EVENT 节点
|
// 如果是网关分支节点. 后续节点可能为 null。但不是 END_EVENT 节点
|
||||||
|
// TODO @芋艿:这个要不要挪到 START_NODE - INCLUSIVE_BRANCH_JOIN_NODE 待定;感觉 switch 那最终是分三个情况;branch、子节点、结束了;(每种情况的注释,需要写的更完整)
|
||||||
if (!BpmSimpleModelNodeType.isBranchNode(node.getType()) && (childNode == null || childNode.getId() == null)) {
|
if (!BpmSimpleModelNodeType.isBranchNode(node.getType()) && (childNode == null || childNode.getId() == null)) {
|
||||||
SequenceFlow sequenceFlow = buildBpmnSequenceFlow(node.getId(), targetId, null, null, null);
|
SequenceFlow sequenceFlow = buildBpmnSequenceFlow(node.getId(), targetId, null, null, null);
|
||||||
mainProcess.addFlowElement(sequenceFlow);
|
mainProcess.addFlowElement(sequenceFlow);
|
||||||
@ -104,6 +106,7 @@ public class SimpleModelUtils {
|
|||||||
}
|
}
|
||||||
BpmSimpleModelNodeType nodeType = BpmSimpleModelNodeType.valueOf(node.getType());
|
BpmSimpleModelNodeType nodeType = BpmSimpleModelNodeType.valueOf(node.getType());
|
||||||
Assert.notNull(nodeType, "模型节点类型不支持");
|
Assert.notNull(nodeType, "模型节点类型不支持");
|
||||||
|
// TODO @jason:下面的 PARALLEL_BRANCH_FORK_NODE、CONDITION_BRANCH_NODE、INCLUSIVE_BRANCH_FORK_NODE 是不是就是 isBranchNode?如果是的话,貌似不用 swtich,而是 if else 分类处理呢。
|
||||||
switch (nodeType) {
|
switch (nodeType) {
|
||||||
case START_NODE:
|
case START_NODE:
|
||||||
case APPROVE_NODE:
|
case APPROVE_NODE:
|
||||||
@ -119,17 +122,24 @@ public class SimpleModelUtils {
|
|||||||
case PARALLEL_BRANCH_FORK_NODE:
|
case PARALLEL_BRANCH_FORK_NODE:
|
||||||
case CONDITION_BRANCH_NODE:
|
case CONDITION_BRANCH_NODE:
|
||||||
case INCLUSIVE_BRANCH_FORK_NODE: {
|
case INCLUSIVE_BRANCH_FORK_NODE: {
|
||||||
|
// TODO @jason:这里 sequenceFlowTargetId 不建议做这样的 default。万一可能有 bug 哈;直接弄到对应的 136- 146 会更安全一点。
|
||||||
String sequenceFlowTargetId = (childNode == null || childNode.getId() == null) ? targetId : childNode.getId();
|
String sequenceFlowTargetId = (childNode == null || childNode.getId() == null) ? targetId : childNode.getId();
|
||||||
List<BpmSimpleModelNodeVO> conditionNodes = node.getConditionNodes();
|
List<BpmSimpleModelNodeVO> conditionNodes = node.getConditionNodes();
|
||||||
Assert.notEmpty(conditionNodes, "网关节点的条件节点不能为空");
|
Assert.notEmpty(conditionNodes, "网关节点的条件节点不能为空");
|
||||||
for (BpmSimpleModelNodeVO item : conditionNodes) {
|
for (BpmSimpleModelNodeVO item : conditionNodes) {
|
||||||
|
// 构建表达式
|
||||||
|
// TODO @jason:条件分支的情况下,需要分 item 搞的条件,和 conditionNodes 搞的条件
|
||||||
String conditionExpression = buildConditionExpression(item);
|
String conditionExpression = buildConditionExpression(item);
|
||||||
|
|
||||||
BpmSimpleModelNodeVO nextNodeOnCondition = item.getChildNode();
|
BpmSimpleModelNodeVO nextNodeOnCondition = item.getChildNode();
|
||||||
|
// TODO @jason:isValidNode
|
||||||
if (nextNodeOnCondition != null && nextNodeOnCondition.getId() != null) {
|
if (nextNodeOnCondition != null && nextNodeOnCondition.getId() != null) {
|
||||||
|
// TODO @jason:会存在 item.name 未空的情况么?这个时候,要不要兜底处理拼接
|
||||||
SequenceFlow sequenceFlow = buildBpmnSequenceFlow(node.getId(), nextNodeOnCondition.getId(),
|
SequenceFlow sequenceFlow = buildBpmnSequenceFlow(node.getId(), nextNodeOnCondition.getId(),
|
||||||
item.getId(), item.getName(), conditionExpression);
|
item.getId(), item.getName(), conditionExpression);
|
||||||
mainProcess.addFlowElement(sequenceFlow);
|
mainProcess.addFlowElement(sequenceFlow);
|
||||||
// 递归调用后续节点
|
// 递归调用后续节点
|
||||||
|
// TODO @jason:最好也有个例子,嘿嘿;S4
|
||||||
buildAndAddBpmnSequenceFlow(mainProcess, nextNodeOnCondition, sequenceFlowTargetId);
|
buildAndAddBpmnSequenceFlow(mainProcess, nextNodeOnCondition, sequenceFlowTargetId);
|
||||||
} else {
|
} else {
|
||||||
SequenceFlow sequenceFlow = buildBpmnSequenceFlow(node.getId(), sequenceFlowTargetId,
|
SequenceFlow sequenceFlow = buildBpmnSequenceFlow(node.getId(), sequenceFlowTargetId,
|
||||||
@ -137,7 +147,7 @@ public class SimpleModelUtils {
|
|||||||
mainProcess.addFlowElement(sequenceFlow);
|
mainProcess.addFlowElement(sequenceFlow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 递归调用后续节点
|
// 递归调用后续节点 TODO @jason:最好有个例子哈
|
||||||
buildAndAddBpmnSequenceFlow(mainProcess, childNode, targetId);
|
buildAndAddBpmnSequenceFlow(mainProcess, childNode, targetId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -188,6 +198,9 @@ public class SimpleModelUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static SequenceFlow buildBpmnSequenceFlow(String sourceId, String targetId, String seqFlowId, String seqName, String conditionExpression) {
|
private static SequenceFlow buildBpmnSequenceFlow(String sourceId, String targetId, String seqFlowId, String seqName, String conditionExpression) {
|
||||||
|
// TODO @jason:最好断言下,sourceId、targetId 必须存在!
|
||||||
|
// TODO @jason:如果 seqFlowId 不存在的时候,是不是要生成一个默认的 seqFlowId?
|
||||||
|
// TODO @jason:如果 name 不存在的时候,是不是要生成一个默认的 name?
|
||||||
SequenceFlow sequenceFlow = new SequenceFlow(sourceId, targetId);
|
SequenceFlow sequenceFlow = new SequenceFlow(sourceId, targetId);
|
||||||
if (StrUtil.isNotEmpty(conditionExpression)) {
|
if (StrUtil.isNotEmpty(conditionExpression)) {
|
||||||
sequenceFlow.setConditionExpression(conditionExpression);
|
sequenceFlow.setConditionExpression(conditionExpression);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user