Java Code Examples for org.activiti.engine.history.HistoricActivityInstance#getEndTime()
The following examples show how to use
org.activiti.engine.history.HistoricActivityInstance#getEndTime() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RuntimeDisplayJsonClientResource.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@RequestMapping(value = "/rest/process-instances/history/{processInstanceId}/model-json", method = RequestMethod.GET, produces = "application/json") public JsonNode getModelHistoryJSON(@PathVariable String processInstanceId) { User currentUser = SecurityUtils.getCurrentUserObject(); if (!permissionService.hasReadPermissionOnProcessInstance(currentUser, processInstanceId)) { throw new NotPermittedException(); } HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); if (processInstance == null) { throw new BadRequestException("No process instance found with id " + processInstanceId); } BpmnModel pojoModel = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId()); if (pojoModel == null || pojoModel.getLocationMap().isEmpty()) { throw new InternalServerErrorException("Process definition could not be found with id " + processInstance.getProcessDefinitionId()); } // Fetch process-instance activities List<HistoricActivityInstance> activityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list(); Set<String> completedActivityInstances = new HashSet<String>(); Set<String> currentActivityinstances = new HashSet<String>(); if (CollectionUtils.isNotEmpty(activityInstances)) { for (HistoricActivityInstance activityInstance : activityInstances) { if (activityInstance.getEndTime() != null) { completedActivityInstances.add(activityInstance.getActivityId()); } else { currentActivityinstances.add(activityInstance.getActivityId()); } } } ObjectNode displayNode = processProcessElements(pojoModel, completedActivityInstances, currentActivityinstances); return displayNode; }
Example 2
Source File: Activity.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
public Activity(HistoricActivityInstance activity) { this.id = activity.getId(); this.activityDefinitionId = activity.getActivityId(); this.activityDefinitionName = activity.getActivityName(); this.activityDefinitionType = activity.getActivityType(); this.startedAt = activity.getStartTime(); this.endedAt = activity.getEndTime(); this.durationInMs = activity.getDurationInMillis(); }
Example 3
Source File: WorkflowInnerServiceSMOImpl.java From MicroCommunity with Apache License 2.0 | 4 votes |
/** * 查询审核历史 * * @param workflowAuditInfoDto * @return */ public List<WorkflowAuditInfoDto> queryWorkflowAuditHistory(@RequestBody WorkflowAuditInfoDto workflowAuditInfoDto) { //List<TaskBo> taskBoList = new ArrayList<TaskBo>(); HistoricProcessInstance hisProcessInstance = (HistoricProcessInstance) historyService .createHistoricProcessInstanceQuery() .processInstanceBusinessKey(workflowAuditInfoDto.getBusinessKey()).singleResult(); // 该流程实例的所有节点审批记录 List<HistoricActivityInstance> hisActInstList = getHisUserTaskActivityInstanceList(hisProcessInstance .getId()); List<WorkflowAuditInfoDto> workflowAuditInfoDtos = new ArrayList<>(); WorkflowAuditInfoDto tmpWorkflowAuditInfoDto = null; for (Iterator iterator = hisActInstList.iterator(); iterator.hasNext(); ) { // 需要转换成HistoricActivityInstance HistoricActivityInstance activityInstance = (HistoricActivityInstance) iterator .next(); // if (activityInstance.getEndTime() == null) { // continue; // } tmpWorkflowAuditInfoDto = new WorkflowAuditInfoDto(); tmpWorkflowAuditInfoDto.setAuditName(activityInstance.getActivityName()); if (activityInstance.getEndTime() != null) { tmpWorkflowAuditInfoDto.setAuditTime(DateUtil.getFormatTimeString(activityInstance.getEndTime(), DateUtil.DATE_FORMATE_STRING_A)); tmpWorkflowAuditInfoDto.setStateName("完成"); tmpWorkflowAuditInfoDto.setState(WorkflowAuditInfoDto.STATE_FINISH); } else { tmpWorkflowAuditInfoDto.setStateName("正在处理"); tmpWorkflowAuditInfoDto.setState(WorkflowAuditInfoDto.STATE_NO); } Long time = activityInstance.getDurationInMillis() == null ? new Date().getTime() - activityInstance.getStartTime().getTime() : activityInstance.getDurationInMillis(); tmpWorkflowAuditInfoDto.setDuration(getCostTime(time)); //如果还没结束则不放里面 List<Comment> comments = taskService.getTaskComments(activityInstance.getTaskId()); String msg = ""; if (comments != null && comments.size() > 0) { for (Comment comment : comments) { msg += (comment.getFullMessage() + "/"); } } msg = msg.endsWith("/") ? msg.substring(0, msg.length() - 2) : msg; tmpWorkflowAuditInfoDto.setUserId(activityInstance.getAssignee()); tmpWorkflowAuditInfoDto.setMessage(msg); workflowAuditInfoDtos.add(tmpWorkflowAuditInfoDto); } return workflowAuditInfoDtos; }
Example 4
Source File: CustomProcessDiagramGenerator.java From lemon with Apache License 2.0 | 4 votes |
public InputStream generateDiagram(String processInstanceId) throws IOException { HistoricProcessInstance historicProcessInstance = Context .getCommandContext().getHistoricProcessInstanceEntityManager() .findHistoricProcessInstance(processInstanceId); String processDefinitionId = historicProcessInstance .getProcessDefinitionId(); GetBpmnModelCmd getBpmnModelCmd = new GetBpmnModelCmd( processDefinitionId); BpmnModel bpmnModel = getBpmnModelCmd.execute(Context .getCommandContext()); // Point point = getMinXAndMinY(bpmnModel); // this.minX = point.x; // this.minY = point.y; // this.minX = (this.minX <= 5) ? 5 : this.minX; // this.minY = (this.minY <= 5) ? 5 : this.minY; // this.minX -= 5; // this.minY -= 5; ProcessDefinitionEntity definition = new GetDeploymentProcessDefinitionCmd( processDefinitionId).execute(Context.getCommandContext()); String diagramResourceName = definition.getDiagramResourceName(); String deploymentId = definition.getDeploymentId(); byte[] bytes = Context .getCommandContext() .getResourceEntityManager() .findResourceByDeploymentIdAndResourceName(deploymentId, diagramResourceName).getBytes(); InputStream originDiagram = new ByteArrayInputStream(bytes); BufferedImage image = ImageIO.read(originDiagram); HistoricActivityInstanceQueryImpl historicActivityInstanceQueryImpl = new HistoricActivityInstanceQueryImpl(); historicActivityInstanceQueryImpl.processInstanceId(processInstanceId) .orderByHistoricActivityInstanceStartTime().asc(); Page page = new Page(0, 100); List<HistoricActivityInstance> activityInstances = Context .getCommandContext() .getHistoricActivityInstanceEntityManager() .findHistoricActivityInstancesByQueryCriteria( historicActivityInstanceQueryImpl, page); this.drawHistoryFlow(image, processInstanceId); for (HistoricActivityInstance historicActivityInstance : activityInstances) { String historicActivityId = historicActivityInstance .getActivityId(); ActivityImpl activity = definition.findActivity(historicActivityId); if (activity != null) { if (historicActivityInstance.getEndTime() == null) { // 节点正在运行中 signRunningNode(image, activity.getX() - this.minX, activity.getY() - this.minY, activity.getWidth(), activity.getHeight(), historicActivityInstance.getActivityType()); } else { String deleteReason = null; if (historicActivityInstance.getTaskId() != null) { deleteReason = Context .getCommandContext() .getHistoricTaskInstanceEntityManager() .findHistoricTaskInstanceById( historicActivityInstance.getTaskId()) .getDeleteReason(); } // 节点已经结束 if ("跳过".equals(deleteReason)) { signSkipNode(image, activity.getX() - this.minX, activity.getY() - this.minY, activity.getWidth(), activity.getHeight(), historicActivityInstance.getActivityType()); } else { signHistoryNode(image, activity.getX() - this.minX, activity.getY() - this.minY, activity.getWidth(), activity.getHeight(), historicActivityInstance.getActivityType()); } } } } ByteArrayOutputStream out = new ByteArrayOutputStream(); String formatName = getDiagramExtension(diagramResourceName); ImageIO.write(image, formatName, out); return new ByteArrayInputStream(out.toByteArray()); }
Example 5
Source File: ActivitiHistoryGraphBuilder.java From lemon with Apache License 2.0 | 4 votes |
/** * 找到这个节点前面的连线. */ public Edge findPreviousEdge(Node currentNode, long currentStartTime) { String activityId = currentNode.getName(); ActivityImpl activityImpl = processDefinitionEntity .findActivity(activityId); HistoricActivityInstance nestestHistoricActivityInstance = null; String temporaryPvmTransitionId = null; // 遍历进入当前节点的所有连线 for (PvmTransition pvmTransition : activityImpl .getIncomingTransitions()) { PvmActivity source = pvmTransition.getSource(); String previousActivityId = source.getId(); HistoricActivityInstance visitiedHistoryActivityInstance = this .findVisitedHistoricActivityInstance(previousActivityId); if (visitiedHistoryActivityInstance == null) { continue; } // 如果上一个节点还未完成,说明不可能是从这个节点过来的,跳过 if (visitiedHistoryActivityInstance.getEndTime() == null) { continue; } logger.debug("current activity start time : {}", new Date( currentStartTime)); logger.debug("nestest activity end time : {}", visitiedHistoryActivityInstance.getEndTime()); // 如果当前节点的开始时间,比上一个节点的结束时间要早,跳过 if (currentStartTime < visitiedHistoryActivityInstance.getEndTime() .getTime()) { continue; } if (nestestHistoricActivityInstance == null) { nestestHistoricActivityInstance = visitiedHistoryActivityInstance; temporaryPvmTransitionId = pvmTransition.getId(); } else if ((currentStartTime - nestestHistoricActivityInstance .getEndTime().getTime()) > (currentStartTime - visitiedHistoryActivityInstance .getEndTime().getTime())) { // 寻找离当前节点最近的上一个节点 // 比较上一个节点的endTime与当前节点startTime的差 nestestHistoricActivityInstance = visitiedHistoryActivityInstance; temporaryPvmTransitionId = pvmTransition.getId(); } } // 没找到上一个节点,就返回null if (nestestHistoricActivityInstance == null) { return null; } Node previousNode = nodeMap .get(nestestHistoricActivityInstance.getId()); if (previousNode == null) { return null; } logger.debug("previousNode : {}:{}", previousNode.getName(), previousNode.getId()); Edge edge = new Edge(); edge.setName(temporaryPvmTransitionId); previousNode.getOutgoingEdges().add(edge); edge.setSrc(previousNode); edge.setDest(currentNode); return edge; }