From effffdd5077d28ed1c58165734fb5c7be9c07279 Mon Sep 17 00:00:00 2001 From: thinkgem Date: Fri, 15 Jul 2016 10:04:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=B5=81=E7=A8=8B=E8=BD=A8?= =?UTF-8?q?=E8=BF=B9=E9=AB=98=E4=BA=AE=E4=B8=8D=E6=98=BE=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProcessInstanceHighlightsResource.java | 60 ++----------------- .../editor/model/ModelSaveRestResource.java | 6 +- 2 files changed, 8 insertions(+), 58 deletions(-) diff --git a/src/main/java/com/thinkgem/jeesite/modules/act/rest/diagram/services/ProcessInstanceHighlightsResource.java b/src/main/java/com/thinkgem/jeesite/modules/act/rest/diagram/services/ProcessInstanceHighlightsResource.java index 1fff7a4a87..eced899bae 100644 --- a/src/main/java/com/thinkgem/jeesite/modules/act/rest/diagram/services/ProcessInstanceHighlightsResource.java +++ b/src/main/java/com/thinkgem/jeesite/modules/act/rest/diagram/services/ProcessInstanceHighlightsResource.java @@ -14,7 +14,6 @@ package com.thinkgem.jeesite.modules.act.rest.diagram.services; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -24,11 +23,9 @@ import org.activiti.engine.RepositoryService; import org.activiti.engine.RuntimeService; import org.activiti.engine.history.HistoricActivityInstance; -import org.activiti.engine.history.HistoricProcessInstance; import org.activiti.engine.impl.persistence.entity.ProcessDefinitionEntity; import org.activiti.engine.impl.pvm.PvmTransition; import org.activiti.engine.impl.pvm.process.ActivityImpl; -import org.activiti.engine.repository.ProcessDefinition; import org.activiti.engine.runtime.ProcessInstance; import org.apache.shiro.authz.annotation.RequiresUser; import org.springframework.beans.factory.annotation.Autowired; @@ -40,7 +37,6 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.thinkgem.jeesite.common.mapper.JsonMapper; @RestController public class ProcessInstanceHighlightsResource { @@ -69,28 +65,13 @@ public ObjectNode getHighlighted(@PathVariable String processInstanceId) { try { ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); - String processDefinitionId = null; - List highLightedActivities = Collections. emptyList(); - List historicActivityInstances = null; - if (processInstance == null) { - HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery() - .processInstanceId(processInstanceId).singleResult(); - processDefinitionId = historicProcessInstance.getProcessDefinitionId(); - historicActivityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).list(); - - System.out.println(JsonMapper.toJsonString(historicActivityInstances)); - - } else { - processDefinitionId = processInstance.getProcessDefinitionId(); - highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId); - } - - ProcessDefinition processDefinition = repositoryService.getProcessDefinition(processDefinitionId); - ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) processDefinition; + ProcessDefinitionEntity processDefinition = (ProcessDefinitionEntity) repositoryService.getProcessDefinition(processInstance + .getProcessDefinitionId()); - responseJSON.put("processDefinitionId", processDefinitionId); + responseJSON.put("processDefinitionId", processInstance.getProcessDefinitionId()); - List highLightedFlows = getHighLightedFlows(processDefinitionEntity, historicActivityInstances);//getHighLightedFlows(processDefinitionEntity, processInstanceId); + List highLightedActivities = runtimeService.getActiveActivityIds(processInstanceId); + List highLightedFlows = getHighLightedFlows(processDefinition, processInstanceId); for (String activityId : highLightedActivities) { activitiesArray.add(activityId); @@ -110,37 +91,6 @@ public ObjectNode getHighlighted(@PathVariable String processInstanceId) { return responseJSON; } - private List getHighLightedFlows(ProcessDefinitionEntity processDefinitionEntity, List historicActivityInstances) { - - List highFlows = new ArrayList();// 用 以保存高亮的线flowId - for (int i = 0; i < historicActivityInstances.size() - 1; i++) {// 对历史流程节点进行遍历 - ActivityImpl activityImpl = processDefinitionEntity.findActivity(historicActivityInstances.get(i).getActivityId());// 得到节点定义的详细信息 - - List sameStartTimeNodes = new ArrayList(); // 用以保存后需开始时间相同的节点 - ActivityImpl sameActivityImpl1 = processDefinitionEntity.findActivity(historicActivityInstances.get(i + 1).getActivityId()); // 将后面第一个节点放在时间相同节点的集合里 - sameStartTimeNodes.add(sameActivityImpl1); - for (int j = i + 1; j < historicActivityInstances.size() - 1; j++) { - HistoricActivityInstance activityImpl1 = historicActivityInstances.get(j); // 后续第一个节点 - HistoricActivityInstance activityImpl2 = historicActivityInstances.get(j + 1); // 后续第二个节点 - if (activityImpl1.getStartTime().equals(activityImpl2.getStartTime())) { // 如果第一个节点和第二个节点开始时间相同保存 - ActivityImpl sameActivityImpl2 = processDefinitionEntity.findActivity(activityImpl2.getActivityId()); - sameStartTimeNodes.add(sameActivityImpl2); - } else { - break; - } - } - List pvmTransitions = activityImpl.getOutgoingTransitions();// 取出节点的所有出去的线 - for (PvmTransition pvmTransition : pvmTransitions) { // 对所有的线进行遍历 - ActivityImpl pvmActivityImpl = (ActivityImpl) pvmTransition.getDestination();// 如果取出的线的目标节点存在时间相同的节点里,保存该线的id,进行高亮显示 - if (sameStartTimeNodes.contains(pvmActivityImpl)) { - highFlows.add(pvmTransition.getId()); - } - } - - } - return highFlows; - } - /** * getHighLightedFlows * diff --git a/src/main/java/com/thinkgem/jeesite/modules/act/rest/editor/model/ModelSaveRestResource.java b/src/main/java/com/thinkgem/jeesite/modules/act/rest/editor/model/ModelSaveRestResource.java index 1a5605137a..1b5c6a1869 100644 --- a/src/main/java/com/thinkgem/jeesite/modules/act/rest/editor/model/ModelSaveRestResource.java +++ b/src/main/java/com/thinkgem/jeesite/modules/act/rest/editor/model/ModelSaveRestResource.java @@ -49,8 +49,8 @@ public class ModelSaveRestResource implements ModelDataJsonConstants { @Autowired private RepositoryService repositoryService; -// @Autowired -// private ObjectMapper objectMapper; + // @Autowired + // private ObjectMapper objectMapper; protected ObjectMapper objectMapper = new ObjectMapper(); @RequiresPermissions("act:model:edit") @@ -85,7 +85,7 @@ public void saveModel(@PathVariable String modelId, @RequestBody MultiValueMap