Commit de297e3a78d5a331e5d51ae0f28f328d40796871
1 parent
61e32752
feat: BPM-更多设置-标题设置
Showing
4 changed files
with
45 additions
and
2 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/BpmModelMetaInfoVO.java
| ... | ... | @@ -74,6 +74,9 @@ public class BpmModelMetaInfoVO { |
| 74 | 74 | @InEnum(BpmAutoApproveTypeEnum.class) |
| 75 | 75 | private Integer autoApprovalType; |
| 76 | 76 | |
| 77 | + @Schema(description = "标题设置", example = "{}") | |
| 78 | + private CustomTitleSetting customTitleSetting; | |
| 79 | + | |
| 77 | 80 | @Schema(description = "流程 ID 规则") |
| 78 | 81 | @Data |
| 79 | 82 | @Valid |
| ... | ... | @@ -98,4 +101,18 @@ public class BpmModelMetaInfoVO { |
| 98 | 101 | |
| 99 | 102 | } |
| 100 | 103 | |
| 104 | + @Schema(description = "标题设置") | |
| 105 | + @Data | |
| 106 | + @Valid | |
| 107 | + public static class CustomTitleSetting { | |
| 108 | + | |
| 109 | + @Schema(description = "是否自定义", example = "false") | |
| 110 | + @NotNull(message = "是否自定义不能为空") | |
| 111 | + private Boolean enable; | |
| 112 | + | |
| 113 | + @Schema(description = "标题", example = "流程标题") | |
| 114 | + private String title; | |
| 115 | + | |
| 116 | + } | |
| 117 | + | |
| 101 | 118 | } | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/definition/BpmProcessDefinitionInfoDO.java
| ... | ... | @@ -170,4 +170,10 @@ public class BpmProcessDefinitionInfoDO extends BaseDO { |
| 170 | 170 | */ |
| 171 | 171 | private Integer autoApprovalType; |
| 172 | 172 | |
| 173 | + /** | |
| 174 | + * 标题设置 | |
| 175 | + */ | |
| 176 | + @TableField(typeHandler = JacksonTypeHandler.class) | |
| 177 | + private BpmModelMetaInfoVO.CustomTitleSetting customTitleSetting; | |
| 178 | + | |
| 173 | 179 | } | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnVariableConstants.java
| ... | ... | @@ -50,6 +50,14 @@ public class BpmnVariableConstants { |
| 50 | 50 | * @see <a href="https://blog.csdn.net/weixin_42065235/article/details/126039993">Flowable/Activiti之SkipExpression 完成自动审批</a> |
| 51 | 51 | */ |
| 52 | 52 | public static final String PROCESS_INSTANCE_SKIP_EXPRESSION_ENABLED = "_FLOWABLE_SKIP_EXPRESSION_ENABLED"; |
| 53 | + /** | |
| 54 | + * 流程实例的变量 - 流程开始时间 | |
| 55 | + */ | |
| 56 | + public static final String PROCESS_START_TIME = "PROCESS_START_TIME"; | |
| 57 | + /** | |
| 58 | + * 流程实例的变量 - 流程定义名称 | |
| 59 | + */ | |
| 60 | + public static final String PROCESS_DEFINITION_NAME = "PROCESS_DEFINITION_NAME"; | |
| 53 | 61 | |
| 54 | 62 | /** |
| 55 | 63 | * 任务的变量 - 状态 | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.bpm.service.task; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.collection.ListUtil; |
| 5 | +import cn.hutool.core.date.DateUtil; | |
| 5 | 6 | import cn.hutool.core.lang.Assert; |
| 6 | 7 | import cn.hutool.core.util.ArrayUtil; |
| 7 | 8 | import cn.hutool.core.util.ObjectUtil; |
| ... | ... | @@ -610,14 +611,25 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService |
| 610 | 611 | ProcessInstanceBuilder processInstanceBuilder = runtimeService.createProcessInstanceBuilder() |
| 611 | 612 | .processDefinitionId(definition.getId()) |
| 612 | 613 | .businessKey(businessKey) |
| 613 | - .name(definition.getName().trim()) | |
| 614 | 614 | .variables(variables); |
| 615 | 615 | // 3.1 创建流程 ID |
| 616 | 616 | BpmModelMetaInfoVO.ProcessIdRule processIdRule = processDefinitionInfo.getProcessIdRule(); |
| 617 | 617 | if (processIdRule != null && Boolean.TRUE.equals(processIdRule.getEnable())) { |
| 618 | 618 | processInstanceBuilder.predefineProcessInstanceId(processIdRedisDAO.generate(processIdRule)); |
| 619 | 619 | } |
| 620 | - // 3.2 发起流程实例 | |
| 620 | + // 3.2 流程名称 | |
| 621 | + BpmModelMetaInfoVO.CustomTitleSetting customTitleSetting = processDefinitionInfo.getCustomTitleSetting(); | |
| 622 | + if (customTitleSetting != null && Boolean.TRUE.equals(customTitleSetting.getEnable())) { | |
| 623 | + AdminUserRespDTO user = adminUserApi.getUser(userId); | |
| 624 | + Map<String, Object> cloneVariables = ObjectUtil.clone(variables); | |
| 625 | + cloneVariables.put(BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_START_USER_ID, user.getNickname()); | |
| 626 | + cloneVariables.put(BpmnVariableConstants.PROCESS_START_TIME, DateUtil.now()); | |
| 627 | + cloneVariables.put(BpmnVariableConstants.PROCESS_DEFINITION_NAME, definition.getName().trim()); | |
| 628 | + processInstanceBuilder.name(StrUtil.format(customTitleSetting.getTitle(), cloneVariables)); | |
| 629 | + } else { | |
| 630 | + processInstanceBuilder.name(definition.getName().trim()); | |
| 631 | + } | |
| 632 | + // 3.3 发起流程实例 | |
| 621 | 633 | ProcessInstance instance = processInstanceBuilder.start(); |
| 622 | 634 | return instance.getId(); |
| 623 | 635 | } | ... | ... |