fix: 根据review结果修改
This commit is contained in:
parent
1553900193
commit
3972fbd1d9
|
@ -50,9 +50,8 @@ public interface ErrorCodeConstants {
|
|||
ErrorCode TASK_TARGET_NODE_NOT_EXISTS = new ErrorCode(1_009_005_004, " 目标节点不存在");
|
||||
ErrorCode TASK_RETURN_FAIL_NO_RETURN_TASK = new ErrorCode(1_009_005_005, "回退任务失败,选择回退的节点没有需要回滚的任务!请重新选择其他任务节点");
|
||||
ErrorCode TASK_RETURN_FAIL_SOURCE_TARGET_ERROR = new ErrorCode(1_009_005_006, "回退任务失败,目标节点是在并行网关上或非同一路线上,不可跳转");
|
||||
ErrorCode TASK_DELEGATE_APPROVE_FAIL = new ErrorCode(1_009_005_007, "任务审批失败:委派任务找不到原审批人");
|
||||
ErrorCode TASK_DELEGATE_USER_REPEAT = new ErrorCode(1_009_005_008, "任务委派失败,委派人和当前审批人为同一人");
|
||||
ErrorCode TASK_DELEGATE_RECEIVE_USER_NULL = new ErrorCode(1_009_005_009, "任务委派失败,接收人不存在");
|
||||
ErrorCode TASK_DELEGATE_USER_REPEAT = new ErrorCode(1_009_005_007, "任务委派失败,委派人和当前审批人为同一人");
|
||||
ErrorCode TASK_DELEGATE_USER_NULL = new ErrorCode(1_009_005_008, "任务委派失败,被委派人不存在");
|
||||
|
||||
// ========== 流程任务分配规则 1-009-006-000 ==========
|
||||
ErrorCode TASK_ASSIGN_RULE_EXISTS = new ErrorCode(1_009_006_000, "流程({}) 的任务({}) 已经存在分配规则");
|
||||
|
|
|
@ -95,7 +95,7 @@ public class BpmTaskController {
|
|||
@Operation(summary = "委派任务", description = "用于【流程详情】的【委派】按钮,和向前加签有点像,和向前加签的唯一的区别是没有单独创立任务")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:task:delegate')")
|
||||
public CommonResult<Boolean> delegateTask(@Valid @RequestBody BpmTaskDelegateReqVO reqVO) {
|
||||
taskService.delegateTask(reqVO);
|
||||
taskService.delegateTask(reqVO,getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@ public class BpmTaskDelegateReqVO {
|
|||
@NotEmpty(message = "任务编号不能为空")
|
||||
private String id;
|
||||
|
||||
@Schema(description = "接收人ID", requiredMode = Schema.RequiredMode.REQUIRED,example = "1")
|
||||
@NotNull(message = "接收人ID不能为空")
|
||||
private Long receiveId;
|
||||
@Schema(description = "被委派人ID", requiredMode = Schema.RequiredMode.REQUIRED,example = "1")
|
||||
@NotNull(message = "被委派人ID不能为空")
|
||||
private Long delegateUserId;
|
||||
|
||||
@Schema(description = "委派原因", requiredMode = Schema.RequiredMode.REQUIRED,example = "做不了决定,需要你先帮忙瞅瞅")
|
||||
@NotEmpty(message = "委派原因不能为空")
|
||||
|
|
|
@ -140,7 +140,8 @@ public interface BpmTaskService {
|
|||
/**
|
||||
* 将指定任务委派给其他人处理,等接收人处理后再回到原审批人手中审批
|
||||
*
|
||||
* @param reqVO 接收人和被委派的任务编号理由参数
|
||||
* @param reqVO 被委派人和被委派的任务编号理由参数
|
||||
* @param userId 委派人ID
|
||||
*/
|
||||
void delegateTask(BpmTaskDelegateReqVO reqVO);
|
||||
void delegateTask(BpmTaskDelegateReqVO reqVO, Long userId);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package cn.iocoder.yudao.module.bpm.service.task;
|
|||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||
|
@ -14,7 +13,6 @@ import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
|
|||
import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmTaskExtMapper;
|
||||
import cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum;
|
||||
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService;
|
||||
|
@ -41,6 +39,7 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.TransactionSynchronization;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
@ -222,10 +221,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||
AdminUserRespDTO currentUser = adminUserApi.getUser(WebFrameworkUtils.getLoginUserId());
|
||||
//原审批人
|
||||
AdminUserRespDTO sourceApproveUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner()));
|
||||
if (sourceApproveUser == null) {
|
||||
throw exception(TASK_DELEGATE_APPROVE_FAIL);
|
||||
}
|
||||
String comment = String.format("[%s]完成委派任务,任务重新回到[%s]手中,审批意见为:%s", currentUser.getNickname(),
|
||||
Assert.notNull(sourceApproveUser, "委派任务找不到原审批人,需要检查数据");
|
||||
//添加审批意见
|
||||
String comment = StrUtil.format("[{}]完成委派任务,任务重新回到[{}]手中,审批意见为:{}", currentUser.getNickname(),
|
||||
sourceApproveUser.getNickname(), reqVO.getReason());
|
||||
taskService.addComment(reqVO.getId(), task.getProcessInstanceId(), BpmProcessInstanceResultEnum.DELEGATE.getResult().toString(), comment);
|
||||
//调用 resolveTask 完成任务,底层调用 TaskHelper.changeTaskAssignee(task, task.getOwner());
|
||||
|
@ -486,23 +484,23 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delegateTask(BpmTaskDelegateReqVO reqVO) {
|
||||
public void delegateTask(BpmTaskDelegateReqVO reqVO,Long userId) {
|
||||
// 校验任务
|
||||
Task task = this.validateTaskDelegate(reqVO);
|
||||
// 添加审批意见
|
||||
AdminUserRespDTO currentUser = adminUserApi.getUser(WebFrameworkUtils.getLoginUserId());
|
||||
AdminUserRespDTO receiveUser = adminUserApi.getUser(reqVO.getReceiveId());
|
||||
if (receiveUser == null) {
|
||||
throw exception(TASK_DELEGATE_RECEIVE_USER_NULL);
|
||||
AdminUserRespDTO currentUser = adminUserApi.getUser(userId);
|
||||
AdminUserRespDTO delegateUser = adminUserApi.getUser(reqVO.getDelegateUserId());
|
||||
if (delegateUser == null) {
|
||||
throw exception(TASK_DELEGATE_USER_NULL);
|
||||
}
|
||||
String comment = String.format("[%s]将任务委派给[%s],委派理由为:%s", currentUser.getNickname(),
|
||||
receiveUser.getNickname(), reqVO.getReason());
|
||||
String comment = StrUtil.format("[{}]将任务委派给[{}],委派理由为:{}", currentUser.getNickname(),
|
||||
delegateUser.getNickname(), reqVO.getReason());
|
||||
String taskId = reqVO.getId();
|
||||
taskService.addComment(taskId, task.getProcessInstanceId(), BpmProcessInstanceResultEnum.DELEGATE.getResult().toString(), comment);
|
||||
// 设置任务所有人 (owner) 为原任务的处理人 (assignee)
|
||||
taskService.setOwner(taskId, task.getAssignee());
|
||||
// 执行委派,将任务委派给 receiveId
|
||||
taskService.delegateTask(taskId, reqVO.getReceiveId().toString());
|
||||
taskService.delegateTask(taskId, reqVO.getDelegateUserId().toString());
|
||||
// 更新任务拓展表为【委派】
|
||||
taskExtMapper.updateByTaskId(
|
||||
new BpmTaskExtDO().setTaskId(task.getId()).setResult(BpmProcessInstanceResultEnum.DELEGATE.getResult())
|
||||
|
@ -519,7 +517,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||
// 校验任务
|
||||
Task task = checkTask(WebFrameworkUtils.getLoginUserId(), reqVO.getId());
|
||||
//校验当前审批人和被委派人不是同一人
|
||||
if (task.getAssignee().equals(reqVO.getReceiveId().toString())) {
|
||||
if (task.getAssignee().equals(reqVO.getDelegateUserId().toString())) {
|
||||
throw exception(TASK_DELEGATE_USER_REPEAT);
|
||||
}
|
||||
return task;
|
||||
|
|
Loading…
Reference in New Issue