Commit dee2b7cb96d7e7b3385c49301835ea503f74095f
1 parent
8c681a77
fix: 代码审查修改
Showing
7 changed files
with
41 additions
and
66 deletions
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmSimpleModelNodeTypeEnum.java
| ... | ... | @@ -30,8 +30,7 @@ public enum BpmSimpleModelNodeTypeEnum implements ArrayValuable<Integer> { |
| 30 | 30 | DELAY_TIMER_NODE(14, "延迟器", "receiveTask"), |
| 31 | 31 | TRIGGER_NODE(15, "触发器", "serviceTask"), |
| 32 | 32 | |
| 33 | - CHILD_PROCESS(20, "子流程", "callActivity"), // TODO @lesan:CHILD_PROCESS、ASYNC_CHILD_PROCESS 可以合并为一个么? | |
| 34 | - ASYNC_CHILD_PROCESS(21, "异步子流程", "callActivity"), | |
| 33 | + CHILD_PROCESS(20, "子流程", "callActivity"), | |
| 35 | 34 | |
| 36 | 35 | // 50 ~ 条件分支 |
| 37 | 36 | CONDITION_NODE(50, "条件", "sequenceFlow"), // 用于构建流转条件的表达式 | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java
| ... | ... | @@ -425,33 +425,30 @@ public class BpmSimpleModelNodeVO { |
| 425 | 425 | @Valid |
| 426 | 426 | public static class ChildProcessSetting { |
| 427 | 427 | |
| 428 | - // TODO @lesan:calledElement => calledProcessDefinitionKey ? 这样更容易理解?不过如果一个流程多次发起,key 变了,好像会有问题? | |
| 429 | 428 | @Schema(description = "被调用流程", requiredMode = Schema.RequiredMode.REQUIRED, example = "xxx") |
| 430 | 429 | @NotEmpty(message = "被调用流程不能为空") |
| 431 | - private String calledElement; | |
| 430 | + private String calledProcessDefinitionKey; | |
| 432 | 431 | |
| 433 | 432 | @Schema(description = "被调用流程名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "xxx") |
| 434 | 433 | @NotEmpty(message = "被调用流程名称不能为空") |
| 435 | - private String calledElementName; | |
| 434 | + private String calledProcessDefinitionName; | |
| 436 | 435 | |
| 437 | 436 | @Schema(description = "是否异步", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") |
| 438 | 437 | @NotNull(message = "是否异步不能为空") |
| 439 | 438 | private Boolean async; |
| 440 | 439 | |
| 441 | - // TODO @lesan:inVariables | |
| 442 | - @Schema(description = "输入参数(主->子)", requiredMode = Schema.RequiredMode.REQUIRED, example = "[]") | |
| 443 | - private List<IOParameter> inVariable; | |
| 440 | + @Schema(description = "输入参数(主->子)", example = "[]") | |
| 441 | + private List<IOParameter> inVariables; | |
| 444 | 442 | |
| 445 | - // TODO @lesan:outVariables | |
| 446 | 443 | @Schema(description = "输出参数(子->主)", example = "[]") |
| 447 | - private List<IOParameter> outVariable; | |
| 444 | + private List<IOParameter> outVariables; | |
| 448 | 445 | |
| 449 | - @Schema(description = "是否自动跳过子流程发起节点", example = "false") | |
| 446 | + @Schema(description = "是否自动跳过子流程发起节点", requiredMode = Schema.RequiredMode.REQUIRED, example = "false") | |
| 450 | 447 | @NotNull(message = "是否自动跳过子流程发起节点不能为空") |
| 451 | 448 | private Boolean skipStartUserNode; |
| 452 | 449 | |
| 453 | 450 | @Schema(description = "子流程发起人配置", requiredMode = Schema.RequiredMode.REQUIRED, example = "{}") |
| 454 | - // TODO @lesan:这个应该也必须填写? | |
| 451 | + @NotNull(message = "子流程发起人配置不能为空") | |
| 455 | 452 | private StartUserSetting startUserSetting; |
| 456 | 453 | |
| 457 | 454 | @Schema(description = "子流程发起人配置") |
| ... | ... | @@ -467,11 +464,10 @@ public class BpmSimpleModelNodeVO { |
| 467 | 464 | @Schema(description = "表单", example = "xxx") |
| 468 | 465 | private String formField; |
| 469 | 466 | |
| 470 | - // TODO @lesan:emptyHandleType => emptyType,和 type 对上? | |
| 471 | 467 | @Schema(description = "当子流程发起人为空时类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 472 | 468 | @NotNull(message = "当子流程发起人为空时类型不能为空") |
| 473 | 469 | @InEnum(BpmChildProcessStartUserEmptyTypeEnum.class) |
| 474 | - private Integer emptyHandleType; | |
| 470 | + private Integer emptyType; | |
| 475 | 471 | |
| 476 | 472 | } |
| 477 | 473 | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/FlowableUtils.java
| 1 | 1 | package cn.iocoder.yudao.module.bpm.framework.flowable.core.util; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.map.MapUtil; | |
| 3 | 4 | import cn.hutool.core.util.ObjectUtil; |
| 4 | -import cn.hutool.core.util.StrUtil; | |
| 5 | 5 | import cn.hutool.extra.spring.SpringUtil; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.core.KeyValue; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| ... | ... | @@ -244,8 +244,7 @@ public class FlowableUtils { |
| 244 | 244 | return formFieldsMap.entrySet().stream() |
| 245 | 245 | .limit(3) |
| 246 | 246 | .map(entry -> new KeyValue<>(entry.getValue().getTitle(), |
| 247 | - // TODO @lesan: MapUtil.getStr 可以更简单? | |
| 248 | - StrUtil.toStringOrEmpty(processVariables.getOrDefault(entry.getValue().getField(), "")))) | |
| 247 | + MapUtil.getStr(processVariables, entry.getValue().getField(), ""))) | |
| 249 | 248 | .collect(Collectors.toList()); |
| 250 | 249 | } |
| 251 | 250 | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java
| ... | ... | @@ -48,7 +48,7 @@ public class SimpleModelUtils { |
| 48 | 48 | new StartUserNodeConvert(), new ApproveNodeConvert(), new CopyNodeConvert(), new TransactorNodeConvert(), |
| 49 | 49 | new DelayTimerNodeConvert(), new TriggerNodeConvert(), |
| 50 | 50 | new ConditionBranchNodeConvert(), new ParallelBranchNodeConvert(), new InclusiveBranchNodeConvert(), new RouteBranchNodeConvert(), |
| 51 | - new ChildProcessConvert(), new AsyncChildProcessConvert()); | |
| 51 | + new ChildProcessConvert()); | |
| 52 | 52 | converts.forEach(convert -> NODE_CONVERTS.put(convert.getType(), convert)); |
| 53 | 53 | } |
| 54 | 54 | |
| ... | ... | @@ -819,46 +819,38 @@ public class SimpleModelUtils { |
| 819 | 819 | @Override |
| 820 | 820 | public CallActivity convert(BpmSimpleModelNodeVO node) { |
| 821 | 821 | BpmSimpleModelNodeVO.ChildProcessSetting childProcessSetting = node.getChildProcessSetting(); |
| 822 | - List<IOParameter> inVariable = childProcessSetting.getInVariable() == null ? | |
| 823 | - new ArrayList<>() : new ArrayList<>(childProcessSetting.getInVariable()); | |
| 822 | + List<IOParameter> inVariables = childProcessSetting.getInVariables() == null ? | |
| 823 | + new ArrayList<>() : new ArrayList<>(childProcessSetting.getInVariables()); | |
| 824 | 824 | CallActivity callActivity = new CallActivity(); |
| 825 | 825 | callActivity.setId(node.getId()); |
| 826 | 826 | callActivity.setName(node.getName()); |
| 827 | - callActivity.setCalledElementType("key"); // TODO @lesan:这里为啥是 key 哈? | |
| 827 | + callActivity.setCalledElementType("key"); | |
| 828 | 828 | // 1. 是否异步 |
| 829 | - callActivity.setAsynchronous(node.getChildProcessSetting().getAsync()); | |
| 829 | + if (node.getChildProcessSetting().getAsync()) { | |
| 830 | + // TODO @lesan: 这里目前测试没有跳过执行call activity 后面的节点 | |
| 831 | + callActivity.setAsynchronous(true); | |
| 832 | + } | |
| 830 | 833 | |
| 831 | 834 | // 2. 调用的子流程 |
| 832 | - callActivity.setCalledElement(childProcessSetting.getCalledElement()); | |
| 833 | - callActivity.setProcessInstanceName(childProcessSetting.getCalledElementName()); | |
| 835 | + callActivity.setCalledElement(childProcessSetting.getCalledProcessDefinitionKey()); | |
| 836 | + callActivity.setProcessInstanceName(childProcessSetting.getCalledProcessDefinitionName()); | |
| 834 | 837 | |
| 835 | 838 | // 3. 是否自动跳过子流程发起节点 |
| 836 | - // TODO @lesan:貌似只有 SourceExpression 的区别,直接通过 valueOf childProcessSetting.getSkipStartUserNode()??? | |
| 837 | - if (Boolean.TRUE.equals(childProcessSetting.getSkipStartUserNode())) { | |
| 838 | - IOParameter ioParameter = new IOParameter(); | |
| 839 | - ioParameter.setSourceExpression("true"); | |
| 840 | - ioParameter.setTarget(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_SKIP_START_USER_NODE); | |
| 841 | - inVariable.add(ioParameter); | |
| 842 | - } else { | |
| 843 | - IOParameter ioParameter = new IOParameter(); | |
| 844 | - ioParameter.setSourceExpression("false"); | |
| 845 | - ioParameter.setTarget(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_SKIP_START_USER_NODE); | |
| 846 | - inVariable.add(ioParameter); | |
| 847 | - } | |
| 848 | - | |
| 849 | - // 4. 主→子变量传递 | |
| 850 | - // 4.1 【默认需要传递的一些变量】流程状态 | |
| 851 | - // TODO @lesan:4.1 这个要不,单独一个序号,类似 3. 这个。然后下面,就是把 主→子变量传递、子→主变量传递;这样逻辑连贯点哈 | |
| 852 | 839 | IOParameter ioParameter = new IOParameter(); |
| 840 | + ioParameter.setSourceExpression(childProcessSetting.getSkipStartUserNode().toString()); | |
| 841 | + ioParameter.setTarget(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_SKIP_START_USER_NODE); | |
| 842 | + inVariables.add(ioParameter); | |
| 843 | + | |
| 844 | + // 4. 【默认需要传递的一些变量】流程状态 | |
| 845 | + ioParameter = new IOParameter(); | |
| 853 | 846 | ioParameter.setSource(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_STATUS); |
| 854 | 847 | ioParameter.setTarget(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_STATUS); |
| 855 | - inVariable.add(ioParameter); | |
| 856 | - callActivity.setInParameters(inVariable); | |
| 848 | + inVariables.add(ioParameter); | |
| 857 | 849 | |
| 858 | - // 5. 子→主变量传递 | |
| 859 | - // TODO @lesan:通过 isNotEmpty 这种哈 | |
| 860 | - if (childProcessSetting.getOutVariable() != null && !childProcessSetting.getOutVariable().isEmpty()) { | |
| 861 | - callActivity.setOutParameters(childProcessSetting.getOutVariable()); | |
| 850 | + // 5. 主→子变量传递、子->主变量传递 | |
| 851 | + callActivity.setInParameters(inVariables); | |
| 852 | + if (ArrayUtil.isNotEmpty(childProcessSetting.getOutVariables()) && ObjUtil.notEqual(childProcessSetting.getAsync(), Boolean.TRUE)) { | |
| 853 | + callActivity.setOutParameters(childProcessSetting.getOutVariables()); | |
| 862 | 854 | } |
| 863 | 855 | |
| 864 | 856 | // 6. 子流程发起人配置 |
| ... | ... | @@ -886,16 +878,6 @@ public class SimpleModelUtils { |
| 886 | 878 | |
| 887 | 879 | } |
| 888 | 880 | |
| 889 | - private static class AsyncChildProcessConvert extends ChildProcessConvert { | |
| 890 | - | |
| 891 | - @Override | |
| 892 | - public BpmSimpleModelNodeTypeEnum getType() { | |
| 893 | - return BpmSimpleModelNodeTypeEnum.ASYNC_CHILD_PROCESS; | |
| 894 | - } | |
| 895 | - | |
| 896 | - } | |
| 897 | - | |
| 898 | - | |
| 899 | 881 | private static String buildGatewayJoinId(String id) { |
| 900 | 882 | return id + "_join"; |
| 901 | 883 | } |
| ... | ... | @@ -926,7 +908,6 @@ public class SimpleModelUtils { |
| 926 | 908 | || nodeType == BpmSimpleModelNodeTypeEnum.TRANSACTOR_NODE |
| 927 | 909 | || nodeType == BpmSimpleModelNodeTypeEnum.COPY_NODE |
| 928 | 910 | || nodeType == BpmSimpleModelNodeTypeEnum.CHILD_PROCESS |
| 929 | - || nodeType == BpmSimpleModelNodeTypeEnum.ASYNC_CHILD_PROCESS | |
| 930 | 911 | || nodeType == BpmSimpleModelNodeTypeEnum.END_NODE) { |
| 931 | 912 | // 添加元素 |
| 932 | 913 | resultNodes.add(currentNode); | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java
| ... | ... | @@ -320,7 +320,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 320 | 320 | // 遍历 tasks 列表,只处理已结束的 UserTask |
| 321 | 321 | // 为什么不通过 activities 呢?因为,加签场景下,它只存在于 tasks,没有 activities,导致如果遍历 activities |
| 322 | 322 | // 的话,它无法成为一个节点 |
| 323 | - // TODO @芋艿:子流程只有activity,这里获取不到已结束的子流程;TODO @lesan:这个会有啥影响?微信聊? | |
| 323 | + // TODO @芋艿:子流程只有activity,这里获取不到已结束的子流程;TODO @lesan:这个会导致timeline不会展示已结束的子流程 | |
| 324 | 324 | List<HistoricTaskInstance> endTasks = filterList(tasks, task -> task.getEndTime() != null); |
| 325 | 325 | List<ActivityNode> approvalNodes = convertList(endTasks, task -> { |
| 326 | 326 | FlowElement flowNode = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey()); |
| ... | ... | @@ -414,7 +414,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 414 | 414 | // 处理每个任务的 tasks 属性 |
| 415 | 415 | for (HistoricActivityInstance activity : taskActivities) { |
| 416 | 416 | HistoricTaskInstance task = taskMap.get(activity.getTaskId()); |
| 417 | - // TODO @lesan:这里为啥 continue 哈? | |
| 417 | + // TODO @lesan:这里为啥 continue 哈? @芋艿:子流程的 activity 中 task 是null 下面的方法会报错 | |
| 418 | 418 | if (task == null) { |
| 419 | 419 | continue; |
| 420 | 420 | } |
| ... | ... | @@ -510,8 +510,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | // 4. 子流程节点 |
| 513 | - if (BpmSimpleModelNodeTypeEnum.CHILD_PROCESS.getType().equals(node.getType()) || | |
| 514 | - BpmSimpleModelNodeTypeEnum.ASYNC_CHILD_PROCESS.getType().equals(node.getType())) { | |
| 513 | + if (BpmSimpleModelNodeTypeEnum.CHILD_PROCESS.getType().equals(node.getType())) { | |
| 515 | 514 | return activityNode; |
| 516 | 515 | } |
| 517 | 516 | return null; | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
| ... | ... | @@ -1230,7 +1230,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { |
| 1230 | 1230 | if (userTaskElement.getId().equals(START_USER_NODE_ID) |
| 1231 | 1231 | && (skipStartUserNodeFlag == null // 目的:一般是“主流程”,发起人节点,自动通过审核 |
| 1232 | 1232 | || Boolean.TRUE.equals(skipStartUserNodeFlag)) // 目的:一般是“子流程”,发起人节点,按配置自动通过审核 |
| 1233 | - && !Boolean.TRUE.equals(returnTaskFlag)) { // TODO @lesan:ObjUtil.notEqual(returnTaskFlag, Boolean.TRUE) 改成这个有问题么?尽量不用 ! 取反 | |
| 1233 | + && ObjUtil.notEqual(returnTaskFlag, Boolean.TRUE)) { | |
| 1234 | 1234 | getSelf().approveTask(Long.valueOf(task.getAssignee()), new BpmTaskApproveReqVO().setId(task.getId()) |
| 1235 | 1235 | .setReason(BpmReasonEnum.ASSIGN_START_USER_APPROVE_WHEN_SKIP_START_USER_NODE.getReason())); |
| 1236 | 1236 | return; | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/listener/BpmCallActivityListener.java
| ... | ... | @@ -59,19 +59,19 @@ public class BpmCallActivityListener implements ExecutionListener { |
| 59 | 59 | // 2.1 当表单值为空时 |
| 60 | 60 | if (StrUtil.isEmpty(formFieldValue)) { |
| 61 | 61 | // 2.1.1 来自主流程发起人 |
| 62 | - if (startUserSetting.getEmptyHandleType().equals(BpmChildProcessStartUserEmptyTypeEnum.MAIN_PROCESS_START_USER.getType())) { | |
| 62 | + if (startUserSetting.getEmptyType().equals(BpmChildProcessStartUserEmptyTypeEnum.MAIN_PROCESS_START_USER.getType())) { | |
| 63 | 63 | FlowableUtils.setAuthenticatedUserId(Long.parseLong(parent.getStartUserId())); |
| 64 | 64 | return; |
| 65 | 65 | } |
| 66 | 66 | // 2.1.2 来自子流程管理员 |
| 67 | - if (startUserSetting.getEmptyHandleType().equals(BpmChildProcessStartUserEmptyTypeEnum.CHILD_PROCESS_ADMIN.getType())) { | |
| 67 | + if (startUserSetting.getEmptyType().equals(BpmChildProcessStartUserEmptyTypeEnum.CHILD_PROCESS_ADMIN.getType())) { | |
| 68 | 68 | BpmProcessDefinitionInfoDO processDefinition = processDefinitionService.getProcessDefinitionInfo(execution.getProcessDefinitionId()); |
| 69 | 69 | List<Long> managerUserIds = processDefinition.getManagerUserIds(); |
| 70 | 70 | FlowableUtils.setAuthenticatedUserId(managerUserIds.get(0)); |
| 71 | 71 | return; |
| 72 | 72 | } |
| 73 | 73 | // 2.1.3 来自主流程管理员 |
| 74 | - if (startUserSetting.getEmptyHandleType().equals(BpmChildProcessStartUserEmptyTypeEnum.MAIN_PROCESS_ADMIN.getType())) { | |
| 74 | + if (startUserSetting.getEmptyType().equals(BpmChildProcessStartUserEmptyTypeEnum.MAIN_PROCESS_ADMIN.getType())) { | |
| 75 | 75 | BpmProcessDefinitionInfoDO processDefinition = processDefinitionService.getProcessDefinitionInfo(parent.getProcessDefinitionId()); |
| 76 | 76 | List<Long> managerUserIds = processDefinition.getManagerUserIds(); |
| 77 | 77 | FlowableUtils.setAuthenticatedUserId(managerUserIds.get(0)); |
| ... | ... | @@ -82,7 +82,8 @@ public class BpmCallActivityListener implements ExecutionListener { |
| 82 | 82 | try { |
| 83 | 83 | FlowableUtils.setAuthenticatedUserId(Long.parseLong(formFieldValue)); |
| 84 | 84 | } catch (Exception e) { |
| 85 | - // todo @lesan:打个日志,方便排查 | |
| 85 | + log.error("[error][监听器:{},子流程监听器设置流程的发起人字符串转 Long 失败,字符串:{}]", | |
| 86 | + DELEGATE_EXPRESSION, formFieldValue); | |
| 86 | 87 | FlowableUtils.setAuthenticatedUserId(Long.parseLong(parent.getStartUserId())); |
| 87 | 88 | } |
| 88 | 89 | } | ... | ... |