package org.springblade.mdm.flow.service.execute;
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
import org.flowable.engine.RuntimeService;
|
import org.flowable.engine.TaskService;
|
import org.flowable.task.api.Task;
|
import org.springblade.core.tool.api.R;
|
import org.springblade.mdm.flow.constants.FlowContants;
|
import org.springblade.mdm.flow.service.ApproveRecordService;
|
import org.springblade.system.feign.IUserClient;
|
import org.springblade.system.pojo.entity.User;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
import java.util.Map;
|
|
/**
|
* 任务完成接口
|
*/
|
@Service
|
public abstract class AbstractFlowCompleteService {
|
@Autowired
|
protected TaskService taskService;
|
@Autowired
|
protected RuntimeService runtimeService;
|
@Autowired
|
protected ApproveRecordService approveRecordService;
|
|
@Transactional
|
public abstract void completeTask(String taskId, String processInstanceId, String comment, @Parameter(name = "variables", description = "流程变量") @RequestBody Map<String, Object> variables);
|
|
/**
|
* 获取审批结果 Y/N
|
* @param variables 前端提交的变量map
|
* @return Y/N 字符串
|
*/
|
protected String getApproveResult(Map<String, Object> variables){
|
return variables.get("approve")+"";
|
}
|
/**
|
* 获取当前正在执行的任务
|
* @param taskId 任务id
|
* @return 任务实体
|
*/
|
Task currentTask(String taskId) {
|
return taskService.createTaskQuery()
|
.taskId(taskId)
|
.singleResult();
|
}
|
void addApproveRecord(String taskId,String comment,Map<String, Object> variables){
|
String operateResult = variables.get("approve")+"";
|
approveRecordService.saveApproveRecords(currentTask(taskId),operateResult,comment);
|
}
|
|
|
}
|