实现流程任务的审批功能的 API 接口
This commit is contained in:
parent
8a10568b24
commit
e931414b55
@ -42,17 +42,18 @@ public class BpmTaskController {
|
||||
return success(taskService.getDoneTaskPage(getLoginUserId(), pageVO));
|
||||
}
|
||||
|
||||
@PutMapping("/complete")
|
||||
@ApiOperation(value = "完成任务", notes = "审批通过 or 不通过")
|
||||
public CommonResult<Boolean> completeTask(@Valid @RequestBody BpmTaskCompleteReqVO reqVO) {
|
||||
taskService.completeTask(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/task-steps")
|
||||
public CommonResult<TaskHandleVO> getTaskSteps(@RequestBody TaskQueryReqVO taskQuery) {
|
||||
return success(taskService.getTaskSteps(taskQuery));
|
||||
}
|
||||
|
||||
@PostMapping("/complete")
|
||||
public CommonResult<Boolean> complete(@RequestBody TaskReqVO taskReq) {
|
||||
taskService.completeTask(taskReq);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/process/history-steps")
|
||||
public CommonResult<List<TaskStepVO>> getHistorySteps(@RequestParam("id") String processInstanceId) {
|
||||
return success(taskService.getHistorySteps(processInstanceId));
|
||||
|
@ -0,0 +1,29 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
|
||||
@ApiModel("流程任务的 Done 已办的分页 Request VO")
|
||||
@Data
|
||||
public class BpmTaskCompleteReqVO {
|
||||
|
||||
@ApiModelProperty(value = "任务编号", required = true, example = "1024")
|
||||
@NotEmpty(message = "任务编号不能为空")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "是否通过", required = true, example = "true", notes = "true 通过;false 不通过")
|
||||
@NotNull(message = "是否通过不能为空")
|
||||
private Boolean pass;
|
||||
|
||||
@ApiModelProperty(value = "审批意见", required = true, example = "不错不错!")
|
||||
@NotEmpty(message = "审批意见不能为空")
|
||||
private String comment;
|
||||
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@ToString
|
||||
public class TaskReqVO {
|
||||
|
||||
private String taskId;
|
||||
|
||||
private Map<String,Object> variables;
|
||||
|
||||
private String comment;
|
||||
}
|
@ -33,7 +33,11 @@ public interface BpmErrorCodeConstants {
|
||||
ErrorCode PROCESS_DEFINITION_IS_SUSPENDED = new ErrorCode(1009003002, "流程定义处于挂起状态");
|
||||
|
||||
// ========== 流程实例 1-009-004-000 ==========
|
||||
ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS = new ErrorCode(1009004000, "流程取消失败,流程不处于运行中");
|
||||
ErrorCode PROCESS_INSTANCE_NOT_EXISTS = new ErrorCode(1009004000, "流程实例不存在");
|
||||
ErrorCode PROCESS_INSTANCE_CANCEL_FAIL_NOT_EXISTS = new ErrorCode(1009004001, "流程取消失败,流程不处于运行中");
|
||||
|
||||
// ========== 流程实例 1-009-005-000 ==========
|
||||
ErrorCode TASK_COMPLETE_FAIL_NOT_EXISTS = new ErrorCode(1009004000, "审批任务失败,原因:该任务不处于未审批");
|
||||
|
||||
// ========== 动态表单模块 1-009-010-000 ==========
|
||||
ErrorCode FORM_NOT_EXISTS = new ErrorCode(1009010000, "动态表单不存在");
|
||||
|
@ -47,6 +47,14 @@ public interface BpmProcessInstanceService {
|
||||
PageResult<BpmProcessInstancePageItemRespVO> getMyProcessInstancePage(Long userId,
|
||||
@Valid BpmProcessInstanceMyPageReqVO pageReqVO);
|
||||
|
||||
/**
|
||||
* 获得流程实例
|
||||
*
|
||||
* @param id 流程实例的编号
|
||||
* @return 流程实例
|
||||
*/
|
||||
ProcessInstance getProcessInstance(String id);
|
||||
|
||||
/**
|
||||
* 获得流程实例列表
|
||||
*
|
||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import org.activiti.engine.task.Task;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -70,29 +71,24 @@ public interface BpmTaskService {
|
||||
void updateTaskAssign(String id, Long userId);
|
||||
|
||||
/**
|
||||
* 签收任务
|
||||
* 完成任务(审批通过 / 不通过)
|
||||
*
|
||||
* @param id 任务编号
|
||||
* @param taskReq 完成请求
|
||||
*/
|
||||
void claimTask(String id);
|
||||
|
||||
/**
|
||||
* 工作流,完成 userTask, 完成用户任务 一般传入参数 1。是否同意(variables). 2. 评论(comment)
|
||||
* variables 变量名 和 评论 由前台传入
|
||||
* @param taskReq 任务参数
|
||||
*/
|
||||
void completeTask(TaskReqVO taskReq);
|
||||
void completeTask(@Valid BpmTaskCompleteReqVO taskReq);
|
||||
|
||||
/**
|
||||
* 根据任务id, 查询已经完成的用户任务,未完成的用户任务
|
||||
* @param taskQuery 查询参数 一般 taskId
|
||||
*/
|
||||
@Deprecated
|
||||
TaskHandleVO getTaskSteps(TaskQueryReqVO taskQuery);
|
||||
|
||||
/**
|
||||
* 根据流程实例id, 查询历史用户任务,包括已完成,未完成
|
||||
* @param processInstanceId 流程实例id
|
||||
*/
|
||||
@Deprecated
|
||||
List<TaskStepVO> getHistorySteps(String processInstanceId);
|
||||
|
||||
/**
|
||||
@ -101,4 +97,5 @@ public interface BpmTaskService {
|
||||
* @return {@link FileResp} 返回文件
|
||||
*/
|
||||
FileResp getHighlightImg(String processInstanceId);
|
||||
|
||||
}
|
||||
|
@ -166,13 +166,8 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||
return runtimeService.createProcessInstanceQuery().processInstanceIds(ids).list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得流程实例
|
||||
*
|
||||
* @param id 流程实例的编号
|
||||
* @return 流程实例
|
||||
*/
|
||||
private ProcessInstance getProcessInstance(String id) {
|
||||
@Override
|
||||
public ProcessInstance getProcessInstance(String id) {
|
||||
return runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult();
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.HIGHLIGHT_IMG_ERROR;
|
||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
|
||||
@ -157,20 +157,24 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void claimTask(String id) {
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void completeTask(BpmTaskCompleteReqVO reqVO) {
|
||||
// 校验任务存在
|
||||
Task task = getTask(reqVO.getId());
|
||||
if (task == null) {
|
||||
throw exception(TASK_COMPLETE_FAIL_NOT_EXISTS);
|
||||
}
|
||||
// 校验流程实例存在
|
||||
ProcessInstance instance = processInstanceService.getProcessInstance(task.getProcessInstanceId());
|
||||
if (instance == null) {
|
||||
throw exception(PROCESS_INSTANCE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void completeTask(TaskReqVO taskReq) {
|
||||
// final Task task = taskRuntime.task(taskReq.getTaskId());
|
||||
//
|
||||
// taskService.addComment(taskReq.getTaskId(), task.getProcessInstanceId(), taskReq.getComment());
|
||||
//
|
||||
// taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskReq.getTaskId())
|
||||
// .withVariables(taskReq.getVariables())
|
||||
// .build());
|
||||
// 完成(审批)任务
|
||||
taskService.complete(task.getId(), instance.getProcessVariables());
|
||||
|
||||
// TODO 芋艿:添加评论
|
||||
// taskService.addComment(task.getId(), task.getProcessInstanceId(), reqVO.getComment());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -347,4 +351,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
}
|
||||
return highLightedFlowIds;
|
||||
}
|
||||
|
||||
private Task getTask(String id) {
|
||||
return taskService.createTaskQuery().taskId(id).singleResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user