mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-12-01 19:51:53 +08:00
实现流程任务的审批功能的 API 接口
This commit is contained in:
parent
8a10568b24
commit
e931414b55
@ -42,17 +42,18 @@ public class BpmTaskController {
|
|||||||
return success(taskService.getDoneTaskPage(getLoginUserId(), pageVO));
|
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")
|
@PostMapping("/task-steps")
|
||||||
public CommonResult<TaskHandleVO> getTaskSteps(@RequestBody TaskQueryReqVO taskQuery) {
|
public CommonResult<TaskHandleVO> getTaskSteps(@RequestBody TaskQueryReqVO taskQuery) {
|
||||||
return success(taskService.getTaskSteps(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")
|
@GetMapping("/process/history-steps")
|
||||||
public CommonResult<List<TaskStepVO>> getHistorySteps(@RequestParam("id") String processInstanceId) {
|
public CommonResult<List<TaskStepVO>> getHistorySteps(@RequestParam("id") String processInstanceId) {
|
||||||
return success(taskService.getHistorySteps(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, "流程定义处于挂起状态");
|
ErrorCode PROCESS_DEFINITION_IS_SUSPENDED = new ErrorCode(1009003002, "流程定义处于挂起状态");
|
||||||
|
|
||||||
// ========== 流程实例 1-009-004-000 ==========
|
// ========== 流程实例 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 ==========
|
// ========== 动态表单模块 1-009-010-000 ==========
|
||||||
ErrorCode FORM_NOT_EXISTS = new ErrorCode(1009010000, "动态表单不存在");
|
ErrorCode FORM_NOT_EXISTS = new ErrorCode(1009010000, "动态表单不存在");
|
||||||
|
@ -47,6 +47,14 @@ public interface BpmProcessInstanceService {
|
|||||||
PageResult<BpmProcessInstancePageItemRespVO> getMyProcessInstancePage(Long userId,
|
PageResult<BpmProcessInstancePageItemRespVO> getMyProcessInstancePage(Long userId,
|
||||||
@Valid BpmProcessInstanceMyPageReqVO pageReqVO);
|
@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 cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import org.activiti.engine.task.Task;
|
import org.activiti.engine.task.Task;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -70,29 +71,24 @@ public interface BpmTaskService {
|
|||||||
void updateTaskAssign(String id, Long userId);
|
void updateTaskAssign(String id, Long userId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 签收任务
|
* 完成任务(审批通过 / 不通过)
|
||||||
*
|
*
|
||||||
* @param id 任务编号
|
* @param taskReq 完成请求
|
||||||
*/
|
*/
|
||||||
void claimTask(String id);
|
void completeTask(@Valid BpmTaskCompleteReqVO taskReq);
|
||||||
|
|
||||||
/**
|
|
||||||
* 工作流,完成 userTask, 完成用户任务 一般传入参数 1。是否同意(variables). 2. 评论(comment)
|
|
||||||
* variables 变量名 和 评论 由前台传入
|
|
||||||
* @param taskReq 任务参数
|
|
||||||
*/
|
|
||||||
void completeTask(TaskReqVO taskReq);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据任务id, 查询已经完成的用户任务,未完成的用户任务
|
* 根据任务id, 查询已经完成的用户任务,未完成的用户任务
|
||||||
* @param taskQuery 查询参数 一般 taskId
|
* @param taskQuery 查询参数 一般 taskId
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
TaskHandleVO getTaskSteps(TaskQueryReqVO taskQuery);
|
TaskHandleVO getTaskSteps(TaskQueryReqVO taskQuery);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据流程实例id, 查询历史用户任务,包括已完成,未完成
|
* 根据流程实例id, 查询历史用户任务,包括已完成,未完成
|
||||||
* @param processInstanceId 流程实例id
|
* @param processInstanceId 流程实例id
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
List<TaskStepVO> getHistorySteps(String processInstanceId);
|
List<TaskStepVO> getHistorySteps(String processInstanceId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,4 +97,5 @@ public interface BpmTaskService {
|
|||||||
* @return {@link FileResp} 返回文件
|
* @return {@link FileResp} 返回文件
|
||||||
*/
|
*/
|
||||||
FileResp getHighlightImg(String processInstanceId);
|
FileResp getHighlightImg(String processInstanceId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -166,13 +166,8 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
|||||||
return runtimeService.createProcessInstanceQuery().processInstanceIds(ids).list();
|
return runtimeService.createProcessInstanceQuery().processInstanceIds(ids).list();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* 获得流程实例
|
public ProcessInstance getProcessInstance(String id) {
|
||||||
*
|
|
||||||
* @param id 流程实例的编号
|
|
||||||
* @return 流程实例
|
|
||||||
*/
|
|
||||||
private ProcessInstance getProcessInstance(String id) {
|
|
||||||
return runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult();
|
return runtimeService.createProcessInstanceQuery().processInstanceId(id).singleResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.*;
|
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.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||||
|
|
||||||
@ -157,20 +157,24 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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
|
taskService.complete(task.getId(), instance.getProcessVariables());
|
||||||
public void completeTask(TaskReqVO taskReq) {
|
|
||||||
// final Task task = taskRuntime.task(taskReq.getTaskId());
|
// TODO 芋艿:添加评论
|
||||||
//
|
// taskService.addComment(task.getId(), task.getProcessInstanceId(), reqVO.getComment());
|
||||||
// taskService.addComment(taskReq.getTaskId(), task.getProcessInstanceId(), taskReq.getComment());
|
|
||||||
//
|
|
||||||
// taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskReq.getTaskId())
|
|
||||||
// .withVariables(taskReq.getVariables())
|
|
||||||
// .build());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -347,4 +351,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
}
|
}
|
||||||
return highLightedFlowIds;
|
return highLightedFlowIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Task getTask(String id) {
|
||||||
|
return taskService.createTaskQuery().taskId(id).singleResult();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user