增加序列号
This commit is contained in:
parent
3c1d31cdfc
commit
c8a0472d9e
|
@ -9,6 +9,7 @@ import com.snow.common.utils.StringUtils;
|
|||
import com.snow.flowable.domain.CompleteTaskDTO;
|
||||
import com.snow.flowable.domain.FileEntry;
|
||||
import com.snow.flowable.domain.FinishTaskDTO;
|
||||
import com.snow.flowable.domain.TaskVO;
|
||||
import com.snow.flowable.service.impl.FlowableServiceImpl;
|
||||
import com.snow.framework.util.ShiroUtils;
|
||||
import com.snow.system.domain.SysOaLeave;
|
||||
|
@ -101,4 +102,16 @@ public class FlowController {
|
|||
flowableService.completeTask(completeTaskDTO);
|
||||
return AjaxResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有节点
|
||||
* @param processInstanceId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getDynamicFlowNodeInfo")
|
||||
@ResponseBody
|
||||
public AjaxResult getDynamicFlowNodeInfo(String processInstanceId){
|
||||
List<TaskVO> dynamicFlowNodeInfo = flowableService.getDynamicFlowNodeInfo(processInstanceId);
|
||||
return AjaxResult.success(dynamicFlowNodeInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
package com.snow.flowable;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.snow.JunitTestApplication;
|
||||
import com.snow.flowable.domain.DeploymentQueryDTO;
|
||||
import com.snow.flowable.domain.StartProcessDTO;
|
||||
import com.snow.flowable.domain.TaskVO;
|
||||
import com.snow.flowable.service.FlowableService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -44,4 +47,9 @@ public class FlowableServiceTests extends JunitTestApplication {
|
|||
flowableService.getDeploymentList(startProcessDTO);
|
||||
|
||||
}
|
||||
@Test
|
||||
public void getDynamicFlowNodeInfo(){
|
||||
List<TaskVO> dynamicFlowNodeInfo = flowableService.getDynamicFlowNodeInfo("38505061-2d6b-11eb-b0ec-040e3c9c6b2f");
|
||||
log.info(JSON.toJSONString(dynamicFlowNodeInfo));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package com.snow.flowable.common;
|
||||
|
||||
|
||||
|
||||
import org.flowable.common.engine.impl.de.odysseus.el.ExpressionFactoryImpl;
|
||||
import org.flowable.common.engine.impl.de.odysseus.el.util.SimpleContext;
|
||||
import org.flowable.common.engine.impl.javax.el.ExpressionFactory;
|
||||
import org.flowable.common.engine.impl.javax.el.ValueExpression;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author qimingjin
|
||||
* @Title:
|
||||
* @Description:
|
||||
* @date 2020/11/24 14:21
|
||||
*/
|
||||
public class ConditionElUtil {
|
||||
private ConditionElUtil() {
|
||||
|
||||
}
|
||||
|
||||
public static Boolean checkFormDataByRuleEl(String el, Map<String, Object> formData) {
|
||||
|
||||
ExpressionFactory factory = new ExpressionFactoryImpl();
|
||||
SimpleContext context = new SimpleContext();
|
||||
|
||||
for (Map.Entry<String, Object> entry : formData.entrySet()) {
|
||||
Object value = entry.getValue();
|
||||
if (value != null) {
|
||||
context.setVariable(entry.getKey(), factory.createValueExpression(value, value.getClass()));
|
||||
}
|
||||
}
|
||||
ValueExpression e = factory.createValueExpression(context, el, Boolean.class);
|
||||
return (Boolean) e.getValue(context);
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String el = "${请假天数>3 && 部门 == '产品部'}";
|
||||
Map<String, Object> formData = new HashMap<>();
|
||||
formData.put("请假天数", 1);
|
||||
formData.put("部门", "产品部");
|
||||
System.out.println(ConditionElUtil.checkFormDataByRuleEl(el, formData));
|
||||
}
|
||||
}
|
|
@ -18,51 +18,42 @@ import java.util.Map;
|
|||
public class Task implements Serializable {
|
||||
private String id;
|
||||
|
||||
String getName;
|
||||
String name;
|
||||
|
||||
String getDescription;
|
||||
String description;
|
||||
|
||||
int getPriority;
|
||||
int priority;
|
||||
|
||||
String getOwner;
|
||||
String owner;
|
||||
|
||||
String getAssignee;
|
||||
String assignee;
|
||||
|
||||
String getProcessInstanceId;
|
||||
String processInstanceId;
|
||||
|
||||
String getExecutionId;
|
||||
String executionId;
|
||||
|
||||
String getTaskDefinitionId;
|
||||
String taskDefinitionId;
|
||||
|
||||
String getProcessDefinitionId;
|
||||
String processDefinitionId;
|
||||
|
||||
String getScopeId;
|
||||
String scopeId;
|
||||
|
||||
String getSubScopeId;
|
||||
|
||||
String getScopeType;
|
||||
|
||||
String getScopeDefinitionId;
|
||||
Date createTime;
|
||||
|
||||
Date getCreateTime;
|
||||
String taskDefinitionKey;
|
||||
|
||||
String getTaskDefinitionKey;
|
||||
Date dueDate;
|
||||
|
||||
Date getDueDate;
|
||||
String category;
|
||||
|
||||
String getCategory;
|
||||
String parentTaskId;
|
||||
|
||||
String getParentTaskId;
|
||||
String tenantId;
|
||||
|
||||
String getTenantId;
|
||||
String formKey;
|
||||
|
||||
String getFormKey;
|
||||
|
||||
Map<String, Object> getTaskLocalVariables;
|
||||
|
||||
Map<String, Object> getProcessVariables;
|
||||
|
||||
List<? extends IdentityLinkInfo> getIdentityLinks;
|
||||
|
||||
Date getClaimTime;
|
||||
Date claimTime;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import lombok.NoArgsConstructor;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qimingjin
|
||||
|
@ -39,7 +40,9 @@ public class TaskVO implements Serializable {
|
|||
private String parentTaskId;
|
||||
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 任务处理人
|
||||
*/
|
||||
private String Assignee;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
|
@ -61,4 +64,32 @@ public class TaskVO implements Serializable {
|
|||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date startTime;
|
||||
|
||||
/**
|
||||
* 任务完成时间
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date completeTime;
|
||||
|
||||
/**
|
||||
* 处理任务时间
|
||||
*/
|
||||
private String handleTaskTime;
|
||||
/**
|
||||
* 任务状态(0--待处理,1--已处理)
|
||||
*/
|
||||
private Integer taskStatus=0;
|
||||
/**
|
||||
* 下个节点
|
||||
*/
|
||||
private String nextTaskName;
|
||||
/**
|
||||
* 任务定义key
|
||||
*/
|
||||
private String taskDefinitionKey;
|
||||
/**
|
||||
* 任务待处理人
|
||||
*/
|
||||
private List<String> handleNameList;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package com.snow.flowable.service;
|
||||
|
||||
/**
|
||||
* @author qimingjin
|
||||
* @Title:
|
||||
* @Description:
|
||||
* @date 2020/11/24 10:08
|
||||
*/
|
||||
public interface ExpressionService {
|
||||
Object getValue(String processInstanceId, String exp);
|
||||
|
||||
// <T> T getValue(String processInstanceId, String exp, Class<T> clazz);
|
||||
}
|
|
@ -4,6 +4,7 @@ import com.snow.flowable.domain.*;
|
|||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.flowable.task.api.history.HistoricTaskInstance;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
@ -90,5 +91,23 @@ public interface FlowableService {
|
|||
*/
|
||||
HistoricProcessInstance getHistoricProcessInstanceById(String id);
|
||||
|
||||
/**
|
||||
* 根据流程实例ID查询任务
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Task getTaskProcessInstanceById(String id);
|
||||
|
||||
/**
|
||||
* 获取历史任务
|
||||
* @param task
|
||||
* @return
|
||||
*/
|
||||
List<HistoricTaskInstance> getHistoricTaskInstance(com.snow.flowable.domain.Task task);
|
||||
|
||||
/**
|
||||
* 动态获取流程节点审批信息
|
||||
* @param processInstanceId
|
||||
*/
|
||||
List<TaskVO> getDynamicFlowNodeInfo(String processInstanceId);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package com.snow.flowable.service.impl;
|
||||
|
||||
import com.snow.flowable.service.ExpressionService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.common.engine.api.delegate.Expression;
|
||||
import org.flowable.common.engine.impl.de.odysseus.el.misc.TypeConverter;
|
||||
import org.flowable.common.engine.impl.de.odysseus.el.misc.TypeConverterImpl;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author qimingjin
|
||||
* @Title:
|
||||
* @Description:
|
||||
* @date 2020/11/24 10:09
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ExpressionServiceImpl implements ExpressionService {
|
||||
|
||||
@Autowired
|
||||
protected ProcessEngineConfigurationImpl processEngineConfiguration;
|
||||
|
||||
@Autowired
|
||||
private RuntimeService runtimeService;
|
||||
|
||||
//@Autowired
|
||||
private TypeConverter typeConverter;
|
||||
@Override
|
||||
public Object getValue(String processInstanceId, String exp) {
|
||||
Expression expression = processEngineConfiguration.getExpressionManager().createExpression(exp);
|
||||
ExecutionEntity executionEntity = (ExecutionEntity) runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).includeProcessVariables().singleResult();
|
||||
return expression.getValue(executionEntity);
|
||||
}
|
||||
|
||||
/*@Override
|
||||
public <T> T getValue(String processInstanceId, String exp, Class<T> clazz) {
|
||||
Object value = this.getValue(processInstanceId, exp);
|
||||
return typeConverter.convert(value, clazz);
|
||||
}*/
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.snow.flowable.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.snow.common.core.text.Convert;
|
||||
import com.snow.common.exception.BusinessException;
|
||||
|
@ -8,24 +9,29 @@ import com.snow.flowable.domain.*;
|
|||
import com.snow.flowable.service.FlowableService;
|
||||
import com.snow.system.domain.SysRole;
|
||||
import com.snow.system.domain.SysUser;
|
||||
import com.snow.system.mapper.SysUserMapper;
|
||||
import com.snow.system.service.ISysRoleService;
|
||||
import com.snow.system.service.impl.SysUserServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.bpmn.model.EndEvent;
|
||||
import org.flowable.bpmn.model.FlowNode;
|
||||
import org.flowable.bpmn.model.*;
|
||||
import org.flowable.bpmn.model.Process;
|
||||
import org.flowable.common.engine.impl.util.IoUtil;
|
||||
import org.flowable.engine.*;
|
||||
import org.flowable.engine.history.HistoricActivityInstance;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.repository.*;
|
||||
import org.flowable.engine.impl.el.JuelExpression;
|
||||
import org.flowable.engine.repository.Deployment;
|
||||
import org.flowable.engine.repository.DeploymentQuery;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.flowable.engine.repository.ProcessDefinitionQuery;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.flowable.image.ProcessDiagramGenerator;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.flowable.task.api.TaskQuery;
|
||||
import org.flowable.task.service.impl.TaskQueryProperty;
|
||||
import org.flowable.ui.modeler.rest.app.AbstractModelBpmnResource;
|
||||
import org.flowable.task.api.history.HistoricTaskInstance;
|
||||
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
|
||||
import org.flowable.variable.api.history.HistoricVariableInstance;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -33,6 +39,7 @@ import org.springframework.util.CollectionUtils;
|
|||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -43,6 +50,9 @@ import java.util.stream.Collectors;
|
|||
* @author qimingjin
|
||||
* @Title:
|
||||
* @Description:
|
||||
* 运行时流程人员表(act_ru_identitylink)
|
||||
*
|
||||
* 任务参与者数据表。主要存储当前节点参与者的信息。
|
||||
* @date 2020/11/19 17:27
|
||||
*/
|
||||
@Slf4j
|
||||
|
@ -72,6 +82,12 @@ public class FlowableServiceImpl implements FlowableService {
|
|||
@Autowired
|
||||
private SysUserServiceImpl sysUserService;
|
||||
|
||||
@Autowired
|
||||
private ExpressionServiceImpl expressionService;
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public List<DeploymentVO> getDeploymentList(DeploymentQueryDTO deploymentQueryDTO) {
|
||||
|
@ -91,19 +107,6 @@ public class FlowableServiceImpl implements FlowableService {
|
|||
}
|
||||
List<Deployment> deployments = deploymentQuery.orderByDeploymenTime().desc().
|
||||
listPage(deploymentQueryDTO.getFirstResult(), deploymentQueryDTO.getMaxResults());
|
||||
/*List<DeploymentVO> deploymentVOList = deployments.stream().map(deployment -> {
|
||||
DeploymentVO deploymentVO = new DeploymentVO();
|
||||
ModelQuery modelQuery = repositoryService.createModelQuery();
|
||||
List<Model> modelList = modelQuery.deploymentId(deployment.getId()).list();
|
||||
List<ModelVO> modelVoList = modelList.stream().map(model -> {
|
||||
ModelVO modelVO = new ModelVO();
|
||||
BeanUtils.copyProperties(model, modelVO);
|
||||
return modelVO;
|
||||
}).collect(Collectors.toList());
|
||||
BeanUtils.copyProperties(deployment, deploymentVO);
|
||||
deploymentVO.setModelVOList(modelVoList);
|
||||
return deploymentVO;
|
||||
}).collect(Collectors.toList());*/
|
||||
List<DeploymentVO> deploymentVOList = deployments.stream().map(t -> {
|
||||
DeploymentVO deploymentVO = new DeploymentVO();
|
||||
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
|
||||
|
@ -281,27 +284,45 @@ public class FlowableServiceImpl implements FlowableService {
|
|||
*/
|
||||
String processDefinitionId = "";
|
||||
if (this.isFinished(processId)) {// 如果流程已经结束,则得到结束节点
|
||||
HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().processInstanceId(processId).singleResult();
|
||||
HistoricProcessInstance pi = historyService.createHistoricProcessInstanceQuery().
|
||||
processInstanceId(processId)
|
||||
.singleResult();
|
||||
|
||||
processDefinitionId=pi.getProcessDefinitionId();
|
||||
} else {// 如果流程没有结束,则取当前活动节点
|
||||
// 根据流程实例ID获得当前处于活动状态的ActivityId合集
|
||||
ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processId).singleResult();
|
||||
ProcessInstance pi = runtimeService.createProcessInstanceQuery().
|
||||
processInstanceId(processId).
|
||||
singleResult();
|
||||
processDefinitionId=pi.getProcessDefinitionId();
|
||||
}
|
||||
//活动节点
|
||||
List<String> highLightedActivitis = new ArrayList<String>();
|
||||
|
||||
//线节点
|
||||
List<String> flows = new ArrayList<>();
|
||||
/**
|
||||
* 获得活动的节点
|
||||
* 获得所有的历史活动的节点对象
|
||||
*/
|
||||
List<HistoricActivityInstance> highLightedActivitList = historyService.createHistoricActivityInstanceQuery().processInstanceId(processId).orderByHistoricActivityInstanceStartTime().asc().list();
|
||||
List<HistoricActivityInstance> highLightedActivitList = historyService.createHistoricActivityInstanceQuery().
|
||||
processInstanceId(processId).
|
||||
orderByHistoricActivityInstanceStartTime().
|
||||
asc().
|
||||
list();
|
||||
|
||||
for(HistoricActivityInstance tempActivity : highLightedActivitList){
|
||||
String activityType = tempActivity.getActivityType();
|
||||
if (activityType.equals("sequenceFlow") || activityType.equals("exclusiveGateway")) {
|
||||
flows.add(tempActivity.getActivityId());
|
||||
} else if (activityType.equals("startEvent")) {
|
||||
String activityId = tempActivity.getActivityId();
|
||||
highLightedActivitis.add(activityId);
|
||||
}
|
||||
|
||||
List<String> flows = new ArrayList<>();
|
||||
}
|
||||
//现在正处的节点
|
||||
List<Task> tasks = taskService.createTaskQuery().processInstanceId(processId).list();
|
||||
for (Task task : tasks) {
|
||||
highLightedActivitis.add(task.getTaskDefinitionKey());
|
||||
}
|
||||
//获取流程图
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId);
|
||||
ProcessEngineConfiguration engconf = processEngine.getProcessEngineConfiguration();
|
||||
|
@ -350,4 +371,220 @@ public class FlowableServiceImpl implements FlowableService {
|
|||
.processInstanceId(id)
|
||||
.singleResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<HistoricTaskInstance> getHistoricTaskInstance(com.snow.flowable.domain.Task task){
|
||||
HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery();
|
||||
if(!StringUtils.isEmpty(task.getProcessInstanceId())){
|
||||
historicTaskInstanceQuery= historicTaskInstanceQuery.processInstanceId(task.getProcessInstanceId());
|
||||
}
|
||||
if(!StringUtils.isEmpty(task.getTaskDefinitionKey())){
|
||||
historicTaskInstanceQuery.processInstanceId(task.getTaskDefinitionKey());
|
||||
}
|
||||
if(!StringUtils.isEmpty(task.getAssignee())){
|
||||
historicTaskInstanceQuery.taskAssignee(task.getAssignee());
|
||||
}
|
||||
List<HistoricTaskInstance> list = historicTaskInstanceQuery.orderByTaskCreateTime().asc().list();
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 思路就是我们取出节点的表达式,然后用我们流程实例的变量来给他翻译出来即可
|
||||
* @param processInstanceId
|
||||
*/
|
||||
@Override
|
||||
public List<TaskVO> getDynamicFlowNodeInfo(String processInstanceId) {
|
||||
//获取历史变量表
|
||||
/* List<HistoricVariableInstance> historicVariableInstanceList = historyService.createHistoricVariableInstanceQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.list();*/
|
||||
HistoricProcessInstance processInstance= getHistoricProcessInstanceById(processInstanceId);
|
||||
List<TaskVO> hisTaskVOList=Lists.newArrayList();
|
||||
com.snow.flowable.domain.Task task=new com.snow.flowable.domain.Task();
|
||||
task.setProcessInstanceId(processInstanceId);
|
||||
List<HistoricTaskInstance> historicTaskInstance = getHistoricTaskInstance(task);
|
||||
if(!CollectionUtils.isEmpty(historicTaskInstance)){
|
||||
hisTaskVOList = historicTaskInstance.stream().map(t -> {
|
||||
TaskVO taskVO = new TaskVO();
|
||||
taskVO.setTaskName(t.getName());
|
||||
taskVO.setProcessInstanceId(t.getProcessInstanceId());
|
||||
taskVO.setStartUserId(processInstance.getStartUserId());
|
||||
taskVO.setStartUserName(getUserNameById(processInstance.getStartUserId()));
|
||||
taskVO.setTaskDefinitionKey(t.getTaskDefinitionKey());
|
||||
if (!StringUtils.isEmpty(t.getCreateTime())) {
|
||||
taskVO.setCreateDate(t.getCreateTime());
|
||||
}
|
||||
if (!StringUtils.isEmpty(t.getEndTime())) {
|
||||
taskVO.setCompleteTime(t.getEndTime());
|
||||
}
|
||||
|
||||
if (!StringUtils.isEmpty(t.getAssignee())) {
|
||||
taskVO.setAssignee(getUserNameById(t.getAssignee()));
|
||||
}else {
|
||||
|
||||
}
|
||||
return taskVO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
List<TaskVO> futureTask = getFutureTask(processInstance);
|
||||
for(int i=0;i<hisTaskVOList.size();i++){
|
||||
for(int j=0;j<futureTask.size();j++){
|
||||
if(hisTaskVOList.get(i).getTaskName().equals(futureTask.get(j).getTaskName())&&CollectionUtils.isEmpty(futureTask.get(j).getHandleNameList())){
|
||||
futureTask.remove(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
hisTaskVOList.addAll(futureTask);
|
||||
return hisTaskVOList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有的任务节点
|
||||
* @param processInstance
|
||||
* @return
|
||||
*/
|
||||
public List<TaskVO> getFutureTask(HistoricProcessInstance processInstance){
|
||||
String processInstanceId=processInstance.getId();
|
||||
String startUserId=processInstance.getStartUserId();
|
||||
List<TaskVO> taskVOList=Lists.newArrayList();
|
||||
|
||||
List<Process> processes = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId()).getProcesses();
|
||||
if(!CollectionUtils.isEmpty(processes)){
|
||||
processes.stream().forEach(process -> {
|
||||
Collection<FlowElement> flowElements = process. getFlowElements();
|
||||
for(FlowElement flowElement:flowElements){
|
||||
if(flowElement instanceof UserTask){
|
||||
List<String> handleNameList=Lists.newArrayList();
|
||||
UserTask userTask=(UserTask)flowElement;
|
||||
//固定人
|
||||
String assignee=userTask.getAssignee();
|
||||
List<String> candidateGroups = userTask.getCandidateGroups();
|
||||
List<String> candidateUsers = userTask.getCandidateUsers();
|
||||
if(!CollectionUtils.isEmpty(candidateUsers)){
|
||||
//获取的是多实例会签
|
||||
MultiInstanceLoopCharacteristics loopCharacteristics = userTask.getLoopCharacteristics();
|
||||
if(loopCharacteristics == null){
|
||||
String expressionValue=null;
|
||||
if(userTask.getId().equals("userTask0")){
|
||||
expressionValue = processInstance.getStartUserId();
|
||||
handleNameList.add(expressionValue);
|
||||
}else {
|
||||
for (String candidateUser:candidateUsers){
|
||||
if(com.snow.common.utils.StringUtils.isNumeric(candidateUser)){
|
||||
SysUser sysUser = sysUserService.selectUserById(Long.parseLong(candidateUser));
|
||||
handleNameList.add(sysUser.getUserName());
|
||||
}else {
|
||||
//获取表达式的值
|
||||
// expressionValue =(String) expressionService.getValue(processInstanceId,candidateUser);
|
||||
//先这样写
|
||||
handleNameList.add(candidateUser);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
TaskVO.TaskVOBuilder taskVOBuilder = TaskVO.builder().taskName(userTask.getName()).
|
||||
handleNameList(handleNameList).
|
||||
taskDefinitionKey(userTask.getId()).
|
||||
startUserId(processInstance.getStartUserId());
|
||||
|
||||
if(com.snow.common.utils.StringUtils.isNumeric(startUserId)){
|
||||
taskVOBuilder.startUserName(getUserNameById(startUserId));
|
||||
}else {
|
||||
taskVOBuilder.startUserName(startUserId);
|
||||
}
|
||||
TaskVO taskVO = taskVOBuilder.build();
|
||||
taskVOList.add(taskVO);
|
||||
}
|
||||
//todo 多实例会签出来
|
||||
else {
|
||||
String inputDataItem = loopCharacteristics.getInputDataItem();
|
||||
List<String> values = (List)expressionService.getValue(processInstanceId, inputDataItem);
|
||||
System.out.println(JSON.toJSON(values));
|
||||
}
|
||||
}
|
||||
if(!CollectionUtils.isEmpty(candidateGroups)){
|
||||
//获取的是多实例会签
|
||||
MultiInstanceLoopCharacteristics loopCharacteristics = userTask.getLoopCharacteristics();
|
||||
if(loopCharacteristics == null){
|
||||
String expressionValue=null;
|
||||
if(userTask.getId().equals("userTask0")){
|
||||
expressionValue = processInstance.getStartUserId();
|
||||
handleNameList.add(expressionValue);
|
||||
}else {
|
||||
for (String candidateGroup:candidateGroups){
|
||||
if(com.snow.common.utils.StringUtils.isNumeric(candidateGroup)){
|
||||
List<SysUser> sysUsers = sysUserMapper.selectUserListByRoleId(candidateGroup);
|
||||
if(!CollectionUtils.isEmpty(sysUsers)){
|
||||
List<String> collect = sysUsers.stream().map(SysUser::getUserName).collect(Collectors.toList());
|
||||
handleNameList.addAll(collect);
|
||||
}
|
||||
}else {
|
||||
//获取表达式的值
|
||||
expressionValue =(String) expressionService.getValue(processInstanceId,candidateGroup);
|
||||
//先这样写
|
||||
handleNameList.add(candidateGroup);
|
||||
}
|
||||
}
|
||||
TaskVO.TaskVOBuilder taskVOBuilder = TaskVO.builder().taskName(userTask.getName()).
|
||||
handleNameList(handleNameList).
|
||||
taskDefinitionKey(userTask.getId()).
|
||||
startUserId(processInstance.getStartUserId());
|
||||
|
||||
if(com.snow.common.utils.StringUtils.isNumeric(startUserId)){
|
||||
taskVOBuilder.startUserName(getUserNameById(startUserId));
|
||||
}else {
|
||||
taskVOBuilder.startUserName(startUserId);
|
||||
}
|
||||
TaskVO taskVO = taskVOBuilder.build();
|
||||
taskVOList.add(taskVO);
|
||||
}
|
||||
}
|
||||
//todo 多实例会签出来
|
||||
else {
|
||||
String inputDataItem = loopCharacteristics.getInputDataItem();
|
||||
List<String> values = (List)expressionService.getValue(processInstanceId, inputDataItem);
|
||||
System.out.println(JSON.toJSON(values));
|
||||
}
|
||||
}
|
||||
if(!StringUtils.isEmpty(userTask.getAssignee())){
|
||||
MultiInstanceLoopCharacteristics loopCharacteristics = userTask.getLoopCharacteristics();
|
||||
if(loopCharacteristics == null){
|
||||
String expressionValue=null;
|
||||
if(userTask.getName().equals("")){
|
||||
expressionValue = processInstance.getStartUserId();
|
||||
}else {
|
||||
//获取表达式的值
|
||||
expressionValue =(String) expressionService.getValue(processInstanceId, userTask.getAssignee());
|
||||
handleNameList.add(expressionValue);
|
||||
}
|
||||
}else {
|
||||
String inputDataItem = loopCharacteristics.getInputDataItem();
|
||||
List<String> values = (List)expressionService.getValue(processInstanceId, inputDataItem);
|
||||
System.out.println(JSON.toJSON(values));
|
||||
}
|
||||
TaskVO.TaskVOBuilder taskVOBuilder = TaskVO.builder().taskName(userTask.getName()).
|
||||
handleNameList(handleNameList).
|
||||
taskDefinitionKey(userTask.getId()).
|
||||
startUserId(processInstance.getStartUserId());
|
||||
|
||||
if(com.snow.common.utils.StringUtils.isNumeric(startUserId)){
|
||||
taskVOBuilder.startUserName(getUserNameById(startUserId));
|
||||
}else {
|
||||
taskVOBuilder.startUserName(startUserId);
|
||||
}
|
||||
TaskVO taskVO = taskVOBuilder.build();
|
||||
taskVOList.add(taskVO);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return taskVOList;
|
||||
}
|
||||
|
||||
public String getUserNameById(String id){
|
||||
return sysUserService.selectUserById(Long.parseLong(id)).getUserName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,13 @@ public interface SysUserMapper
|
|||
*/
|
||||
public List<SysUser> selectAllocatedList(SysUser user);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param roleId
|
||||
* @return
|
||||
*/
|
||||
public List<SysUser> selectUserListByRoleId(String roleId);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询未分配用户角色列表
|
||||
*
|
||||
|
|
|
@ -108,7 +108,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<!-- 数据范围过滤 -->
|
||||
${params.dataScope}
|
||||
</select>
|
||||
<select id="selectUserListByRoleId" parameterType="string" resultMap="SysUserResult">
|
||||
select distinct u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.status, u.create_time
|
||||
from sys_user u
|
||||
left join sys_user_role r on r.user_id = u.user_id
|
||||
where u.del_flag = '0' and r.role_id = #{roleId}
|
||||
|
||||
</select>
|
||||
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||
select distinct u.user_id, u.dept_id, u.login_name, u.user_name, u.user_type, u.email, u.avatar, u.phonenumber, u.status, u.create_time
|
||||
from sys_user u
|
||||
|
|
Loading…
Reference in New Issue