diff --git a/snow-admin/src/main/java/com/snow/web/controller/flowable/FlowController.java b/snow-admin/src/main/java/com/snow/web/controller/flowable/FlowController.java index d504b61..c454def 100644 --- a/snow-admin/src/main/java/com/snow/web/controller/flowable/FlowController.java +++ b/snow-admin/src/main/java/com/snow/web/controller/flowable/FlowController.java @@ -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 dynamicFlowNodeInfo = flowableService.getDynamicFlowNodeInfo(processInstanceId); + return AjaxResult.success(dynamicFlowNodeInfo); + } } diff --git a/snow-admin/src/test/java/com.snow/flowable/FlowableServiceTests.java b/snow-admin/src/test/java/com.snow/flowable/FlowableServiceTests.java index ae9aaee..1185e98 100644 --- a/snow-admin/src/test/java/com.snow/flowable/FlowableServiceTests.java +++ b/snow-admin/src/test/java/com.snow/flowable/FlowableServiceTests.java @@ -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 dynamicFlowNodeInfo = flowableService.getDynamicFlowNodeInfo("38505061-2d6b-11eb-b0ec-040e3c9c6b2f"); + log.info(JSON.toJSONString(dynamicFlowNodeInfo)); + } } diff --git a/snow-flowable/src/main/java/com/snow/flowable/common/ConditionElUtil.java b/snow-flowable/src/main/java/com/snow/flowable/common/ConditionElUtil.java new file mode 100644 index 0000000..1447fae --- /dev/null +++ b/snow-flowable/src/main/java/com/snow/flowable/common/ConditionElUtil.java @@ -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 formData) { + + ExpressionFactory factory = new ExpressionFactoryImpl(); + SimpleContext context = new SimpleContext(); + + for (Map.Entry 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 formData = new HashMap<>(); + formData.put("请假天数", 1); + formData.put("部门", "产品部"); + System.out.println(ConditionElUtil.checkFormDataByRuleEl(el, formData)); + } +} \ No newline at end of file diff --git a/snow-flowable/src/main/java/com/snow/flowable/domain/Task.java b/snow-flowable/src/main/java/com/snow/flowable/domain/Task.java index e9cbc37..5723b7c 100644 --- a/snow-flowable/src/main/java/com/snow/flowable/domain/Task.java +++ b/snow-flowable/src/main/java/com/snow/flowable/domain/Task.java @@ -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 getTaskLocalVariables; - - Map getProcessVariables; - - List getIdentityLinks; - - Date getClaimTime; + Date claimTime; } diff --git a/snow-flowable/src/main/java/com/snow/flowable/domain/TaskVO.java b/snow-flowable/src/main/java/com/snow/flowable/domain/TaskVO.java index 5f8730b..467a4c7 100644 --- a/snow-flowable/src/main/java/com/snow/flowable/domain/TaskVO.java +++ b/snow-flowable/src/main/java/com/snow/flowable/domain/TaskVO.java @@ -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 handleNameList; } + diff --git a/snow-flowable/src/main/java/com/snow/flowable/service/ExpressionService.java b/snow-flowable/src/main/java/com/snow/flowable/service/ExpressionService.java new file mode 100644 index 0000000..452dd60 --- /dev/null +++ b/snow-flowable/src/main/java/com/snow/flowable/service/ExpressionService.java @@ -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 getValue(String processInstanceId, String exp, Class clazz); +} diff --git a/snow-flowable/src/main/java/com/snow/flowable/service/FlowableService.java b/snow-flowable/src/main/java/com/snow/flowable/service/FlowableService.java index 16769fe..079d829 100644 --- a/snow-flowable/src/main/java/com/snow/flowable/service/FlowableService.java +++ b/snow-flowable/src/main/java/com/snow/flowable/service/FlowableService.java @@ -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); - Task getTaskProcessInstanceById(String id); + /** + * 根据流程实例ID查询任务 + * @param id + * @return + */ + Task getTaskProcessInstanceById(String id); + + /** + * 获取历史任务 + * @param task + * @return + */ + List getHistoricTaskInstance(com.snow.flowable.domain.Task task); + + /** + * 动态获取流程节点审批信息 + * @param processInstanceId + */ + List getDynamicFlowNodeInfo(String processInstanceId); } diff --git a/snow-flowable/src/main/java/com/snow/flowable/service/impl/ExpressionServiceImpl.java b/snow-flowable/src/main/java/com/snow/flowable/service/impl/ExpressionServiceImpl.java new file mode 100644 index 0000000..e0ea89d --- /dev/null +++ b/snow-flowable/src/main/java/com/snow/flowable/service/impl/ExpressionServiceImpl.java @@ -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 getValue(String processInstanceId, String exp, Class clazz) { + Object value = this.getValue(processInstanceId, exp); + return typeConverter.convert(value, clazz); + }*/ +} diff --git a/snow-flowable/src/main/java/com/snow/flowable/service/impl/FlowableServiceImpl.java b/snow-flowable/src/main/java/com/snow/flowable/service/impl/FlowableServiceImpl.java index 6370fb7..0b90f2f 100644 --- a/snow-flowable/src/main/java/com/snow/flowable/service/impl/FlowableServiceImpl.java +++ b/snow-flowable/src/main/java/com/snow/flowable/service/impl/FlowableServiceImpl.java @@ -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 getDeploymentList(DeploymentQueryDTO deploymentQueryDTO) { @@ -91,19 +107,6 @@ public class FlowableServiceImpl implements FlowableService { } List deployments = deploymentQuery.orderByDeploymenTime().desc(). listPage(deploymentQueryDTO.getFirstResult(), deploymentQueryDTO.getMaxResults()); - /*List deploymentVOList = deployments.stream().map(deployment -> { - DeploymentVO deploymentVO = new DeploymentVO(); - ModelQuery modelQuery = repositoryService.createModelQuery(); - List modelList = modelQuery.deploymentId(deployment.getId()).list(); - List 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 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 highLightedActivitis = new ArrayList(); - + //线节点 + List flows = new ArrayList<>(); /** - * 获得活动的节点 + * 获得所有的历史活动的节点对象 */ - List highLightedActivitList = historyService.createHistoricActivityInstanceQuery().processInstanceId(processId).orderByHistoricActivityInstanceStartTime().asc().list(); + List highLightedActivitList = historyService.createHistoricActivityInstanceQuery(). + processInstanceId(processId). + orderByHistoricActivityInstanceStartTime(). + asc(). + list(); for(HistoricActivityInstance tempActivity : highLightedActivitList){ - String activityId = tempActivity.getActivityId(); - highLightedActivitis.add(activityId); + 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 tasks = taskService.createTaskQuery().processInstanceId(processId).list(); + for (Task task : tasks) { + highLightedActivitis.add(task.getTaskDefinitionKey()); } - - List flows = new ArrayList<>(); //获取流程图 BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinitionId); ProcessEngineConfiguration engconf = processEngine.getProcessEngineConfiguration(); @@ -350,4 +371,220 @@ public class FlowableServiceImpl implements FlowableService { .processInstanceId(id) .singleResult(); } + + @Override + public List 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 list = historicTaskInstanceQuery.orderByTaskCreateTime().asc().list(); + + return list; + } + + /** + * 思路就是我们取出节点的表达式,然后用我们流程实例的变量来给他翻译出来即可 + * @param processInstanceId + */ + @Override + public List getDynamicFlowNodeInfo(String processInstanceId) { + //获取历史变量表 + /* List historicVariableInstanceList = historyService.createHistoricVariableInstanceQuery() + .processInstanceId(processInstanceId) + .list();*/ + HistoricProcessInstance processInstance= getHistoricProcessInstanceById(processInstanceId); + List hisTaskVOList=Lists.newArrayList(); + com.snow.flowable.domain.Task task=new com.snow.flowable.domain.Task(); + task.setProcessInstanceId(processInstanceId); + List 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 futureTask = getFutureTask(processInstance); + for(int i=0;i getFutureTask(HistoricProcessInstance processInstance){ + String processInstanceId=processInstance.getId(); + String startUserId=processInstance.getStartUserId(); + List taskVOList=Lists.newArrayList(); + + List processes = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId()).getProcesses(); + if(!CollectionUtils.isEmpty(processes)){ + processes.stream().forEach(process -> { + Collection flowElements = process. getFlowElements(); + for(FlowElement flowElement:flowElements){ + if(flowElement instanceof UserTask){ + List handleNameList=Lists.newArrayList(); + UserTask userTask=(UserTask)flowElement; + //固定人 + String assignee=userTask.getAssignee(); + List candidateGroups = userTask.getCandidateGroups(); + List 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 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 sysUsers = sysUserMapper.selectUserListByRoleId(candidateGroup); + if(!CollectionUtils.isEmpty(sysUsers)){ + List 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 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 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(); + } } diff --git a/snow-system/src/main/java/com/snow/system/mapper/SysUserMapper.java b/snow-system/src/main/java/com/snow/system/mapper/SysUserMapper.java index c1924ab..7b1c1d8 100644 --- a/snow-system/src/main/java/com/snow/system/mapper/SysUserMapper.java +++ b/snow-system/src/main/java/com/snow/system/mapper/SysUserMapper.java @@ -26,6 +26,13 @@ public interface SysUserMapper */ public List selectAllocatedList(SysUser user); + /** + * + * @param roleId + * @return + */ + public List selectUserListByRoleId(String roleId); + /** * 根据条件分页查询未分配用户角色列表 * diff --git a/snow-system/src/main/resources/mapper/system/SysUserMapper.xml b/snow-system/src/main/resources/mapper/system/SysUserMapper.xml index 175e0a0..befe74b 100644 --- a/snow-system/src/main/resources/mapper/system/SysUserMapper.xml +++ b/snow-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -108,7 +108,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ${params.dataScope} - +