Commit 8a8544b3bd3ca74b929ef0644faadd7ce13190a2
1 parent
1c78cdc2
【功能修改】工作流:调整 cc 抄送表的字段
Showing
9 changed files
with
67 additions
and
58 deletions
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/CollectionUtils.java
| @@ -3,6 +3,7 @@ package cn.iocoder.yudao.framework.common.util.collection; | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.framework.common.util.collection; | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.collection.CollectionUtil; | 4 | import cn.hutool.core.collection.CollectionUtil; |
| 5 | import cn.hutool.core.util.ArrayUtil; | 5 | import cn.hutool.core.util.ArrayUtil; |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | import com.google.common.collect.ImmutableMap; | 7 | import com.google.common.collect.ImmutableMap; |
| 7 | 8 | ||
| 8 | import java.util.*; | 9 | import java.util.*; |
| @@ -73,6 +74,13 @@ public class CollectionUtils { | @@ -73,6 +74,13 @@ public class CollectionUtils { | ||
| 73 | return from.stream().filter(filter).map(func).filter(Objects::nonNull).collect(Collectors.toList()); | 74 | return from.stream().filter(filter).map(func).filter(Objects::nonNull).collect(Collectors.toList()); |
| 74 | } | 75 | } |
| 75 | 76 | ||
| 77 | + public static <T, U> PageResult<U> convertPage(PageResult<T> from, Function<T, U> func) { | ||
| 78 | + if (ArrayUtil.isEmpty(from)) { | ||
| 79 | + return new PageResult<>(from.getTotal()); | ||
| 80 | + } | ||
| 81 | + return new PageResult<>(convertList(from.getList(), func), from.getTotal()); | ||
| 82 | + } | ||
| 83 | + | ||
| 76 | public static <T, U> List<U> convertListByFlatMap(Collection<T> from, | 84 | public static <T, U> List<U> convertListByFlatMap(Collection<T> from, |
| 77 | Function<T, ? extends Stream<? extends U>> func) { | 85 | Function<T, ? extends Stream<? extends U>> func) { |
| 78 | if (CollUtil.isEmpty(from)) { | 86 | if (CollUtil.isEmpty(from)) { |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmProcessInstanceCopyController.java
| @@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | @@ -6,6 +6,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; | 6 | import cn.iocoder.yudao.framework.common.util.collection.MapUtils; |
| 7 | import cn.iocoder.yudao.framework.common.util.date.DateUtils; | 7 | import cn.iocoder.yudao.framework.common.util.date.DateUtils; |
| 8 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 8 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 9 | +import cn.iocoder.yudao.module.bpm.controller.admin.base.user.UserSimpleBaseVO; | ||
| 9 | import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.cc.BpmProcessInstanceCopyRespVO; | 10 | import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.cc.BpmProcessInstanceCopyRespVO; |
| 10 | import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO; | 11 | import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO; |
| 11 | import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceCopyDO; | 12 | import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceCopyDO; |
| @@ -28,8 +29,7 @@ import java.util.Map; | @@ -28,8 +29,7 @@ import java.util.Map; | ||
| 28 | import java.util.stream.Stream; | 29 | import java.util.stream.Stream; |
| 29 | 30 | ||
| 30 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 31 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 31 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap; | ||
| 32 | -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | 32 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; |
| 33 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | 33 | import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; |
| 34 | 34 | ||
| 35 | @Tag(name = "管理后台 - 流程实例抄送") | 35 | @Tag(name = "管理后台 - 流程实例抄送") |
| @@ -62,11 +62,15 @@ public class BpmProcessInstanceCopyController { | @@ -62,11 +62,15 @@ public class BpmProcessInstanceCopyController { | ||
| 62 | convertSet(pageResult.getList(), BpmProcessInstanceCopyDO::getProcessInstanceId)); | 62 | convertSet(pageResult.getList(), BpmProcessInstanceCopyDO::getProcessInstanceId)); |
| 63 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(pageResult.getList(), | 63 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(pageResult.getList(), |
| 64 | copy -> Stream.of(copy.getStartUserId(), Long.parseLong(copy.getCreator())))); | 64 | copy -> Stream.of(copy.getStartUserId(), Long.parseLong(copy.getCreator())))); |
| 65 | - return success(BeanUtils.toBean(pageResult, BpmProcessInstanceCopyRespVO.class, copyVO -> { | ||
| 66 | - MapUtils.findAndThen(userMap, Long.valueOf(copyVO.getCreator()), user -> copyVO.setCreatorName(user.getNickname())); | ||
| 67 | - MapUtils.findAndThen(userMap, copyVO.getStartUserId(), user -> copyVO.setStartUserName(user.getNickname())); | 65 | + return success(convertPage(pageResult, copy -> { |
| 66 | + BpmProcessInstanceCopyRespVO copyVO = BeanUtils.toBean(copy, BpmProcessInstanceCopyRespVO.class); | ||
| 67 | + MapUtils.findAndThen(userMap, Long.valueOf(copy.getCreator()), | ||
| 68 | + user -> copyVO.setStartUser(BeanUtils.toBean(user, UserSimpleBaseVO.class))); | ||
| 69 | + MapUtils.findAndThen(userMap, copy.getStartUserId(), | ||
| 70 | + user -> copyVO.setCreateUser(BeanUtils.toBean(user, UserSimpleBaseVO.class))); | ||
| 68 | MapUtils.findAndThen(processInstanceMap, copyVO.getProcessInstanceId(), | 71 | MapUtils.findAndThen(processInstanceMap, copyVO.getProcessInstanceId(), |
| 69 | processInstance -> copyVO.setProcessInstanceStartTime(DateUtils.of(processInstance.getStartTime()))); | 72 | processInstance -> copyVO.setProcessInstanceStartTime(DateUtils.of(processInstance.getStartTime()))); |
| 73 | + return copyVO; | ||
| 70 | })); | 74 | })); |
| 71 | } | 75 | } |
| 72 | 76 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/cc/BpmProcessInstanceCopyRespVO.java
| 1 | package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.cc; | 1 | package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.cc; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.module.bpm.controller.admin.base.user.UserSimpleBaseVO; | ||
| 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 | ||
| @@ -12,32 +13,30 @@ public class BpmProcessInstanceCopyRespVO { | @@ -12,32 +13,30 @@ public class BpmProcessInstanceCopyRespVO { | ||
| 12 | @Schema(description = "抄送主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | 13 | @Schema(description = "抄送主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") |
| 13 | private Long id; | 14 | private Long id; |
| 14 | 15 | ||
| 15 | - @Schema(description = "发起人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "888") | ||
| 16 | - private Long startUserId; | ||
| 17 | - @Schema(description = "发起人昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") | ||
| 18 | - private String startUserName; | 16 | + @Schema(description = "发起人", requiredMode = Schema.RequiredMode.REQUIRED) |
| 17 | + private UserSimpleBaseVO startUser; | ||
| 19 | 18 | ||
| 20 | @Schema(description = "流程实例编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "A233") | 19 | @Schema(description = "流程实例编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "A233") |
| 21 | private String processInstanceId; | 20 | private String processInstanceId; |
| 22 | - @Schema(description = "流程实例的名称",requiredMode = Schema.RequiredMode.REQUIRED, example = "测试") | 21 | + @Schema(description = "流程实例的名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "测试") |
| 23 | private String processInstanceName; | 22 | private String processInstanceName; |
| 24 | - @Schema(description = "流程实例的发起时间",requiredMode = Schema.RequiredMode.REQUIRED) | 23 | + @Schema(description = "流程实例的发起时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 25 | private LocalDateTime processInstanceStartTime; | 24 | private LocalDateTime processInstanceStartTime; |
| 26 | 25 | ||
| 27 | - @Schema(description = "抄送的节点的活动编号") | 26 | + @Schema(description = "流程活动的编号", requiredMode = Schema.RequiredMode.REQUIRED) |
| 28 | private String activityId; | 27 | private String activityId; |
| 29 | - @Schema(description = "发起抄送的任务编号") | 28 | + @Schema(description = "流程活动的名字", requiredMode = Schema.RequiredMode.REQUIRED) |
| 29 | + private String activityName; | ||
| 30 | + | ||
| 31 | + @Schema(description = "流程活动的编号") | ||
| 30 | private String taskId; | 32 | private String taskId; |
| 31 | - @Schema(description = "发起抄送的任务名称") | ||
| 32 | - private String taskName; | ||
| 33 | 33 | ||
| 34 | - @Schema(description = "抄送人", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 35 | - private String creator; | ||
| 36 | - @Schema(description = "抄送人昵称") | ||
| 37 | - private String creatorName; | ||
| 38 | @Schema(description = "抄送人意见") | 34 | @Schema(description = "抄送人意见") |
| 39 | private String reason; | 35 | private String reason; |
| 40 | 36 | ||
| 37 | + @Schema(description = "创建人", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 38 | + private UserSimpleBaseVO createUser; | ||
| 39 | + | ||
| 41 | @Schema(description = "抄送时间", requiredMode = Schema.RequiredMode.REQUIRED) | 40 | @Schema(description = "抄送时间", requiredMode = Schema.RequiredMode.REQUIRED) |
| 42 | private LocalDateTime createTime; | 41 | private LocalDateTime createTime; |
| 43 | 42 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskApproveReqVO.java
| @@ -4,7 +4,6 @@ import io.swagger.v3.oas.annotations.media.Schema; | @@ -4,7 +4,6 @@ import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | import jakarta.validation.constraints.NotEmpty; | 4 | import jakarta.validation.constraints.NotEmpty; |
| 5 | import lombok.Data; | 5 | import lombok.Data; |
| 6 | 6 | ||
| 7 | -import java.util.Collection; | ||
| 8 | import java.util.Map; | 7 | import java.util.Map; |
| 9 | 8 | ||
| 10 | @Schema(description = "管理后台 - 通过流程任务的 Request VO") | 9 | @Schema(description = "管理后台 - 通过流程任务的 Request VO") |
| @@ -19,9 +18,6 @@ public class BpmTaskApproveReqVO { | @@ -19,9 +18,6 @@ public class BpmTaskApproveReqVO { | ||
| 19 | @NotEmpty(message = "审批意见不能为空") | 18 | @NotEmpty(message = "审批意见不能为空") |
| 20 | private String reason; | 19 | private String reason; |
| 21 | 20 | ||
| 22 | - @Schema(description = "抄送的用户编号数组", example = "1,2") | ||
| 23 | - private Collection<Long> copyUserIds; | ||
| 24 | - | ||
| 25 | @Schema(description = "变量实例(动态表单)", requiredMode = Schema.RequiredMode.REQUIRED) | 21 | @Schema(description = "变量实例(动态表单)", requiredMode = Schema.RequiredMode.REQUIRED) |
| 26 | private Map<String, Object> variables; | 22 | private Map<String, Object> variables; |
| 27 | 23 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/dataobject/task/BpmProcessInstanceCopyDO.java
| @@ -4,6 +4,8 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | @@ -4,6 +4,8 @@ import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 4 | import com.baomidou.mybatisplus.annotation.TableId; | 4 | import com.baomidou.mybatisplus.annotation.TableId; |
| 5 | import com.baomidou.mybatisplus.annotation.TableName; | 5 | import com.baomidou.mybatisplus.annotation.TableName; |
| 6 | import lombok.*; | 6 | import lombok.*; |
| 7 | +import org.flowable.bpmn.model.FlowNode; | ||
| 8 | +import org.flowable.task.api.history.HistoricTaskInstance; | ||
| 7 | 9 | ||
| 8 | /** | 10 | /** |
| 9 | * 流程抄送 DO | 11 | * 流程抄送 DO |
| @@ -49,23 +51,25 @@ public class BpmProcessInstanceCopyDO extends BaseDO { | @@ -49,23 +51,25 @@ public class BpmProcessInstanceCopyDO extends BaseDO { | ||
| 49 | */ | 51 | */ |
| 50 | private String category; | 52 | private String category; |
| 51 | /** | 53 | /** |
| 52 | - * 流程活动编号 | 54 | + * 流程活动的编号 |
| 53 | * <p/> | 55 | * <p/> |
| 54 | - * 对应 BPMN XML 节点编号,用于查询抄送节点的表单字段权限 | ||
| 55 | - * 这里冗余的原因:如果是钉钉易搭的抄送节点 (ServiceTask),使用 taskId 可能查不到对应的 activityId | 56 | + * |
| 57 | + * 冗余 {@link FlowNode#getId()},对应 BPMN XML 节点编号 | ||
| 58 | + * 原因:用于查询抄送节点的表单字段权限。因为仿钉钉/飞书的抄送节点 (ServiceTask),没有 taskId,只有 activityId | ||
| 56 | */ | 59 | */ |
| 57 | private String activityId; | 60 | private String activityId; |
| 58 | /** | 61 | /** |
| 59 | - * 任务主键 | ||
| 60 | - * 关联 Task 的 id 属性 | 62 | + * 流程活动的名字 |
| 63 | + * | ||
| 64 | + * 冗余 {@link FlowNode#getName()} | ||
| 61 | */ | 65 | */ |
| 62 | - private String taskId; | 66 | + private String activityName; |
| 63 | /** | 67 | /** |
| 64 | - * 任务名称 | 68 | + * 流程活动的编号 |
| 65 | * | 69 | * |
| 66 | - * 冗余 Task 的 name 属性 | 70 | + * 关联 {@link HistoricTaskInstance#getId()} |
| 67 | */ | 71 | */ |
| 68 | - private String taskName; | 72 | + private String taskId; |
| 69 | 73 | ||
| 70 | /** | 74 | /** |
| 71 | * 用户编号(被抄送的用户编号) | 75 | * 用户编号(被抄送的用户编号) |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmCopyTaskDelegate.java
| @@ -16,7 +16,7 @@ import static cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.BpmCo | @@ -16,7 +16,7 @@ import static cn.iocoder.yudao.module.bpm.framework.flowable.core.listener.BpmCo | ||
| 16 | /** | 16 | /** |
| 17 | * 处理抄送用户的 {@link JavaDelegate} 的实现类 | 17 | * 处理抄送用户的 {@link JavaDelegate} 的实现类 |
| 18 | * <p> | 18 | * <p> |
| 19 | - * 目前只有快搭模式的【抄送节点】使用 | 19 | + * 目前只有仿钉钉/飞书模式的【抄送节点】使用 |
| 20 | * | 20 | * |
| 21 | * @author jason | 21 | * @author jason |
| 22 | */ | 22 | */ |
| @@ -41,7 +41,7 @@ public class BpmCopyTaskDelegate implements JavaDelegate { | @@ -41,7 +41,7 @@ public class BpmCopyTaskDelegate implements JavaDelegate { | ||
| 41 | // 2. 执行抄送 | 41 | // 2. 执行抄送 |
| 42 | FlowElement currentFlowElement = execution.getCurrentFlowElement(); | 42 | FlowElement currentFlowElement = execution.getCurrentFlowElement(); |
| 43 | processInstanceCopyService.createProcessInstanceCopy(userIds, null, execution.getProcessInstanceId(), | 43 | processInstanceCopyService.createProcessInstanceCopy(userIds, null, execution.getProcessInstanceId(), |
| 44 | - currentFlowElement.getId(), null, currentFlowElement.getName()); | 44 | + currentFlowElement.getId(), currentFlowElement.getName(), null); |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | } | 47 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceCopyService.java
| @@ -3,9 +3,10 @@ package cn.iocoder.yudao.module.bpm.service.task; | @@ -3,9 +3,10 @@ package cn.iocoder.yudao.module.bpm.service.task; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO; | 4 | import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO; |
| 5 | import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceCopyDO; | 5 | import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceCopyDO; |
| 6 | +import jakarta.validation.constraints.NotEmpty; | ||
| 7 | +import org.flowable.bpmn.model.FlowNode; | ||
| 6 | 8 | ||
| 7 | import java.util.Collection; | 9 | import java.util.Collection; |
| 8 | -import java.util.Set; | ||
| 9 | 10 | ||
| 10 | /** | 11 | /** |
| 11 | * 流程抄送 Service 接口 | 12 | * 流程抄送 Service 接口 |
| @@ -15,7 +16,7 @@ import java.util.Set; | @@ -15,7 +16,7 @@ import java.util.Set; | ||
| 15 | public interface BpmProcessInstanceCopyService { | 16 | public interface BpmProcessInstanceCopyService { |
| 16 | 17 | ||
| 17 | /** | 18 | /** |
| 18 | - * 流程实例的抄送 | 19 | + * 【管理员】流程实例的抄送 |
| 19 | * | 20 | * |
| 20 | * @param userIds 抄送的用户编号 | 21 | * @param userIds 抄送的用户编号 |
| 21 | * @param reason 抄送意见 | 22 | * @param reason 抄送意见 |
| @@ -24,17 +25,20 @@ public interface BpmProcessInstanceCopyService { | @@ -24,17 +25,20 @@ public interface BpmProcessInstanceCopyService { | ||
| 24 | void createProcessInstanceCopy(Collection<Long> userIds, String reason, String taskId); | 25 | void createProcessInstanceCopy(Collection<Long> userIds, String reason, String taskId); |
| 25 | 26 | ||
| 26 | /** | 27 | /** |
| 27 | - * 流程实例的抄送 | 28 | + * 【自动抄送】流程实例的抄送 |
| 28 | * | 29 | * |
| 29 | * @param userIds 抄送的用户编号 | 30 | * @param userIds 抄送的用户编号 |
| 30 | * @param reason 抄送意见 | 31 | * @param reason 抄送意见 |
| 31 | * @param processInstanceId 流程编号 | 32 | * @param processInstanceId 流程编号 |
| 32 | - * @param activityId 流程活动编号 id (对应 BPMN XML 节点 Id) | ||
| 33 | - * @param taskId 任务编号 | ||
| 34 | - * @param taskName 任务名称 | 33 | + * @param activityId 流程活动编号(对应 {@link FlowNode#getId()}) |
| 34 | + * @param activityName 任务编号(对应 {@link FlowNode#getName()}) | ||
| 35 | + * @param taskId 任务编号,允许空 | ||
| 35 | */ | 36 | */ |
| 36 | - void createProcessInstanceCopy(Collection<Long> userIds, String reason, String processInstanceId, String activityId, | ||
| 37 | - String taskId, String taskName); | 37 | + void createProcessInstanceCopy(Collection<Long> userIds, String reason, |
| 38 | + @NotEmpty(message = "流程实例编号不能为空") String processInstanceId, | ||
| 39 | + @NotEmpty(message = "流程活动编号不能为空") String activityId, | ||
| 40 | + @NotEmpty(message = "流程活动名字不能为空") String activityName, | ||
| 41 | + String taskId); | ||
| 38 | 42 | ||
| 39 | /** | 43 | /** |
| 40 | * 获得抄送的流程的分页 | 44 | * 获得抄送的流程的分页 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceCopyServiceImpl.java
| @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.bpm.service.task; | @@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.bpm.service.task; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.util.ObjectUtil; | 3 | import cn.hutool.core.util.ObjectUtil; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||
| 6 | import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO; | 5 | import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCopyPageReqVO; |
| 7 | import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceCopyDO; | 6 | import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmProcessInstanceCopyDO; |
| 8 | import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmProcessInstanceCopyMapper; | 7 | import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmProcessInstanceCopyMapper; |
| @@ -19,7 +18,6 @@ import org.springframework.validation.annotation.Validated; | @@ -19,7 +18,6 @@ import org.springframework.validation.annotation.Validated; | ||
| 19 | 18 | ||
| 20 | import java.util.Collection; | 19 | import java.util.Collection; |
| 21 | import java.util.List; | 20 | import java.util.List; |
| 22 | -import java.util.Set; | ||
| 23 | 21 | ||
| 24 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 22 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 25 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | 23 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; |
| @@ -54,13 +52,14 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy | @@ -54,13 +52,14 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy | ||
| 54 | if (ObjectUtil.isNull(task)) { | 52 | if (ObjectUtil.isNull(task)) { |
| 55 | throw exception(ErrorCodeConstants.TASK_NOT_EXISTS); | 53 | throw exception(ErrorCodeConstants.TASK_NOT_EXISTS); |
| 56 | } | 54 | } |
| 57 | - String processInstanceId = task.getProcessInstanceId(); | ||
| 58 | - createProcessInstanceCopy(userIds, reason, processInstanceId, task.getTaskDefinitionKey(), task.getId(), task.getName()); | 55 | + // 执行抄送 |
| 56 | + createProcessInstanceCopy(userIds, reason, | ||
| 57 | + task.getProcessInstanceId(), task.getTaskDefinitionKey(), task.getId(), task.getName()); | ||
| 59 | } | 58 | } |
| 60 | 59 | ||
| 61 | @Override | 60 | @Override |
| 62 | - public void createProcessInstanceCopy(Collection<Long> userIds, String reason, String processInstanceId, String activityId, | ||
| 63 | - String taskId, String taskName) { | 61 | + public void createProcessInstanceCopy(Collection<Long> userIds, String reason, String processInstanceId, |
| 62 | + String activityId, String activityName, String taskId) { | ||
| 64 | // 1.1 校验流程实例存在 | 63 | // 1.1 校验流程实例存在 |
| 65 | ProcessInstance processInstance = processInstanceService.getProcessInstance(processInstanceId); | 64 | ProcessInstance processInstance = processInstanceService.getProcessInstance(processInstanceId); |
| 66 | if (processInstance == null) { | 65 | if (processInstance == null) { |
| @@ -77,8 +76,8 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy | @@ -77,8 +76,8 @@ public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopy | ||
| 77 | List<BpmProcessInstanceCopyDO> copyList = convertList(userIds, userId -> new BpmProcessInstanceCopyDO() | 76 | List<BpmProcessInstanceCopyDO> copyList = convertList(userIds, userId -> new BpmProcessInstanceCopyDO() |
| 78 | .setUserId(userId).setReason(reason).setStartUserId(Long.valueOf(processInstance.getStartUserId())) | 77 | .setUserId(userId).setReason(reason).setStartUserId(Long.valueOf(processInstance.getStartUserId())) |
| 79 | .setProcessInstanceId(processInstanceId).setProcessInstanceName(processInstance.getName()) | 78 | .setProcessInstanceId(processInstanceId).setProcessInstanceName(processInstance.getName()) |
| 80 | - .setCategory(processDefinition.getCategory()).setActivityId(activityId) | ||
| 81 | - .setTaskId(taskId).setTaskName(taskName)); | 79 | + .setCategory(processDefinition.getCategory()).setTaskId(taskId) |
| 80 | + .setActivityId(activityId).setActivityName(activityName)); | ||
| 82 | processInstanceCopyMapper.insertBatch(copyList); | 81 | processInstanceCopyMapper.insertBatch(copyList); |
| 83 | } | 82 | } |
| 84 | 83 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
| @@ -426,11 +426,6 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -426,11 +426,6 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 426 | throw exception(PROCESS_INSTANCE_NOT_EXISTS); | 426 | throw exception(PROCESS_INSTANCE_NOT_EXISTS); |
| 427 | } | 427 | } |
| 428 | 428 | ||
| 429 | - // 2. 抄送用户 | ||
| 430 | - if (CollUtil.isNotEmpty(reqVO.getCopyUserIds())) { | ||
| 431 | - processInstanceCopyService.createProcessInstanceCopy(reqVO.getCopyUserIds(), null, reqVO.getId()); | ||
| 432 | - } | ||
| 433 | - | ||
| 434 | // 情况一:被委派的任务,不调用 complete 去完成任务 | 429 | // 情况一:被委派的任务,不调用 complete 去完成任务 |
| 435 | if (DelegationState.PENDING.equals(task.getDelegationState())) { | 430 | if (DelegationState.PENDING.equals(task.getDelegationState())) { |
| 436 | approveDelegateTask(reqVO, task); | 431 | approveDelegateTask(reqVO, task); |
| @@ -444,12 +439,12 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -444,12 +439,12 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 444 | } | 439 | } |
| 445 | 440 | ||
| 446 | // 情况三:审批普通的任务。大多数情况下,都是这样 | 441 | // 情况三:审批普通的任务。大多数情况下,都是这样 |
| 447 | - // 3.1 更新 task 状态、原因 | 442 | + // 2.1 更新 task 状态、原因 |
| 448 | updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.APPROVE.getStatus(), reqVO.getReason()); | 443 | updateTaskStatusAndReason(task.getId(), BpmTaskStatusEnum.APPROVE.getStatus(), reqVO.getReason()); |
| 449 | - // 3.2 添加评论 | 444 | + // 2.2 添加评论 |
| 450 | taskService.addComment(task.getId(), task.getProcessInstanceId(), BpmCommentTypeEnum.APPROVE.getType(), | 445 | taskService.addComment(task.getId(), task.getProcessInstanceId(), BpmCommentTypeEnum.APPROVE.getType(), |
| 451 | BpmCommentTypeEnum.APPROVE.formatComment(reqVO.getReason())); | 446 | BpmCommentTypeEnum.APPROVE.formatComment(reqVO.getReason())); |
| 452 | - // 3.3 调用 BPM complete 去完成任务 | 447 | + // 2.3 调用 BPM complete 去完成任务 |
| 453 | // 其中,variables 是存储动态表单到 local 任务级别。过滤一下,避免 ProcessInstance 系统级的变量被占用 | 448 | // 其中,variables 是存储动态表单到 local 任务级别。过滤一下,避免 ProcessInstance 系统级的变量被占用 |
| 454 | if (CollUtil.isNotEmpty(reqVO.getVariables())) { | 449 | if (CollUtil.isNotEmpty(reqVO.getVariables())) { |
| 455 | Map<String, Object> variables = FlowableUtils.filterTaskFormVariable(reqVO.getVariables()); | 450 | Map<String, Object> variables = FlowableUtils.filterTaskFormVariable(reqVO.getVariables()); |