Commit 555bac151d20cd003e7e79e7bdfc03eeac5dc1c6
1 parent
e21c262b
feat: 基本完成流程抄送
Showing
23 changed files
with
859 additions
and
53 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/candidate/vo/BpmTaskCandidateVO.java renamed to yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/candidate/vo/BpmTaskCandidateRuleVO.java
| @@ -14,7 +14,7 @@ import java.util.Set; | @@ -14,7 +14,7 @@ import java.util.Set; | ||
| 14 | * @see BpmTaskAssignRuleBaseVO | 14 | * @see BpmTaskAssignRuleBaseVO |
| 15 | */ | 15 | */ |
| 16 | @Data | 16 | @Data |
| 17 | -public class BpmTaskCandidateVO { | 17 | +public class BpmTaskCandidateRuleVO { |
| 18 | 18 | ||
| 19 | @Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "bpm_task_assign_rule_type") | 19 | @Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "bpm_task_assign_rule_type") |
| 20 | @NotNull(message = "规则类型不能为空") | 20 | @NotNull(message = "规则类型不能为空") |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java
| 1 | package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; | 1 | package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO; | ||
| 3 | import io.swagger.v3.oas.annotations.media.Schema; | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | import lombok.Data; | 5 | import lombok.Data; |
| 5 | 6 | ||
| @@ -17,4 +18,7 @@ public class BpmTaskApproveReqVO { | @@ -17,4 +18,7 @@ public class BpmTaskApproveReqVO { | ||
| 17 | @NotEmpty(message = "审批意见不能为空") | 18 | @NotEmpty(message = "审批意见不能为空") |
| 18 | private String reason; | 19 | private String reason; |
| 19 | 20 | ||
| 21 | + @Schema(description = "审批时流程抄送人", requiredMode = Schema.RequiredMode.NOT_REQUIRED) | ||
| 22 | + private BpmTaskCandidateRuleVO ccCandidateRule; | ||
| 23 | + | ||
| 20 | } | 24 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/cc/BpmProcessInstanceCopyConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.bpm.convert.cc; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO; | ||
| 4 | +import cn.iocoder.yudao.module.bpm.service.cc.BpmProcessInstanceCopyVO; | ||
| 5 | +import org.mapstruct.Mapper; | ||
| 6 | +import org.mapstruct.factory.Mappers; | ||
| 7 | + | ||
| 8 | +import java.util.List; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 动态表单 Convert | ||
| 12 | + * | ||
| 13 | + * @author 芋艿 | ||
| 14 | + */ | ||
| 15 | +@Mapper | ||
| 16 | +public interface BpmProcessInstanceCopyConvert { | ||
| 17 | + | ||
| 18 | + BpmProcessInstanceCopyConvert INSTANCE = Mappers.getMapper(BpmProcessInstanceCopyConvert.class); | ||
| 19 | + BpmProcessInstanceCopyDO copy(BpmProcessInstanceCopyDO bean); | ||
| 20 | + | ||
| 21 | + BpmProcessInstanceCopyVO convert(BpmProcessInstanceCopyDO bean); | ||
| 22 | + | ||
| 23 | + List<BpmProcessInstanceCopyVO> convertList2(List<BpmProcessInstanceCopyDO> list); | ||
| 24 | + | ||
| 25 | +} |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/cc/BpmProcessInstanceCopyDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.bpm.dal.dataobject.cc; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 4 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 5 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 6 | +import lombok.*; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 流程抄送对象 | ||
| 10 | + * | ||
| 11 | + * @author kyle | ||
| 12 | + * @date 2022-05-19 | ||
| 13 | + */ | ||
| 14 | +@TableName(value = "bpm_process_instance_copy", autoResultMap = true) | ||
| 15 | +@Data | ||
| 16 | +@EqualsAndHashCode(callSuper = true) | ||
| 17 | +@ToString(callSuper = true) | ||
| 18 | +@Builder | ||
| 19 | +@NoArgsConstructor | ||
| 20 | +@AllArgsConstructor | ||
| 21 | +public class BpmProcessInstanceCopyDO extends BaseDO { | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 编号 | ||
| 25 | + */ | ||
| 26 | + @TableId | ||
| 27 | + private Long id; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 发起人Id | ||
| 31 | + */ | ||
| 32 | + private Long startUserId; | ||
| 33 | + /** | ||
| 34 | + * 表单名 | ||
| 35 | + */ | ||
| 36 | + private String name; | ||
| 37 | + /** | ||
| 38 | + * 流程主键 | ||
| 39 | + */ | ||
| 40 | + private String processInstanceId; | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * 任务主键 | ||
| 44 | + */ | ||
| 45 | + private String taskId; | ||
| 46 | + /** | ||
| 47 | + * 用户主键 | ||
| 48 | + */ | ||
| 49 | + private Long userId; | ||
| 50 | + | ||
| 51 | + | ||
| 52 | +} |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/cc/BpmProcessInstanceCopyMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.bpm.dal.mysql.cc; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||
| 4 | +import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO; | ||
| 5 | +import org.apache.ibatis.annotations.Mapper; | ||
| 6 | + | ||
| 7 | +@Mapper | ||
| 8 | +public interface BpmProcessInstanceCopyMapper extends BaseMapperX<BpmProcessInstanceCopyDO> { | ||
| 9 | +} |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/bpm/config/BpmCandidateProcessorConfiguration.java
| @@ -41,7 +41,7 @@ public class BpmCandidateProcessorConfiguration { | @@ -41,7 +41,7 @@ public class BpmCandidateProcessorConfiguration { | ||
| 41 | 41 | ||
| 42 | /** | 42 | /** |
| 43 | * 可以自己定制脚本,然后通过这里设置到处理器里面去 | 43 | * 可以自己定制脚本,然后通过这里设置到处理器里面去 |
| 44 | - * @param scriptsOp | 44 | + * @param scriptsOp 脚本包装对象 |
| 45 | * @return | 45 | * @return |
| 46 | */ | 46 | */ |
| 47 | @Bean | 47 | @Bean |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/candidate/BpmCandidateSourceInfo.java
| 1 | package cn.iocoder.yudao.module.bpm.service.candidate; | 1 | package cn.iocoder.yudao.module.bpm.service.candidate; |
| 2 | 2 | ||
| 3 | -import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateVO; | ||
| 4 | -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleBaseVO; | 3 | +import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO; |
| 5 | import io.swagger.v3.oas.annotations.media.Schema; | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | import lombok.AllArgsConstructor; | 5 | import lombok.AllArgsConstructor; |
| 7 | import lombok.Data; | 6 | import lombok.Data; |
| 8 | import lombok.NoArgsConstructor; | 7 | import lombok.NoArgsConstructor; |
| 9 | -import org.flowable.engine.delegate.DelegateExecution; | ||
| 10 | 8 | ||
| 9 | +import javax.validation.constraints.NotEmpty; | ||
| 10 | +import javax.validation.constraints.NotNull; | ||
| 11 | import java.util.HashSet; | 11 | import java.util.HashSet; |
| 12 | import java.util.Set; | 12 | import java.util.Set; |
| 13 | 13 | ||
| @@ -20,21 +20,20 @@ import java.util.Set; | @@ -20,21 +20,20 @@ import java.util.Set; | ||
| 20 | public class BpmCandidateSourceInfo { | 20 | public class BpmCandidateSourceInfo { |
| 21 | 21 | ||
| 22 | @Schema(description = "流程id") | 22 | @Schema(description = "流程id") |
| 23 | + @NotNull | ||
| 23 | private String processInstanceId; | 24 | private String processInstanceId; |
| 24 | 25 | ||
| 25 | @Schema(description = "当前任务ID") | 26 | @Schema(description = "当前任务ID") |
| 27 | + @NotNull | ||
| 26 | private String taskId; | 28 | private String taskId; |
| 27 | - | ||
| 28 | /** | 29 | /** |
| 29 | * 通过这些规则,生成最终需要生成的用户 | 30 | * 通过这些规则,生成最终需要生成的用户 |
| 30 | */ | 31 | */ |
| 31 | @Schema(description = "当前任务预选规则") | 32 | @Schema(description = "当前任务预选规则") |
| 32 | - private Set<BpmTaskCandidateVO> rules; | ||
| 33 | - | ||
| 34 | - @Schema(description = "源执行流程") | ||
| 35 | - private DelegateExecution execution; | 33 | + @NotEmpty(message = "不允许空规则") |
| 34 | + private Set<BpmTaskCandidateRuleVO> rules; | ||
| 36 | 35 | ||
| 37 | - public void addRule(BpmTaskCandidateVO vo) { | 36 | + public void addRule(BpmTaskCandidateRuleVO vo) { |
| 38 | assert vo != null; | 37 | assert vo != null; |
| 39 | if (rules == null) { | 38 | if (rules == null) { |
| 40 | rules = new HashSet<>(); | 39 | rules = new HashSet<>(); |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/candidate/BpmCandidateSourceInfoProcessor.java
| 1 | package cn.iocoder.yudao.module.bpm.service.candidate; | 1 | package cn.iocoder.yudao.module.bpm.service.candidate; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | -import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateVO; | 4 | +import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO; |
| 5 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; | 5 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; |
| 6 | +import org.flowable.engine.delegate.DelegateExecution; | ||
| 6 | 7 | ||
| 7 | import java.util.Collections; | 8 | import java.util.Collections; |
| 8 | import java.util.HashSet; | 9 | import java.util.HashSet; |
| @@ -29,24 +30,24 @@ public interface BpmCandidateSourceInfoProcessor { | @@ -29,24 +30,24 @@ public interface BpmCandidateSourceInfoProcessor { | ||
| 29 | * 默认的处理 | 30 | * 默认的处理 |
| 30 | * 如果想去操作所有的规则,则可以覆盖此方法 | 31 | * 如果想去操作所有的规则,则可以覆盖此方法 |
| 31 | * | 32 | * |
| 32 | - * @param request | ||
| 33 | - * @param chain | 33 | + * @param request 原始请求 |
| 34 | + * @param delegateExecution 审批过程中的对象 | ||
| 34 | * @return 必须包含的是用户ID,而不是其他的ID | 35 | * @return 必须包含的是用户ID,而不是其他的ID |
| 35 | * @throws Exception | 36 | * @throws Exception |
| 36 | */ | 37 | */ |
| 37 | - default Set<Long> process(BpmCandidateSourceInfo request, BpmCandidateSourceInfoProcessorChain chain) throws Exception { | ||
| 38 | - Set<BpmTaskCandidateVO> rules = request.getRules(); | 38 | + default Set<Long> process(BpmCandidateSourceInfo request, DelegateExecution delegateExecution) throws Exception { |
| 39 | + Set<BpmTaskCandidateRuleVO> rules = request.getRules(); | ||
| 39 | Set<Long> results = new HashSet<>(); | 40 | Set<Long> results = new HashSet<>(); |
| 40 | - for (BpmTaskCandidateVO rule : rules) { | 41 | + for (BpmTaskCandidateRuleVO rule : rules) { |
| 41 | // 每个处理器都有机会处理自己支持的事件 | 42 | // 每个处理器都有机会处理自己支持的事件 |
| 42 | if (CollUtil.contains(getSupportedTypes(), rule.getType())) { | 43 | if (CollUtil.contains(getSupportedTypes(), rule.getType())) { |
| 43 | - results.addAll(doProcess(request, rule)); | 44 | + results.addAll(doProcess(request, rule, delegateExecution)); |
| 44 | } | 45 | } |
| 45 | } | 46 | } |
| 46 | return results; | 47 | return results; |
| 47 | } | 48 | } |
| 48 | 49 | ||
| 49 | - default Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateVO rule) { | 50 | + default Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) { |
| 50 | return Collections.emptySet(); | 51 | return Collections.emptySet(); |
| 51 | } | 52 | } |
| 52 | } | 53 | } |
| 53 | \ No newline at end of file | 54 | \ No newline at end of file |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/candidate/BpmCandidateSourceInfoProcessorChain.java
| 1 | package cn.iocoder.yudao.module.bpm.service.candidate; | 1 | package cn.iocoder.yudao.module.bpm.service.candidate; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.hutool.core.collection.ListUtil; | ||
| 4 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 5 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 5 | -import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateVO; | 6 | +import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO; |
| 6 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | 7 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 7 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | 8 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 8 | import org.flowable.engine.delegate.DelegateExecution; | 9 | import org.flowable.engine.delegate.DelegateExecution; |
| @@ -11,7 +12,6 @@ import org.springframework.stereotype.Service; | @@ -11,7 +12,6 @@ import org.springframework.stereotype.Service; | ||
| 11 | 12 | ||
| 12 | import javax.annotation.Resource; | 13 | import javax.annotation.Resource; |
| 13 | import java.util.*; | 14 | import java.util.*; |
| 14 | -import java.util.stream.Collectors; | ||
| 15 | 15 | ||
| 16 | @Service | 16 | @Service |
| 17 | public class BpmCandidateSourceInfoProcessorChain { | 17 | public class BpmCandidateSourceInfoProcessorChain { |
| @@ -31,7 +31,7 @@ public class BpmCandidateSourceInfoProcessorChain { | @@ -31,7 +31,7 @@ public class BpmCandidateSourceInfoProcessorChain { | ||
| 31 | @Resource | 31 | @Resource |
| 32 | // 动态扩展处理节点 | 32 | // 动态扩展处理节点 |
| 33 | public BpmCandidateSourceInfoProcessorChain addProcessor(ObjectProvider<BpmCandidateSourceInfoProcessor> processorOp) { | 33 | public BpmCandidateSourceInfoProcessorChain addProcessor(ObjectProvider<BpmCandidateSourceInfoProcessor> processorOp) { |
| 34 | - List<BpmCandidateSourceInfoProcessor> processor = processorOp.orderedStream().collect(Collectors.toList()); | 34 | + List<BpmCandidateSourceInfoProcessor> processor = ListUtil.toList(processorOp.iterator()); |
| 35 | if (null == processorList) { | 35 | if (null == processorList) { |
| 36 | processorList = new ArrayList<>(processor.size()); | 36 | processorList = new ArrayList<>(processor.size()); |
| 37 | } | 37 | } |
| @@ -40,14 +40,14 @@ public class BpmCandidateSourceInfoProcessorChain { | @@ -40,14 +40,14 @@ public class BpmCandidateSourceInfoProcessorChain { | ||
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | // 获取处理器处理 | 42 | // 获取处理器处理 |
| 43 | - public Set<Long> process(BpmCandidateSourceInfo sourceInfo) throws Exception { | 43 | + public Set<Long> process(BpmCandidateSourceInfo sourceInfo, DelegateExecution execution) throws Exception { |
| 44 | // Verify our parameters | 44 | // Verify our parameters |
| 45 | if (sourceInfo == null) { | 45 | if (sourceInfo == null) { |
| 46 | throw new IllegalArgumentException(); | 46 | throw new IllegalArgumentException(); |
| 47 | } | 47 | } |
| 48 | for (BpmCandidateSourceInfoProcessor processor : processorList) { | 48 | for (BpmCandidateSourceInfoProcessor processor : processorList) { |
| 49 | try { | 49 | try { |
| 50 | - for (BpmTaskCandidateVO vo : sourceInfo.getRules()) { | 50 | + for (BpmTaskCandidateRuleVO vo : sourceInfo.getRules()) { |
| 51 | processor.validRuleOptions(vo.getType(), vo.getOptions()); | 51 | processor.validRuleOptions(vo.getType(), vo.getOptions()); |
| 52 | } | 52 | } |
| 53 | } catch (Exception e) { | 53 | } catch (Exception e) { |
| @@ -59,7 +59,7 @@ public class BpmCandidateSourceInfoProcessorChain { | @@ -59,7 +59,7 @@ public class BpmCandidateSourceInfoProcessorChain { | ||
| 59 | Exception saveException = null; | 59 | Exception saveException = null; |
| 60 | for (BpmCandidateSourceInfoProcessor processor : processorList) { | 60 | for (BpmCandidateSourceInfoProcessor processor : processorList) { |
| 61 | try { | 61 | try { |
| 62 | - saveResult = processor.process(sourceInfo, this); | 62 | + saveResult = processor.process(sourceInfo, execution); |
| 63 | if (CollUtil.isNotEmpty(saveResult)) { | 63 | if (CollUtil.isNotEmpty(saveResult)) { |
| 64 | removeDisableUsers(saveResult); | 64 | removeDisableUsers(saveResult); |
| 65 | break; | 65 | break; |
| @@ -78,10 +78,9 @@ public class BpmCandidateSourceInfoProcessorChain { | @@ -78,10 +78,9 @@ public class BpmCandidateSourceInfoProcessorChain { | ||
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | public Set<Long> calculateTaskCandidateUsers(DelegateExecution execution, BpmCandidateSourceInfo sourceInfo) { | 80 | public Set<Long> calculateTaskCandidateUsers(DelegateExecution execution, BpmCandidateSourceInfo sourceInfo) { |
| 81 | - sourceInfo.setExecution(execution); | ||
| 82 | Set<Long> results = Collections.emptySet(); | 81 | Set<Long> results = Collections.emptySet(); |
| 83 | try { | 82 | try { |
| 84 | - results = process(sourceInfo); | 83 | + results = process(sourceInfo, execution); |
| 85 | } catch (Exception e) { | 84 | } catch (Exception e) { |
| 86 | e.printStackTrace(); | 85 | e.printStackTrace(); |
| 87 | } | 86 | } |
| @@ -90,6 +89,7 @@ public class BpmCandidateSourceInfoProcessorChain { | @@ -90,6 +89,7 @@ public class BpmCandidateSourceInfoProcessorChain { | ||
| 90 | 89 | ||
| 91 | /** | 90 | /** |
| 92 | * 移除禁用用户 | 91 | * 移除禁用用户 |
| 92 | + * | ||
| 93 | * @param assigneeUserIds | 93 | * @param assigneeUserIds |
| 94 | */ | 94 | */ |
| 95 | public void removeDisableUsers(Set<Long> assigneeUserIds) { | 95 | public void removeDisableUsers(Set<Long> assigneeUserIds) { |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/candidate/sourceInfoProcessor/BpmCandidateAdminUserApiSourceInfoProcessor.java
| 1 | package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor; | 1 | package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.util.collection.SetUtils; | 3 | import cn.iocoder.yudao.framework.common.util.collection.SetUtils; |
| 4 | -import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateVO; | 4 | +import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO; |
| 5 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; | 5 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; |
| 6 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; | 6 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; |
| 7 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor; | 7 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor; |
| 8 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | 8 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 9 | +import org.flowable.engine.delegate.DelegateExecution; | ||
| 9 | 10 | ||
| 10 | import javax.annotation.Resource; | 11 | import javax.annotation.Resource; |
| 11 | import java.util.Set; | 12 | import java.util.Set; |
| @@ -25,7 +26,7 @@ public class BpmCandidateAdminUserApiSourceInfoProcessor implements BpmCandidate | @@ -25,7 +26,7 @@ public class BpmCandidateAdminUserApiSourceInfoProcessor implements BpmCandidate | ||
| 25 | } | 26 | } |
| 26 | 27 | ||
| 27 | @Override | 28 | @Override |
| 28 | - public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateVO rule) { | 29 | + public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) { |
| 29 | return rule.getOptions(); | 30 | return rule.getOptions(); |
| 30 | } | 31 | } |
| 31 | } | 32 | } |
| 32 | \ No newline at end of file | 33 | \ No newline at end of file |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/candidate/sourceInfoProcessor/BpmCandidateDeptApiSourceInfoProcessor.java
| 1 | package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor; | 1 | package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.util.collection.SetUtils; | 3 | import cn.iocoder.yudao.framework.common.util.collection.SetUtils; |
| 4 | -import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateVO; | 4 | +import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO; |
| 5 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; | 5 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; |
| 6 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; | 6 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; |
| 7 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor; | 7 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor; |
| @@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.system.api.dept.DeptApi; | @@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.system.api.dept.DeptApi; | ||
| 9 | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | 9 | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; |
| 10 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | 10 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 11 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | 11 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 12 | +import org.flowable.engine.delegate.DelegateExecution; | ||
| 12 | 13 | ||
| 13 | import javax.annotation.Resource; | 14 | import javax.annotation.Resource; |
| 14 | import java.util.Collections; | 15 | import java.util.Collections; |
| @@ -36,7 +37,7 @@ public class BpmCandidateDeptApiSourceInfoProcessor implements BpmCandidateSourc | @@ -36,7 +37,7 @@ public class BpmCandidateDeptApiSourceInfoProcessor implements BpmCandidateSourc | ||
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | @Override | 39 | @Override |
| 39 | - public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateVO rule) { | 40 | + public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) { |
| 40 | if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(), rule.getType())) { | 41 | if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(), rule.getType())) { |
| 41 | List<AdminUserRespDTO> users = adminUserApi.getUserListByDeptIds(rule.getOptions()); | 42 | List<AdminUserRespDTO> users = adminUserApi.getUserListByDeptIds(rule.getOptions()); |
| 42 | return convertSet(users, AdminUserRespDTO::getId); | 43 | return convertSet(users, AdminUserRespDTO::getId); |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/candidate/sourceInfoProcessor/BpmCandidatePostApiSourceInfoProcessor.java
| 1 | package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor; | 1 | package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.util.collection.SetUtils; | 3 | import cn.iocoder.yudao.framework.common.util.collection.SetUtils; |
| 4 | -import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateVO; | 4 | +import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO; |
| 5 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; | 5 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; |
| 6 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; | 6 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; |
| 7 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor; | 7 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor; |
| 8 | import cn.iocoder.yudao.module.system.api.dept.PostApi; | 8 | import cn.iocoder.yudao.module.system.api.dept.PostApi; |
| 9 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | 9 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 10 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | 10 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 11 | +import org.flowable.engine.delegate.DelegateExecution; | ||
| 11 | 12 | ||
| 12 | import javax.annotation.Resource; | 13 | import javax.annotation.Resource; |
| 13 | import java.util.List; | 14 | import java.util.List; |
| @@ -32,7 +33,7 @@ public class BpmCandidatePostApiSourceInfoProcessor implements BpmCandidateSourc | @@ -32,7 +33,7 @@ public class BpmCandidatePostApiSourceInfoProcessor implements BpmCandidateSourc | ||
| 32 | } | 33 | } |
| 33 | 34 | ||
| 34 | @Override | 35 | @Override |
| 35 | - public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateVO rule) { | 36 | + public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) { |
| 36 | List<AdminUserRespDTO> users = adminUserApi.getUserListByPostIds(rule.getOptions()); | 37 | List<AdminUserRespDTO> users = adminUserApi.getUserListByPostIds(rule.getOptions()); |
| 37 | return convertSet(users, AdminUserRespDTO::getId); | 38 | return convertSet(users, AdminUserRespDTO::getId); |
| 38 | } | 39 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/candidate/sourceInfoProcessor/BpmCandidateRoleApiSourceInfoProcessor.java
| 1 | package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor; | 1 | package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.util.collection.SetUtils; | 3 | import cn.iocoder.yudao.framework.common.util.collection.SetUtils; |
| 4 | -import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateVO; | 4 | +import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO; |
| 5 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; | 5 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; |
| 6 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; | 6 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; |
| 7 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor; | 7 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor; |
| 8 | import cn.iocoder.yudao.module.system.api.permission.PermissionApi; | 8 | import cn.iocoder.yudao.module.system.api.permission.PermissionApi; |
| 9 | import cn.iocoder.yudao.module.system.api.permission.RoleApi; | 9 | import cn.iocoder.yudao.module.system.api.permission.RoleApi; |
| 10 | +import org.flowable.engine.delegate.DelegateExecution; | ||
| 10 | 11 | ||
| 11 | import javax.annotation.Resource; | 12 | import javax.annotation.Resource; |
| 12 | import java.util.Set; | 13 | import java.util.Set; |
| @@ -29,7 +30,7 @@ public class BpmCandidateRoleApiSourceInfoProcessor implements BpmCandidateSourc | @@ -29,7 +30,7 @@ public class BpmCandidateRoleApiSourceInfoProcessor implements BpmCandidateSourc | ||
| 29 | } | 30 | } |
| 30 | 31 | ||
| 31 | @Override | 32 | @Override |
| 32 | - public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateVO rule) { | 33 | + public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) { |
| 33 | return permissionApi.getUserRoleIdListByRoleIds(rule.getOptions()); | 34 | return permissionApi.getUserRoleIdListByRoleIds(rule.getOptions()); |
| 34 | } | 35 | } |
| 35 | 36 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/candidate/sourceInfoProcessor/BpmCandidateScriptApiSourceInfoProcessor.java
| @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor; | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor; | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 4 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 5 | import cn.iocoder.yudao.framework.common.util.collection.SetUtils; | 5 | import cn.iocoder.yudao.framework.common.util.collection.SetUtils; |
| 6 | -import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateVO; | 6 | +import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO; |
| 7 | import cn.iocoder.yudao.module.bpm.enums.DictTypeConstants; | 7 | import cn.iocoder.yudao.module.bpm.enums.DictTypeConstants; |
| 8 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; | 8 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; |
| 9 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript; | 9 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript; |
| @@ -51,8 +51,8 @@ public class BpmCandidateScriptApiSourceInfoProcessor implements BpmCandidateSou | @@ -51,8 +51,8 @@ public class BpmCandidateScriptApiSourceInfoProcessor implements BpmCandidateSou | ||
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | @Override | 53 | @Override |
| 54 | - public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateVO rule) { | ||
| 55 | - return calculateTaskCandidateUsersByScript(request.getExecution(), rule.getOptions()); | 54 | + public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) { |
| 55 | + return calculateTaskCandidateUsersByScript(delegateExecution, rule.getOptions()); | ||
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | private Set<Long> calculateTaskCandidateUsersByScript(DelegateExecution execution, Set<Long> options) { | 58 | private Set<Long> calculateTaskCandidateUsersByScript(DelegateExecution execution, Set<Long> options) { |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/candidate/sourceInfoProcessor/BpmCandidateUserGroupApiSourceInfoProcessor.java
| 1 | package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor; | 1 | package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.common.util.collection.SetUtils; | 3 | import cn.iocoder.yudao.framework.common.util.collection.SetUtils; |
| 4 | -import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateVO; | 4 | +import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO; |
| 5 | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; | 5 | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; |
| 6 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; | 6 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; |
| 7 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; | 7 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; |
| 8 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor; | 8 | import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor; |
| 9 | import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; | 9 | import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; |
| 10 | +import org.flowable.engine.delegate.DelegateExecution; | ||
| 10 | 11 | ||
| 11 | import javax.annotation.Resource; | 12 | import javax.annotation.Resource; |
| 12 | import java.util.HashSet; | 13 | import java.util.HashSet; |
| @@ -30,7 +31,7 @@ public class BpmCandidateUserGroupApiSourceInfoProcessor implements BpmCandidate | @@ -30,7 +31,7 @@ public class BpmCandidateUserGroupApiSourceInfoProcessor implements BpmCandidate | ||
| 30 | } | 31 | } |
| 31 | 32 | ||
| 32 | @Override | 33 | @Override |
| 33 | - public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateVO rule) { | 34 | + public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) { |
| 34 | List<BpmUserGroupDO> userGroups = userGroupService.getUserGroupList(rule.getOptions()); | 35 | List<BpmUserGroupDO> userGroups = userGroupService.getUserGroupList(rule.getOptions()); |
| 35 | Set<Long> userIds = new HashSet<>(); | 36 | Set<Long> userIds = new HashSet<>(); |
| 36 | userGroups.forEach(group -> userIds.addAll(group.getMemberUserIds())); | 37 | userGroups.forEach(group -> userIds.addAll(group.getMemberUserIds())); |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.bpm.service.cc; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * 流程抄送Service接口 | ||
| 7 | + * | ||
| 8 | + * 现在是在审批的时候进行流程抄送 | ||
| 9 | + */ | ||
| 10 | +public interface BpmProcessInstanceCopyService { | ||
| 11 | + | ||
| 12 | + /** | ||
| 13 | + * 查询流程抄送 | ||
| 14 | + * | ||
| 15 | + * @param copyId 流程抄送主键 | ||
| 16 | + * @return 流程抄送 | ||
| 17 | + */ | ||
| 18 | + BpmProcessInstanceCopyVO queryById(Long copyId); | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 抄送 | ||
| 22 | + * @param sourceInfo 抄送源信息,方便抄送处理 | ||
| 23 | + * @return | ||
| 24 | + */ | ||
| 25 | + boolean makeCopy(BpmCandidateSourceInfo sourceInfo); | ||
| 26 | +} |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.bpm.service.cc; | ||
| 2 | + | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import cn.iocoder.yudao.module.bpm.convert.cc.BpmProcessInstanceCopyConvert; | ||
| 5 | +import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO; | ||
| 6 | +import cn.iocoder.yudao.module.bpm.dal.mysql.cc.BpmProcessInstanceCopyMapper; | ||
| 7 | +import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; | ||
| 8 | +import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessorChain; | ||
| 9 | +import cn.iocoder.yudao.module.bpm.service.cc.dto.BpmDelegateExecutionDTO; | ||
| 10 | +import cn.iocoder.yudao.module.bpm.util.FlowableUtils; | ||
| 11 | +import lombok.extern.slf4j.Slf4j; | ||
| 12 | +import org.flowable.engine.RuntimeService; | ||
| 13 | +import org.flowable.engine.delegate.DelegateExecution; | ||
| 14 | +import org.flowable.engine.runtime.ProcessInstance; | ||
| 15 | +import org.springframework.stereotype.Service; | ||
| 16 | +import org.springframework.validation.annotation.Validated; | ||
| 17 | + | ||
| 18 | +import javax.annotation.Resource; | ||
| 19 | +import java.util.ArrayList; | ||
| 20 | +import java.util.List; | ||
| 21 | +import java.util.Set; | ||
| 22 | + | ||
| 23 | +@Slf4j | ||
| 24 | +@Service | ||
| 25 | +@Validated | ||
| 26 | +public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopyService { | ||
| 27 | + @Resource | ||
| 28 | + private BpmProcessInstanceCopyMapper processInstanceCopyMapper; | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 和flowable有关的,查询流程名用的 | ||
| 32 | + */ | ||
| 33 | + @Resource | ||
| 34 | + private RuntimeService runtimeService; | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * 找抄送人用的 | ||
| 38 | + */ | ||
| 39 | + @Resource | ||
| 40 | + private BpmCandidateSourceInfoProcessorChain processorChain; | ||
| 41 | + | ||
| 42 | + @Override | ||
| 43 | + public BpmProcessInstanceCopyVO queryById(Long copyId) { | ||
| 44 | + BpmProcessInstanceCopyDO bpmProcessInstanceCopyDO = processInstanceCopyMapper.selectById(copyId); | ||
| 45 | + return BpmProcessInstanceCopyConvert.INSTANCE.convert(bpmProcessInstanceCopyDO); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @Override | ||
| 49 | + public boolean makeCopy(BpmCandidateSourceInfo sourceInfo) { | ||
| 50 | + if (null == sourceInfo) { | ||
| 51 | + return false; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + DelegateExecution executionEntity = new BpmDelegateExecutionDTO(sourceInfo.getProcessInstanceId()); | ||
| 55 | + Set<Long> ccCandidates = processorChain.calculateTaskCandidateUsers(executionEntity, sourceInfo); | ||
| 56 | + if (CollUtil.isEmpty(ccCandidates)) { | ||
| 57 | + log.warn("相关抄送人不存在 {}", sourceInfo.getTaskId()); | ||
| 58 | + return false; | ||
| 59 | + } else { | ||
| 60 | + BpmProcessInstanceCopyDO copyDO = new BpmProcessInstanceCopyDO(); | ||
| 61 | + // 调用 | ||
| 62 | + //设置任务id | ||
| 63 | + copyDO.setTaskId(sourceInfo.getTaskId()); | ||
| 64 | + copyDO.setProcessInstanceId(sourceInfo.getProcessInstanceId()); | ||
| 65 | + ProcessInstance processInstance = runtimeService.createProcessInstanceQuery() | ||
| 66 | + .processInstanceId(sourceInfo.getProcessInstanceId()) | ||
| 67 | + .singleResult(); | ||
| 68 | + if (null == processInstance) { | ||
| 69 | + log.warn("相关流程实例不存在 {}", sourceInfo.getTaskId()); | ||
| 70 | + return false; | ||
| 71 | + } | ||
| 72 | + copyDO.setStartUserId(FlowableUtils.getStartUserIdFromProcessInstance(processInstance)); | ||
| 73 | + copyDO.setName(FlowableUtils.getFlowName(processInstance.getProcessDefinitionId())); | ||
| 74 | + List<BpmProcessInstanceCopyDO> copyList = new ArrayList<>(ccCandidates.size()); | ||
| 75 | + for (Long userId : ccCandidates) { | ||
| 76 | + BpmProcessInstanceCopyDO copy = BpmProcessInstanceCopyConvert.INSTANCE.copy(copyDO); | ||
| 77 | + copy.setUserId(userId); | ||
| 78 | + copyList.add(copy); | ||
| 79 | + } | ||
| 80 | + return processInstanceCopyMapper.insertBatch(copyList); | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + public List<BpmProcessInstanceCopyVO> queryByProcessId() { | ||
| 85 | + return null; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + | ||
| 89 | +} |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.bpm.service.cc; | ||
| 2 | + | ||
| 3 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 4 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 5 | +import lombok.Data; | ||
| 6 | + | ||
| 7 | +import java.util.Date; | ||
| 8 | + | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 流程抄送视图对象 wf_copy | ||
| 12 | + * | ||
| 13 | + * @author ruoyi | ||
| 14 | + * @date 2022-05-19 | ||
| 15 | + */ | ||
| 16 | +@Data | ||
| 17 | +public class BpmProcessInstanceCopyVO { | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * 编号 | ||
| 21 | + */ | ||
| 22 | + @Schema(description = "抄送主键") | ||
| 23 | + private Long id; | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 发起人Id | ||
| 27 | + */ | ||
| 28 | + @Schema(description = "发起人Id") | ||
| 29 | + private Long startUserId; | ||
| 30 | + /** | ||
| 31 | + * 表单名 | ||
| 32 | + */ | ||
| 33 | + @Schema(description = "流程实例的名字") | ||
| 34 | + private String name; | ||
| 35 | + /** | ||
| 36 | + * 流程主键 | ||
| 37 | + */ | ||
| 38 | + @Schema(description = "流程实例的主键") | ||
| 39 | + private String processInstanceId; | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 任务主键 | ||
| 43 | + */ | ||
| 44 | + @Schema(description = "发起抄送的任务编号") | ||
| 45 | + private String taskId; | ||
| 46 | + /** | ||
| 47 | + * 用户主键 | ||
| 48 | + */ | ||
| 49 | + @Schema(description = "用户编号") | ||
| 50 | + private Long userId; | ||
| 51 | +} |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/cc/dto/BpmDelegateExecutionDTO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.bpm.service.cc.dto; | ||
| 2 | + | ||
| 3 | +import org.flowable.bpmn.model.FlowElement; | ||
| 4 | +import org.flowable.bpmn.model.FlowableListener; | ||
| 5 | +import org.flowable.engine.delegate.DelegateExecution; | ||
| 6 | +import org.flowable.engine.delegate.ReadOnlyDelegateExecution; | ||
| 7 | +import org.flowable.variable.api.persistence.entity.VariableInstance; | ||
| 8 | + | ||
| 9 | +import java.util.Collection; | ||
| 10 | +import java.util.List; | ||
| 11 | +import java.util.Map; | ||
| 12 | +import java.util.Set; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * 仅为了传输processInstanceId | ||
| 16 | + */ | ||
| 17 | +public class BpmDelegateExecutionDTO implements DelegateExecution { | ||
| 18 | + | ||
| 19 | + public BpmDelegateExecutionDTO(String getProcessInstanceId) { | ||
| 20 | + this.getProcessInstanceId = getProcessInstanceId; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + private final String getProcessInstanceId; | ||
| 24 | + | ||
| 25 | + @Override | ||
| 26 | + public String getId() { | ||
| 27 | + return null; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + @Override | ||
| 31 | + public String getProcessInstanceId() { | ||
| 32 | + return null; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + @Override | ||
| 36 | + public String getRootProcessInstanceId() { | ||
| 37 | + return null; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + @Override | ||
| 41 | + public String getEventName() { | ||
| 42 | + return null; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + @Override | ||
| 46 | + public void setEventName(String eventName) { | ||
| 47 | + | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @Override | ||
| 51 | + public String getProcessInstanceBusinessKey() { | ||
| 52 | + return null; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + @Override | ||
| 56 | + public String getProcessInstanceBusinessStatus() { | ||
| 57 | + return null; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + @Override | ||
| 61 | + public String getProcessDefinitionId() { | ||
| 62 | + return null; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + @Override | ||
| 66 | + public String getPropagatedStageInstanceId() { | ||
| 67 | + return null; | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @Override | ||
| 71 | + public String getParentId() { | ||
| 72 | + return null; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + @Override | ||
| 76 | + public String getSuperExecutionId() { | ||
| 77 | + return null; | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + @Override | ||
| 81 | + public String getCurrentActivityId() { | ||
| 82 | + return null; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + @Override | ||
| 86 | + public String getTenantId() { | ||
| 87 | + return null; | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + @Override | ||
| 91 | + public FlowElement getCurrentFlowElement() { | ||
| 92 | + return null; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + @Override | ||
| 96 | + public void setCurrentFlowElement(FlowElement flowElement) { | ||
| 97 | + | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + @Override | ||
| 101 | + public FlowableListener getCurrentFlowableListener() { | ||
| 102 | + return null; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + @Override | ||
| 106 | + public void setCurrentFlowableListener(FlowableListener currentListener) { | ||
| 107 | + | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + @Override | ||
| 111 | + public ReadOnlyDelegateExecution snapshotReadOnly() { | ||
| 112 | + return null; | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + @Override | ||
| 116 | + public DelegateExecution getParent() { | ||
| 117 | + return null; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + @Override | ||
| 121 | + public List<? extends DelegateExecution> getExecutions() { | ||
| 122 | + return null; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + @Override | ||
| 126 | + public void setActive(boolean isActive) { | ||
| 127 | + | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + @Override | ||
| 131 | + public boolean isActive() { | ||
| 132 | + return false; | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + @Override | ||
| 136 | + public boolean isEnded() { | ||
| 137 | + return false; | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + @Override | ||
| 141 | + public void setConcurrent(boolean isConcurrent) { | ||
| 142 | + | ||
| 143 | + } | ||
| 144 | + | ||
| 145 | + @Override | ||
| 146 | + public boolean isConcurrent() { | ||
| 147 | + return false; | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + @Override | ||
| 151 | + public boolean isProcessInstanceType() { | ||
| 152 | + return false; | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + @Override | ||
| 156 | + public void inactivate() { | ||
| 157 | + | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + @Override | ||
| 161 | + public boolean isScope() { | ||
| 162 | + return false; | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + @Override | ||
| 166 | + public void setScope(boolean isScope) { | ||
| 167 | + | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + @Override | ||
| 171 | + public boolean isMultiInstanceRoot() { | ||
| 172 | + return false; | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + @Override | ||
| 176 | + public void setMultiInstanceRoot(boolean isMultiInstanceRoot) { | ||
| 177 | + | ||
| 178 | + } | ||
| 179 | + | ||
| 180 | + @Override | ||
| 181 | + public Map<String, Object> getVariables() { | ||
| 182 | + return null; | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + @Override | ||
| 186 | + public Map<String, VariableInstance> getVariableInstances() { | ||
| 187 | + return null; | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | + @Override | ||
| 191 | + public Map<String, Object> getVariables(Collection<String> collection) { | ||
| 192 | + return null; | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + @Override | ||
| 196 | + public Map<String, VariableInstance> getVariableInstances(Collection<String> collection) { | ||
| 197 | + return null; | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + @Override | ||
| 201 | + public Map<String, Object> getVariables(Collection<String> collection, boolean b) { | ||
| 202 | + return null; | ||
| 203 | + } | ||
| 204 | + | ||
| 205 | + @Override | ||
| 206 | + public Map<String, VariableInstance> getVariableInstances(Collection<String> collection, boolean b) { | ||
| 207 | + return null; | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + @Override | ||
| 211 | + public Map<String, Object> getVariablesLocal() { | ||
| 212 | + return null; | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + @Override | ||
| 216 | + public Map<String, VariableInstance> getVariableInstancesLocal() { | ||
| 217 | + return null; | ||
| 218 | + } | ||
| 219 | + | ||
| 220 | + @Override | ||
| 221 | + public Map<String, Object> getVariablesLocal(Collection<String> collection) { | ||
| 222 | + return null; | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + @Override | ||
| 226 | + public Map<String, VariableInstance> getVariableInstancesLocal(Collection<String> collection) { | ||
| 227 | + return null; | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + @Override | ||
| 231 | + public Map<String, Object> getVariablesLocal(Collection<String> collection, boolean b) { | ||
| 232 | + return null; | ||
| 233 | + } | ||
| 234 | + | ||
| 235 | + @Override | ||
| 236 | + public Map<String, VariableInstance> getVariableInstancesLocal(Collection<String> collection, boolean b) { | ||
| 237 | + return null; | ||
| 238 | + } | ||
| 239 | + | ||
| 240 | + @Override | ||
| 241 | + public Object getVariable(String s) { | ||
| 242 | + return null; | ||
| 243 | + } | ||
| 244 | + | ||
| 245 | + @Override | ||
| 246 | + public VariableInstance getVariableInstance(String s) { | ||
| 247 | + return null; | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + @Override | ||
| 251 | + public Object getVariable(String s, boolean b) { | ||
| 252 | + return null; | ||
| 253 | + } | ||
| 254 | + | ||
| 255 | + @Override | ||
| 256 | + public VariableInstance getVariableInstance(String s, boolean b) { | ||
| 257 | + return null; | ||
| 258 | + } | ||
| 259 | + | ||
| 260 | + @Override | ||
| 261 | + public Object getVariableLocal(String s) { | ||
| 262 | + return null; | ||
| 263 | + } | ||
| 264 | + | ||
| 265 | + @Override | ||
| 266 | + public VariableInstance getVariableInstanceLocal(String s) { | ||
| 267 | + return null; | ||
| 268 | + } | ||
| 269 | + | ||
| 270 | + @Override | ||
| 271 | + public Object getVariableLocal(String s, boolean b) { | ||
| 272 | + return null; | ||
| 273 | + } | ||
| 274 | + | ||
| 275 | + @Override | ||
| 276 | + public VariableInstance getVariableInstanceLocal(String s, boolean b) { | ||
| 277 | + return null; | ||
| 278 | + } | ||
| 279 | + | ||
| 280 | + @Override | ||
| 281 | + public <T> T getVariable(String s, Class<T> aClass) { | ||
| 282 | + return null; | ||
| 283 | + } | ||
| 284 | + | ||
| 285 | + @Override | ||
| 286 | + public <T> T getVariableLocal(String s, Class<T> aClass) { | ||
| 287 | + return null; | ||
| 288 | + } | ||
| 289 | + | ||
| 290 | + @Override | ||
| 291 | + public Set<String> getVariableNames() { | ||
| 292 | + return null; | ||
| 293 | + } | ||
| 294 | + | ||
| 295 | + @Override | ||
| 296 | + public Set<String> getVariableNamesLocal() { | ||
| 297 | + return null; | ||
| 298 | + } | ||
| 299 | + | ||
| 300 | + @Override | ||
| 301 | + public void setVariable(String s, Object o) { | ||
| 302 | + | ||
| 303 | + } | ||
| 304 | + | ||
| 305 | + @Override | ||
| 306 | + public void setVariable(String s, Object o, boolean b) { | ||
| 307 | + | ||
| 308 | + } | ||
| 309 | + | ||
| 310 | + @Override | ||
| 311 | + public Object setVariableLocal(String s, Object o) { | ||
| 312 | + return null; | ||
| 313 | + } | ||
| 314 | + | ||
| 315 | + @Override | ||
| 316 | + public Object setVariableLocal(String s, Object o, boolean b) { | ||
| 317 | + return null; | ||
| 318 | + } | ||
| 319 | + | ||
| 320 | + @Override | ||
| 321 | + public void setVariables(Map<String, ?> map) { | ||
| 322 | + | ||
| 323 | + } | ||
| 324 | + | ||
| 325 | + @Override | ||
| 326 | + public void setVariablesLocal(Map<String, ?> map) { | ||
| 327 | + | ||
| 328 | + } | ||
| 329 | + | ||
| 330 | + @Override | ||
| 331 | + public boolean hasVariables() { | ||
| 332 | + return false; | ||
| 333 | + } | ||
| 334 | + | ||
| 335 | + @Override | ||
| 336 | + public boolean hasVariablesLocal() { | ||
| 337 | + return false; | ||
| 338 | + } | ||
| 339 | + | ||
| 340 | + @Override | ||
| 341 | + public boolean hasVariable(String s) { | ||
| 342 | + return false; | ||
| 343 | + } | ||
| 344 | + | ||
| 345 | + @Override | ||
| 346 | + public boolean hasVariableLocal(String s) { | ||
| 347 | + return false; | ||
| 348 | + } | ||
| 349 | + | ||
| 350 | + @Override | ||
| 351 | + public void removeVariable(String s) { | ||
| 352 | + | ||
| 353 | + } | ||
| 354 | + | ||
| 355 | + @Override | ||
| 356 | + public void removeVariableLocal(String s) { | ||
| 357 | + | ||
| 358 | + } | ||
| 359 | + | ||
| 360 | + @Override | ||
| 361 | + public void removeVariables(Collection<String> collection) { | ||
| 362 | + | ||
| 363 | + } | ||
| 364 | + | ||
| 365 | + @Override | ||
| 366 | + public void removeVariablesLocal(Collection<String> collection) { | ||
| 367 | + | ||
| 368 | + } | ||
| 369 | + | ||
| 370 | + @Override | ||
| 371 | + public void removeVariables() { | ||
| 372 | + | ||
| 373 | + } | ||
| 374 | + | ||
| 375 | + @Override | ||
| 376 | + public void removeVariablesLocal() { | ||
| 377 | + | ||
| 378 | + } | ||
| 379 | + | ||
| 380 | + @Override | ||
| 381 | + public void setTransientVariable(String s, Object o) { | ||
| 382 | + | ||
| 383 | + } | ||
| 384 | + | ||
| 385 | + @Override | ||
| 386 | + public void setTransientVariableLocal(String s, Object o) { | ||
| 387 | + | ||
| 388 | + } | ||
| 389 | + | ||
| 390 | + @Override | ||
| 391 | + public void setTransientVariables(Map<String, Object> map) { | ||
| 392 | + | ||
| 393 | + } | ||
| 394 | + | ||
| 395 | + @Override | ||
| 396 | + public Object getTransientVariable(String s) { | ||
| 397 | + return null; | ||
| 398 | + } | ||
| 399 | + | ||
| 400 | + @Override | ||
| 401 | + public Map<String, Object> getTransientVariables() { | ||
| 402 | + return null; | ||
| 403 | + } | ||
| 404 | + | ||
| 405 | + @Override | ||
| 406 | + public void setTransientVariablesLocal(Map<String, Object> map) { | ||
| 407 | + | ||
| 408 | + } | ||
| 409 | + | ||
| 410 | + @Override | ||
| 411 | + public Object getTransientVariableLocal(String s) { | ||
| 412 | + return null; | ||
| 413 | + } | ||
| 414 | + | ||
| 415 | + @Override | ||
| 416 | + public Map<String, Object> getTransientVariablesLocal() { | ||
| 417 | + return null; | ||
| 418 | + } | ||
| 419 | + | ||
| 420 | + @Override | ||
| 421 | + public void removeTransientVariableLocal(String s) { | ||
| 422 | + | ||
| 423 | + } | ||
| 424 | + | ||
| 425 | + @Override | ||
| 426 | + public void removeTransientVariable(String s) { | ||
| 427 | + | ||
| 428 | + } | ||
| 429 | + | ||
| 430 | + @Override | ||
| 431 | + public void removeTransientVariables() { | ||
| 432 | + | ||
| 433 | + } | ||
| 434 | + | ||
| 435 | + @Override | ||
| 436 | + public void removeTransientVariablesLocal() { | ||
| 437 | + | ||
| 438 | + } | ||
| 439 | +} |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
| @@ -19,6 +19,8 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmCommentTypeEnum; | @@ -19,6 +19,8 @@ import cn.iocoder.yudao.module.bpm.enums.task.BpmCommentTypeEnum; | ||
| 19 | import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum; | 19 | import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum; |
| 20 | import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; | 20 | import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; |
| 21 | import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskAddSignTypeEnum; | 21 | import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskAddSignTypeEnum; |
| 22 | +import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; | ||
| 23 | +import cn.iocoder.yudao.module.bpm.service.cc.BpmProcessInstanceCopyService; | ||
| 22 | import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService; | 24 | import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService; |
| 23 | import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService; | 25 | import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService; |
| 24 | import cn.iocoder.yudao.module.system.api.dept.DeptApi; | 26 | import cn.iocoder.yudao.module.system.api.dept.DeptApi; |
| @@ -94,6 +96,9 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -94,6 +96,9 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 94 | @Resource | 96 | @Resource |
| 95 | private ManagementService managementService; | 97 | private ManagementService managementService; |
| 96 | 98 | ||
| 99 | + @Resource | ||
| 100 | + private BpmProcessInstanceCopyService processInstanceCopyService; | ||
| 101 | + | ||
| 97 | @Override | 102 | @Override |
| 98 | public PageResult<BpmTaskTodoPageItemRespVO> getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageVO) { | 103 | public PageResult<BpmTaskTodoPageItemRespVO> getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageVO) { |
| 99 | // 查询待办任务 | 104 | // 查询待办任务 |
| @@ -237,6 +242,17 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -237,6 +242,17 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 237 | .setReason(reqVO.getReason())); | 242 | .setReason(reqVO.getReason())); |
| 238 | // 处理加签任务 | 243 | // 处理加签任务 |
| 239 | handleParentTask(task); | 244 | handleParentTask(task); |
| 245 | + | ||
| 246 | + // 在能正常审批的情况下抄送流程 | ||
| 247 | + if (null != reqVO.getCcCandidateRule()) { | ||
| 248 | + BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo(); | ||
| 249 | + sourceInfo.setTaskId(reqVO.getId()); | ||
| 250 | + sourceInfo.setProcessInstanceId(instance.getId()); | ||
| 251 | + sourceInfo.addRule(reqVO.getCcCandidateRule()); | ||
| 252 | + if (!processInstanceCopyService.makeCopy(sourceInfo)) { | ||
| 253 | + throw new RuntimeException("抄送任务失败"); | ||
| 254 | + } | ||
| 255 | + } | ||
| 240 | } | 256 | } |
| 241 | 257 | ||
| 242 | 258 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/util/FlowableUtils.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.bpm.util; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +import cn.hutool.extra.spring.SpringUtil; | ||
| 5 | +import cn.iocoder.yudao.framework.common.util.number.NumberUtils; | ||
| 6 | +import org.flowable.bpmn.model.BpmnModel; | ||
| 7 | +import org.flowable.bpmn.model.ExtensionElement; | ||
| 8 | +import org.flowable.bpmn.model.FlowElement; | ||
| 9 | +import org.flowable.bpmn.model.FlowNode; | ||
| 10 | +import org.flowable.engine.RepositoryService; | ||
| 11 | +import org.flowable.engine.RuntimeService; | ||
| 12 | +import org.flowable.engine.repository.ProcessDefinition; | ||
| 13 | +import org.flowable.engine.runtime.ProcessInstance; | ||
| 14 | + | ||
| 15 | +import java.util.List; | ||
| 16 | +import java.util.Map; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * 流程引擎工具类封装 | ||
| 20 | + * | ||
| 21 | + * @author: linjinp | ||
| 22 | + * @create: 2019-12-24 13:51 | ||
| 23 | + **/ | ||
| 24 | +public class FlowableUtils { | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 获取流程名称 | ||
| 28 | + * | ||
| 29 | + * @param processDefinitionId | ||
| 30 | + * @return | ||
| 31 | + */ | ||
| 32 | + public static String getFlowName(String processDefinitionId) { | ||
| 33 | + RepositoryService repositoryService = SpringUtil.getBean(RepositoryService.class); | ||
| 34 | + ProcessDefinition processDefinition = repositoryService.getProcessDefinition(processDefinitionId); | ||
| 35 | + return processDefinition.getName(); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 获取节点数据 | ||
| 40 | + * | ||
| 41 | + * @param processInstanceId | ||
| 42 | + * @param nodeId | ||
| 43 | + * @return | ||
| 44 | + */ | ||
| 45 | + public static FlowNode getFlowNode(String processInstanceId, String nodeId) { | ||
| 46 | + | ||
| 47 | + RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.class); | ||
| 48 | + RepositoryService repositoryService = SpringUtil.getBean(RepositoryService.class); | ||
| 49 | + | ||
| 50 | + String definitionld = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult().getProcessDefinitionId(); //获取bpm(模型)对象 | ||
| 51 | + BpmnModel bpmnModel = repositoryService.getBpmnModel(definitionld); | ||
| 52 | + //传节点定义key获取当前节点 | ||
| 53 | + FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(nodeId); | ||
| 54 | + return flowNode; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public static ExtensionElement generateFlowNodeIdExtension(String nodeId) { | ||
| 58 | + ExtensionElement extensionElement = new ExtensionElement(); | ||
| 59 | + extensionElement.setElementText(nodeId); | ||
| 60 | + extensionElement.setName("nodeId"); | ||
| 61 | + extensionElement.setNamespacePrefix("flowable"); | ||
| 62 | + extensionElement.setNamespace("nodeId"); | ||
| 63 | + return extensionElement; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + public static String getNodeIdFromExtension(FlowElement flowElement) { | ||
| 67 | + Map<String, List<ExtensionElement>> extensionElements = flowElement.getExtensionElements(); | ||
| 68 | + return extensionElements.get("nodeId").get(0).getElementText(); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + public static Long getStartUserIdFromProcessInstance(ProcessInstance instance) { | ||
| 72 | + if (null == instance) { | ||
| 73 | + return null; | ||
| 74 | + } | ||
| 75 | + return NumberUtils.parseLong(instance.getStartUserId()); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | +} |
yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/candidate/BpmCandidateSourceInfoProcessorChainTest.java
| @@ -4,8 +4,7 @@ import cn.hutool.core.map.MapUtil; | @@ -4,8 +4,7 @@ import cn.hutool.core.map.MapUtil; | ||
| 4 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | 4 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 5 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 5 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 6 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | 6 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 7 | -import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateVO; | ||
| 8 | -import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmTaskAssignRuleDO; | 7 | +import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO; |
| 9 | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; | 8 | import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO; |
| 10 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; | 9 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum; |
| 11 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum; | 10 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum; |
| @@ -13,10 +12,7 @@ import cn.iocoder.yudao.module.bpm.framework.bpm.config.BpmCandidateProcessorCon | @@ -13,10 +12,7 @@ import cn.iocoder.yudao.module.bpm.framework.bpm.config.BpmCandidateProcessorCon | ||
| 13 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript; | 12 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript; |
| 14 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl.BpmTaskAssignLeaderX1Script; | 13 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl.BpmTaskAssignLeaderX1Script; |
| 15 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl.BpmTaskAssignLeaderX2Script; | 14 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl.BpmTaskAssignLeaderX2Script; |
| 16 | -import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo; | ||
| 17 | -import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessorChain; | ||
| 18 | import cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor.BpmCandidateScriptApiSourceInfoProcessor; | 15 | import cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor.BpmCandidateScriptApiSourceInfoProcessor; |
| 19 | -import cn.iocoder.yudao.module.bpm.service.definition.BpmTaskAssignRuleServiceImpl; | ||
| 20 | import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; | 16 | import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService; |
| 21 | import cn.iocoder.yudao.module.system.api.dept.DeptApi; | 17 | import cn.iocoder.yudao.module.system.api.dept.DeptApi; |
| 22 | import cn.iocoder.yudao.module.system.api.dept.PostApi; | 18 | import cn.iocoder.yudao.module.system.api.dept.PostApi; |
| @@ -28,7 +24,6 @@ import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | @@ -28,7 +24,6 @@ import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||
| 28 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | 24 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 29 | import org.flowable.engine.delegate.DelegateExecution; | 25 | import org.flowable.engine.delegate.DelegateExecution; |
| 30 | import org.junit.jupiter.api.Test; | 26 | import org.junit.jupiter.api.Test; |
| 31 | -import org.springframework.beans.factory.ObjectProvider; | ||
| 32 | import org.springframework.boot.test.mock.mockito.MockBean; | 27 | import org.springframework.boot.test.mock.mockito.MockBean; |
| 33 | import org.springframework.context.annotation.Import; | 28 | import org.springframework.context.annotation.Import; |
| 34 | 29 | ||
| @@ -72,7 +67,7 @@ public class BpmCandidateSourceInfoProcessorChainTest extends BaseDbUnitTest { | @@ -72,7 +67,7 @@ public class BpmCandidateSourceInfoProcessorChainTest extends BaseDbUnitTest { | ||
| 72 | @Test | 67 | @Test |
| 73 | public void testCalculateTaskCandidateUsers_Role() { | 68 | public void testCalculateTaskCandidateUsers_Role() { |
| 74 | // 准备参数 | 69 | // 准备参数 |
| 75 | - BpmTaskCandidateVO rule = new BpmTaskCandidateVO().setOptions(asSet(1L, 2L)) | 70 | + BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L)) |
| 76 | .setType(BpmTaskAssignRuleTypeEnum.ROLE.getType()); | 71 | .setType(BpmTaskAssignRuleTypeEnum.ROLE.getType()); |
| 77 | // mock 方法 | 72 | // mock 方法 |
| 78 | when(permissionApi.getUserRoleIdListByRoleIds(eq(rule.getOptions()))) | 73 | when(permissionApi.getUserRoleIdListByRoleIds(eq(rule.getOptions()))) |
| @@ -90,7 +85,7 @@ public class BpmCandidateSourceInfoProcessorChainTest extends BaseDbUnitTest { | @@ -90,7 +85,7 @@ public class BpmCandidateSourceInfoProcessorChainTest extends BaseDbUnitTest { | ||
| 90 | @Test | 85 | @Test |
| 91 | public void testCalculateTaskCandidateUsers_DeptMember() { | 86 | public void testCalculateTaskCandidateUsers_DeptMember() { |
| 92 | // 准备参数 | 87 | // 准备参数 |
| 93 | - BpmTaskCandidateVO rule = new BpmTaskCandidateVO().setOptions(asSet(1L, 2L)) | 88 | + BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L)) |
| 94 | .setType(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType()); | 89 | .setType(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType()); |
| 95 | // mock 方法 | 90 | // mock 方法 |
| 96 | List<AdminUserRespDTO> users = CollectionUtils.convertList(asSet(11L, 22L), | 91 | List<AdminUserRespDTO> users = CollectionUtils.convertList(asSet(11L, 22L), |
| @@ -109,7 +104,7 @@ public class BpmCandidateSourceInfoProcessorChainTest extends BaseDbUnitTest { | @@ -109,7 +104,7 @@ public class BpmCandidateSourceInfoProcessorChainTest extends BaseDbUnitTest { | ||
| 109 | @Test | 104 | @Test |
| 110 | public void testCalculateTaskCandidateUsers_DeptLeader() { | 105 | public void testCalculateTaskCandidateUsers_DeptLeader() { |
| 111 | // 准备参数 | 106 | // 准备参数 |
| 112 | - BpmTaskCandidateVO rule = new BpmTaskCandidateVO().setOptions(asSet(1L, 2L)) | 107 | + BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L)) |
| 113 | .setType(BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType()); | 108 | .setType(BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType()); |
| 114 | // mock 方法 | 109 | // mock 方法 |
| 115 | DeptRespDTO dept1 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(11L)); | 110 | DeptRespDTO dept1 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(11L)); |
| @@ -128,7 +123,7 @@ public class BpmCandidateSourceInfoProcessorChainTest extends BaseDbUnitTest { | @@ -128,7 +123,7 @@ public class BpmCandidateSourceInfoProcessorChainTest extends BaseDbUnitTest { | ||
| 128 | @Test | 123 | @Test |
| 129 | public void testCalculateTaskCandidateUsers_Post() { | 124 | public void testCalculateTaskCandidateUsers_Post() { |
| 130 | // 准备参数 | 125 | // 准备参数 |
| 131 | - BpmTaskCandidateVO rule = new BpmTaskCandidateVO().setOptions(asSet(1L, 2L)) | 126 | + BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L)) |
| 132 | .setType(BpmTaskAssignRuleTypeEnum.POST.getType()); | 127 | .setType(BpmTaskAssignRuleTypeEnum.POST.getType()); |
| 133 | // mock 方法 | 128 | // mock 方法 |
| 134 | List<AdminUserRespDTO> users = CollectionUtils.convertList(asSet(11L, 22L), | 129 | List<AdminUserRespDTO> users = CollectionUtils.convertList(asSet(11L, 22L), |
| @@ -147,7 +142,7 @@ public class BpmCandidateSourceInfoProcessorChainTest extends BaseDbUnitTest { | @@ -147,7 +142,7 @@ public class BpmCandidateSourceInfoProcessorChainTest extends BaseDbUnitTest { | ||
| 147 | @Test | 142 | @Test |
| 148 | public void testCalculateTaskCandidateUsers_User() { | 143 | public void testCalculateTaskCandidateUsers_User() { |
| 149 | // 准备参数 | 144 | // 准备参数 |
| 150 | - BpmTaskCandidateVO rule = new BpmTaskCandidateVO().setOptions(asSet(1L, 2L)) | 145 | + BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L)) |
| 151 | .setType(BpmTaskAssignRuleTypeEnum.USER.getType()); | 146 | .setType(BpmTaskAssignRuleTypeEnum.USER.getType()); |
| 152 | // mock 方法 | 147 | // mock 方法 |
| 153 | mockGetUserMap(asSet(1L, 2L)); | 148 | mockGetUserMap(asSet(1L, 2L)); |
| @@ -163,7 +158,7 @@ public class BpmCandidateSourceInfoProcessorChainTest extends BaseDbUnitTest { | @@ -163,7 +158,7 @@ public class BpmCandidateSourceInfoProcessorChainTest extends BaseDbUnitTest { | ||
| 163 | @Test | 158 | @Test |
| 164 | public void testCalculateTaskCandidateUsers_UserGroup() { | 159 | public void testCalculateTaskCandidateUsers_UserGroup() { |
| 165 | // 准备参数 | 160 | // 准备参数 |
| 166 | - BpmTaskCandidateVO rule = new BpmTaskCandidateVO().setOptions(asSet(1L, 2L)) | 161 | + BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L)) |
| 167 | .setType(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType()); | 162 | .setType(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType()); |
| 168 | // mock 方法 | 163 | // mock 方法 |
| 169 | BpmUserGroupDO userGroup1 = randomPojo(BpmUserGroupDO.class, o -> o.setMemberUserIds(asSet(11L, 12L))); | 164 | BpmUserGroupDO userGroup1 = randomPojo(BpmUserGroupDO.class, o -> o.setMemberUserIds(asSet(11L, 12L))); |
| @@ -188,7 +183,7 @@ public class BpmCandidateSourceInfoProcessorChainTest extends BaseDbUnitTest { | @@ -188,7 +183,7 @@ public class BpmCandidateSourceInfoProcessorChainTest extends BaseDbUnitTest { | ||
| 188 | @Test | 183 | @Test |
| 189 | public void testCalculateTaskCandidateUsers_Script() { | 184 | public void testCalculateTaskCandidateUsers_Script() { |
| 190 | // 准备参数 | 185 | // 准备参数 |
| 191 | - BpmTaskCandidateVO rule = new BpmTaskCandidateVO().setOptions(asSet(20L, 21L)) | 186 | + BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(20L, 21L)) |
| 192 | .setType(BpmTaskAssignRuleTypeEnum.SCRIPT.getType()); | 187 | .setType(BpmTaskAssignRuleTypeEnum.SCRIPT.getType()); |
| 193 | // mock 方法 | 188 | // mock 方法 |
| 194 | BpmTaskAssignScript script1 = new BpmTaskAssignScript() { | 189 | BpmTaskAssignScript script1 = new BpmTaskAssignScript() { |
yudao-module-bpm/yudao-module-bpm-biz/src/test/java/cn/iocoder/yudao/module/bpm/service/cc/BpmProcessInstanceCopyServiceTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.bpm.service.cc; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | ||
| 4 | +import org.junit.jupiter.api.Test; | ||
| 5 | +import org.springframework.context.annotation.Import; | ||
| 6 | + | ||
| 7 | +import javax.annotation.Resource; | ||
| 8 | + | ||
| 9 | +@Import({BpmProcessInstanceCopyServiceImpl.class}) | ||
| 10 | +class BpmProcessInstanceCopyServiceTest extends BaseDbUnitTest { | ||
| 11 | + @Resource | ||
| 12 | + private BpmProcessInstanceCopyServiceImpl service; | ||
| 13 | + | ||
| 14 | + @Test | ||
| 15 | + void queryById() { | ||
| 16 | + } | ||
| 17 | +} | ||
| 0 | \ No newline at end of file | 18 | \ No newline at end of file |