diff --git a/len-activiti/src/main/java/com/len/controller/ActivitiController.java b/len-activiti/src/main/java/com/len/controller/ActivitiController.java index 953be89..3b147d0 100644 --- a/len-activiti/src/main/java/com/len/controller/ActivitiController.java +++ b/len-activiti/src/main/java/com/len/controller/ActivitiController.java @@ -37,11 +37,10 @@ import org.activiti.editor.language.json.converter.BpmnJsonConverter; import org.activiti.engine.IdentityService; import org.activiti.engine.RepositoryService; import org.activiti.engine.RuntimeService; +import org.activiti.engine.TaskService; import org.activiti.engine.identity.Group; import org.activiti.engine.identity.User; -import org.activiti.engine.impl.RepositoryServiceImpl; import org.activiti.engine.impl.persistence.entity.GroupEntity; -import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity; import org.activiti.engine.impl.persistence.entity.UserEntity; import org.activiti.engine.impl.pvm.process.ActivityImpl; import org.activiti.engine.repository.Deployment; @@ -74,28 +73,31 @@ import java.util.Map; public class ActivitiController extends BaseController { @Autowired - RepositoryService repositoryService; + private RepositoryService repositoryService; @Autowired - ObjectMapper objectMapper; + private ObjectMapper objectMapper; @Autowired - RuntimeService runtimeService; + private RuntimeService runtimeService; @Autowired - IdentityService identityService; + private IdentityService identityService; @Autowired - SysUserService userService; + private SysUserService userService; @Autowired - RoleService roleService; + private RoleService roleService; @Autowired - RoleUserService roleUserService; + private RoleUserService roleUserService; @Autowired - ActAssigneeService actAssigneeService; + private ActAssigneeService actAssigneeService; + + @Autowired + private TaskService taskService; /** @@ -288,14 +290,6 @@ public class ActivitiController extends BaseController { return j; } - public List getActivityList(String deploymentId) { - org.activiti.engine.repository.ProcessDefinition processDefinition = repositoryService - .createProcessDefinitionQuery().deploymentId(deploymentId).singleResult(); - ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService) - .getDeployedProcessDefinition(processDefinition.getId()); - return processDefinitionEntity.getActivities(); - - } /** * 根据流程部署id获取节点并且传到前端 @@ -304,16 +298,13 @@ public class ActivitiController extends BaseController { * @param model * @return */ - @GetMapping("goAssignee/{id}") - public String goAssignee(@PathVariable("id") String deploymentId, + @GetMapping("goAssignee/{deploymentId}") + public String goAssignee(@PathVariable("deploymentId") String deploymentId, org.springframework.ui.Model model) { - /**根据流程实例id查询出所有流程节点*/ - List activityList = getActivityList(deploymentId); - + List activityList = actAssigneeService.getActivityList(deploymentId); /**角色和节点关系封装成list*/ List roleList = roleService.selectListByPage(new SysRole()); - List checkboxes = new ArrayList<>(); Checkbox checkbox = null; Map map = null; List> mapList = new ArrayList<>(); @@ -399,7 +390,7 @@ public class ActivitiController extends BaseController { public JsonUtil delDeploy(org.springframework.ui.Model model, String id) { JsonUtil j = new JsonUtil(); try { - List activityList = getActivityList(id); + List activityList = actAssigneeService.getActivityList(id); for (ActivityImpl activity : activityList) { String nodeId = activity.getId(); if (StringUtils.isEmpty(nodeId) || "start".equals(nodeId) || "end".equals(nodeId)) { diff --git a/len-activiti/src/main/java/com/len/service/ActAssigneeService.java b/len-activiti/src/main/java/com/len/service/ActAssigneeService.java index 5ce437f..e289669 100644 --- a/len-activiti/src/main/java/com/len/service/ActAssigneeService.java +++ b/len-activiti/src/main/java/com/len/service/ActAssigneeService.java @@ -2,6 +2,9 @@ package com.len.service; import com.len.base.BaseService; import com.len.entity.ActAssignee; +import org.activiti.engine.impl.pvm.process.ActivityImpl; + +import java.util.List; /** * @author zhuxiaomeng @@ -11,4 +14,8 @@ import com.len.entity.ActAssignee; public interface ActAssigneeService extends BaseService { int deleteByNodeId(String nodeId); + public List getActivityList(String deploymentId); + + public List selectAllActivity(List activities); + } diff --git a/len-activiti/src/main/java/com/len/service/impl/ActAssigneeServiceImpl.java b/len-activiti/src/main/java/com/len/service/impl/ActAssigneeServiceImpl.java index 040e3bf..bdaf176 100644 --- a/len-activiti/src/main/java/com/len/service/impl/ActAssigneeServiceImpl.java +++ b/len-activiti/src/main/java/com/len/service/impl/ActAssigneeServiceImpl.java @@ -5,28 +5,66 @@ import com.len.base.impl.BaseServiceImpl; import com.len.entity.ActAssignee; import com.len.mapper.ActAssigneeMapper; import com.len.service.ActAssigneeService; +import org.activiti.bpmn.converter.BpmnXMLConverter; +import org.activiti.bpmn.model.BpmnModel; +import org.activiti.engine.RepositoryService; +import org.activiti.engine.impl.RepositoryServiceImpl; +import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity; +import org.activiti.engine.impl.pvm.process.ActivityImpl; +import org.activiti.engine.impl.util.io.InputStreamSource; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + /** * @author zhuxiaomeng * @date 2018/1/23. * @email 154040976@qq.com */ @Service -public class ActAssigneeServiceImpl extends BaseServiceImpl implements - ActAssigneeService{ +public class ActAssigneeServiceImpl extends BaseServiceImpl implements + ActAssigneeService { - @Autowired - ActAssigneeMapper actAssigneeMapper; + @Autowired + ActAssigneeMapper actAssigneeMapper; - @Override - public BaseMapper getMappser() { - return actAssigneeMapper; - } + @Autowired + private RepositoryService repositoryService; - @Override - public int deleteByNodeId(String nodeId) { - return actAssigneeMapper.deleteByNodeId(nodeId); - } + @Override + public BaseMapper getMappser() { + return actAssigneeMapper; + } + + @Override + public int deleteByNodeId(String nodeId) { + return actAssigneeMapper.deleteByNodeId(nodeId); + } + + @Override + public List getActivityList(String deploymentId) { + org.activiti.engine.repository.ProcessDefinition processDefinition = repositoryService + .createProcessDefinitionQuery().deploymentId(deploymentId).singleResult(); + ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService) + .getDeployedProcessDefinition(processDefinition.getId()); + InputStream inputStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), processDefinition.getResourceName()); + BpmnModel bm = new BpmnXMLConverter().convertToBpmnModel(new InputStreamSource(inputStream), false, true); + return selectAllActivity(processDefinitionEntity.getActivities()); + + } + + @Override + public List selectAllActivity(List activities) { + List list = new ArrayList<>(activities); + for (ActivityImpl activity : activities) { + List childActivities = activity.getActivities(); + if (!childActivities.isEmpty()) { + list.addAll(selectAllActivity(childActivities)); + } + } + return list; + } } diff --git a/len-activiti/src/main/resources/ftl/actList.ftl b/len-activiti/src/main/resources/ftl/actList.ftl index 0f45fe7..8d57061 100644 --- a/len-activiti/src/main/resources/ftl/actList.ftl +++ b/len-activiti/src/main/resources/ftl/actList.ftl @@ -138,7 +138,7 @@ layer.msg('请选择一个流程', {icon: 5}); return false; } - assignee(data[0].deploymentId); + assignee(data[0].id,data[0].deploymentId); } ,reload:function(){ $('#deploymentId').val(''); @@ -194,7 +194,7 @@ * 流程绑定节点 * @param id */ - function assignee(id){ + function assignee(id,deploymentId){ var index = layer.open({ id: 'assignee', @@ -205,7 +205,7 @@ shadeClose: false, shade: 0.4, title: '设置流程节点', - content: 'goAssignee/'+id + content: 'goAssignee/'+deploymentId }); layer.full(index); }