Commit b5777b57f18212ea23d62f1cd1d5003bf1853fa3
Committed by
Gitee
!863 添加assigne处理器
Merge pull request !863 from 云开/feature/BPM_CC_COPY
Showing
5 changed files
with
102 additions
and
74 deletions
yudao-framework/yudao-spring-boot-starter-flowable/src/main/java/cn/iocoder/yudao/framework/flowable/core/enums/ProcessConstants.java
0 → 100644
| 1 | +package cn.iocoder.yudao.framework.flowable.core.enums; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 流程常量信息 | ||
| 5 | + */ | ||
| 6 | +public interface ProcessConstants { | ||
| 7 | + | ||
| 8 | + String BPMN_FILE_SUFFIX = ".bpmn"; | ||
| 9 | + | ||
| 10 | + /** | ||
| 11 | + * nameapace | ||
| 12 | + * bpmn中的命名空间 | ||
| 13 | + * 这个东西有可能导致无法切换工作流程的实现 | ||
| 14 | + */ | ||
| 15 | + String NAMESPASE = "http://flowable.org/bpmn"; | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 自定义属性 dataType | ||
| 19 | + */ | ||
| 20 | + String PROCESS_CUSTOM_DATA_TYPE = "dataType"; | ||
| 21 | + | ||
| 22 | +} |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceCopyController.java
| @@ -49,7 +49,7 @@ public class BpmProcessInstanceCopyController { | @@ -49,7 +49,7 @@ public class BpmProcessInstanceCopyController { | ||
| 49 | @PostMapping("/create") | 49 | @PostMapping("/create") |
| 50 | @Operation(summary = "抄送流程") | 50 | @Operation(summary = "抄送流程") |
| 51 | @PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:create')") | 51 | @PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:create')") |
| 52 | - public CommonResult<Boolean> createProcessInstanceCC(@Valid @RequestBody BpmProcessInstanceCopyCreateReqVO createReqVO) { | 52 | + public CommonResult<Boolean> createProcessInstanceCopy(@Valid @RequestBody BpmProcessInstanceCopyCreateReqVO createReqVO) { |
| 53 | processInstanceCopyService.createProcessInstanceCopy(getLoginUserId(), createReqVO); | 53 | processInstanceCopyService.createProcessInstanceCopy(getLoginUserId(), createReqVO); |
| 54 | return success(true); | 54 | return success(true); |
| 55 | } | 55 | } |
| @@ -57,7 +57,7 @@ public class BpmProcessInstanceCopyController { | @@ -57,7 +57,7 @@ public class BpmProcessInstanceCopyController { | ||
| 57 | @GetMapping("/my-page") | 57 | @GetMapping("/my-page") |
| 58 | @Operation(summary = "获得抄送流程分页列表") | 58 | @Operation(summary = "获得抄送流程分页列表") |
| 59 | @PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:query')") | 59 | @PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:query')") |
| 60 | - public CommonResult<PageResult<BpmProcessInstanceCopyPageItemRespVO>> getProcessInstanceCCPage( | 60 | + public CommonResult<PageResult<BpmProcessInstanceCopyPageItemRespVO>> getProcessInstanceCopyPage( |
| 61 | @Valid BpmProcessInstanceCopyMyPageReqVO pageReqVO) { | 61 | @Valid BpmProcessInstanceCopyMyPageReqVO pageReqVO) { |
| 62 | PageResult<BpmProcessInstanceCopyDO> pageResult = processInstanceCopyService.getMyProcessInstanceCopyPage(getLoginUserId(), pageReqVO); | 62 | PageResult<BpmProcessInstanceCopyDO> pageResult = processInstanceCopyService.getMyProcessInstanceCopyPage(getLoginUserId(), pageReqVO); |
| 63 | if (CollUtil.isEmpty(pageResult.getList())) { | 63 | if (CollUtil.isEmpty(pageResult.getList())) { |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmProcessInstanceCopyVO.java deleted
| 1 | -package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; | ||
| 2 | - | ||
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | -import lombok.Data; | ||
| 5 | - | ||
| 6 | -import java.time.LocalDateTime; | ||
| 7 | - | ||
| 8 | -// TODO @kyle:1)明确是 Req 还是 Resp;2)注释可以合并到 swagger 里;3)example 写一下,这样一些 mock 接口平台可以读取 example | ||
| 9 | -/** | ||
| 10 | - * 流程抄送视图对象 | ||
| 11 | - */ | ||
| 12 | -@Data | ||
| 13 | -public class BpmProcessInstanceCopyVO { | ||
| 14 | - | ||
| 15 | - /** | ||
| 16 | - * 编号 | ||
| 17 | - */ | ||
| 18 | - @Schema(description = "抄送主键") | ||
| 19 | - private Long id; | ||
| 20 | - | ||
| 21 | - /** | ||
| 22 | - * 发起人Id | ||
| 23 | - */ | ||
| 24 | - @Schema(description = "发起人Id") | ||
| 25 | - private Long startUserId; | ||
| 26 | - | ||
| 27 | - @Schema(description = "发起人别名") | ||
| 28 | - private String startUserNickname; | ||
| 29 | - | ||
| 30 | - /** | ||
| 31 | - * 流程主键 | ||
| 32 | - */ | ||
| 33 | - @Schema(description = "流程实例的主键") | ||
| 34 | - private String processInstanceId; | ||
| 35 | - | ||
| 36 | - @Schema(description = "流程实例的名字") | ||
| 37 | - private String processInstanceName; | ||
| 38 | - | ||
| 39 | - /** | ||
| 40 | - * 任务主键 | ||
| 41 | - */ | ||
| 42 | - @Schema(description = "发起抄送的任务编号") | ||
| 43 | - private String taskId; | ||
| 44 | - | ||
| 45 | - @Schema(description = "发起抄送的任务名称") | ||
| 46 | - private String taskName; | ||
| 47 | - /** | ||
| 48 | - * 用户主键 | ||
| 49 | - */ | ||
| 50 | - @Schema(description = "用户编号") | ||
| 51 | - private Long userId; | ||
| 52 | - | ||
| 53 | - @Schema(description = "用户别名") | ||
| 54 | - private Long userNickname; | ||
| 55 | - | ||
| 56 | - @Schema(description = "抄送原因") | ||
| 57 | - private String reason; | ||
| 58 | - | ||
| 59 | - @Schema(description = "抄送人") | ||
| 60 | - private String creator; | ||
| 61 | - | ||
| 62 | - @Schema(description = "抄送时间") | ||
| 63 | - private LocalDateTime createTime; | ||
| 64 | - | ||
| 65 | -} |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/handler/MultiInstanceHandler.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.bpm.framework.flowable.core.handler; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import cn.hutool.core.util.ObjectUtil; | ||
| 5 | +import cn.iocoder.yudao.framework.flowable.core.enums.ProcessConstants; | ||
| 6 | +import cn.iocoder.yudao.module.system.api.permission.PermissionApi; | ||
| 7 | +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||
| 8 | +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | ||
| 9 | +import jakarta.annotation.Resource; | ||
| 10 | +import lombok.AllArgsConstructor; | ||
| 11 | +import org.flowable.bpmn.model.FlowElement; | ||
| 12 | +import org.flowable.bpmn.model.UserTask; | ||
| 13 | +import org.flowable.engine.delegate.DelegateExecution; | ||
| 14 | +import org.springframework.stereotype.Component; | ||
| 15 | + | ||
| 16 | +import java.util.ArrayList; | ||
| 17 | +import java.util.LinkedHashSet; | ||
| 18 | +import java.util.List; | ||
| 19 | +import java.util.Set; | ||
| 20 | +import java.util.stream.Collectors; | ||
| 21 | + | ||
| 22 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | ||
| 23 | + | ||
| 24 | +/** | ||
| 25 | + * 多实例处理类 | ||
| 26 | + */ | ||
| 27 | +@AllArgsConstructor | ||
| 28 | +@Component("multiInstanceHandler") | ||
| 29 | +public class MultiInstanceHandler { | ||
| 30 | + | ||
| 31 | + @Resource | ||
| 32 | + private AdminUserApi userApi; | ||
| 33 | + | ||
| 34 | + @Resource | ||
| 35 | + private PermissionApi permissionApi; | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * 流程发起人那种情况不需要处理, | ||
| 39 | + * 由 flowable 完成 | ||
| 40 | + * | ||
| 41 | + * @param execution flowable的执行对象 | ||
| 42 | + * @return 用户ID | ||
| 43 | + */ | ||
| 44 | + public Set<String> getUserIds(DelegateExecution execution) { | ||
| 45 | + Set<String> candidateUserIds = new LinkedHashSet<>(); | ||
| 46 | + FlowElement flowElement = execution.getCurrentFlowElement(); | ||
| 47 | + if (ObjectUtil.isNotEmpty(flowElement) && flowElement instanceof UserTask userTask) { | ||
| 48 | + String dataType = userTask.getAttributeValue(ProcessConstants.NAMESPASE, ProcessConstants.PROCESS_CUSTOM_DATA_TYPE); | ||
| 49 | + if ("USERS".equals(dataType) && CollUtil.isNotEmpty(userTask.getCandidateUsers())) { | ||
| 50 | + // 添加候选用户id | ||
| 51 | + candidateUserIds.addAll(userTask.getCandidateUsers()); | ||
| 52 | + } else if (CollUtil.isNotEmpty(userTask.getCandidateGroups())) { | ||
| 53 | + // 获取组的ID,角色ID集合或部门ID集合 | ||
| 54 | + List<Long> groups = userTask.getCandidateGroups().stream() | ||
| 55 | + // 例如部门DEPT100,100才是部门id | ||
| 56 | + .map(item -> Long.parseLong(item.substring(4))) | ||
| 57 | + .collect(Collectors.toList()); | ||
| 58 | + List<Long> userIds = new ArrayList<>(); | ||
| 59 | + if ("ROLES".equals(dataType)) { | ||
| 60 | + // 通过角色id,获取所有用户id集合 | ||
| 61 | + Set<Long> userRoleIdListByRoleIds = permissionApi.getUserRoleIdListByRoleIds(groups); | ||
| 62 | + userIds = new ArrayList<>(userRoleIdListByRoleIds); | ||
| 63 | + } else if ("DEPTS".equals(dataType)) { | ||
| 64 | + // 通过部门id,获取所有用户id集合 | ||
| 65 | + List<AdminUserRespDTO> userListByDeptIds = userApi.getUserListByDeptIds(groups); | ||
| 66 | + userIds = convertList(userListByDeptIds, AdminUserRespDTO::getId); | ||
| 67 | + } | ||
| 68 | + // 添加候选用户id | ||
| 69 | + userIds.forEach(id -> candidateUserIds.add(String.valueOf(id))); | ||
| 70 | + } | ||
| 71 | + } | ||
| 72 | + return candidateUserIds; | ||
| 73 | + } | ||
| 74 | +} |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/definition/BpmProcessDefinitionServiceImpl.java
| @@ -5,8 +5,8 @@ import cn.hutool.core.util.ObjectUtil; | @@ -5,8 +5,8 @@ import cn.hutool.core.util.ObjectUtil; | ||
| 5 | import cn.hutool.core.util.StrUtil; | 5 | import cn.hutool.core.util.StrUtil; |
| 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | import cn.iocoder.yudao.framework.common.util.object.PageUtils; | 7 | import cn.iocoder.yudao.framework.common.util.object.PageUtils; |
| 8 | +import cn.iocoder.yudao.framework.flowable.core.enums.ProcessConstants; | ||
| 8 | import cn.iocoder.yudao.framework.flowable.core.util.BpmnModelUtils; | 9 | import cn.iocoder.yudao.framework.flowable.core.util.BpmnModelUtils; |
| 9 | -import cn.iocoder.yudao.framework.flowable.core.util.FlowableUtils; | ||
| 10 | import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; | 10 | import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; |
| 11 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionListReqVO; | 11 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionListReqVO; |
| 12 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageItemRespVO; | 12 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.process.BpmProcessDefinitionPageItemRespVO; |
| @@ -17,6 +17,8 @@ import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; | @@ -17,6 +17,8 @@ import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmFormDO; | ||
| 17 | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; | 17 | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmProcessDefinitionExtDO; |
| 18 | import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessDefinitionExtMapper; | 18 | import cn.iocoder.yudao.module.bpm.dal.mysql.definition.BpmProcessDefinitionExtMapper; |
| 19 | import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; | 19 | import cn.iocoder.yudao.module.bpm.service.definition.dto.BpmProcessDefinitionCreateReqDTO; |
| 20 | +import jakarta.annotation.Resource; | ||
| 21 | +import jakarta.validation.Valid; | ||
| 20 | import lombok.extern.slf4j.Slf4j; | 22 | import lombok.extern.slf4j.Slf4j; |
| 21 | import org.flowable.bpmn.converter.BpmnXMLConverter; | 23 | import org.flowable.bpmn.converter.BpmnXMLConverter; |
| 22 | import org.flowable.bpmn.model.BpmnModel; | 24 | import org.flowable.bpmn.model.BpmnModel; |
| @@ -29,13 +31,10 @@ import org.flowable.engine.repository.ProcessDefinitionQuery; | @@ -29,13 +31,10 @@ import org.flowable.engine.repository.ProcessDefinitionQuery; | ||
| 29 | import org.springframework.stereotype.Service; | 31 | import org.springframework.stereotype.Service; |
| 30 | import org.springframework.validation.annotation.Validated; | 32 | import org.springframework.validation.annotation.Validated; |
| 31 | 33 | ||
| 32 | -import jakarta.annotation.Resource; | ||
| 33 | -import jakarta.validation.Valid; | ||
| 34 | import java.util.*; | 34 | import java.util.*; |
| 35 | 35 | ||
| 36 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 36 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 37 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; | 37 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; |
| 38 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; | ||
| 39 | import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_KEY_NOT_MATCH; | 38 | import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_KEY_NOT_MATCH; |
| 40 | import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_NAME_NOT_MATCH; | 39 | import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.PROCESS_DEFINITION_NAME_NOT_MATCH; |
| 41 | import static java.util.Collections.emptyList; | 40 | import static java.util.Collections.emptyList; |
| @@ -53,8 +52,6 @@ import static java.util.Collections.emptyList; | @@ -53,8 +52,6 @@ import static java.util.Collections.emptyList; | ||
| 53 | @Slf4j | 52 | @Slf4j |
| 54 | public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionService { | 53 | public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionService { |
| 55 | 54 | ||
| 56 | - private static final String BPMN_FILE_SUFFIX = ".bpmn"; | ||
| 57 | - | ||
| 58 | @Resource | 55 | @Resource |
| 59 | private RepositoryService repositoryService; | 56 | private RepositoryService repositoryService; |
| 60 | 57 | ||
| @@ -125,7 +122,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ | @@ -125,7 +122,7 @@ public class BpmProcessDefinitionServiceImpl implements BpmProcessDefinitionServ | ||
| 125 | // 创建 Deployment 部署 | 122 | // 创建 Deployment 部署 |
| 126 | Deployment deploy = repositoryService.createDeployment() | 123 | Deployment deploy = repositoryService.createDeployment() |
| 127 | .key(createReqDTO.getKey()).name(createReqDTO.getName()).category(createReqDTO.getCategory()) | 124 | .key(createReqDTO.getKey()).name(createReqDTO.getName()).category(createReqDTO.getCategory()) |
| 128 | - .addBytes(createReqDTO.getKey() + BPMN_FILE_SUFFIX, createReqDTO.getBpmnBytes()) | 125 | + .addBytes(createReqDTO.getKey() + ProcessConstants.BPMN_FILE_SUFFIX, createReqDTO.getBpmnBytes()) |
| 129 | .tenantId(TenantContextHolder.getTenantIdStr()) | 126 | .tenantId(TenantContextHolder.getTenantIdStr()) |
| 130 | .deploy(); | 127 | .deploy(); |
| 131 | 128 |