mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 01:01:52 +08:00
调整流程任务的审批结果,拆成 approve 和 reject 接口
This commit is contained in:
parent
e931414b55
commit
fc6a768058
@ -42,10 +42,17 @@ 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);
|
||||
@PutMapping("/approve")
|
||||
@ApiOperation("通过任务")
|
||||
public CommonResult<Boolean> approveTask(@Valid @RequestBody BpmTaskApproveReqVO reqVO) {
|
||||
taskService.approveTask(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PutMapping("/reject")
|
||||
@ApiOperation("不通过任务")
|
||||
public CommonResult<Boolean> rejectTask(@Valid @RequestBody BpmTaskRejectReqVO reqVO) {
|
||||
taskService.rejectTask(reqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
@ -10,18 +10,14 @@ import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
|
||||
@ApiModel("流程任务的 Done 已办的分页 Request VO")
|
||||
@ApiModel("通过流程任务的 Request VO")
|
||||
@Data
|
||||
public class BpmTaskCompleteReqVO {
|
||||
public class BpmTaskApproveReqVO {
|
||||
|
||||
@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;
|
@ -0,0 +1,21 @@
|
||||
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 javax.validation.constraints.NotEmpty;
|
||||
|
||||
@ApiModel("不通过流程任务的 Request VO")
|
||||
@Data
|
||||
public class BpmTaskRejectReqVO {
|
||||
|
||||
@ApiModelProperty(value = "任务编号", required = true, example = "1024")
|
||||
@NotEmpty(message = "任务编号不能为空")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "审批意见", required = true, example = "不错不错!")
|
||||
@NotEmpty(message = "审批意见不能为空")
|
||||
private String comment;
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.enums.task;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 流程实例的删除原因
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum BpmProcessInstanceDeleteReasonEnum {
|
||||
|
||||
REJECT_TASK("驳回任务");
|
||||
|
||||
private final String reason;
|
||||
|
||||
}
|
@ -13,7 +13,7 @@ import lombok.Getter;
|
||||
public enum BpmProcessInstanceResultEnum {
|
||||
|
||||
PROCESS(1, "处理中"),
|
||||
PASS(2, "通过"),
|
||||
APPROVE(2, "通过"),
|
||||
REJECT(3, "不通过"),
|
||||
CANCEL(4, "已取消");
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class LeaveApplyEndProcessor implements ExecutionListener {
|
||||
OALeaveDO updateDo = new OALeaveDO();
|
||||
updateDo.setId(Long.valueOf(businessKey));
|
||||
if (Objects.equals(approved, true)) {
|
||||
updateDo.setStatus(BpmProcessInstanceResultEnum.PASS.getResult());
|
||||
updateDo.setStatus(BpmProcessInstanceResultEnum.APPROVE.getResult());
|
||||
} else {
|
||||
updateDo.setStatus(BpmProcessInstanceResultEnum.REJECT.getResult());
|
||||
}
|
||||
|
@ -4,6 +4,8 @@ import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmP
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceCreateReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstanceMyPageReqVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.instance.BpmProcessInstancePageItemRespVO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import org.activiti.engine.runtime.ProcessInstance;
|
||||
@ -37,6 +39,22 @@ public interface BpmProcessInstanceService {
|
||||
*/
|
||||
void cancelProcessInstance(Long userId, @Valid BpmProcessInstanceCancelReqVO cancelReqVO);
|
||||
|
||||
/**
|
||||
* 删除流程实例
|
||||
*
|
||||
* @param id 流程编号
|
||||
* @param reason 删除原因。可选 {@link BpmProcessInstanceDeleteReasonEnum}
|
||||
*/
|
||||
void deleteProcessInstance(String id, String reason);
|
||||
|
||||
/**
|
||||
* 更新流程实例的结果
|
||||
*
|
||||
* @param id 流程编号
|
||||
* @param result 结果,{@link BpmProcessInstanceResultEnum}
|
||||
*/
|
||||
void updateProcessInstanceResult(String id, Integer result);
|
||||
|
||||
/**
|
||||
* 获得流程实例的分页
|
||||
*
|
||||
|
@ -71,11 +71,18 @@ public interface BpmTaskService {
|
||||
void updateTaskAssign(String id, Long userId);
|
||||
|
||||
/**
|
||||
* 完成任务(审批通过 / 不通过)
|
||||
* 通过任务
|
||||
*
|
||||
* @param taskReq 完成请求
|
||||
* @param reqVO 通过请求
|
||||
*/
|
||||
void completeTask(@Valid BpmTaskCompleteReqVO taskReq);
|
||||
void approveTask(@Valid BpmTaskApproveReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 不通过任务
|
||||
*
|
||||
* @param reqVO 不通过请求
|
||||
*/
|
||||
void rejectTask(@Valid BpmTaskRejectReqVO reqVO);
|
||||
|
||||
/**
|
||||
* 根据任务id, 查询已经完成的用户任务,未完成的用户任务
|
||||
|
@ -140,9 +140,18 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
||||
// 通过删除流程实例,实现流程实例的取消
|
||||
runtimeService.deleteProcessInstance(cancelReqVO.getId(), cancelReqVO.getReason());
|
||||
// 更新流程实例的拓展表为取消状态
|
||||
processInstanceExtMapper.updateByProcessInstanceId(cancelReqVO.getId(),
|
||||
new BpmProcessInstanceExtDO().setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus())
|
||||
.setResult(BpmProcessInstanceResultEnum.CANCEL.getResult()));
|
||||
updateProcessInstanceResult(cancelReqVO.getId(), BpmProcessInstanceResultEnum.CANCEL.getResult());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteProcessInstance(String id, String reason) {
|
||||
runtimeService.deleteProcessInstance(id, reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProcessInstanceResult(String id, Integer result) {
|
||||
processInstanceExtMapper.updateByProcessInstanceId(id, new BpmProcessInstanceExtDO()
|
||||
.setStatus(BpmProcessInstanceStatusEnum.FINISH.getStatus()).setResult(result));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,6 +5,8 @@ import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.*;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.convert.task.BpmTaskConvert;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService;
|
||||
import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService;
|
||||
@ -37,6 +39,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
@ -158,7 +161,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void completeTask(BpmTaskCompleteReqVO reqVO) {
|
||||
public void approveTask(BpmTaskApproveReqVO reqVO) {
|
||||
// 校验任务存在
|
||||
Task task = getTask(reqVO.getId());
|
||||
if (task == null) {
|
||||
@ -170,8 +173,31 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
throw exception(PROCESS_INSTANCE_NOT_EXISTS);
|
||||
}
|
||||
|
||||
// 完成(审批)任务
|
||||
taskService.complete(task.getId(), instance.getProcessVariables());
|
||||
// 完成任务,审批通过
|
||||
taskService.complete(task.getId(), instance.getProcessVariables()); // TODO 芋艿:variables 的选择
|
||||
|
||||
// TODO 芋艿:添加评论
|
||||
// taskService.addComment(task.getId(), task.getProcessInstanceId(), reqVO.getComment());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rejectTask(@Valid BpmTaskRejectReqVO 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);
|
||||
}
|
||||
|
||||
// 删除流程实例,以实现驳回任务时,取消整个审批流程
|
||||
processInstanceService.deleteProcessInstance(instance.getId(), BpmProcessInstanceDeleteReasonEnum.REJECT_TASK.getReason());
|
||||
// 更新流程实例为不通过
|
||||
processInstanceService.updateProcessInstanceResult(instance.getProcessInstanceId(),
|
||||
BpmProcessInstanceResultEnum.REJECT.getResult());
|
||||
|
||||
// TODO 芋艿:添加评论
|
||||
// taskService.addComment(task.getId(), task.getProcessInstanceId(), reqVO.getComment());
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.task.listener;
|
||||
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmProcessInstanceExtDO;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceResultEnum;
|
||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
|
||||
import org.activiti.engine.delegate.event.ActivitiEvent;
|
||||
import org.activiti.engine.delegate.event.ActivitiEventListener;
|
||||
@ -31,7 +32,9 @@ public class BpmProcessInstanceEventListener implements ActivitiEventListener {
|
||||
// 正常完成
|
||||
if (event.getType() == ActivitiEventType.PROCESS_COMPLETED
|
||||
|| event.getType() == ActivitiEventType.PROCESS_COMPLETED_WITH_ERROR_END_EVENT) {
|
||||
// TODO 芋艿:更新
|
||||
// 正常完成,说明所有流程任务都是审批通过
|
||||
processInstanceService.updateProcessInstanceResult(event.getProcessInstanceId(),
|
||||
BpmProcessInstanceResultEnum.APPROVE.getResult());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,3 +8,26 @@ export function getTodoTaskPage(query) {
|
||||
})
|
||||
}
|
||||
|
||||
export function completeTask(data) {
|
||||
return request({
|
||||
url: '/bpm/task/complete',
|
||||
method: 'PUT',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function approveTask(data) {
|
||||
return request({
|
||||
url: '/bpm/task/approve',
|
||||
method: 'PUT',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function rejectTask(data) {
|
||||
return request({
|
||||
url: '/bpm/task/reject',
|
||||
method: 'PUT',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
@ -41,15 +41,14 @@
|
||||
</div>
|
||||
</el-col>
|
||||
</el-card>
|
||||
<el-card class="box-card">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="el-icon-picture-outline">流程图</span>
|
||||
</div>
|
||||
<my-process-viewer key="designer" v-model="bpmnXML" v-bind="bpmnControlForm" />
|
||||
</el-card>
|
||||
</div>
|
||||
|
||||
<el-card class="box-card">
|
||||
<div slot="header" class="clearfix">
|
||||
<span class="el-icon-picture-outline">流程图</span>
|
||||
</div>
|
||||
<my-process-viewer key="designer" v-model="bpmnXML" v-bind="bpmnControlForm" />
|
||||
</el-card>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -64,11 +64,11 @@
|
||||
<el-table-column label="状态" align="center" prop="status">
|
||||
<template slot-scope="scope">
|
||||
<span>
|
||||
<el-tag type="primary" v-if="scope.row.result === 1"> <!-- 进行中 -->
|
||||
{{ getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS, scope.row.result) }}
|
||||
<el-tag type="primary" v-if="scope.row.status === 1"> <!-- 进行中 -->
|
||||
{{ getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS, scope.row.status) }}
|
||||
</el-tag>
|
||||
<el-tag type="success" v-if="scope.row.result === 2"> <!-- 已结束 -->
|
||||
{{ getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS, scope.row.result) }}
|
||||
<el-tag type="success" v-if="scope.row.status === 2"> <!-- 已结束 -->
|
||||
{{ getDictDataLabel(DICT_TYPE.BPM_PROCESS_INSTANCE_STATUS, scope.row.status) }}
|
||||
</el-tag>
|
||||
</span>
|
||||
</template>
|
||||
|
@ -37,6 +37,8 @@
|
||||
<template slot-scope="scope">
|
||||
<!-- TODO 权限、颜色 -->
|
||||
<el-button size="mini" type="text" icon="el-icon-edit">审批</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="audit(scope.row, true)">通过</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" @click="audit(scope.row, false)">不通过</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" v-if="scope.row.suspensionState === 2">激活</el-button>
|
||||
<el-button size="mini" type="text" icon="el-icon-edit" v-if="scope.row.suspensionState === 1">挂起</el-button>
|
||||
</template>
|
||||
@ -50,7 +52,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getTodoTaskPage } from '@/api/bpm/task'
|
||||
import {approveTask, completeTask, getTodoTaskPage, rejectTask} from '@/api/bpm/task'
|
||||
|
||||
export default {
|
||||
name: "Todo",
|
||||
@ -124,6 +126,19 @@ export default {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
audit(row, pass) {
|
||||
if (pass) {
|
||||
approveTask({
|
||||
id: row.id,
|
||||
comment: '通过'
|
||||
})
|
||||
} else {
|
||||
rejectTask({
|
||||
id: row.id,
|
||||
comment: '不通过'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user