修复activiti子流程节点监听失败问题
This commit is contained in:
parent
8a0661af9e
commit
1d5ca2417b
|
@ -37,11 +37,10 @@ import org.activiti.editor.language.json.converter.BpmnJsonConverter;
|
||||||
import org.activiti.engine.IdentityService;
|
import org.activiti.engine.IdentityService;
|
||||||
import org.activiti.engine.RepositoryService;
|
import org.activiti.engine.RepositoryService;
|
||||||
import org.activiti.engine.RuntimeService;
|
import org.activiti.engine.RuntimeService;
|
||||||
|
import org.activiti.engine.TaskService;
|
||||||
import org.activiti.engine.identity.Group;
|
import org.activiti.engine.identity.Group;
|
||||||
import org.activiti.engine.identity.User;
|
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.GroupEntity;
|
||||||
import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity;
|
|
||||||
import org.activiti.engine.impl.persistence.entity.UserEntity;
|
import org.activiti.engine.impl.persistence.entity.UserEntity;
|
||||||
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||||
import org.activiti.engine.repository.Deployment;
|
import org.activiti.engine.repository.Deployment;
|
||||||
|
@ -74,28 +73,31 @@ import java.util.Map;
|
||||||
public class ActivitiController extends BaseController {
|
public class ActivitiController extends BaseController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RepositoryService repositoryService;
|
private RepositoryService repositoryService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
ObjectMapper objectMapper;
|
private ObjectMapper objectMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RuntimeService runtimeService;
|
private RuntimeService runtimeService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
IdentityService identityService;
|
private IdentityService identityService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
SysUserService userService;
|
private SysUserService userService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RoleService roleService;
|
private RoleService roleService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RoleUserService roleUserService;
|
private RoleUserService roleUserService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
ActAssigneeService actAssigneeService;
|
private ActAssigneeService actAssigneeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TaskService taskService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -288,14 +290,6 @@ public class ActivitiController extends BaseController {
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<ActivityImpl> 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获取节点并且传到前端
|
* 根据流程部署id获取节点并且传到前端
|
||||||
|
@ -304,16 +298,13 @@ public class ActivitiController extends BaseController {
|
||||||
* @param model
|
* @param model
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("goAssignee/{id}")
|
@GetMapping("goAssignee/{deploymentId}")
|
||||||
public String goAssignee(@PathVariable("id") String deploymentId,
|
public String goAssignee(@PathVariable("deploymentId") String deploymentId,
|
||||||
org.springframework.ui.Model model) {
|
org.springframework.ui.Model model) {
|
||||||
|
|
||||||
/**根据流程实例id查询出所有流程节点*/
|
/**根据流程实例id查询出所有流程节点*/
|
||||||
List<ActivityImpl> activityList = getActivityList(deploymentId);
|
List<ActivityImpl> activityList = actAssigneeService.getActivityList(deploymentId);
|
||||||
|
|
||||||
/**角色和节点关系封装成list*/
|
/**角色和节点关系封装成list*/
|
||||||
List<SysRole> roleList = roleService.selectListByPage(new SysRole());
|
List<SysRole> roleList = roleService.selectListByPage(new SysRole());
|
||||||
List<Checkbox> checkboxes = new ArrayList<>();
|
|
||||||
Checkbox checkbox = null;
|
Checkbox checkbox = null;
|
||||||
Map<String, Object> map = null;
|
Map<String, Object> map = null;
|
||||||
List<Map<String, Object>> mapList = new ArrayList<>();
|
List<Map<String, Object>> mapList = new ArrayList<>();
|
||||||
|
@ -399,7 +390,7 @@ public class ActivitiController extends BaseController {
|
||||||
public JsonUtil delDeploy(org.springframework.ui.Model model, String id) {
|
public JsonUtil delDeploy(org.springframework.ui.Model model, String id) {
|
||||||
JsonUtil j = new JsonUtil();
|
JsonUtil j = new JsonUtil();
|
||||||
try {
|
try {
|
||||||
List<ActivityImpl> activityList = getActivityList(id);
|
List<ActivityImpl> activityList = actAssigneeService.getActivityList(id);
|
||||||
for (ActivityImpl activity : activityList) {
|
for (ActivityImpl activity : activityList) {
|
||||||
String nodeId = activity.getId();
|
String nodeId = activity.getId();
|
||||||
if (StringUtils.isEmpty(nodeId) || "start".equals(nodeId) || "end".equals(nodeId)) {
|
if (StringUtils.isEmpty(nodeId) || "start".equals(nodeId) || "end".equals(nodeId)) {
|
||||||
|
|
|
@ -2,6 +2,9 @@ package com.len.service;
|
||||||
|
|
||||||
import com.len.base.BaseService;
|
import com.len.base.BaseService;
|
||||||
import com.len.entity.ActAssignee;
|
import com.len.entity.ActAssignee;
|
||||||
|
import org.activiti.engine.impl.pvm.process.ActivityImpl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zhuxiaomeng
|
* @author zhuxiaomeng
|
||||||
|
@ -11,4 +14,8 @@ import com.len.entity.ActAssignee;
|
||||||
public interface ActAssigneeService extends BaseService<ActAssignee,String> {
|
public interface ActAssigneeService extends BaseService<ActAssignee,String> {
|
||||||
int deleteByNodeId(String nodeId);
|
int deleteByNodeId(String nodeId);
|
||||||
|
|
||||||
|
public List<ActivityImpl> getActivityList(String deploymentId);
|
||||||
|
|
||||||
|
public List<ActivityImpl> selectAllActivity(List<ActivityImpl> activities);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,28 +5,66 @@ import com.len.base.impl.BaseServiceImpl;
|
||||||
import com.len.entity.ActAssignee;
|
import com.len.entity.ActAssignee;
|
||||||
import com.len.mapper.ActAssigneeMapper;
|
import com.len.mapper.ActAssigneeMapper;
|
||||||
import com.len.service.ActAssigneeService;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author zhuxiaomeng
|
* @author zhuxiaomeng
|
||||||
* @date 2018/1/23.
|
* @date 2018/1/23.
|
||||||
* @email 154040976@qq.com
|
* @email 154040976@qq.com
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ActAssigneeServiceImpl extends BaseServiceImpl<ActAssignee,String> implements
|
public class ActAssigneeServiceImpl extends BaseServiceImpl<ActAssignee, String> implements
|
||||||
ActAssigneeService{
|
ActAssigneeService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
ActAssigneeMapper actAssigneeMapper;
|
ActAssigneeMapper actAssigneeMapper;
|
||||||
|
|
||||||
@Override
|
@Autowired
|
||||||
public BaseMapper<ActAssignee, String> getMappser() {
|
private RepositoryService repositoryService;
|
||||||
return actAssigneeMapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int deleteByNodeId(String nodeId) {
|
public BaseMapper<ActAssignee, String> getMappser() {
|
||||||
return actAssigneeMapper.deleteByNodeId(nodeId);
|
return actAssigneeMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int deleteByNodeId(String nodeId) {
|
||||||
|
return actAssigneeMapper.deleteByNodeId(nodeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ActivityImpl> 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<ActivityImpl> selectAllActivity(List<ActivityImpl> activities) {
|
||||||
|
List<ActivityImpl> list = new ArrayList<>(activities);
|
||||||
|
for (ActivityImpl activity : activities) {
|
||||||
|
List<ActivityImpl> childActivities = activity.getActivities();
|
||||||
|
if (!childActivities.isEmpty()) {
|
||||||
|
list.addAll(selectAllActivity(childActivities));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@
|
||||||
layer.msg('请选择一个流程', {icon: 5});
|
layer.msg('请选择一个流程', {icon: 5});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
assignee(data[0].deploymentId);
|
assignee(data[0].id,data[0].deploymentId);
|
||||||
}
|
}
|
||||||
,reload:function(){
|
,reload:function(){
|
||||||
$('#deploymentId').val('');
|
$('#deploymentId').val('');
|
||||||
|
@ -194,7 +194,7 @@
|
||||||
* 流程绑定节点
|
* 流程绑定节点
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
function assignee(id){
|
function assignee(id,deploymentId){
|
||||||
var index =
|
var index =
|
||||||
layer.open({
|
layer.open({
|
||||||
id: 'assignee',
|
id: 'assignee',
|
||||||
|
@ -205,7 +205,7 @@
|
||||||
shadeClose: false,
|
shadeClose: false,
|
||||||
shade: 0.4,
|
shade: 0.4,
|
||||||
title: '设置流程节点',
|
title: '设置流程节点',
|
||||||
content: 'goAssignee/'+id
|
content: 'goAssignee/'+deploymentId
|
||||||
});
|
});
|
||||||
layer.full(index);
|
layer.full(index);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue