Activiti:获取当前Task在流程图的坐标
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 读取资源 | |
* | |
* @return | |
*/ | |
public String loadResource() { | |
try { | |
InputStream resourceAsStream = null; | |
if (StringUtils.isNotBlank(processInstanceId)) { | |
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); | |
ProcessDefinition singleResult = repositoryService.createProcessDefinitionQuery() | |
.processDefinitionId(processInstance.getProcessDefinitionId()).singleResult(); | |
String resourceName = ""; | |
if (resourceType.equals("image")) { | |
resourceName = singleResult.getDiagramResourceName(); | |
} else if (resourceType.equals("xml")) { | |
resourceName = singleResult.getResourceName(); | |
} | |
resourceAsStream = repositoryService.getResourceAsStream(singleResult.getDeploymentId(), resourceName); | |
} else { | |
resourceAsStream = repositoryService.getResourceAsStream(deploymentId, resourceName); | |
} | |
byte[] b = new byte[1024]; | |
int len = -1; | |
while ((len = resourceAsStream.read(b, 0, 1024)) != -1) { | |
Struts2Utils.getResponse().getOutputStream().write(b, 0, len); | |
} | |
} catch (Exception e) { | |
logger.error("读取资源出错:", e); | |
} | |
return null; | |
} | |
/** | |
* 流程跟踪图 | |
* @return | |
*/ | |
public String traceProcess() { | |
try { | |
Execution execution = runtimeService.createExecutionQuery().executionId(processInstanceId).singleResult();//执行实例 | |
Object property = PropertyUtils.getProperty(execution, "activityId"); | |
String activityId = ""; | |
if (property != null) { | |
activityId = property.toString(); | |
} | |
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); | |
ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService) | |
.getDeployedProcessDefinition(processInstance.getProcessDefinitionId()); | |
List<ActivityImpl> activitiList = processDefinition.getActivities();//获得当前任务的所有节点 | |
ActivityImpl activity = null; | |
for (ActivityImpl activityImpl : activitiList) { | |
String id = activityImpl.getId(); | |
if (id.equals(activityId)) {//获得执行到那个节点 | |
activity = activityImpl; | |
break; | |
} | |
} | |
Map<String, Object> activityImageInfo = new HashMap<String, Object>(); | |
activityImageInfo.put("x", activity.getX()); | |
activityImageInfo.put("y", activity.getY()); | |
activityImageInfo.put("width", activity.getWidth()); | |
activityImageInfo.put("height", activity.getHeight()); | |
Struts2Utils.renderJson(activityImageInfo); | |
} catch (Exception e) { | |
logger.error("查看流程跟踪图出错:"); | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment