@@ -1,6 +1,6 @@
|
||||
package com.ruoyi.workflow.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.workflow.domain.vo.FlowTaskVo;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.task.api.Task;
|
||||
@@ -54,5 +54,5 @@ public interface IFlowInstanceService {
|
||||
* @param variables 流程变量
|
||||
* @return
|
||||
*/
|
||||
AjaxResult startProcessInstanceById(String procDefId, Map<String, Object> variables);
|
||||
R startProcessInstanceById(String procDefId, Map<String, Object> variables);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.ruoyi.workflow.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.workflow.domain.vo.FlowTaskVo;
|
||||
import org.flowable.task.api.Task;
|
||||
|
||||
@@ -17,7 +17,7 @@ public interface IFlowTaskService {
|
||||
*
|
||||
* @param task 请求实体参数
|
||||
*/
|
||||
AjaxResult complete(FlowTaskVo task);
|
||||
R complete(FlowTaskVo task);
|
||||
|
||||
/**
|
||||
* 驳回任务
|
||||
@@ -40,7 +40,7 @@ public interface IFlowTaskService {
|
||||
* @param flowTaskVo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult findReturnTaskList(FlowTaskVo flowTaskVo);
|
||||
R findReturnTaskList(FlowTaskVo flowTaskVo);
|
||||
|
||||
/**
|
||||
* 删除任务
|
||||
@@ -84,21 +84,21 @@ public interface IFlowTaskService {
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
AjaxResult myProcess(Integer pageNum, Integer pageSize);
|
||||
R myProcess(Integer pageNum, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 取消申请
|
||||
* @param flowTaskVo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult stopProcess(FlowTaskVo flowTaskVo);
|
||||
R stopProcess(FlowTaskVo flowTaskVo);
|
||||
|
||||
/**
|
||||
* 撤回流程
|
||||
* @param flowTaskVo
|
||||
* @return
|
||||
*/
|
||||
AjaxResult revokeProcess(FlowTaskVo flowTaskVo);
|
||||
R revokeProcess(FlowTaskVo flowTaskVo);
|
||||
|
||||
|
||||
/**
|
||||
@@ -108,7 +108,7 @@ public interface IFlowTaskService {
|
||||
* @param pageSize 每页条数
|
||||
* @return
|
||||
*/
|
||||
AjaxResult todoList(Integer pageNum, Integer pageSize);
|
||||
R todoList(Integer pageNum, Integer pageSize);
|
||||
|
||||
|
||||
/**
|
||||
@@ -118,7 +118,7 @@ public interface IFlowTaskService {
|
||||
* @param pageSize 每页条数
|
||||
* @return
|
||||
*/
|
||||
AjaxResult finishedList(Integer pageNum, Integer pageSize);
|
||||
R finishedList(Integer pageNum, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 流程历史流转记录
|
||||
@@ -126,7 +126,7 @@ public interface IFlowTaskService {
|
||||
* @param procInsId 流程实例Id
|
||||
* @return
|
||||
*/
|
||||
AjaxResult flowRecord(String procInsId, String deployId);
|
||||
R flowRecord(String procInsId, String deployId);
|
||||
|
||||
/**
|
||||
* 根据任务ID查询挂载的表单信息
|
||||
@@ -148,19 +148,19 @@ public interface IFlowTaskService {
|
||||
* @param procInsId
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getFlowViewer(String procInsId);
|
||||
R getFlowViewer(String procInsId);
|
||||
|
||||
/**
|
||||
* 获取流程变量
|
||||
* @param taskId
|
||||
* @return
|
||||
*/
|
||||
AjaxResult processVariables(String taskId);
|
||||
R processVariables(String taskId);
|
||||
|
||||
/**
|
||||
* 获取下一节点
|
||||
* @param flowTaskVo 任务
|
||||
* @return
|
||||
*/
|
||||
AjaxResult getNextFlowNode(FlowTaskVo flowTaskVo);
|
||||
R getNextFlowNode(FlowTaskVo flowTaskVo);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.common.core.domain.PageQuery;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.flowable.common.constant.ProcessConstants;
|
||||
import com.ruoyi.flowable.common.enums.FlowComment;
|
||||
import com.ruoyi.flowable.factory.FlowServiceFactory;
|
||||
@@ -213,7 +213,7 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
|
||||
// variables.put("skip", true);
|
||||
// variables.put(ProcessConstants.FLOWABLE_SKIP_EXPRESSION_ENABLED, true);
|
||||
// 设置流程发起人Id到流程中
|
||||
String UserIdStr = LoginUtils.getUserId().toString();
|
||||
String UserIdStr = LoginHelper.getUserId().toString();
|
||||
identityService.setAuthenticatedUserId(UserIdStr);
|
||||
variables.put(ProcessConstants.PROCESS_INITIATOR, UserIdStr);
|
||||
ProcessInstance processInstance = runtimeService.startProcessInstanceById(procDefId, variables);
|
||||
@@ -223,7 +223,7 @@ public class FlowDefinitionServiceImpl extends FlowServiceFactory implements IFl
|
||||
if (!StrUtil.equalsAny(task.getAssignee(), UserIdStr)) {
|
||||
throw new ServiceException("数据验证失败,该工作流第一个用户任务的指派人并非当前用户,不能执行该操作!");
|
||||
}
|
||||
taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), LoginUtils.getNickName() + "发起流程申请");
|
||||
taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.NORMAL.getType(), LoginHelper.getNickName() + "发起流程申请");
|
||||
// taskService.setAssignee(task.getId(), UserIdStr);
|
||||
taskService.complete(task.getId(), variables);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.ruoyi.workflow.service.impl;
|
||||
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.workflow.domain.vo.FlowTaskVo;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.flowable.factory.FlowServiceFactory;
|
||||
import com.ruoyi.workflow.domain.vo.FlowTaskVo;
|
||||
import com.ruoyi.workflow.service.IFlowInstanceService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.common.engine.api.FlowableObjectNotFoundException;
|
||||
@@ -109,19 +109,19 @@ public class FlowInstanceServiceImpl extends FlowServiceFactory implements IFlow
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult startProcessInstanceById(String procDefId, Map<String, Object> variables) {
|
||||
public R startProcessInstanceById(String procDefId, Map<String, Object> variables) {
|
||||
|
||||
try {
|
||||
// 设置流程发起人Id到流程中
|
||||
Long userId = LoginUtils.getUserId();
|
||||
Long userId = LoginHelper.getUserId();
|
||||
// identityService.setAuthenticatedUserId(userId.toString());
|
||||
variables.put("initiator", userId);
|
||||
variables.put("_FLOWABLE_SKIP_EXPRESSION_ENABLED", true);
|
||||
runtimeService.startProcessInstanceById(procDefId, variables);
|
||||
return AjaxResult.success("流程启动成功");
|
||||
return R.ok("流程启动成功");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error("流程启动错误");
|
||||
return R.fail("流程启动错误");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ package com.ruoyi.workflow.service.impl;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.helper.LoginHelper;
|
||||
import com.ruoyi.common.utils.JsonUtils;
|
||||
import com.ruoyi.common.utils.LoginUtils;
|
||||
import com.ruoyi.flowable.common.constant.ProcessConstants;
|
||||
import com.ruoyi.flowable.common.enums.FlowComment;
|
||||
import com.ruoyi.flowable.factory.FlowServiceFactory;
|
||||
@@ -86,17 +86,17 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public AjaxResult complete(FlowTaskVo taskVo) {
|
||||
public R complete(FlowTaskVo taskVo) {
|
||||
Task task = taskService.createTaskQuery().taskId(taskVo.getTaskId()).singleResult();
|
||||
if (Objects.isNull(task)) {
|
||||
return AjaxResult.error("任务不存在");
|
||||
return R.fail("任务不存在");
|
||||
}
|
||||
if (DelegationState.PENDING.equals(task.getDelegationState())) {
|
||||
taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.DELEGATE.getType(), taskVo.getComment());
|
||||
taskService.resolveTask(taskVo.getTaskId(), taskVo.getValues());
|
||||
} else {
|
||||
taskService.addComment(taskVo.getTaskId(), taskVo.getInstanceId(), FlowComment.NORMAL.getType(), taskVo.getComment());
|
||||
Long userId = LoginUtils.getUserId();
|
||||
Long userId = LoginHelper.getUserId();
|
||||
taskService.setAssignee(taskVo.getTaskId(), userId.toString());
|
||||
if (ObjectUtil.isNotEmpty(taskVo.getValues())) {
|
||||
taskService.complete(taskVo.getTaskId(), taskVo.getValues());
|
||||
@@ -104,7 +104,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
taskService.complete(taskVo.getTaskId());
|
||||
}
|
||||
}
|
||||
return AjaxResult.success();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -318,7 +318,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult findReturnTaskList(FlowTaskVo flowTaskVo) {
|
||||
public R findReturnTaskList(FlowTaskVo flowTaskVo) {
|
||||
// 当前任务 task
|
||||
Task task = taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult();
|
||||
// 获取流程定义信息
|
||||
@@ -349,7 +349,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
userTaskList.retainAll(road);
|
||||
}
|
||||
}
|
||||
return AjaxResult.success(userTaskList);
|
||||
return R.ok(userTaskList);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -416,9 +416,9 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult myProcess(Integer pageNum, Integer pageSize) {
|
||||
public R myProcess(Integer pageNum, Integer pageSize) {
|
||||
Page<FlowTaskDto> page = new Page<>();
|
||||
Long userId = LoginUtils.getUserId();
|
||||
Long userId = LoginHelper.getUserId();
|
||||
HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery()
|
||||
.startedBy(userId.toString())
|
||||
.orderByProcessInstanceStartTime()
|
||||
@@ -460,7 +460,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
flowList.add(flowTask);
|
||||
}
|
||||
page.setRecords(flowList);
|
||||
return AjaxResult.success(page);
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -470,7 +470,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult stopProcess(FlowTaskVo flowTaskVo) {
|
||||
public R stopProcess(FlowTaskVo flowTaskVo) {
|
||||
List<Task> task = taskService.createTaskQuery().processInstanceId(flowTaskVo.getInstanceId()).list();
|
||||
if (CollectionUtils.isEmpty(task)) {
|
||||
throw new RuntimeException("流程未启动或已执行完成,取消申请失败");
|
||||
@@ -483,7 +483,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
Process process = bpmnModel.getMainProcess();
|
||||
List<EndEvent> endNodes = process.findFlowElementsOfType(EndEvent.class, false);
|
||||
if (CollectionUtils.isNotEmpty(endNodes)) {
|
||||
Authentication.setAuthenticatedUserId(LoginUtils.getUserId().toString());
|
||||
Authentication.setAuthenticatedUserId(LoginHelper.getUserId().toString());
|
||||
// taskService.addComment(task.getId(), processInstance.getProcessInstanceId(), FlowComment.STOP.getType(),
|
||||
// StringUtils.isBlank(flowTaskVo.getComment()) ? "取消申请" : flowTaskVo.getComment());
|
||||
String endId = endNodes.get(0).getId();
|
||||
@@ -496,7 +496,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
}
|
||||
}
|
||||
|
||||
return AjaxResult.success();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -506,7 +506,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult revokeProcess(FlowTaskVo flowTaskVo) {
|
||||
public R revokeProcess(FlowTaskVo flowTaskVo) {
|
||||
Task task = taskService.createTaskQuery().processInstanceId(flowTaskVo.getInstanceId()).singleResult();
|
||||
if (task == null) {
|
||||
throw new RuntimeException("流程未启动或已执行完成,无法撤回");
|
||||
@@ -520,7 +520,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
String myTaskId = null;
|
||||
HistoricTaskInstance myTask = null;
|
||||
for (HistoricTaskInstance hti : htiList) {
|
||||
if (LoginUtils.getUserId().toString().equals(hti.getAssignee())) {
|
||||
if (LoginHelper.getUserId().toString().equals(hti.getAssignee())) {
|
||||
myTaskId = hti.getId();
|
||||
myTask = hti;
|
||||
break;
|
||||
@@ -554,7 +554,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
List<SequenceFlow> oriSequenceFlows = new ArrayList<>(flowNode.getOutgoingFlows());
|
||||
|
||||
|
||||
return AjaxResult.success();
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -565,9 +565,9 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult todoList(Integer pageNum, Integer pageSize) {
|
||||
public R todoList(Integer pageNum, Integer pageSize) {
|
||||
Page<FlowTaskDto> page = new Page<>();
|
||||
Long userId = LoginUtils.getUserId();
|
||||
Long userId = LoginHelper.getUserId();
|
||||
TaskQuery taskQuery = taskService.createTaskQuery()
|
||||
.active()
|
||||
.includeProcessVariables()
|
||||
@@ -606,7 +606,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
}
|
||||
|
||||
page.setRecords(flowList);
|
||||
return AjaxResult.success(page);
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
|
||||
@@ -618,9 +618,9 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult finishedList(Integer pageNum, Integer pageSize) {
|
||||
public R finishedList(Integer pageNum, Integer pageSize) {
|
||||
Page<FlowTaskDto> page = new Page<>();
|
||||
Long userId = LoginUtils.getUserId();
|
||||
Long userId = LoginHelper.getUserId();
|
||||
HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
|
||||
.includeProcessVariables()
|
||||
.finished()
|
||||
@@ -666,7 +666,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
// Map<String, Object> result = new HashMap<>();
|
||||
// result.put("result",page);
|
||||
// result.put("finished",true);
|
||||
return AjaxResult.success(page);
|
||||
return R.ok(page);
|
||||
}
|
||||
|
||||
private static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
|
||||
@@ -681,7 +681,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult flowRecord(String procInsId, String deployId) {
|
||||
public R flowRecord(String procInsId, String deployId) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (StringUtils.isNotBlank(procInsId)) {
|
||||
List<HistoricActivityInstance> list = historyService
|
||||
@@ -746,11 +746,11 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
if (StringUtils.isNotBlank(deployId)) {
|
||||
SysForm sysForm = sysInstanceFormService.selectSysDeployFormByDeployId(deployId);
|
||||
if (Objects.isNull(sysForm)) {
|
||||
return AjaxResult.error("请先配置流程表单");
|
||||
return R.fail("请先配置流程表单");
|
||||
}
|
||||
map.put("formData", JsonUtils.parseObject(sysForm.getFormContent(), Map.class));
|
||||
}
|
||||
return AjaxResult.success(map);
|
||||
return R.ok(map);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -820,7 +820,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult getFlowViewer(String procInsId) {
|
||||
public R getFlowViewer(String procInsId) {
|
||||
// 构建查询条件
|
||||
HistoricActivityInstanceQuery query = historyService.createHistoricActivityInstanceQuery()
|
||||
.processInstanceId(procInsId);
|
||||
@@ -833,7 +833,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
.stream().distinct().map(HistoricActivityInstance::getActivityId)
|
||||
.collect(Collectors.toList());
|
||||
// 构建视图类
|
||||
return AjaxResult.success(new FlowViewerVo(finishedTaskList, unfinishedTaskList));
|
||||
return R.ok(new FlowViewerVo(finishedTaskList, unfinishedTaskList));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -843,14 +843,14 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult processVariables(String taskId) {
|
||||
public R processVariables(String taskId) {
|
||||
// 流程变量
|
||||
HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().finished().taskId(taskId).singleResult();
|
||||
if (Objects.nonNull(historicTaskInstance)) {
|
||||
return AjaxResult.success(historicTaskInstance.getProcessVariables());
|
||||
return R.ok(historicTaskInstance.getProcessVariables());
|
||||
} else {
|
||||
Map<String, Object> variables = taskService.getVariables(taskId);
|
||||
return AjaxResult.success(variables);
|
||||
return R.ok(variables);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -861,7 +861,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult getNextFlowNode(FlowTaskVo flowTaskVo) {
|
||||
public R getNextFlowNode(FlowTaskVo flowTaskVo) {
|
||||
Task task = taskService.createTaskQuery().taskId(flowTaskVo.getTaskId()).singleResult();
|
||||
FlowNextDto flowNextDto = new FlowNextDto();
|
||||
if (Objects.nonNull(task)) {
|
||||
@@ -911,10 +911,10 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return AjaxResult.success("流程已完结", null);
|
||||
return R.ok("流程已完结", null);
|
||||
}
|
||||
}
|
||||
return AjaxResult.success(flowNextDto);
|
||||
return R.ok(flowNextDto);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user