Commit bc781d947368535d0775d6d22823b255ceb62847
1 parent
6388950a
fix: 【工作流】按 review 修改代码
Showing
9 changed files
with
209 additions
and
265 deletions
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/enums/SymbolConstant.java deleted
| 1 | -package cn.iocoder.yudao.framework.common.enums; | ||
| 2 | - | ||
| 3 | -// TODO 这种简单的,暂时不用枚举哈,直接代码里写死就好啦; | ||
| 4 | -/** | ||
| 5 | - * 符号常量 | ||
| 6 | - */ | ||
| 7 | -public interface SymbolConstant { | ||
| 8 | - | ||
| 9 | - String D =","; | ||
| 10 | - | ||
| 11 | - /** | ||
| 12 | - * _ | ||
| 13 | - */ | ||
| 14 | - String XH="_"; | ||
| 15 | - /** | ||
| 16 | - * - | ||
| 17 | - */ | ||
| 18 | - String HG="-"; | ||
| 19 | - | ||
| 20 | - /** | ||
| 21 | - * / | ||
| 22 | - */ | ||
| 23 | - String XG="/"; | ||
| 24 | - | ||
| 25 | - /** | ||
| 26 | - * 箭头 | ||
| 27 | - */ | ||
| 28 | - String ARROWHEAD="->"; | ||
| 29 | - | ||
| 30 | - /** | ||
| 31 | - * 数组的开始元素 | ||
| 32 | - */ | ||
| 33 | - String ARRAY_START="["; | ||
| 34 | - | ||
| 35 | - /** | ||
| 36 | - * 数组的结束元素 | ||
| 37 | - */ | ||
| 38 | - String ARRAY_END="]"; | ||
| 39 | - | ||
| 40 | - /** | ||
| 41 | - * null 字符串 | ||
| 42 | - */ | ||
| 43 | - String NULL_STRING="null"; | ||
| 44 | - | ||
| 45 | - /** | ||
| 46 | - * 点号 | ||
| 47 | - */ | ||
| 48 | - String DIAN="\\."; | ||
| 49 | -} |
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmCommentTypeEnum.java
| @@ -10,26 +10,26 @@ import lombok.Getter; | @@ -10,26 +10,26 @@ import lombok.Getter; | ||
| 10 | @AllArgsConstructor | 10 | @AllArgsConstructor |
| 11 | public enum BpmCommentTypeEnum { | 11 | public enum BpmCommentTypeEnum { |
| 12 | 12 | ||
| 13 | - APPROVE(1, "通过"), | ||
| 14 | - REJECT(2, "不通过"), | ||
| 15 | - CANCEL(3, "已取消"), | ||
| 16 | - | ||
| 17 | - // TODO @海:18 行可以去掉哈;这个是之前为了 status 隔离用的; | ||
| 18 | - // ========== 流程任务独有的状态 ========== | ||
| 19 | - | ||
| 20 | - BACK(4, "退回"), // 退回 | ||
| 21 | - DELEGATE(5, "委派"), | ||
| 22 | - ADD_SIGN(6, "加签"), | ||
| 23 | - SUB_SIGN(7,"减签"), | 13 | + APPROVE(1, "通过", ""), |
| 14 | + REJECT(2, "不通过", ""), | ||
| 15 | + CANCEL(3, "已取消", ""), | ||
| 16 | + BACK(4, "退回", ""), | ||
| 17 | + DELEGATE(5, "委派", ""), | ||
| 18 | + ADD_SIGN(6, "加签", "[{}]{}给了[{}],理由为:{}"), | ||
| 19 | + SUB_SIGN(7, "减签", "[{}]操作了【减签】,审批人[{}]的任务被取消"), | ||
| 24 | ; | 20 | ; |
| 25 | 21 | ||
| 26 | - // TODO @海:字段叫 type 更合适噢 | ||
| 27 | /** | 22 | /** |
| 28 | * 结果 | 23 | * 结果 |
| 29 | */ | 24 | */ |
| 30 | - private final Integer result; | 25 | + private final Integer type; |
| 31 | /** | 26 | /** |
| 32 | * 描述 | 27 | * 描述 |
| 33 | */ | 28 | */ |
| 34 | private final String desc; | 29 | private final String desc; |
| 30 | + /** | ||
| 31 | + * 模板信息 | ||
| 32 | + */ | ||
| 33 | + private final String templateComment; | ||
| 34 | + | ||
| 35 | } | 35 | } |
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/task/BpmProcessInstanceResultEnum.java
| @@ -27,19 +27,27 @@ public enum BpmProcessInstanceResultEnum { | @@ -27,19 +27,27 @@ public enum BpmProcessInstanceResultEnum { | ||
| 27 | DELEGATE(6, "委派"), | 27 | DELEGATE(6, "委派"), |
| 28 | /** | 28 | /** |
| 29 | * 【加签】源任务已经审批完成,但是它使用了后加签,后加签的任务未完成,源任务就会是这个状态 | 29 | * 【加签】源任务已经审批完成,但是它使用了后加签,后加签的任务未完成,源任务就会是这个状态 |
| 30 | + * 相当于是 通过 APPROVE 的特殊状态 | ||
| 30 | * 例如:A审批, A 后加签了 B,并且审批通过了任务,但是 B 还未审批,则当前任务状态为“待后加签任务完成” | 31 | * 例如:A审批, A 后加签了 B,并且审批通过了任务,但是 B 还未审批,则当前任务状态为“待后加签任务完成” |
| 31 | */ | 32 | */ |
| 32 | - ADD_SIGN_AFTER(7, "待后加签任务完成"), // TODO @海:这个定义,是不是 通过(待后加签任务完成),相当于是 APPROVE 的特殊状态 | 33 | + ADD_SIGN_AFTER(7, "待后加签任务完成"), |
| 33 | /** | 34 | /** |
| 34 | * 【加签】源任务未审批,但是向前加签了,所以源任务状态变为“待前加签任务完成” | 35 | * 【加签】源任务未审批,但是向前加签了,所以源任务状态变为“待前加签任务完成” |
| 36 | + * 相当于是 处理中 PROCESS 的特殊状态 | ||
| 35 | * 例如:A 审批, A 前加签了 B,B 还未审核 | 37 | * 例如:A 审批, A 前加签了 B,B 还未审核 |
| 36 | */ | 38 | */ |
| 37 | - ADD_SIGN_BEFORE(8, "待前加签任务完成"), // TODO @海:这个定义,是不是 处理中(待前加签任务审批),相当于是 PROCESS 的特殊状态 | 39 | + ADD_SIGN_BEFORE(8, "待前加签任务完成"), |
| 38 | /** | 40 | /** |
| 39 | * 【加签】后加签任务被创建时的初始状态 | 41 | * 【加签】后加签任务被创建时的初始状态 |
| 42 | + * 相当于是 处理中 PROCESS 的特殊状态 | ||
| 40 | * 因为需要源任务先完成,才能到后加签的人来审批,所以加了一个状态区分 | 43 | * 因为需要源任务先完成,才能到后加签的人来审批,所以加了一个状态区分 |
| 41 | */ | 44 | */ |
| 42 | - WAIT_BEFORE_TASK(9, "待前置任务完成"); // TODO @海:这个定义,是不是 处理中(待前置任务审批),相当于是 PROCESS 的特殊状态 | 45 | + WAIT_BEFORE_TASK(9, "待前置任务完成"); |
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 能被减签的状态 | ||
| 49 | + */ | ||
| 50 | + public static final List<Integer> CAN_SUB_SIGN_STATUS_LIST = Arrays.asList(PROCESS.result, WAIT_BEFORE_TASK.result); | ||
| 43 | 51 | ||
| 44 | /** | 52 | /** |
| 45 | * 结果 | 53 | * 结果 |
| @@ -66,10 +74,4 @@ public enum BpmProcessInstanceResultEnum { | @@ -66,10 +74,4 @@ public enum BpmProcessInstanceResultEnum { | ||
| 66 | ADD_SIGN_AFTER.getResult()); | 74 | ADD_SIGN_AFTER.getResult()); |
| 67 | } | 75 | } |
| 68 | 76 | ||
| 69 | - // TODO @海:静态变量,需要放到成员变量前面;另外,如果是复数,可以加 S(ES) 或者 LIST | ||
| 70 | - /** | ||
| 71 | - * 能被减签的状态 | ||
| 72 | - */ | ||
| 73 | - public static final List<Integer> CAN_SUB_SIGN_STATUS = Arrays.asList(PROCESS.result, WAIT_BEFORE_TASK.result); | ||
| 74 | - | ||
| 75 | } | 77 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/BpmTaskController.java
| @@ -4,16 +4,15 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; | @@ -4,16 +4,15 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; | 5 | import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; |
| 6 | import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; | 6 | import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService; |
| 7 | -import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 8 | -import io.swagger.v3.oas.annotations.Parameter; | ||
| 9 | import io.swagger.v3.oas.annotations.Operation; | 7 | import io.swagger.v3.oas.annotations.Operation; |
| 8 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 9 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 10 | import org.springframework.security.access.prepost.PreAuthorize; | 10 | import org.springframework.security.access.prepost.PreAuthorize; |
| 11 | import org.springframework.validation.annotation.Validated; | 11 | import org.springframework.validation.annotation.Validated; |
| 12 | import org.springframework.web.bind.annotation.*; | 12 | import org.springframework.web.bind.annotation.*; |
| 13 | 13 | ||
| 14 | import javax.annotation.Resource; | 14 | import javax.annotation.Resource; |
| 15 | import javax.validation.Valid; | 15 | import javax.validation.Valid; |
| 16 | - | ||
| 17 | import java.util.List; | 16 | import java.util.List; |
| 18 | 17 | ||
| 19 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 18 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| @@ -95,35 +94,29 @@ public class BpmTaskController { | @@ -95,35 +94,29 @@ public class BpmTaskController { | ||
| 95 | @Operation(summary = "委派任务", description = "用于【流程详情】的【委派】按钮。和向前【加签】有点像,唯一区别是【委托】没有单独创立任务") | 94 | @Operation(summary = "委派任务", description = "用于【流程详情】的【委派】按钮。和向前【加签】有点像,唯一区别是【委托】没有单独创立任务") |
| 96 | @PreAuthorize("@ss.hasPermission('bpm:task:update')") | 95 | @PreAuthorize("@ss.hasPermission('bpm:task:update')") |
| 97 | public CommonResult<Boolean> delegateTask(@Valid @RequestBody BpmTaskDelegateReqVO reqVO) { | 96 | public CommonResult<Boolean> delegateTask(@Valid @RequestBody BpmTaskDelegateReqVO reqVO) { |
| 98 | - // TODO @海:, 后面要有空格 | ||
| 99 | - taskService.delegateTask(reqVO,getLoginUserId()); | 97 | + taskService.delegateTask(getLoginUserId(), reqVO); |
| 100 | return success(true); | 98 | return success(true); |
| 101 | } | 99 | } |
| 102 | 100 | ||
| 103 | - // TODO @海:权限统一使用 bpm:task:update;是否可以加减签,可以交给后续的权限配置实现; | ||
| 104 | @PutMapping("/add-sign") | 101 | @PutMapping("/add-sign") |
| 105 | @Operation(summary = "加签", description = "before 前加签,after 后加签") | 102 | @Operation(summary = "加签", description = "before 前加签,after 后加签") |
| 106 | - @PreAuthorize("@ss.hasPermission('bpm:task:add-sign')") | ||
| 107 | - public CommonResult<Boolean> addSign(@Valid @RequestBody BpmTaskAddSignReqVO reqVO) { | ||
| 108 | - // TODO @海:userId 建议作为第一个参数;一般是,谁做了什么操作;另外,addSignTask,保持风格统一哈; | ||
| 109 | - taskService.addSign(reqVO,getLoginUserId()); | 103 | + @PreAuthorize("@ss.hasPermission('bpm:task:update')") |
| 104 | + public CommonResult<Boolean> addSignTask(@Valid @RequestBody BpmTaskAddSignReqVO reqVO) { | ||
| 105 | + taskService.addSignTask(getLoginUserId(), reqVO); | ||
| 110 | return success(true); | 106 | return success(true); |
| 111 | } | 107 | } |
| 112 | 108 | ||
| 113 | - // TODO @海:权限统一使用 bpm:task:update;是否可以加减签,可以交给后续的权限配置实现; | ||
| 114 | @PutMapping("/sub-sign") | 109 | @PutMapping("/sub-sign") |
| 115 | @Operation(summary = "减签") | 110 | @Operation(summary = "减签") |
| 116 | - @PreAuthorize("@ss.hasPermission('bpm:task:sub-sign')") | ||
| 117 | - // TODO @海: @RequestBody BpmTaskSubSignReqVO 应该是一个空格;然后参数名可以简写成 reqVO; | ||
| 118 | - public CommonResult<Boolean> subSign(@Valid @RequestBody BpmTaskSubSignReqVO bpmTaskSubSignReqVO) { | ||
| 119 | - taskService.subSign(bpmTaskSubSignReqVO,getLoginUserId()); | 111 | + @PreAuthorize("@ss.hasPermission('bpm:task:update')") |
| 112 | + public CommonResult<Boolean> subSignTask(@Valid @RequestBody BpmTaskSubSignReqVO reqVO) { | ||
| 113 | + taskService.subSignTask(getLoginUserId(), reqVO); | ||
| 120 | return success(true); | 114 | return success(true); |
| 121 | } | 115 | } |
| 122 | 116 | ||
| 123 | - // TODO @海:是不是 url 和方法名,叫 get-child-task-list,更抽象和复用一些? | ||
| 124 | - @GetMapping("/get-sub-sign") | 117 | + @GetMapping("/get-children-task-list") |
| 125 | @Operation(summary = "获取能被减签的任务") | 118 | @Operation(summary = "获取能被减签的任务") |
| 126 | - @PreAuthorize("@ss.hasPermission('bpm:task:sub-sign')") | 119 | + @PreAuthorize("@ss.hasPermission('bpm:task:update')") |
| 127 | public CommonResult<List<BpmTaskSubSignRespVO>> getChildrenTaskList(@RequestParam("taskId") String taskId) { | 120 | public CommonResult<List<BpmTaskSubSignRespVO>> getChildrenTaskList(@RequestParam("taskId") String taskId) { |
| 128 | return success(taskService.getChildrenTaskList(taskId)); | 121 | return success(taskService.getChildrenTaskList(taskId)); |
| 129 | } | 122 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskAddSignReqVO.java
| @@ -4,13 +4,16 @@ import io.swagger.v3.oas.annotations.media.Schema; | @@ -4,13 +4,16 @@ import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| 5 | 5 | ||
| 6 | import javax.validation.constraints.NotEmpty; | 6 | import javax.validation.constraints.NotEmpty; |
| 7 | -import java.util.List; | ||
| 8 | import java.util.Set; | 7 | import java.util.Set; |
| 9 | 8 | ||
| 10 | @Schema(description = "管理后台 - 加签流程任务的 Request VO") | 9 | @Schema(description = "管理后台 - 加签流程任务的 Request VO") |
| 11 | @Data | 10 | @Data |
| 12 | public class BpmTaskAddSignReqVO { | 11 | public class BpmTaskAddSignReqVO { |
| 13 | 12 | ||
| 13 | + @Schema(description = "需要加签的任务 ID") | ||
| 14 | + @NotEmpty(message = "任务编号不能为空") | ||
| 15 | + private String id; | ||
| 16 | + | ||
| 14 | @Schema(description = "加签的用户 ID") | 17 | @Schema(description = "加签的用户 ID") |
| 15 | @NotEmpty(message = "加签用户 ID 不能为空") | 18 | @NotEmpty(message = "加签用户 ID 不能为空") |
| 16 | private Set<Long> userIdList; | 19 | private Set<Long> userIdList; |
| @@ -23,9 +26,4 @@ public class BpmTaskAddSignReqVO { | @@ -23,9 +26,4 @@ public class BpmTaskAddSignReqVO { | ||
| 23 | @NotEmpty(message = "加签原因不能为空") | 26 | @NotEmpty(message = "加签原因不能为空") |
| 24 | private String reason; | 27 | private String reason; |
| 25 | 28 | ||
| 26 | - // TODO @海:重要参数,可以放到最前面哈; | ||
| 27 | - @Schema(description = "需要加签的任务 ID") | ||
| 28 | - @NotEmpty(message = "任务编号不能为空") | ||
| 29 | - private String id; | ||
| 30 | - | ||
| 31 | } | 29 | } |
| 32 | \ No newline at end of file | 30 | \ No newline at end of file |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/convert/task/BpmTaskConvert.java
| @@ -147,7 +147,8 @@ public interface BpmTaskConvert { | @@ -147,7 +147,8 @@ public interface BpmTaskConvert { | ||
| 147 | .setDefinitionKey(element.getId())); | 147 | .setDefinitionKey(element.getId())); |
| 148 | } | 148 | } |
| 149 | 149 | ||
| 150 | - // TODO @海:可以使用 mapstruct 映射么? | 150 | + //此处不用 mapstruct 映射,因为 TaskEntityImpl 还有很多其他属性,这里我们只设置我们需要的 |
| 151 | + //使用 mapstruct 会将里面嵌套的各个属性值都设置进去,会出现意想不到的问题 | ||
| 151 | default TaskEntityImpl convert(TaskEntityImpl task,TaskEntityImpl parentTask){ | 152 | default TaskEntityImpl convert(TaskEntityImpl task,TaskEntityImpl parentTask){ |
| 152 | task.setCategory(parentTask.getCategory()); | 153 | task.setCategory(parentTask.getCategory()); |
| 153 | task.setDescription(parentTask.getDescription()); | 154 | task.setDescription(parentTask.getDescription()); |
| @@ -183,15 +184,15 @@ public interface BpmTaskConvert { | @@ -183,15 +184,15 @@ public interface BpmTaskConvert { | ||
| 183 | 184 | ||
| 184 | /** | 185 | /** |
| 185 | * 转换任务为父子级 | 186 | * 转换任务为父子级 |
| 186 | - * @param result | ||
| 187 | - * @return | 187 | + * @param sourceList 原始数据 |
| 188 | + * @return 转换后的父子级数组 | ||
| 188 | */ | 189 | */ |
| 189 | - default List<BpmTaskRespVO> convertChildrenList(List<BpmTaskRespVO> result){ | ||
| 190 | - List<BpmTaskRespVO> childrenTaskList = CollectionUtils.filterList(result, r -> StrUtil.isNotEmpty(r.getParentTaskId())); | 190 | + default List<BpmTaskRespVO> convertChildrenList(List<BpmTaskRespVO> sourceList){ |
| 191 | + List<BpmTaskRespVO> childrenTaskList = CollectionUtils.filterList(sourceList, r -> StrUtil.isNotEmpty(r.getParentTaskId())); | ||
| 191 | Map<String, List<BpmTaskRespVO>> parentChildrenTaskListMap = CollectionUtils.convertMultiMap(childrenTaskList, BpmTaskRespVO::getParentTaskId); | 192 | Map<String, List<BpmTaskRespVO>> parentChildrenTaskListMap = CollectionUtils.convertMultiMap(childrenTaskList, BpmTaskRespVO::getParentTaskId); |
| 192 | - for (BpmTaskRespVO bpmTaskRespVO : result) { | 193 | + for (BpmTaskRespVO bpmTaskRespVO : sourceList) { |
| 193 | bpmTaskRespVO.setChildren(parentChildrenTaskListMap.get(bpmTaskRespVO.getId())); | 194 | bpmTaskRespVO.setChildren(parentChildrenTaskListMap.get(bpmTaskRespVO.getId())); |
| 194 | } | 195 | } |
| 195 | - return CollectionUtils.filterList(result, r -> StrUtil.isEmpty(r.getParentTaskId())); | 196 | + return CollectionUtils.filterList(sourceList, r -> StrUtil.isEmpty(r.getParentTaskId())); |
| 196 | } | 197 | } |
| 197 | } | 198 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/dal/mysql/task/BpmTaskExtMapper.java
| @@ -24,7 +24,7 @@ public interface BpmTaskExtMapper extends BaseMapperX<BpmTaskExtDO> { | @@ -24,7 +24,7 @@ public interface BpmTaskExtMapper extends BaseMapperX<BpmTaskExtDO> { | ||
| 24 | default List<BpmTaskExtDO> selectProcessListByTaskIds(Collection<String> taskIds) { | 24 | default List<BpmTaskExtDO> selectProcessListByTaskIds(Collection<String> taskIds) { |
| 25 | return selectList(new LambdaQueryWrapperX<BpmTaskExtDO>() | 25 | return selectList(new LambdaQueryWrapperX<BpmTaskExtDO>() |
| 26 | .in(BpmTaskExtDO::getTaskId, taskIds) | 26 | .in(BpmTaskExtDO::getTaskId, taskIds) |
| 27 | - .in(BpmTaskExtDO::getResult, BpmProcessInstanceResultEnum.CAN_SUB_SIGN_STATUS)); | 27 | + .in(BpmTaskExtDO::getResult, BpmProcessInstanceResultEnum.CAN_SUB_SIGN_STATUS_LIST)); |
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | 30 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskService.java
| @@ -65,7 +65,8 @@ public interface BpmTaskService { | @@ -65,7 +65,8 @@ public interface BpmTaskService { | ||
| 65 | 65 | ||
| 66 | 66 | ||
| 67 | /** | 67 | /** |
| 68 | - * 通过任务 ID 集合,获取任务扩展表信息集合 // TODO @海洋:方法注释,和下面的参数,需要空一行 | 68 | + * 通过任务 ID 集合,获取任务扩展表信息集合 |
| 69 | + * | ||
| 69 | * @param taskIdList 任务 ID 集合 | 70 | * @param taskIdList 任务 ID 集合 |
| 70 | * @return 任务列表 | 71 | * @return 任务列表 |
| 71 | */ | 72 | */ |
| @@ -143,34 +144,34 @@ public interface BpmTaskService { | @@ -143,34 +144,34 @@ public interface BpmTaskService { | ||
| 143 | * 将任务回退到指定的 targetDefinitionKey 位置 | 144 | * 将任务回退到指定的 targetDefinitionKey 位置 |
| 144 | * | 145 | * |
| 145 | * @param userId 用户编号 | 146 | * @param userId 用户编号 |
| 146 | - * @param reqVO 回退的任务key和当前所在的任务ID | 147 | + * @param reqVO 回退的任务key和当前所在的任务ID |
| 147 | */ | 148 | */ |
| 148 | void returnTask(Long userId, BpmTaskReturnReqVO reqVO); | 149 | void returnTask(Long userId, BpmTaskReturnReqVO reqVO); |
| 149 | 150 | ||
| 150 | - // TODO @海:userId 放前面 | 151 | + |
| 151 | /** | 152 | /** |
| 152 | * 将指定任务委派给其他人处理,等接收人处理后再回到原审批人手中审批 | 153 | * 将指定任务委派给其他人处理,等接收人处理后再回到原审批人手中审批 |
| 153 | * | 154 | * |
| 154 | - * @param reqVO 被委派人和被委派的任务编号理由参数 | ||
| 155 | * @param userId 用户编号 | 155 | * @param userId 用户编号 |
| 156 | + * @param reqVO 被委派人和被委派的任务编号理由参数 | ||
| 156 | */ | 157 | */ |
| 157 | - void delegateTask(BpmTaskDelegateReqVO reqVO, Long userId); | 158 | + void delegateTask(Long userId, BpmTaskDelegateReqVO reqVO); |
| 158 | 159 | ||
| 159 | /** | 160 | /** |
| 160 | * 任务加签 | 161 | * 任务加签 |
| 161 | * | 162 | * |
| 162 | - * @param reqVO 被加签的用户和任务 ID,加签类型 | ||
| 163 | - * @param userId 当前用户 ID | 163 | + * @param userId 被加签的用户和任务 ID,加签类型 |
| 164 | + * @param reqVO 当前用户 ID | ||
| 164 | */ | 165 | */ |
| 165 | - void addSign(BpmTaskAddSignReqVO reqVO, Long userId); | 166 | + void addSignTask(Long userId, BpmTaskAddSignReqVO reqVO); |
| 166 | 167 | ||
| 167 | /** | 168 | /** |
| 168 | * 任务减签名 | 169 | * 任务减签名 |
| 169 | * | 170 | * |
| 170 | - * @param bpmTaskSubSignReqVO 被减签的任务 ID,理由 | ||
| 171 | - * @param loginUserId 当前用户ID | 171 | + * @param userId 当前用户ID |
| 172 | + * @param reqVO 被减签的任务 ID,理由 | ||
| 172 | */ | 173 | */ |
| 173 | - void subSign(BpmTaskSubSignReqVO bpmTaskSubSignReqVO, Long loginUserId); | 174 | + void subSignTask(Long userId, BpmTaskSubSignReqVO reqVO); |
| 174 | 175 | ||
| 175 | /** | 176 | /** |
| 176 | * 获取指定任务的子任务和审批人信息 | 177 | * 获取指定任务的子任务和审批人信息 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
| @@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.bpm.service.task; | @@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.bpm.service.task; | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.util.ArrayUtil; | 4 | import cn.hutool.core.util.ArrayUtil; |
| 5 | import cn.hutool.core.util.IdUtil; | 5 | import cn.hutool.core.util.IdUtil; |
| 6 | +import cn.hutool.core.util.ObjectUtil; | ||
| 6 | import cn.hutool.core.util.StrUtil; | 7 | import cn.hutool.core.util.StrUtil; |
| 7 | -import cn.iocoder.yudao.framework.common.enums.SymbolConstant; | ||
| 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 9 | import cn.iocoder.yudao.framework.common.util.date.DateUtils; | 9 | import cn.iocoder.yudao.framework.common.util.date.DateUtils; |
| 10 | import cn.iocoder.yudao.framework.common.util.number.NumberUtils; | 10 | import cn.iocoder.yudao.framework.common.util.number.NumberUtils; |
| @@ -15,7 +15,10 @@ import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; | @@ -15,7 +15,10 @@ import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*; | ||
| 15 | import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert; | 15 | import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert; |
| 16 | import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO; | 16 | import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO; |
| 17 | import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmTaskExtMapper; | 17 | import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmTaskExtMapper; |
| 18 | -import cn.iocoder.yudao.module.bpm.enums.task.*; | 18 | +import cn.iocoder.yudao.module.bpm.enums.task.BpmCommentTypeEnum; |
| 19 | +import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum; | ||
| 20 | +import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum; | ||
| 21 | +import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskAddSignTypeEnum; | ||
| 19 | import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService; | 22 | import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService; |
| 20 | import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService; | 23 | import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService; |
| 21 | import cn.iocoder.yudao.module.system.api.dept.DeptApi; | 24 | import cn.iocoder.yudao.module.system.api.dept.DeptApi; |
| @@ -222,8 +225,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -222,8 +225,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 222 | // 情况二:后加签的任务 | 225 | // 情况二:后加签的任务 |
| 223 | if (BpmTaskAddSignTypeEnum.AFTER.getType().equals(task.getScopeType())) { | 226 | if (BpmTaskAddSignTypeEnum.AFTER.getType().equals(task.getScopeType())) { |
| 224 | // 后加签处理 | 227 | // 后加签处理 |
| 225 | - // TODO @海洋:这个是不是 approveAfterSignTask | ||
| 226 | - handleAfterSignTask(task, reqVO); | 228 | + approveAfterSignTask(task, reqVO); |
| 227 | return; | 229 | return; |
| 228 | } | 230 | } |
| 229 | 231 | ||
| @@ -240,13 +242,13 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -240,13 +242,13 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 240 | 242 | ||
| 241 | /** | 243 | /** |
| 242 | * 审批通过存在“后加签”的任务。 | 244 | * 审批通过存在“后加签”的任务。 |
| 243 | - * | 245 | + * <p> |
| 244 | * 注意:该任务不能马上完成,需要一个中间状态(ADD_SIGN_AFTER),并激活剩余所有子任务(PROCESS)为可审批处理 | 246 | * 注意:该任务不能马上完成,需要一个中间状态(ADD_SIGN_AFTER),并激活剩余所有子任务(PROCESS)为可审批处理 |
| 245 | * | 247 | * |
| 246 | - * @param task 当前任务 | 248 | + * @param task 当前任务 |
| 247 | * @param reqVO 前端请求参数 | 249 | * @param reqVO 前端请求参数 |
| 248 | */ | 250 | */ |
| 249 | - private void handleAfterSignTask(Task task,BpmTaskApproveReqVO reqVO){ | 251 | + private void approveAfterSignTask(Task task, BpmTaskApproveReqVO reqVO) { |
| 250 | // 1. 有向后加签,则该任务状态临时设置为 ADD_SIGN_AFTER 状态 | 252 | // 1. 有向后加签,则该任务状态临时设置为 ADD_SIGN_AFTER 状态 |
| 251 | taskExtMapper.updateByTaskId( | 253 | taskExtMapper.updateByTaskId( |
| 252 | new BpmTaskExtDO().setTaskId(task.getId()).setResult(BpmProcessInstanceResultEnum.ADD_SIGN_AFTER.getResult()) | 254 | new BpmTaskExtDO().setTaskId(task.getId()).setResult(BpmProcessInstanceResultEnum.ADD_SIGN_AFTER.getResult()) |
| @@ -257,7 +259,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -257,7 +259,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 257 | for (String childrenTaskId : childrenTaskIdList) { | 259 | for (String childrenTaskId : childrenTaskIdList) { |
| 258 | taskService.resolveTask(childrenTaskId); | 260 | taskService.resolveTask(childrenTaskId); |
| 259 | } | 261 | } |
| 260 | - // 更新任务扩展表中子任务为进行中 | 262 | + // 2.1 更新任务扩展表中子任务为进行中 |
| 261 | taskExtMapper.updateBatchByTaskIdList(childrenTaskIdList, | 263 | taskExtMapper.updateBatchByTaskIdList(childrenTaskIdList, |
| 262 | new BpmTaskExtDO().setResult(BpmProcessInstanceResultEnum.PROCESS.getResult())); | 264 | new BpmTaskExtDO().setResult(BpmProcessInstanceResultEnum.PROCESS.getResult())); |
| 263 | } | 265 | } |
| @@ -269,106 +271,108 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -269,106 +271,108 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 269 | */ | 271 | */ |
| 270 | private void handleParentTask(Task task) { | 272 | private void handleParentTask(Task task) { |
| 271 | String parentTaskId = task.getParentTaskId(); | 273 | String parentTaskId = task.getParentTaskId(); |
| 272 | - // TODO @ 海:if return 原则 | 274 | + if (StrUtil.isBlank(parentTaskId)) { |
| 275 | + return; | ||
| 276 | + } | ||
| 273 | if (StrUtil.isNotBlank(parentTaskId)) { | 277 | if (StrUtil.isNotBlank(parentTaskId)) { |
| 274 | // 1. 判断当前任务的父任务是否还有子任务 | 278 | // 1. 判断当前任务的父任务是否还有子任务 |
| 275 | - long subTaskCount = getSubTaskCount(parentTaskId); | ||
| 276 | - // TODO @ 海:if >= 0 return;这样括号又可以少一层; | ||
| 277 | - if (subTaskCount == 0) { | ||
| 278 | - // 2. 获取父任务 | ||
| 279 | - Task parentTask = validateTaskExist(parentTaskId); | ||
| 280 | - | ||
| 281 | - // 3. 情况一:处理向前加签 | ||
| 282 | - String scopeType = parentTask.getScopeType(); | ||
| 283 | - if (BpmTaskAddSignTypeEnum.BEFORE.getType().equals(scopeType)) { | ||
| 284 | - // 3.1 如果是向前加签的任务,则调用 resolveTask 指派父任务,将 owner 重新赋值给父任务的 assignee | ||
| 285 | - taskService.resolveTask(parentTaskId); | ||
| 286 | - // 3.2 更新任务拓展表为处理中 | ||
| 287 | - taskExtMapper.updateByTaskId( | ||
| 288 | - new BpmTaskExtDO().setTaskId(parentTask.getId()).setResult(BpmProcessInstanceResultEnum.PROCESS.getResult())); | ||
| 289 | - } else if (BpmTaskAddSignTypeEnum.AFTER.getType().equals(scopeType)) { | ||
| 290 | - // 3. 情况二:处理向后加签 | ||
| 291 | - handleAfterSign(parentTask); | ||
| 292 | - } | 279 | + Long childrenTaskCount = getChildrenTaskCount(parentTaskId); |
| 280 | + if (childrenTaskCount > 0) { | ||
| 281 | + return; | ||
| 282 | + } | ||
| 283 | + // 2. 获取父任务 | ||
| 284 | + Task parentTask = validateTaskExist(parentTaskId); | ||
| 285 | + | ||
| 286 | + // 3. 情况一:处理向前加签 | ||
| 287 | + String scopeType = parentTask.getScopeType(); | ||
| 288 | + if (BpmTaskAddSignTypeEnum.BEFORE.getType().equals(scopeType)) { | ||
| 289 | + // 3.1 如果是向前加签的任务,则调用 resolveTask 指派父任务,将 owner 重新赋值给父任务的 assignee | ||
| 290 | + taskService.resolveTask(parentTaskId); | ||
| 291 | + // 3.2 更新任务拓展表为处理中 | ||
| 292 | + taskExtMapper.updateByTaskId( | ||
| 293 | + new BpmTaskExtDO().setTaskId(parentTask.getId()).setResult(BpmProcessInstanceResultEnum.PROCESS.getResult())); | ||
| 294 | + } else if (BpmTaskAddSignTypeEnum.AFTER.getType().equals(scopeType)) { | ||
| 295 | + // 3. 情况二:处理向后加签 | ||
| 296 | + handleAfterSign(parentTask); | ||
| 297 | + } | ||
| 293 | 298 | ||
| 294 | - // 4. 子任务已处理完成,清空 scopeType 字段,修改 parentTask 信息,方便后续可以继续向前后向后加签 | ||
| 295 | - // 再查询一次的原因是避免报错:Task was updated by another transaction concurrently | ||
| 296 | - // 因为前面处理后可能会导致 parentTask rev 字段被修改,需要重新获取最新的 | ||
| 297 | - parentTask = getTask(parentTaskId); | ||
| 298 | - // TODO @ 海:if return 原则; | ||
| 299 | - if (parentTask != null) { | ||
| 300 | - // 为空的情况是:已经通过 handleAfterSign 方法将任务完成了,所以 ru_task 表会查不到数据 | ||
| 301 | - clearTaskScopeTypeAndSave(parentTask); | ||
| 302 | - } | 299 | + // 4. 子任务已处理完成,清空 scopeType 字段,修改 parentTask 信息,方便后续可以继续向前后向后加签 |
| 300 | + // 再查询一次的原因是避免报错:Task was updated by another transaction concurrently | ||
| 301 | + // 因为前面处理后可能会导致 parentTask rev 字段被修改,需要重新获取最新的 | ||
| 302 | + parentTask = getTask(parentTaskId); | ||
| 303 | + if (parentTask == null) { | ||
| 304 | + // 为空的情况是:已经通过 handleAfterSign 方法将任务完成了,所以 ru_task 表会查不到数据 | ||
| 305 | + return; | ||
| 303 | } | 306 | } |
| 307 | + clearTaskScopeTypeAndSave(parentTask); | ||
| 304 | } | 308 | } |
| 305 | } | 309 | } |
| 306 | 310 | ||
| 307 | - // TODO @海:这个方法的 4.1 从 1 开始计数哈;另外;看看能不能用 if return 进一步简化代码的层级; | ||
| 308 | /** | 311 | /** |
| 309 | * 处理后加签任务 | 312 | * 处理后加签任务 |
| 310 | * | 313 | * |
| 311 | - * @param parentTask 当前审批任务的父任务 | 314 | + * @param parentTask 当前审批任务的父任务 |
| 312 | */ | 315 | */ |
| 313 | private void handleAfterSign(Task parentTask) { | 316 | private void handleAfterSign(Task parentTask) { |
| 314 | - // TODO @海:这个方法在注释下。感觉整体是,先完成自己;然后递归处理父节点;但是完成机子被放到了 5.1,就感觉上有点割裂; | ||
| 315 | String parentTaskId = parentTask.getId(); | 317 | String parentTaskId = parentTask.getId(); |
| 316 | - //4.1 更新 parentTask 的任务拓展表为通过 | 318 | + //1. 更新 parentTask 的任务拓展表为通过,并调用 complete 完成自己 |
| 317 | BpmTaskExtDO currentTaskExt = taskExtMapper.selectByTaskId(parentTask.getId()); | 319 | BpmTaskExtDO currentTaskExt = taskExtMapper.selectByTaskId(parentTask.getId()); |
| 318 | BpmTaskExtDO currentTaskUpdateEntity = new BpmTaskExtDO().setTaskId(parentTask.getId()) | 320 | BpmTaskExtDO currentTaskUpdateEntity = new BpmTaskExtDO().setTaskId(parentTask.getId()) |
| 319 | .setResult(BpmProcessInstanceResultEnum.APPROVE.getResult()); | 321 | .setResult(BpmProcessInstanceResultEnum.APPROVE.getResult()); |
| 320 | if (currentTaskExt.getEndTime() == null) { | 322 | if (currentTaskExt.getEndTime() == null) { |
| 321 | - // 有这个判断是因为 | ||
| 322 | - // 4.2 以前没设置过结束时间,才去设置 | 323 | + // 1.1 有这个判断是因为,以前没设置过结束时间,才去设置 |
| 323 | currentTaskUpdateEntity.setEndTime(LocalDateTime.now()); | 324 | currentTaskUpdateEntity.setEndTime(LocalDateTime.now()); |
| 324 | } | 325 | } |
| 326 | + // 1.2 完成自己 | ||
| 325 | taskExtMapper.updateByTaskId(currentTaskUpdateEntity); | 327 | taskExtMapper.updateByTaskId(currentTaskUpdateEntity); |
| 326 | - | ||
| 327 | - // 5. 继续往上处理,父任务继续往上查询 | ||
| 328 | - // 5.1 先完成自己 | ||
| 329 | taskService.complete(parentTaskId); | 328 | taskService.complete(parentTaskId); |
| 330 | - // 5.2 如果有父级,递归查询上级任务是否都已经完成 | 329 | + |
| 330 | + // 2. 如果有父级,递归查询上级任务是否都已经完成 | ||
| 331 | + if (StrUtil.isEmpty(parentTask.getParentTaskId())) { | ||
| 332 | + return; | ||
| 333 | + } | ||
| 331 | // TODO @海:这块待讨论,脑子略乱;感觉 handleAfterSign 的后半段,和 handleParentTask 有点重叠??? | 334 | // TODO @海:这块待讨论,脑子略乱;感觉 handleAfterSign 的后半段,和 handleParentTask 有点重叠??? |
| 332 | - if (StrUtil.isNotEmpty(parentTask.getParentTaskId())) { | ||
| 333 | - // 判断整条链路的任务是否完成 | ||
| 334 | - // 例如从 A 任务加签了一个 B 任务,B 任务又加签了一个 C 任务,C 任务加签了 D 任务 | ||
| 335 | - // 此时,D 任务完成,要一直往上找到祖先任务 A调用 complete 方法完成 A 任务 | ||
| 336 | - boolean allChildrenTaskFinish = true; | ||
| 337 | - while (StrUtil.isNotBlank(parentTask.getParentTaskId())) { | ||
| 338 | - parentTask = validateTaskExist(parentTask.getParentTaskId()); | ||
| 339 | - BpmTaskExtDO bpmTaskExtDO = taskExtMapper.selectByTaskId(parentTask.getId()); | ||
| 340 | - if (bpmTaskExtDO == null) { | ||
| 341 | - break; | ||
| 342 | - } | ||
| 343 | - boolean currentTaskFinish = BpmProcessInstanceResultEnum.isEndResult(bpmTaskExtDO.getResult()); | ||
| 344 | - // 5.3 如果 allChildrenTaskFinish 已经被赋值为 false ,则不会再赋值为 true,因为整个链路没有完成 | ||
| 345 | - if (allChildrenTaskFinish) { | ||
| 346 | - allChildrenTaskFinish = currentTaskFinish; | ||
| 347 | - } | ||
| 348 | - if (!currentTaskFinish) { | ||
| 349 | - // 6 处理非完成状态的任务 | ||
| 350 | - // 6.1 判断当前任务的父任务是否还有子任务 | ||
| 351 | - Long subTaskCount = getSubTaskCount(bpmTaskExtDO.getTaskId()); | ||
| 352 | - if (subTaskCount == 0) { | ||
| 353 | - // 6.2 没有子任务,判断当前任务状态是否为 ADD_SIGN_BEFORE 待前加签任务完成 | ||
| 354 | - if (BpmProcessInstanceResultEnum.ADD_SIGN_BEFORE.getResult().equals(bpmTaskExtDO.getResult())) { | ||
| 355 | - // 6.3 需要修改该任务状态为处理中 | ||
| 356 | - taskService.resolveTask(bpmTaskExtDO.getTaskId()); | ||
| 357 | - bpmTaskExtDO.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()); | ||
| 358 | - taskExtMapper.updateByTaskId(bpmTaskExtDO); | ||
| 359 | - } | ||
| 360 | - // 6.4 清空 scopeType 字段,用于任务没有子任务时使用该方法,方便任务可以再次被不同的方式加签 | ||
| 361 | - parentTask = getTask(bpmTaskExtDO.getTaskId()); | ||
| 362 | - if (parentTask != null) { | ||
| 363 | - clearTaskScopeTypeAndSave(parentTask); | ||
| 364 | - } | ||
| 365 | - } | ||
| 366 | - } | 335 | + // 2.1 判断整条链路的任务是否完成 |
| 336 | + // 例如从 A 任务加签了一个 B 任务,B 任务又加签了一个 C 任务,C 任务加签了 D 任务 | ||
| 337 | + // 此时,D 任务完成,要一直往上找到祖先任务 A调用 complete 方法完成 A 任务 | ||
| 338 | + boolean allChildrenTaskFinish = true; | ||
| 339 | + while (StrUtil.isNotBlank(parentTask.getParentTaskId())) { | ||
| 340 | + parentTask = validateTaskExist(parentTask.getParentTaskId()); | ||
| 341 | + BpmTaskExtDO bpmTaskExtDO = taskExtMapper.selectByTaskId(parentTask.getId()); | ||
| 342 | + if (bpmTaskExtDO == null) { | ||
| 343 | + break; | ||
| 367 | } | 344 | } |
| 345 | + boolean currentTaskFinish = BpmProcessInstanceResultEnum.isEndResult(bpmTaskExtDO.getResult()); | ||
| 346 | + // 2.2 如果 allChildrenTaskFinish 已经被赋值为 false ,则不会再赋值为 true,因为整个链路没有完成 | ||
| 368 | if (allChildrenTaskFinish) { | 347 | if (allChildrenTaskFinish) { |
| 369 | - // 7. 完成最后的顶级祖先任务 | ||
| 370 | - taskService.complete(parentTask.getId()); | 348 | + allChildrenTaskFinish = currentTaskFinish; |
| 371 | } | 349 | } |
| 350 | + // 2.3 任务已完成则不处理 | ||
| 351 | + if (currentTaskFinish) { | ||
| 352 | + continue; | ||
| 353 | + } | ||
| 354 | + | ||
| 355 | + // 3 处理非完成状态的任务 | ||
| 356 | + // 3.1 判断当前任务的父任务是否还有子任务 | ||
| 357 | + Long childrenTaskCount = getChildrenTaskCount(bpmTaskExtDO.getTaskId()); | ||
| 358 | + if (childrenTaskCount > 0) { | ||
| 359 | + continue; | ||
| 360 | + } | ||
| 361 | + // 3.2 没有子任务,判断当前任务状态是否为 ADD_SIGN_BEFORE 待前加签任务完成 | ||
| 362 | + if (BpmProcessInstanceResultEnum.ADD_SIGN_BEFORE.getResult().equals(bpmTaskExtDO.getResult())) { | ||
| 363 | + // 3.3 需要修改该任务状态为处理中 | ||
| 364 | + taskService.resolveTask(bpmTaskExtDO.getTaskId()); | ||
| 365 | + bpmTaskExtDO.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()); | ||
| 366 | + taskExtMapper.updateByTaskId(bpmTaskExtDO); | ||
| 367 | + } | ||
| 368 | + // 3.4 清空 scopeType 字段,用于任务没有子任务时使用该方法,方便任务可以再次被不同的方式加签 | ||
| 369 | + parentTask = validateTaskExist(bpmTaskExtDO.getTaskId()); | ||
| 370 | + clearTaskScopeTypeAndSave(parentTask); | ||
| 371 | + } | ||
| 372 | + | ||
| 373 | + // 4. 完成最后的顶级祖先任务 | ||
| 374 | + if (allChildrenTaskFinish) { | ||
| 375 | + taskService.complete(parentTask.getId()); | ||
| 372 | } | 376 | } |
| 373 | } | 377 | } |
| 374 | 378 | ||
| @@ -383,14 +387,14 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -383,14 +387,14 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 383 | taskService.saveTask(task); | 387 | taskService.saveTask(task); |
| 384 | } | 388 | } |
| 385 | 389 | ||
| 386 | - // TODO @海:Sub 还有 Child 感觉整体用词不是很统一;是不是要统一下;然后 Sub 还可以指的减签;看看是不是名词确实得一致哈; | 390 | + |
| 387 | /** | 391 | /** |
| 388 | * 获取子任务个数 | 392 | * 获取子任务个数 |
| 389 | * | 393 | * |
| 390 | * @param parentTaskId 父任务 ID | 394 | * @param parentTaskId 父任务 ID |
| 391 | * @return 剩余子任务个数 | 395 | * @return 剩余子任务个数 |
| 392 | */ | 396 | */ |
| 393 | - private Long getSubTaskCount(String parentTaskId) { | 397 | + private Long getChildrenTaskCount(String parentTaskId) { |
| 394 | String tableName = managementService.getTableName(TaskEntity.class); | 398 | String tableName = managementService.getTableName(TaskEntity.class); |
| 395 | String sql = "SELECT COUNT(1) from " + tableName + " WHERE PARENT_TASK_ID_=#{parentTaskId}"; | 399 | String sql = "SELECT COUNT(1) from " + tableName + " WHERE PARENT_TASK_ID_=#{parentTaskId}"; |
| 396 | return taskService.createNativeTaskQuery().sql(sql).parameter("parentTaskId", parentTaskId).count(); | 400 | return taskService.createNativeTaskQuery().sql(sql).parameter("parentTaskId", parentTaskId).count(); |
| @@ -410,7 +414,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -410,7 +414,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 410 | String comment = StrUtil.format("[{}]完成委派任务,任务重新回到[{}]手中,审批意见为:{}", currentUser.getNickname(), | 414 | String comment = StrUtil.format("[{}]完成委派任务,任务重新回到[{}]手中,审批意见为:{}", currentUser.getNickname(), |
| 411 | sourceApproveUser.getNickname(), reqVO.getReason()); | 415 | sourceApproveUser.getNickname(), reqVO.getReason()); |
| 412 | taskService.addComment(reqVO.getId(), task.getProcessInstanceId(), | 416 | taskService.addComment(reqVO.getId(), task.getProcessInstanceId(), |
| 413 | - BpmCommentTypeEnum.DELEGATE.getResult().toString(), comment); | 417 | + BpmCommentTypeEnum.DELEGATE.getType().toString(), comment); |
| 414 | 418 | ||
| 415 | // 2.1 调用 resolveTask 完成任务。 | 419 | // 2.1 调用 resolveTask 完成任务。 |
| 416 | // 底层调用 TaskHelper.changeTaskAssignee(task, task.getOwner()):将 owner 设置为 assignee | 420 | // 底层调用 TaskHelper.changeTaskAssignee(task, task.getOwner()):将 owner 设置为 assignee |
| @@ -528,7 +532,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -528,7 +532,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 528 | TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { | 532 | TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() { |
| 529 | @Override | 533 | @Override |
| 530 | public void afterCommit() { | 534 | public void afterCommit() { |
| 531 | - if(StrUtil.isNotEmpty(task.getAssignee())){ | 535 | + if (StrUtil.isNotEmpty(task.getAssignee())) { |
| 532 | ProcessInstance processInstance = | 536 | ProcessInstance processInstance = |
| 533 | processInstanceService.getProcessInstance(task.getProcessInstanceId()); | 537 | processInstanceService.getProcessInstance(task.getProcessInstanceId()); |
| 534 | AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())); | 538 | AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId())); |
| @@ -539,8 +543,8 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -539,8 +543,8 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 539 | }); | 543 | }); |
| 540 | } | 544 | } |
| 541 | 545 | ||
| 542 | - private Task validateTaskExist(String id){ | ||
| 543 | - Task task = taskService.createTaskQuery().taskId(id).singleResult(); | 546 | + private Task validateTaskExist(String id) { |
| 547 | + Task task = getTask(id); | ||
| 544 | if (task == null) { | 548 | if (task == null) { |
| 545 | throw exception(TASK_NOT_EXISTS); | 549 | throw exception(TASK_NOT_EXISTS); |
| 546 | } | 550 | } |
| @@ -646,7 +650,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -646,7 +650,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 646 | return; | 650 | return; |
| 647 | } | 651 | } |
| 648 | taskService.addComment(task.getId(), currentTask.getProcessInstanceId(), | 652 | taskService.addComment(task.getId(), currentTask.getProcessInstanceId(), |
| 649 | - BpmCommentTypeEnum.BACK.getResult().toString(), reqVO.getReason()); | 653 | + BpmCommentTypeEnum.BACK.getType().toString(), reqVO.getReason()); |
| 650 | }); | 654 | }); |
| 651 | 655 | ||
| 652 | // 3. 执行驳回 | 656 | // 3. 执行驳回 |
| @@ -659,7 +663,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -659,7 +663,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 659 | 663 | ||
| 660 | @Override | 664 | @Override |
| 661 | @Transactional(rollbackFor = Exception.class) | 665 | @Transactional(rollbackFor = Exception.class) |
| 662 | - public void delegateTask(BpmTaskDelegateReqVO reqVO, Long userId) { | 666 | + public void delegateTask(Long userId, BpmTaskDelegateReqVO reqVO) { |
| 663 | // 1.1 校验任务 | 667 | // 1.1 校验任务 |
| 664 | Task task = validateTaskCanDelegate(userId, reqVO); | 668 | Task task = validateTaskCanDelegate(userId, reqVO); |
| 665 | // 1.2 校验目标用户存在 | 669 | // 1.2 校验目标用户存在 |
| @@ -674,7 +678,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -674,7 +678,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 674 | delegateUser.getNickname(), reqVO.getReason()); | 678 | delegateUser.getNickname(), reqVO.getReason()); |
| 675 | String taskId = reqVO.getId(); | 679 | String taskId = reqVO.getId(); |
| 676 | taskService.addComment(taskId, task.getProcessInstanceId(), | 680 | taskService.addComment(taskId, task.getProcessInstanceId(), |
| 677 | - BpmCommentTypeEnum.DELEGATE.getResult().toString(), comment); | 681 | + BpmCommentTypeEnum.DELEGATE.getType().toString(), comment); |
| 678 | 682 | ||
| 679 | // 3.1 设置任务所有人 (owner) 为原任务的处理人 (assignee) | 683 | // 3.1 设置任务所有人 (owner) 为原任务的处理人 (assignee) |
| 680 | taskService.setOwner(taskId, task.getAssignee()); | 684 | taskService.setOwner(taskId, task.getAssignee()); |
| @@ -705,23 +709,18 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -705,23 +709,18 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 705 | 709 | ||
| 706 | @Override | 710 | @Override |
| 707 | @Transactional(rollbackFor = Exception.class) | 711 | @Transactional(rollbackFor = Exception.class) |
| 708 | - public void addSign(BpmTaskAddSignReqVO reqVO, Long userId) { | ||
| 709 | - // TODO @海:// 后面要有个空格;中英文之间,也要有空格;例如说:// 1. 获取和校验任务 | ||
| 710 | - //1.获取和校验任务 | 712 | + public void addSignTask(Long userId, BpmTaskAddSignReqVO reqVO) { |
| 713 | + // 1. 获取和校验任务 | ||
| 711 | TaskEntityImpl taskEntity = validateAddSign(userId, reqVO); | 714 | TaskEntityImpl taskEntity = validateAddSign(userId, reqVO); |
| 712 | - // TODO @海:每个变量,以及相关逻辑,一定要和自己的逻辑块呆在一起。例如说这里的 currentUser 获取,应该在 4. 那块 | ||
| 713 | - AdminUserRespDTO currentUser = adminUserApi.getUser(userId); | ||
| 714 | List<AdminUserRespDTO> userList = adminUserApi.getUserList(reqVO.getUserIdList()); | 715 | List<AdminUserRespDTO> userList = adminUserApi.getUserList(reqVO.getUserIdList()); |
| 715 | if (CollUtil.isEmpty(userList)) { | 716 | if (CollUtil.isEmpty(userList)) { |
| 716 | throw exception(TASK_ADD_SIGN_USER_NOT_EXIST); | 717 | throw exception(TASK_ADD_SIGN_USER_NOT_EXIST); |
| 717 | } | 718 | } |
| 718 | - // TODO @海:大的逻辑块之间,最好有一个空格。这样的目的,是避免逻辑堆砌在一起,方便流量; | ||
| 719 | - // 2.处理当前任务 | ||
| 720 | - // 2.1 开启计数功能 // TODO @海:这个目的可以写下; | 719 | + |
| 720 | + // 2. 处理当前任务 | ||
| 721 | + // 2.1 开启计数功能,主要用于为了让表 ACT_RU_TASK 中的 SUB_TASK_COUNT_ 字段记录下总共有多少子任务,后续可能有用 | ||
| 721 | taskEntity.setCountEnabled(true); | 722 | taskEntity.setCountEnabled(true); |
| 722 | - // TODO @海:可以直接 if,不搞一个变量哈 | ||
| 723 | - boolean addSignToBefore = reqVO.getType().equals(BpmTaskAddSignTypeEnum.BEFORE.getType()); | ||
| 724 | - if (addSignToBefore) { | 723 | + if (reqVO.getType().equals(BpmTaskAddSignTypeEnum.BEFORE.getType())) { |
| 725 | // 2.2 向前加签,设置 owner,置空 assign。等子任务都完成后,再调用 resolveTask 重新将 owner 设置为 assign | 724 | // 2.2 向前加签,设置 owner,置空 assign。等子任务都完成后,再调用 resolveTask 重新将 owner 设置为 assign |
| 726 | // 原因是:不能和向前加签的子任务一起审批,需要等前面的子任务都完成才能审批 | 725 | // 原因是:不能和向前加签的子任务一起审批,需要等前面的子任务都完成才能审批 |
| 727 | taskEntity.setOwner(taskEntity.getAssignee()); | 726 | taskEntity.setOwner(taskEntity.getAssignee()); |
| @@ -738,20 +737,20 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -738,20 +737,20 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 738 | taskService.saveTask(taskEntity); | 737 | taskService.saveTask(taskEntity); |
| 739 | 738 | ||
| 740 | // 3. 创建加签任务 | 739 | // 3. 创建加签任务 |
| 741 | - createSignSubTasks(convertList(reqVO.getUserIdList(), String::valueOf), taskEntity); | 740 | + createAddSignChildrenTasks(convertList(reqVO.getUserIdList(), String::valueOf), taskEntity); |
| 742 | 741 | ||
| 743 | // 4. 记录加签 comment,拼接结果为: [当前用户]向前加签/向后加签给了[多个用户],理由为:reason | 742 | // 4. 记录加签 comment,拼接结果为: [当前用户]向前加签/向后加签给了[多个用户],理由为:reason |
| 744 | - // TODO @海:BpmCommentTypeEnum 可以加一个 comment 字段,作为评论模版,统一管理; | ||
| 745 | - String comment = StrUtil.format("[{}]{}给了[{}],理由为:{}", currentUser.getNickname(), BpmTaskAddSignTypeEnum.formatDesc(reqVO.getType()), | ||
| 746 | - String.join(SymbolConstant.D, convertList(userList, AdminUserRespDTO::getNickname)), reqVO.getReason()); | 743 | + AdminUserRespDTO currentUser = adminUserApi.getUser(userId); |
| 744 | + String comment = StrUtil.format(BpmCommentTypeEnum.ADD_SIGN.getTemplateComment(), currentUser.getNickname(), BpmTaskAddSignTypeEnum.formatDesc(reqVO.getType()), | ||
| 745 | + String.join(",", convertList(userList, AdminUserRespDTO::getNickname)), reqVO.getReason()); | ||
| 747 | taskService.addComment(reqVO.getId(), taskEntity.getProcessInstanceId(), | 746 | taskService.addComment(reqVO.getId(), taskEntity.getProcessInstanceId(), |
| 748 | - BpmCommentTypeEnum.ADD_SIGN.getResult().toString(), comment); | 747 | + BpmCommentTypeEnum.ADD_SIGN.getType().toString(), comment); |
| 749 | } | 748 | } |
| 750 | 749 | ||
| 751 | 750 | ||
| 752 | /** | 751 | /** |
| 753 | * 校验任务的加签是否一致 | 752 | * 校验任务的加签是否一致 |
| 754 | - * | 753 | + * <p> |
| 755 | * 1. 如果存在“向前加签”的任务,则不能“向后加签” | 754 | * 1. 如果存在“向前加签”的任务,则不能“向后加签” |
| 756 | * 2. 如果存在“向后加签”的任务,则不能“向前加签” | 755 | * 2. 如果存在“向后加签”的任务,则不能“向前加签” |
| 757 | * | 756 | * |
| @@ -763,25 +762,20 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -763,25 +762,20 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 763 | TaskEntityImpl taskEntity = (TaskEntityImpl) validateTask(userId, reqVO.getId()); | 762 | TaskEntityImpl taskEntity = (TaskEntityImpl) validateTask(userId, reqVO.getId()); |
| 764 | // 向前加签和向后加签不能同时存在 | 763 | // 向前加签和向后加签不能同时存在 |
| 765 | if (StrUtil.isNotBlank(taskEntity.getScopeType()) | 764 | if (StrUtil.isNotBlank(taskEntity.getScopeType()) |
| 766 | - && !BpmTaskAddSignTypeEnum.AFTER_CHILDREN_TASK.getDesc().equals(taskEntity.getScopeType())) { | ||
| 767 | - // TODO @海:下面这个判断,是不是可以写上面这个判断后面? | ||
| 768 | - // TODO @海:一个小技巧,如果写不等于的时候,一般可以用 ObjectUtil.notEquals,这样少一层取反,理解起来简单点; | ||
| 769 | - if (!taskEntity.getScopeType().equals(reqVO.getType())) { | ||
| 770 | - throw exception(TASK_ADD_SIGN_TYPE_ERROR, | ||
| 771 | - BpmTaskAddSignTypeEnum.formatDesc(taskEntity.getScopeType()), BpmTaskAddSignTypeEnum.formatDesc(reqVO.getType())); | ||
| 772 | - } | 765 | + && ObjectUtil.notEqual(BpmTaskAddSignTypeEnum.AFTER_CHILDREN_TASK.getType(), taskEntity.getScopeType()) |
| 766 | + && ObjectUtil.notEqual(taskEntity.getScopeType(), reqVO.getType())) { | ||
| 767 | + throw exception(TASK_ADD_SIGN_TYPE_ERROR, | ||
| 768 | + BpmTaskAddSignTypeEnum.formatDesc(taskEntity.getScopeType()), BpmTaskAddSignTypeEnum.formatDesc(reqVO.getType())); | ||
| 773 | } | 769 | } |
| 774 | // 同一个 key 的任务,审批人不重复 | 770 | // 同一个 key 的任务,审批人不重复 |
| 775 | List<Task> taskList = taskService.createTaskQuery().processInstanceId(taskEntity.getProcessInstanceId()) | 771 | List<Task> taskList = taskService.createTaskQuery().processInstanceId(taskEntity.getProcessInstanceId()) |
| 776 | .taskDefinitionKey(taskEntity.getTaskDefinitionKey()).list(); | 772 | .taskDefinitionKey(taskEntity.getTaskDefinitionKey()).list(); |
| 777 | - // TODO @海:这里是不是 Task::getAssignee 解析成 List<Long> 下面会更简洁一点? | ||
| 778 | - List<String> currentAssigneeList = convertList(taskList, Task::getAssignee); | ||
| 779 | - // TODO @海:frontAssigneeList 改成 addAssigneeList,新增的;避免和 front 前端这样界面耦合的名词哈; | ||
| 780 | - List<String> frontAssigneeList = convertList(reqVO.getUserIdList(), String::valueOf); | ||
| 781 | - currentAssigneeList.retainAll(frontAssigneeList); | 773 | + List<Long> currentAssigneeList = convertList(taskList, task -> NumberUtils.parseLong(task.getAssignee())); |
| 774 | + // 保留交集在 currentAssigneeList 中 | ||
| 775 | + currentAssigneeList.retainAll(reqVO.getUserIdList()); | ||
| 782 | if (CollUtil.isNotEmpty(currentAssigneeList)) { | 776 | if (CollUtil.isNotEmpty(currentAssigneeList)) { |
| 783 | - List<AdminUserRespDTO> userList = adminUserApi.getUserList(convertList(currentAssigneeList, NumberUtils::parseLong)); | ||
| 784 | - throw exception(TASK_ADD_SIGN_USER_REPEAT, String.join(SymbolConstant.D, convertList(userList, AdminUserRespDTO::getNickname))); | 777 | + List<AdminUserRespDTO> userList = adminUserApi.getUserList(currentAssigneeList); |
| 778 | + throw exception(TASK_ADD_SIGN_USER_REPEAT, String.join(",", convertList(userList, AdminUserRespDTO::getNickname))); | ||
| 785 | } | 779 | } |
| 786 | return taskEntity; | 780 | return taskEntity; |
| 787 | } | 781 | } |
| @@ -792,19 +786,19 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -792,19 +786,19 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 792 | * @param addSingUserIdList 被加签的用户 ID | 786 | * @param addSingUserIdList 被加签的用户 ID |
| 793 | * @param taskEntity 被加签的任务 | 787 | * @param taskEntity 被加签的任务 |
| 794 | */ | 788 | */ |
| 795 | - private void createSignSubTasks(List<String> addSingUserIdList, TaskEntityImpl taskEntity) { | ||
| 796 | - // TODO @海:可以 if return;这样括号层级少一点;下面的 if (StrUtil.isNotBlank(addSignId)) { 也是类似; | ||
| 797 | - if (CollUtil.isNotEmpty(addSingUserIdList)) { | ||
| 798 | - // 创建加签人的新任务,全部基于 taskEntity 为父任务来创建 | ||
| 799 | - addSingUserIdList.forEach(addSignId -> { | ||
| 800 | - if (StrUtil.isNotBlank(addSignId)) { | ||
| 801 | - createSubTask(taskEntity, addSignId); | ||
| 802 | - } | ||
| 803 | - }); | 789 | + private void createAddSignChildrenTasks(List<String> addSingUserIdList, TaskEntityImpl taskEntity) { |
| 790 | + if (CollUtil.isEmpty(addSingUserIdList)) { | ||
| 791 | + return; | ||
| 792 | + } | ||
| 793 | + // 创建加签人的新任务,全部基于 taskEntity 为父任务来创建 | ||
| 794 | + for (String addSignId : addSingUserIdList) { | ||
| 795 | + if (StrUtil.isBlank(addSignId)) { | ||
| 796 | + continue; | ||
| 797 | + } | ||
| 798 | + createChildrenTask(taskEntity, addSignId); | ||
| 804 | } | 799 | } |
| 805 | } | 800 | } |
| 806 | 801 | ||
| 807 | - // TODO @海:这个是不是命名上,要和 createSignSubTasks 保持一致? | ||
| 808 | /** | 802 | /** |
| 809 | * 创建子任务 | 803 | * 创建子任务 |
| 810 | * | 804 | * |
| @@ -812,10 +806,10 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -812,10 +806,10 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 812 | * @param assignee 子任务的执行人 | 806 | * @param assignee 子任务的执行人 |
| 813 | * @return | 807 | * @return |
| 814 | */ | 808 | */ |
| 815 | - private void createSubTask(TaskEntityImpl parentTask, String assignee) { | 809 | + private void createChildrenTask(TaskEntityImpl parentTask, String assignee) { |
| 816 | // 1. 生成子任务 | 810 | // 1. 生成子任务 |
| 817 | TaskEntityImpl task = (TaskEntityImpl) taskService.newTask(IdUtil.fastSimpleUUID()); | 811 | TaskEntityImpl task = (TaskEntityImpl) taskService.newTask(IdUtil.fastSimpleUUID()); |
| 818 | - task = BpmTaskConvert.INSTANCE.convert(task,parentTask); | 812 | + task = BpmTaskConvert.INSTANCE.convert(task, parentTask); |
| 819 | if (BpmTaskAddSignTypeEnum.BEFORE.getType().equals(parentTask.getScopeType())) { | 813 | if (BpmTaskAddSignTypeEnum.BEFORE.getType().equals(parentTask.getScopeType())) { |
| 820 | // 2.1 前加签,才设置审批人,否则设置 owner | 814 | // 2.1 前加签,才设置审批人,否则设置 owner |
| 821 | task.setAssignee(assignee); | 815 | task.setAssignee(assignee); |
| @@ -831,28 +825,28 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -831,28 +825,28 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 831 | 825 | ||
| 832 | @Override | 826 | @Override |
| 833 | @Transactional(rollbackFor = Exception.class) | 827 | @Transactional(rollbackFor = Exception.class) |
| 834 | - public void subSign(BpmTaskSubSignReqVO reqVO,Long userId) { | 828 | + public void subSignTask(Long userId, BpmTaskSubSignReqVO reqVO) { |
| 835 | Task task = validateSubSign(reqVO.getId()); | 829 | Task task = validateSubSign(reqVO.getId()); |
| 836 | AdminUserRespDTO user = adminUserApi.getUser(userId); | 830 | AdminUserRespDTO user = adminUserApi.getUser(userId); |
| 837 | AdminUserRespDTO cancelUser = null; | 831 | AdminUserRespDTO cancelUser = null; |
| 838 | - if(StrUtil.isNotBlank(task.getAssignee())){ | 832 | + if (StrUtil.isNotBlank(task.getAssignee())) { |
| 839 | cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getAssignee())); | 833 | cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getAssignee())); |
| 840 | } | 834 | } |
| 841 | - if(cancelUser == null && StrUtil.isNotBlank(task.getOwner())){ | 835 | + if (cancelUser == null && StrUtil.isNotBlank(task.getOwner())) { |
| 842 | cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())); | 836 | cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner())); |
| 843 | } | 837 | } |
| 844 | - Assert.notNull(cancelUser,"任务中没有所有者和审批人,数据错误"); | 838 | + Assert.notNull(cancelUser, "任务中没有所有者和审批人,数据错误"); |
| 845 | //1. 获取所有需要删除的任务 ID ,包含当前任务和所有子任务 | 839 | //1. 获取所有需要删除的任务 ID ,包含当前任务和所有子任务 |
| 846 | List<String> allTaskIdList = getAllChildTaskIds(task.getId()); | 840 | List<String> allTaskIdList = getAllChildTaskIds(task.getId()); |
| 847 | //2. 删除任务和所有子任务 | 841 | //2. 删除任务和所有子任务 |
| 848 | taskService.deleteTasks(allTaskIdList); | 842 | taskService.deleteTasks(allTaskIdList); |
| 849 | //3. 修改扩展表状态为取消 | 843 | //3. 修改扩展表状态为取消 |
| 850 | - taskExtMapper.updateBatchByTaskIdList(allTaskIdList,new BpmTaskExtDO().setResult(BpmProcessInstanceResultEnum.CANCEL.getResult()) | ||
| 851 | - .setReason(StrUtil.format("由于{}操作[减签],任务被取消",user.getNickname()))); | 844 | + taskExtMapper.updateBatchByTaskIdList(allTaskIdList, new BpmTaskExtDO().setResult(BpmProcessInstanceResultEnum.CANCEL.getResult()) |
| 845 | + .setReason(StrUtil.format("由于{}操作[减签],任务被取消", user.getNickname()))); | ||
| 852 | //4.记录日志到父任务中 先记录日志是因为,通过 handleParentTask 方法之后,任务可能被完成了,并且不存在了,会报异常,所以先记录 | 846 | //4.记录日志到父任务中 先记录日志是因为,通过 handleParentTask 方法之后,任务可能被完成了,并且不存在了,会报异常,所以先记录 |
| 853 | - String comment = StrUtil.format("{}操作了【减签】,审批人{}的任务被取消",user.getNickname(),cancelUser.getNickname()); | ||
| 854 | - taskService.addComment(task.getParentTaskId(),task.getProcessInstanceId(), | ||
| 855 | - BpmCommentTypeEnum.SUB_SIGN.getResult().toString(),comment); | 847 | + String comment = StrUtil.format(BpmCommentTypeEnum.SUB_SIGN.getTemplateComment(), user.getNickname(), cancelUser.getNickname()); |
| 848 | + taskService.addComment(task.getParentTaskId(), task.getProcessInstanceId(), | ||
| 849 | + BpmCommentTypeEnum.SUB_SIGN.getType().toString(), comment); | ||
| 856 | //5. 处理当前任务的父任务 | 850 | //5. 处理当前任务的父任务 |
| 857 | this.handleParentTask(task); | 851 | this.handleParentTask(task); |
| 858 | 852 | ||
| @@ -860,13 +854,14 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -860,13 +854,14 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 860 | 854 | ||
| 861 | /** | 855 | /** |
| 862 | * 校验任务是否能被减签 | 856 | * 校验任务是否能被减签 |
| 857 | + * | ||
| 863 | * @param id 任务ID | 858 | * @param id 任务ID |
| 864 | * @return 任务信息 | 859 | * @return 任务信息 |
| 865 | */ | 860 | */ |
| 866 | private Task validateSubSign(String id) { | 861 | private Task validateSubSign(String id) { |
| 867 | Task task = validateTaskExist(id); | 862 | Task task = validateTaskExist(id); |
| 868 | //必须有parentId | 863 | //必须有parentId |
| 869 | - if(StrUtil.isEmpty(task.getParentTaskId())){ | 864 | + if (StrUtil.isEmpty(task.getParentTaskId())) { |
| 870 | throw exception(TASK_SUB_SIGN_NO_PARENT); | 865 | throw exception(TASK_SUB_SIGN_NO_PARENT); |
| 871 | } | 866 | } |
| 872 | return task; | 867 | return task; |
| @@ -874,6 +869,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -874,6 +869,7 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 874 | 869 | ||
| 875 | /** | 870 | /** |
| 876 | * 获取所有要被取消的删除的任务 ID 集合 | 871 | * 获取所有要被取消的删除的任务 ID 集合 |
| 872 | + * | ||
| 877 | * @param parentTaskId 父级任务ID | 873 | * @param parentTaskId 父级任务ID |
| 878 | * @return 所有任务ID | 874 | * @return 所有任务ID |
| 879 | */ | 875 | */ |
| @@ -888,7 +884,8 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -888,7 +884,8 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 888 | 884 | ||
| 889 | /** | 885 | /** |
| 890 | * 递归处理子级任务 | 886 | * 递归处理子级任务 |
| 891 | - * @param taskId 当前任务ID | 887 | + * |
| 888 | + * @param taskId 当前任务ID | ||
| 892 | * @param taskIds 结果 | 889 | * @param taskIds 结果 |
| 893 | */ | 890 | */ |
| 894 | private void recursiveGetChildTaskIds(String taskId, List<String> taskIds) { | 891 | private void recursiveGetChildTaskIds(String taskId, List<String> taskIds) { |
| @@ -901,10 +898,11 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -901,10 +898,11 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 901 | 898 | ||
| 902 | /** | 899 | /** |
| 903 | * 获取指定父级任务的所有子任务 ID 集合 | 900 | * 获取指定父级任务的所有子任务 ID 集合 |
| 901 | + * | ||
| 904 | * @param parentTaskId 父任务 ID | 902 | * @param parentTaskId 父任务 ID |
| 905 | * @return 所有子任务的 ID 集合 | 903 | * @return 所有子任务的 ID 集合 |
| 906 | */ | 904 | */ |
| 907 | - private List<String> getChildrenTaskIdList(String parentTaskId){ | 905 | + private List<String> getChildrenTaskIdList(String parentTaskId) { |
| 908 | String tableName = managementService.getTableName(TaskEntity.class); | 906 | String tableName = managementService.getTableName(TaskEntity.class); |
| 909 | String sql = "select ID_ from " + tableName + " where PARENT_TASK_ID_=#{parentTaskId}"; | 907 | String sql = "select ID_ from " + tableName + " where PARENT_TASK_ID_=#{parentTaskId}"; |
| 910 | List<Task> childrenTaskList = taskService.createNativeTaskQuery().sql(sql).parameter("parentTaskId", parentTaskId).list(); | 908 | List<Task> childrenTaskList = taskService.createNativeTaskQuery().sql(sql).parameter("parentTaskId", parentTaskId).list(); |
| @@ -912,9 +910,9 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -912,9 +910,9 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 912 | } | 910 | } |
| 913 | 911 | ||
| 914 | @Override | 912 | @Override |
| 915 | - public List<BpmTaskSubSignRespVO> getChildrenTaskList(String taskId){ | 913 | + public List<BpmTaskSubSignRespVO> getChildrenTaskList(String taskId) { |
| 916 | List<String> childrenTaskIdList = getChildrenTaskIdList(taskId); | 914 | List<String> childrenTaskIdList = getChildrenTaskIdList(taskId); |
| 917 | - if(CollUtil.isEmpty(childrenTaskIdList)){ | 915 | + if (CollUtil.isEmpty(childrenTaskIdList)) { |
| 918 | return Collections.emptyList(); | 916 | return Collections.emptyList(); |
| 919 | } | 917 | } |
| 920 | //1. 只查询进行中的任务 | 918 | //1. 只查询进行中的任务 |
| @@ -926,11 +924,11 @@ public class BpmTaskServiceImpl implements BpmTaskService { | @@ -926,11 +924,11 @@ public class BpmTaskServiceImpl implements BpmTaskService { | ||
| 926 | List<Long> userIds = taskList.stream() | 924 | List<Long> userIds = taskList.stream() |
| 927 | .flatMap(control -> | 925 | .flatMap(control -> |
| 928 | Stream.of(control.getAssignee(), control.getOwner()) | 926 | Stream.of(control.getAssignee(), control.getOwner()) |
| 929 | - .filter(Objects::nonNull)) | 927 | + .filter(Objects::nonNull)) |
| 930 | .distinct() | 928 | .distinct() |
| 931 | .map(NumberUtils::parseLong) | 929 | .map(NumberUtils::parseLong) |
| 932 | .collect(Collectors.toList()); | 930 | .collect(Collectors.toList()); |
| 933 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds); | 931 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds); |
| 934 | - return BpmTaskConvert.INSTANCE.convertList(bpmTaskExtDOList,userMap,idTaskMap); | 932 | + return BpmTaskConvert.INSTANCE.convertList(bpmTaskExtDOList, userMap, idTaskMap); |
| 935 | } | 933 | } |
| 936 | } | 934 | } |