| | |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.fasterxml.jackson.databind.node.ObjectNode; |
| | | import com.highdatas.mdm.pojo.Result; |
| | | import com.highdatas.mdm.process.canvas.ProcessDiagramGenerator; |
| | | import com.highdatas.mdm.util.WorkflowUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.activiti.bpmn.converter.BpmnXMLConverter; |
| | |
| | | import org.activiti.editor.constants.ModelDataJsonConstants; |
| | | import org.activiti.editor.language.json.converter.BpmnJsonConverter; |
| | | import org.activiti.engine.ActivitiException; |
| | | import org.activiti.engine.HistoryService; |
| | | import org.activiti.engine.RepositoryService; |
| | | import org.activiti.engine.repository.Deployment; |
| | | import org.activiti.engine.repository.Model; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.ClassUtils; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | private static final String MODEL_DESCRIPTION = "description"; |
| | | @Autowired |
| | | RepositoryService service; |
| | | @Autowired |
| | | HistoryService historyService; |
| | | |
| | | @Autowired |
| | | ObjectMapper objectMapper; |
| | | @Value("${img.url}") |
| | |
| | | response.flushBuffer(); |
| | | } |
| | | |
| | | public boolean updateProcessDefStatus(String type, String modelId) { |
| | | @Override |
| | | public InputStream getModelImg(String modelId) { |
| | | InputStream resource = null; |
| | | try{ |
| | | Model model = service.createModelQuery().modelId(modelId).singleResult(); |
| | | JsonNode editorNode = new ObjectMapper().readTree(service.getModelEditorSource(model.getId())); |
| | | BpmnJsonConverter jsonConverter = new BpmnJsonConverter(); |
| | | BpmnModel bpmnModel = jsonConverter.convertToBpmnModel(editorNode); |
| | | ProcessDiagramGenerator diagramGenerator = new ProcessDiagramGenerator(); |
| | | resource = diagramGenerator.generateDiagram(bpmnModel, "png",null,null, "宋体","宋体" ,null, null,0); |
| | | return resource; |
| | | } |
| | | catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | finally { |
| | | if (resource != null) { |
| | | try { |
| | | resource.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | public boolean updateProcessDefStatus(String type, String modelId) { |
| | | Model model = service.createModelQuery().modelId(modelId).singleResult(); |
| | | ProcessDefinition processDefinition = service.createProcessDefinitionQuery().deploymentId(model.getDeploymentId()).singleResult(); |
| | | String processDefinitionId = processDefinition.getId(); |