|
|
|
@ -1,16 +1,16 @@
|
|
|
|
|
package com.ruoyi.flowable.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import com.ruoyi.flowable.common.constant.ProcessConstants;
|
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
|
|
import com.ruoyi.flowable.common.enums.FlowComment;
|
|
|
|
|
import com.ruoyi.common.exception.CustomException;
|
|
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
|
import com.ruoyi.flowable.common.constant.ProcessConstants;
|
|
|
|
|
import com.ruoyi.flowable.common.enums.FlowComment;
|
|
|
|
|
import com.ruoyi.flowable.domain.dto.FlowCommentDto;
|
|
|
|
|
import com.ruoyi.flowable.domain.dto.FlowNextDto;
|
|
|
|
|
import com.ruoyi.flowable.domain.dto.FlowTaskDto;
|
|
|
|
@ -22,25 +22,22 @@ import com.ruoyi.flowable.flow.FindNextNodeUtil;
|
|
|
|
|
import com.ruoyi.flowable.flow.FlowableUtils;
|
|
|
|
|
import com.ruoyi.flowable.service.IFlowTaskService;
|
|
|
|
|
import com.ruoyi.flowable.service.ISysDeployFormService;
|
|
|
|
|
import com.ruoyi.system.domain.SysForm;
|
|
|
|
|
import com.ruoyi.system.service.ISysRoleService;
|
|
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
|
|
import org.apache.commons.collections4.MapUtils;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.flowable.bpmn.model.Process;
|
|
|
|
|
import org.flowable.bpmn.model.*;
|
|
|
|
|
import org.flowable.common.engine.api.FlowableException;
|
|
|
|
|
import org.flowable.common.engine.api.FlowableObjectNotFoundException;
|
|
|
|
|
import org.flowable.common.engine.api.query.QueryProperty;
|
|
|
|
|
import org.flowable.common.engine.impl.identity.Authentication;
|
|
|
|
|
import org.flowable.engine.ProcessEngineConfiguration;
|
|
|
|
|
import org.flowable.engine.history.HistoricActivityInstance;
|
|
|
|
|
import org.flowable.engine.history.HistoricProcessInstance;
|
|
|
|
|
import org.flowable.engine.history.HistoricProcessInstanceQuery;
|
|
|
|
|
import org.flowable.engine.impl.ActivityInstanceQueryProperty;
|
|
|
|
|
import org.flowable.engine.repository.ProcessDefinition;
|
|
|
|
|
import org.flowable.engine.runtime.ActivityInstance;
|
|
|
|
|
import org.flowable.engine.runtime.Execution;
|
|
|
|
|
import org.flowable.engine.runtime.ProcessInstance;
|
|
|
|
|
import org.flowable.engine.task.Comment;
|
|
|
|
@ -413,12 +410,35 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public AjaxResult myProcess(Integer pageNum, Integer pageSize) {
|
|
|
|
|
Page<FlowTaskDto> page = new Page<>();
|
|
|
|
|
|
|
|
|
|
Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
|
|
|
|
|
HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery()
|
|
|
|
|
.startedBy(userId.toString())
|
|
|
|
|
.orderByProcessInstanceStartTime()
|
|
|
|
|
.desc();
|
|
|
|
|
return AjaxResult.success(buildFlowTask(pageNum, pageSize, historicProcessInstanceQuery));
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 所有流程
|
|
|
|
|
*
|
|
|
|
|
* @param pageNum
|
|
|
|
|
* @param pageSize
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public AjaxResult allProcess(Integer pageNum, Integer pageSize) {
|
|
|
|
|
// 管理员才有权查询此接口
|
|
|
|
|
|
|
|
|
|
HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery()
|
|
|
|
|
.orderByProcessInstanceStartTime()
|
|
|
|
|
.includeProcessVariables()
|
|
|
|
|
.desc();
|
|
|
|
|
return AjaxResult.success(buildFlowTask(pageNum, pageSize, historicProcessInstanceQuery));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Page<FlowTaskDto> buildFlowTask(Integer pageNum, Integer pageSize, HistoricProcessInstanceQuery historicProcessInstanceQuery) {
|
|
|
|
|
|
|
|
|
|
Page<FlowTaskDto> page = new Page<>();
|
|
|
|
|
List<HistoricProcessInstance> historicProcessInstances = historicProcessInstanceQuery.listPage(pageSize * (pageNum - 1), pageSize);
|
|
|
|
|
page.setTotal(historicProcessInstanceQuery.count());
|
|
|
|
|
List<FlowTaskDto> flowList = new ArrayList<>();
|
|
|
|
@ -445,6 +465,12 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
|
|
|
|
flowTask.setProcDefVersion(pd.getVersion());
|
|
|
|
|
flowTask.setCategory(pd.getCategory());
|
|
|
|
|
flowTask.setProcDefVersion(pd.getVersion());
|
|
|
|
|
if (MapUtils.isNotEmpty(hisIns.getProcessVariables())
|
|
|
|
|
&& hisIns.getProcessVariables().containsKey("submitDate")
|
|
|
|
|
&& StringUtils.isNotBlank(MapUtils.getString(hisIns.getProcessVariables(), "submitDate"))) {
|
|
|
|
|
String submitDate = MapUtils.getString(hisIns.getProcessVariables(), "submitDate");
|
|
|
|
|
flowTask.setCreateTime(DateUtil.parse(submitDate));
|
|
|
|
|
}
|
|
|
|
|
// 当前所处流程 todo: 本地启动放开以下注释
|
|
|
|
|
// List<Task> taskList = taskService.createTaskQuery().processInstanceId(hisIns.getId()).list();
|
|
|
|
|
// if (CollectionUtils.isNotEmpty(taskList)) {
|
|
|
|
@ -456,7 +482,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
|
|
|
|
flowList.add(flowTask);
|
|
|
|
|
}
|
|
|
|
|
page.setRecords(flowList);
|
|
|
|
|
return AjaxResult.success(page);
|
|
|
|
|
return page;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -889,6 +915,19 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public AjaxResult updateVariablesSubmitDate(String processInstanceId, String submitDate) {
|
|
|
|
|
if (StringUtils.isBlank(processInstanceId) || StringUtils.isBlank(submitDate)) {
|
|
|
|
|
return AjaxResult.error("更新提交时间失败,参数无效");
|
|
|
|
|
}
|
|
|
|
|
Execution execution = runtimeService.createExecutionQuery().processInstanceId(processInstanceId).variableExists("submitDate").singleResult();
|
|
|
|
|
if (Objects.isNull(execution)) {
|
|
|
|
|
return AjaxResult.error("更新提交时间失败,查询错误");
|
|
|
|
|
}
|
|
|
|
|
runtimeService.setVariable(execution.getId(),"submitDate",submitDate);
|
|
|
|
|
return AjaxResult.success();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取下一节点
|
|
|
|
|
*
|
|
|
|
@ -986,4 +1025,4 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
|
|
|
|
return 0 + "秒";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|