Map<String,Object> result = new HashMap<String,Object>();
if(StringUtil.isNotEmpty(processInstanceId)){
String userId = (String) filter.get("userId");
ProcessEngine engine = getProcessEngine(userId);
ProcessInstance processInstance = engine.getRuntimeService().getProcessInstance(processInstanceId);
String processName = processInstance.getProcessDefinition().getName();
try{
TaskQuery tq = engine.getTaskService().createTaskQuery();
IdentityService identityService = engine.getIdentityService();
tq.processInstanceId(processInstanceId);
tq.taskIsEnd().orderByEndTime().asc();
List<TaskInstance> instances = tq.list();
List<Map<String,Object>> instanceMaps = new ArrayList<Map<String,Object>>();
for(TaskInstance tmp:instances){
Map<String,Object> instanceMap = tmp.getPersistentState();
String assigneeUserId = tmp.getAssignee();
if(StringUtil.isNotEmpty(assigneeUserId)){
UserTo tmpUser = identityService.getUserTo(assigneeUserId);
if(tmpUser!=null){
instanceMap.put("assgneeUserName", tmpUser.getUserName());
}
}else{
instanceMap.put("assgneeUserName", "(空用户名)");
}
instanceMaps.add(instanceMap);
}
tq.taskNotEnd().orderByTaskCreateTime().asc();
List<TaskInstance> instancesNotEnd = tq.list();
List<Map<String,Object>> notEndInstanceMaps = new ArrayList<Map<String,Object>>();
for(TaskInstance tmp:instancesNotEnd){
Map<String,Object> instanceMap = tmp.getPersistentState();
String assigneeUserId = tmp.getAssignee();
if(StringUtil.isNotEmpty(assigneeUserId)){
UserTo tmpUser = identityService.getUserTo(assigneeUserId);
if(tmpUser!=null){
instanceMap.put("assgneeUserName", tmpUser.getUserName());
}
}else{
instanceMap.put("assgneeUserName", "(空用户名)");
}
notEndInstanceMaps.add(instanceMap);
}
Map<String,Map<String,Object>> postionMap = engine.getModelService().GetFlowGraphicsElementPosition(processInstance.getProcessDefinitionId());
result.put("notEnddataList", notEndInstanceMaps);
result.put("dataList", instanceMaps);
result.put("positionInfo", JSONUtil.parseObject2JSON(postionMap));
result.put("taskEndedJson", JSONUtil.parseObject2JSON(instanceMaps));
result.put("taskNotEndJson", JSONUtil.parseObject2JSON(instancesNotEnd));