Activiti工作流流程图获取可以根据部署id或者流程定义id获取工作流的步骤全图,非实时节点步骤图

时间:2024-04-07 09:01:29
/**
 * 两种情况
 * @param deploymentId
 * @param procDefId
 * @param response
 */
@GetMapping("/proc/viewImage")
@ResponseBody
public void viewImage(String deploymentId,String procDefId, HttpServletResponse response){
    String imageName=null;
    if (StringUtils.isEmpty(deploymentId)&&StringUtils.isEmpty(procDefId)){
        throw new AudaqueException("部署ID和实例id都不存在");
    }

    if (!StringUtils.isEmpty(deploymentId)){
        List<DeployMentVo> deployMentVos= actExtendProcessMapper.findDeployMentVo(deploymentId);
        if (!CollectionUtils.isEmpty(deployMentVos)){
            for(DeployMentVo deployMentVo:deployMentVos){
                if ( deployMentVo.getName().indexOf(".png")>0){
                    imageName=deployMentVo.getName();
                }
            }
        }else{
            throw new AudaqueException("流程图片不存在");
        }
    }
    if (!StringUtils.isEmpty(procDefId)){
        ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().processDefinitionId(procDefId).singleResult();
        imageName = processDefinition.getDiagramResourceName();
        deploymentId=processDefinition.getDeploymentId();
    }
    InputStream in = repositoryService.getResourceAsStream(deploymentId,imageName);//此处方法实际项目应该放在service里面
    try {
        OutputStream out = response.getOutputStream();
        // 把图片的输入流程写入resp的输出流中
        byte[] b = new byte[1024];
        for (int len = -1; (len= in.read(b))!=-1; ) {
            out.write(b, 0, len);
        }
        // 关闭流
        out.close();
        in.close();
    } catch ( IOException e) {
        e.printStackTrace();
    }
}

起始就是这个表act_ge_bytearray的数据bytes_

Activiti工作流流程图获取可以根据部署id或者流程定义id获取工作流的步骤全图,非实时节点步骤图